From 8d1ee28e6711eec49735625f8e148993aebbec4a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 11 Mar 2022 23:30:46 +0900 Subject: [PATCH] Add settings modification UI to skin editor --- .../Rulesets/Edit/ScrollingToolboxGroup.cs | 4 ++- osu.Game/Skinning/Editor/SkinEditor.cs | 28 ++++++++++++++++++- osu.Game/Skinning/Editor/SkinEditorOverlay.cs | 4 ++- .../Skinning/Editor/SkinSettingsToolbox.cs | 23 +++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Skinning/Editor/SkinSettingsToolbox.cs diff --git a/osu.Game/Rulesets/Edit/ScrollingToolboxGroup.cs b/osu.Game/Rulesets/Edit/ScrollingToolboxGroup.cs index 9998a997b3..98e026c49a 100644 --- a/osu.Game/Rulesets/Edit/ScrollingToolboxGroup.cs +++ b/osu.Game/Rulesets/Edit/ScrollingToolboxGroup.cs @@ -11,6 +11,8 @@ namespace osu.Game.Rulesets.Edit { protected readonly OsuScrollContainer Scroll; + protected readonly FillFlowContainer FillFlow; + protected override Container Content { get; } public ScrollingToolboxGroup(string title, float scrollAreaHeight) @@ -20,7 +22,7 @@ namespace osu.Game.Rulesets.Edit { RelativeSizeAxes = Axes.X, Height = scrollAreaHeight, - Child = Content = new FillFlowContainer + Child = Content = FillFlow = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index 459fbf3be5..ef26682c03 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Collections.Specialized; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -11,10 +12,12 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; using osu.Framework.Testing; +using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; using osu.Game.Graphics.UserInterface; +using osu.Game.Rulesets.Edit; using osu.Game.Screens.Edit.Components.Menus; namespace osu.Game.Skinning.Editor @@ -44,6 +47,8 @@ namespace osu.Game.Skinning.Editor private Container content; + private EditorToolboxGroup settingsToolbox; + public SkinEditor(Drawable targetScreen) { RelativeSizeAxes = Axes.Both; @@ -103,7 +108,8 @@ namespace osu.Game.Skinning.Editor ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize), - new Dimension() + new Dimension(), + new Dimension(GridSizeMode.AutoSize), }, Content = new[] { @@ -119,6 +125,11 @@ namespace osu.Game.Skinning.Editor { RelativeSizeAxes = Axes.Both, }, + settingsToolbox = new SkinSettingsToolbox + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + } } } } @@ -143,12 +154,15 @@ namespace osu.Game.Skinning.Editor hasBegunMutating = false; Scheduler.AddOnce(skinChanged); }, true); + + SelectedComponents.BindCollectionChanged(selectionChanged); } public void UpdateTargetScreen(Drawable targetScreen) { this.targetScreen = targetScreen; + SelectedComponents.Clear(); Scheduler.AddOnce(loadBlueprintContainer); void loadBlueprintContainer() @@ -210,6 +224,18 @@ namespace osu.Game.Skinning.Editor SelectedComponents.Add(component); } + private void selectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + settingsToolbox.Clear(); + + var first = SelectedComponents.OfType().FirstOrDefault(); + + if (first != null) + { + settingsToolbox.Children = first.CreateSettingsControls().ToArray(); + } + } + private IEnumerable availableTargets => targetScreen.ChildrenOfType(); private ISkinnableTarget getTarget(SkinnableTarget target) diff --git a/osu.Game/Skinning/Editor/SkinEditorOverlay.cs b/osu.Game/Skinning/Editor/SkinEditorOverlay.cs index abd8272633..08cdbf0aa9 100644 --- a/osu.Game/Skinning/Editor/SkinEditorOverlay.cs +++ b/osu.Game/Skinning/Editor/SkinEditorOverlay.cs @@ -101,9 +101,11 @@ namespace osu.Game.Skinning.Editor private void editorVisibilityChanged(ValueChangedEvent visibility) { + const float toolbar_padding_requirement = 0.18f; + if (visibility.NewValue == Visibility.Visible) { - target.SetCustomRect(new RectangleF(0.18f, 0.1f, VISIBLE_TARGET_SCALE, VISIBLE_TARGET_SCALE), true); + target.SetCustomRect(new RectangleF(toolbar_padding_requirement, 0.1f, 0.8f - toolbar_padding_requirement, 0.7f), true); } else { diff --git a/osu.Game/Skinning/Editor/SkinSettingsToolbox.cs b/osu.Game/Skinning/Editor/SkinSettingsToolbox.cs new file mode 100644 index 0000000000..c0ef8e7316 --- /dev/null +++ b/osu.Game/Skinning/Editor/SkinSettingsToolbox.cs @@ -0,0 +1,23 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Game.Rulesets.Edit; +using osuTK; + +namespace osu.Game.Skinning.Editor +{ + internal class SkinSettingsToolbox : ScrollingToolboxGroup + { + public const float WIDTH = 200; + + public SkinSettingsToolbox() + : base("Settings", 600) + { + RelativeSizeAxes = Axes.None; + Width = WIDTH; + + FillFlow.Spacing = new Vector2(10); + } + } +}