1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 13:33:03 +08:00

Add settings modification UI to skin editor

This commit is contained in:
Dean Herbert 2022-03-11 23:30:46 +09:00
parent c99397f75a
commit 8d1ee28e67
4 changed files with 56 additions and 3 deletions

View File

@ -11,6 +11,8 @@ namespace osu.Game.Rulesets.Edit
{ {
protected readonly OsuScrollContainer Scroll; protected readonly OsuScrollContainer Scroll;
protected readonly FillFlowContainer FillFlow;
protected override Container<Drawable> Content { get; } protected override Container<Drawable> Content { get; }
public ScrollingToolboxGroup(string title, float scrollAreaHeight) public ScrollingToolboxGroup(string title, float scrollAreaHeight)
@ -20,7 +22,7 @@ namespace osu.Game.Rulesets.Edit
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = scrollAreaHeight, Height = scrollAreaHeight,
Child = Content = new FillFlowContainer Child = Content = FillFlow = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -11,10 +12,12 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit.Components.Menus; using osu.Game.Screens.Edit.Components.Menus;
namespace osu.Game.Skinning.Editor namespace osu.Game.Skinning.Editor
@ -44,6 +47,8 @@ namespace osu.Game.Skinning.Editor
private Container content; private Container content;
private EditorToolboxGroup settingsToolbox;
public SkinEditor(Drawable targetScreen) public SkinEditor(Drawable targetScreen)
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -103,7 +108,8 @@ namespace osu.Game.Skinning.Editor
ColumnDimensions = new[] ColumnDimensions = new[]
{ {
new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize),
new Dimension() new Dimension(),
new Dimension(GridSizeMode.AutoSize),
}, },
Content = new[] Content = new[]
{ {
@ -119,6 +125,11 @@ namespace osu.Game.Skinning.Editor
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
settingsToolbox = new SkinSettingsToolbox
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
}
} }
} }
} }
@ -143,12 +154,15 @@ namespace osu.Game.Skinning.Editor
hasBegunMutating = false; hasBegunMutating = false;
Scheduler.AddOnce(skinChanged); Scheduler.AddOnce(skinChanged);
}, true); }, true);
SelectedComponents.BindCollectionChanged(selectionChanged);
} }
public void UpdateTargetScreen(Drawable targetScreen) public void UpdateTargetScreen(Drawable targetScreen)
{ {
this.targetScreen = targetScreen; this.targetScreen = targetScreen;
SelectedComponents.Clear();
Scheduler.AddOnce(loadBlueprintContainer); Scheduler.AddOnce(loadBlueprintContainer);
void loadBlueprintContainer() void loadBlueprintContainer()
@ -210,6 +224,18 @@ namespace osu.Game.Skinning.Editor
SelectedComponents.Add(component); SelectedComponents.Add(component);
} }
private void selectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
settingsToolbox.Clear();
var first = SelectedComponents.OfType<Drawable>().FirstOrDefault();
if (first != null)
{
settingsToolbox.Children = first.CreateSettingsControls().ToArray();
}
}
private IEnumerable<ISkinnableTarget> availableTargets => targetScreen.ChildrenOfType<ISkinnableTarget>(); private IEnumerable<ISkinnableTarget> availableTargets => targetScreen.ChildrenOfType<ISkinnableTarget>();
private ISkinnableTarget getTarget(SkinnableTarget target) private ISkinnableTarget getTarget(SkinnableTarget target)

View File

@ -101,9 +101,11 @@ namespace osu.Game.Skinning.Editor
private void editorVisibilityChanged(ValueChangedEvent<Visibility> visibility) private void editorVisibilityChanged(ValueChangedEvent<Visibility> visibility)
{ {
const float toolbar_padding_requirement = 0.18f;
if (visibility.NewValue == Visibility.Visible) 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 else
{ {

View File

@ -0,0 +1,23 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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);
}
}
}