From 1831f581aa15f14f4cd01bf73122dedc5a5d804b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 May 2021 18:07:58 +0900 Subject: [PATCH] Add basic metadata display and remove outdated message about not saving --- osu.Game/Skinning/Editor/SkinEditor.cs | 55 ++++++++++++++++---------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index b098136eda..0e243d1a02 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -36,7 +36,8 @@ namespace osu.Game.Skinning.Editor private Bindable currentSkin; - private SkinBlueprintContainer blueprintContainer; + [Resolved] + private OsuColour colours { get; set; } public SkinEditor(Drawable targetScreen) { @@ -46,7 +47,7 @@ namespace osu.Game.Skinning.Editor } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load() { InternalChild = new OsuContextMenuContainer { @@ -61,7 +62,7 @@ namespace osu.Game.Skinning.Editor Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.X }, - blueprintContainer = new SkinBlueprintContainer(targetScreen), + new SkinBlueprintContainer(targetScreen), new SkinComponentToolbox(600) { Anchor = Anchor.CentreLeft, @@ -103,13 +104,42 @@ namespace osu.Game.Skinning.Editor }, } }; + } - headerText.AddParagraph("Skin editor (preview)", cp => cp.Font = OsuFont.Default.With(size: 24)); - headerText.AddParagraph("This is a preview of what is to come. Changes are lost on changing screens.", cp => + protected override void LoadComplete() + { + base.LoadComplete(); + + Show(); + + // as long as the skin editor is loaded, let's make sure we can modify the current skin. + currentSkin = skins.CurrentSkin.GetBoundCopy(); + + // schedule ensures this only happens when the skin editor is visible. + // also avoid some weird endless recursion / bindable feedback loop (something to do with tracking skins across three different bindable types). + // probably something which will be factored out in a future database refactor so not too concerning for now. + currentSkin.BindValueChanged(skin => Scheduler.AddOnce(skinChanged), true); + } + + private void skinChanged() + { + headerText.Clear(); + + headerText.AddParagraph("Skin editor", cp => cp.Font = OsuFont.Default.With(size: 24)); + headerText.NewParagraph(); + headerText.AddText("Currently editing ", cp => { cp.Font = OsuFont.Default.With(size: 12); cp.Colour = colours.Yellow; }); + + headerText.AddText($"{currentSkin.Value.SkinInfo}", cp => + { + cp.Font = OsuFont.Default.With(size: 12, weight: FontWeight.Bold); + cp.Colour = colours.Yellow; + }); + + skins.EnsureMutableSkin(); } private void placeComponent(Type type) @@ -130,21 +160,6 @@ namespace osu.Game.Skinning.Editor return targetScreen.ChildrenOfType().FirstOrDefault(c => c.Target == target); } - protected override void LoadComplete() - { - base.LoadComplete(); - - Show(); - - // as long as the skin editor is loaded, let's make sure we can modify the current skin. - currentSkin = skins.CurrentSkin.GetBoundCopy(); - - // schedule ensures this only happens when the skin editor is visible. - // also avoid some weird endless recursion / bindable feedback loop (something to do with tracking skins across three different bindable types). - // probably something which will be factored out in a future database refactor so not too concerning for now. - currentSkin.BindValueChanged(skin => Scheduler.AddOnce(skins.EnsureMutableSkin), true); - } - private void revert() { SkinnableElementTargetContainer[] targetContainers = targetScreen.ChildrenOfType().ToArray();