1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-30 21:42:56 +08:00
osu-lazer/osu.Game/Overlays/SkinEditor/SkinSettingsToolbox.cs

57 lines
1.8 KiB
C#
Raw Normal View History

// 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 System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
2023-01-17 00:55:28 +08:00
using osu.Game.Localisation;
using osu.Game.Overlays.Settings;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components;
using osuTK;
2023-01-26 17:21:04 +08:00
namespace osu.Game.Overlays.SkinEditor
{
2022-11-24 13:32:20 +08:00
internal partial class SkinSettingsToolbox : EditorSidebarSection
{
[Resolved]
private IEditorChangeHandler? changeHandler { get; set; }
protected override Container<Drawable> Content { get; }
private readonly Drawable component;
public SkinSettingsToolbox(Drawable component)
2023-01-17 00:55:28 +08:00
: base(SkinEditorStrings.Settings(component.GetType().Name))
{
this.component = component;
base.Content.Add(Content = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(10),
});
}
[BackgroundDependencyLoader]
private void load()
{
var controls = component.CreateSettingsControls().ToArray();
Content.AddRange(controls);
// track any changes to update undo states.
foreach (var c in controls.OfType<ISettingsItem>())
{
// TODO: SettingChanged is called too often for cases like SettingsTextBox and SettingsSlider.
// We will want to expose a SettingCommitted or similar to make this work better.
c.SettingChanged += () => changeHandler?.SaveState();
}
}
}
}