From 4525ed645c4c844c21774eeb6b2ced2e0028c3e9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 15 Mar 2022 16:36:04 +0900 Subject: [PATCH 1/2] Update skin editor to use `EditorSidebar` --- .../TestSceneSkinEditorComponentsList.cs | 12 ++++++--- .../Skinning/Editor/SkinComponentToolbox.cs | 12 +++------ osu.Game/Skinning/Editor/SkinEditor.cs | 27 +++++++++++++------ .../Skinning/Editor/SkinSettingsToolbox.cs | 20 ++++++++------ 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs index 58c89411c0..5385a9983b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs @@ -2,7 +2,9 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; using osu.Game.Skinning.Editor; @@ -11,13 +13,17 @@ namespace osu.Game.Tests.Visual.Gameplay { public class TestSceneSkinEditorComponentsList : SkinnableTestScene { + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + [Test] public void TestToggleEditor() { - AddStep("show available components", () => SetContents(_ => new SkinComponentToolbox(300) + AddStep("show available components", () => SetContents(_ => new SkinComponentToolbox { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Width = 0.6f, })); } diff --git a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs index 2781f1958f..05da229c3e 100644 --- a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs +++ b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs @@ -18,19 +18,17 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osu.Game.Rulesets.Difficulty; -using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; +using osu.Game.Screens.Edit.Components; using osuTK; using osuTK.Graphics; namespace osu.Game.Skinning.Editor { - public class SkinComponentToolbox : ScrollingToolboxGroup + public class SkinComponentToolbox : EditorSidebarSection { - public const float WIDTH = 200; - public Action RequestPlacement; private const float component_display_scale = 0.8f; @@ -45,11 +43,9 @@ namespace osu.Game.Skinning.Editor [Cached(typeof(HealthProcessor))] private HealthProcessor healthProcessor = new DrainingHealthProcessor(0); - public SkinComponentToolbox(float height) - : base("Components", height) + public SkinComponentToolbox() + : base("Components") { - RelativeSizeAxes = Axes.None; - Width = WIDTH; } [BackgroundDependencyLoader] diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index acae09ee71..381f7a1cc3 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -18,6 +18,7 @@ using osu.Game.Graphics.Cursor; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; using osu.Game.Rulesets.Edit; +using osu.Game.Screens.Edit.Components; using osu.Game.Screens.Edit.Components.Menus; namespace osu.Game.Skinning.Editor @@ -130,21 +131,31 @@ namespace osu.Game.Skinning.Editor { new Drawable[] { - new SkinComponentToolbox(600) + new EditorSidebar { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - RequestPlacement = placeComponent + Children = new[] + { + new SkinComponentToolbox + { + RequestPlacement = placeComponent + }, + } }, content = new Container { RelativeSizeAxes = Axes.Both, }, - settingsToolbox = new SkinSettingsToolbox + new EditorSidebar { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - } + Children = new[] + { + settingsToolbox = new SkinSettingsToolbox + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + } + } + }, } } } diff --git a/osu.Game/Skinning/Editor/SkinSettingsToolbox.cs b/osu.Game/Skinning/Editor/SkinSettingsToolbox.cs index c0ef8e7316..fc06d3647a 100644 --- a/osu.Game/Skinning/Editor/SkinSettingsToolbox.cs +++ b/osu.Game/Skinning/Editor/SkinSettingsToolbox.cs @@ -2,22 +2,26 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics; -using osu.Game.Rulesets.Edit; +using osu.Framework.Graphics.Containers; +using osu.Game.Screens.Edit.Components; using osuTK; namespace osu.Game.Skinning.Editor { - internal class SkinSettingsToolbox : ScrollingToolboxGroup + internal class SkinSettingsToolbox : EditorSidebarSection { - public const float WIDTH = 200; + protected override Container Content { get; } public SkinSettingsToolbox() - : base("Settings", 600) + : base("Settings") { - RelativeSizeAxes = Axes.None; - Width = WIDTH; - - FillFlow.Spacing = new Vector2(10); + base.Content.Add(Content = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(10), + }); } } } From 54e351efe9e6dfe53fe13034108a454ff480ab03 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 15 Mar 2022 16:57:39 +0900 Subject: [PATCH 2/2] Convert top level skin editor layout to use grid container Fix `SkinEditor`'s initial target not being a `Screen` --- osu.Game/Skinning/Editor/SkinEditor.cs | 180 +++++++++++++------------ 1 file changed, 95 insertions(+), 85 deletions(-) diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index 381f7a1cc3..f7e5aeecdf 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -17,7 +17,6 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; -using osu.Game.Rulesets.Edit; using osu.Game.Screens.Edit.Components; using osu.Game.Screens.Edit.Components.Menus; @@ -51,7 +50,7 @@ namespace osu.Game.Skinning.Editor private Container content; - private EditorToolboxGroup settingsToolbox; + private EditorSidebarSection settingsToolbox; public SkinEditor() { @@ -72,92 +71,111 @@ namespace osu.Game.Skinning.Editor InternalChild = new OsuContextMenuContainer { RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + Child = new GridContainer { - new Container + RelativeSizeAxes = Axes.Both, + RowDimensions = new[] { - Name = "Menu container", - RelativeSizeAxes = Axes.X, - Depth = float.MinValue, - Height = menu_height, - Children = new Drawable[] - { - new EditorMenuBar - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - RelativeSizeAxes = Axes.Both, - Items = new[] - { - new MenuItem("File") - { - Items = new[] - { - new EditorMenuItem("Save", MenuItemType.Standard, Save), - new EditorMenuItem("Revert to default", MenuItemType.Destructive, revert), - new EditorMenuItemSpacer(), - new EditorMenuItem("Exit", MenuItemType.Standard, Hide), - }, - }, - } - }, - headerText = new OsuTextFlowContainer - { - TextAnchor = Anchor.TopRight, - Padding = new MarginPadding(5), - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.X, - RelativeSizeAxes = Axes.Y, - }, - }, - }, - new SkinEditorSceneLibrary - { - RelativeSizeAxes = Axes.X, - Y = menu_height, + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), + new Dimension(), }, - new GridContainer + Content = new[] { - RelativeSizeAxes = Axes.Both, - ColumnDimensions = new[] + new Drawable[] { - new Dimension(GridSizeMode.AutoSize), - new Dimension(), - new Dimension(GridSizeMode.AutoSize), - }, - Content = new[] - { - new Drawable[] + new Container { - new EditorSidebar + Name = "Menu container", + RelativeSizeAxes = Axes.X, + Depth = float.MinValue, + Height = menu_height, + Children = new Drawable[] { - Children = new[] + new EditorMenuBar { - new SkinComponentToolbox + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Both, + Items = new[] { - RequestPlacement = placeComponent + new MenuItem("File") + { + Items = new[] + { + new EditorMenuItem("Save", MenuItemType.Standard, Save), + new EditorMenuItem("Revert to default", MenuItemType.Destructive, revert), + new EditorMenuItemSpacer(), + new EditorMenuItem("Exit", MenuItemType.Standard, Hide), + }, + }, + } + }, + headerText = new OsuTextFlowContainer + { + TextAnchor = Anchor.TopRight, + Padding = new MarginPadding(5), + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + }, + }, + }, + }, + new Drawable[] + { + new SkinEditorSceneLibrary + { + RelativeSizeAxes = Axes.X, + }, + }, + new Drawable[] + { + new GridContainer + { + RelativeSizeAxes = Axes.Both, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize), + new Dimension(), + new Dimension(GridSizeMode.AutoSize), + }, + Content = new[] + { + new Drawable[] + { + new EditorSidebar + { + Children = new[] + { + new SkinComponentToolbox + { + RequestPlacement = placeComponent + }, + } + }, + content = new Container + { + Depth = float.MaxValue, + RelativeSizeAxes = Axes.Both, + }, + new EditorSidebar + { + Children = new[] + { + settingsToolbox = new SkinSettingsToolbox + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + } + } }, } - }, - content = new Container - { - RelativeSizeAxes = Axes.Both, - }, - new EditorSidebar - { - Children = new[] - { - settingsToolbox = new SkinSettingsToolbox - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - } - } - }, + } } - } + }, } } }; @@ -191,17 +209,9 @@ namespace osu.Game.Skinning.Editor SelectedComponents.Clear(); Scheduler.AddOnce(loadBlueprintContainer); + Scheduler.AddOnce(populateSettings); - void loadBlueprintContainer() - { - content.Children = new Drawable[] - { - new SkinBlueprintContainer(targetScreen) - { - Margin = new MarginPadding { Top = 100 }, - } - }; - } + void loadBlueprintContainer() => content.Child = new SkinBlueprintContainer(targetScreen); } private void skinChanged()