From 8d85723a62f1e0ad3f0d6b9e2e2480ce877b0b72 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 7 Mar 2022 19:23:57 +0900 Subject: [PATCH] Split out `SceneLibrary` into its own component --- osu.Game/Skinning/Editor/SkinEditor.cs | 126 ++++++++++++++++--------- 1 file changed, 82 insertions(+), 44 deletions(-) diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index 37900d9920..9d5d496837 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -6,8 +6,10 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; using osu.Framework.Screens; @@ -24,6 +26,7 @@ using osu.Game.Screens.Play; using osu.Game.Screens.Select; using osuTK; +using osuTK.Graphics; namespace osu.Game.Skinning.Editor { @@ -48,12 +51,6 @@ public class SkinEditor : VisibilityContainer [Resolved] private OsuColour colours { get; set; } - [Resolved] - private IBindable ruleset { get; set; } - - [Resolved(canBeNull: true)] - private OsuGame game { get; set; } - private bool hasBegunMutating; private Container content; @@ -117,47 +114,12 @@ private void load() }, }, }, - new FillFlowContainer + new SceneLibrary { RelativeSizeAxes = Axes.X, Y = 45, - Height = 30, - Name = "Scene library", - Spacing = new Vector2(10), - Padding = new MarginPadding(10), - Direction = FillDirection.Horizontal, - Children = new Drawable[] - { - new PurpleTriangleButton - { - Text = "Song Select", - Width = 100, - Height = 30, - Action = () => game?.PerformFromScreen(screen => - { - if (screen is SongSelect) - return; - - screen.Push(new PlaySongSelect()); - }, new[] { typeof(SongSelect) }) - }, - new PurpleTriangleButton - { - Text = "Gameplay", - Width = 100, - Height = 30, - Action = () => game?.PerformFromScreen(screen => - { - if (screen is Player) - return; - - var replayGeneratingMod = ruleset.Value.CreateInstance().GetAutoplayMod(); - if (replayGeneratingMod != null) - screen.Push(new ReplayPlayer((beatmap, mods) => replayGeneratingMod.CreateReplayScore(beatmap, mods))); - }, new[] { typeof(Player) }) - }, - } }, + new GridContainer { RelativeSizeAxes = Axes.Both, @@ -226,7 +188,10 @@ void loadBlueprintContainer() { content.Children = new Drawable[] { - new SkinBlueprintContainer(targetScreen), + new SkinBlueprintContainer(targetScreen) + { + Margin = new MarginPadding { Top = 100 }, + } }; } } @@ -345,5 +310,78 @@ public void DeleteItems(ISkinnableDrawable[] items) foreach (var item in items) availableTargets.FirstOrDefault(t => t.Components.Contains(item))?.Remove(item); } + + private class SceneLibrary : CompositeDrawable + { + public const float HEIGHT = 30; + private const float padding = 10; + + [Resolved(canBeNull: true)] + private OsuGame game { get; set; } + + [Resolved] + private IBindable ruleset { get; set; } + + [BackgroundDependencyLoader] + private void load() + { + InternalChildren = new Drawable[] + { + new OsuScrollContainer(Direction.Horizontal) + { + RelativeSizeAxes = Axes.X, + Height = HEIGHT + padding * 2, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.5f) + }, + new FillFlowContainer + { + Name = "Scene library", + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Spacing = new Vector2(padding), + Padding = new MarginPadding(padding), + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + new PurpleTriangleButton + { + Text = "Song Select", + Width = 100, + Height = HEIGHT, + Action = () => game?.PerformFromScreen(screen => + { + if (screen is SongSelect) + return; + + screen.Push(new PlaySongSelect()); + }, new[] { typeof(SongSelect) }) + }, + new PurpleTriangleButton + { + Text = "Gameplay", + Width = 100, + Height = HEIGHT, + Action = () => game?.PerformFromScreen(screen => + { + if (screen is Player) + return; + + var replayGeneratingMod = ruleset.Value.CreateInstance().GetAutoplayMod(); + if (replayGeneratingMod != null) + screen.Push(new ReplayPlayer((beatmap, mods) => replayGeneratingMod.CreateReplayScore(beatmap, mods))); + }, new[] { typeof(Player), typeof(SongSelect) }) + }, + } + }, + } + } + }; + } + } } }