From 4770a64709e529479c69ad7a4ae024a9801f2fe0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Apr 2021 18:47:22 +0900 Subject: [PATCH 01/12] Add proof of concept components list --- .../TestSceneSkinEditorComponentsList.cs | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs new file mode 100644 index 0000000000..4aec91a81f --- /dev/null +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs @@ -0,0 +1,93 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Diagnostics; +using System.Linq; +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Osu; +using osu.Game.Screens.Play.HUD; +using osuTK; + +namespace osu.Game.Tests.Visual.Gameplay +{ + public class TestSceneSkinEditorComponentsList : SkinnableTestScene + { + [Test] + public void TestToggleEditor() + { + AddStep("show available components", () => + { + SetContents(() => + { + FillFlowContainer fill; + + var scroll = new OsuScrollContainer + { + RelativeSizeAxes = Axes.Both, + Child = fill = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Width = 0.5f, + Direction = FillDirection.Vertical, + Spacing = new Vector2(20) + } + }; + + var skinnableTypes = typeof(OsuGame).Assembly.GetTypes().Where(t => typeof(ISkinnableComponent).IsAssignableFrom(t)).ToArray(); + + foreach (var type in skinnableTypes) + { + try + { + fill.Add(new OsuSpriteText { Text = type.Name }); + + var instance = (Drawable)Activator.CreateInstance(type); + + Debug.Assert(instance != null); + + instance.Anchor = Anchor.TopCentre; + instance.Origin = Anchor.TopCentre; + + var container = new Container + { + RelativeSizeAxes = Axes.X, + Height = 100, + Children = new[] + { + instance + } + }; + + switch (instance) + { + case IScoreCounter score: + score.Current.Value = 133773; + break; + + case IComboCounter combo: + combo.Current.Value = 727; + break; + } + + fill.Add(container); + } + catch { } + } + + return scroll; + }); + }); + } + + protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset(); + } +} From 6442fb819f61dfebd2733cf4033260f8e57b3646 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Apr 2021 12:09:58 +0900 Subject: [PATCH 02/12] Split out component from test scene and fix SongProgress --- .../TestSceneSkinEditorComponentsList.cs | 77 +--------- osu.Game/Screens/Play/SongProgress.cs | 16 ++- .../Skinning/Editor/SkinComponentToolbox.cs | 134 ++++++++++++++++++ 3 files changed, 149 insertions(+), 78 deletions(-) create mode 100644 osu.Game/Skinning/Editor/SkinComponentToolbox.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs index 4aec91a81f..2fd40f5d7c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs @@ -1,18 +1,11 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; -using System.Diagnostics; -using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; -using osu.Game.Screens.Play.HUD; -using osuTK; +using osu.Game.Skinning.Editor; namespace osu.Game.Tests.Visual.Gameplay { @@ -21,71 +14,11 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestToggleEditor() { - AddStep("show available components", () => + AddStep("show available components", () => SetContents(() => new SkinComponentToolbox { - SetContents(() => - { - FillFlowContainer fill; - - var scroll = new OsuScrollContainer - { - RelativeSizeAxes = Axes.Both, - Child = fill = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Width = 0.5f, - Direction = FillDirection.Vertical, - Spacing = new Vector2(20) - } - }; - - var skinnableTypes = typeof(OsuGame).Assembly.GetTypes().Where(t => typeof(ISkinnableComponent).IsAssignableFrom(t)).ToArray(); - - foreach (var type in skinnableTypes) - { - try - { - fill.Add(new OsuSpriteText { Text = type.Name }); - - var instance = (Drawable)Activator.CreateInstance(type); - - Debug.Assert(instance != null); - - instance.Anchor = Anchor.TopCentre; - instance.Origin = Anchor.TopCentre; - - var container = new Container - { - RelativeSizeAxes = Axes.X, - Height = 100, - Children = new[] - { - instance - } - }; - - switch (instance) - { - case IScoreCounter score: - score.Current.Value = 133773; - break; - - case IComboCounter combo: - combo.Current.Value = 727; - break; - } - - fill.Add(container); - } - catch { } - } - - return scroll; - }); - }); + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + })); } protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset(); diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index db81633aea..2e94421f36 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -76,10 +76,6 @@ namespace osu.Game.Screens.Play { new SongProgressDisplay { - Masking = true, - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, Children = new Drawable[] { info = new SongProgressInfo @@ -187,8 +183,16 @@ namespace osu.Game.Screens.Play public class SongProgressDisplay : Container, ISkinnableComponent { - // TODO: move actual implementation into this. - // exists for skin customisation purposes. + public SongProgressDisplay() + { + // TODO: move actual implementation into this. + // exists for skin customisation purposes. + + Masking = true; + RelativeSizeAxes = Axes.Both; + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; + } } } } diff --git a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs new file mode 100644 index 0000000000..5b2b9a8608 --- /dev/null +++ b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs @@ -0,0 +1,134 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Diagnostics; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Play.HUD; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Skinning.Editor +{ + public class SkinComponentToolbox : CompositeDrawable + { + public SkinComponentToolbox() + { + RelativeSizeAxes = Axes.Y; + Width = 500; + } + + [BackgroundDependencyLoader] + private void load() + { + FillFlowContainer fill; + + InternalChild = new OsuScrollContainer + { + RelativeSizeAxes = Axes.Both, + Child = fill = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Width = 0.5f, + Direction = FillDirection.Vertical, + Spacing = new Vector2(20) + } + }; + + var skinnableTypes = typeof(OsuGame).Assembly.GetTypes().Where(t => typeof(ISkinnableComponent).IsAssignableFrom(t)).ToArray(); + + foreach (var type in skinnableTypes) + { + var container = attemptAddComponent(type); + if (container != null) + fill.Add(container); + } + } + + private static Drawable attemptAddComponent(Type type) + { + try + { + var instance = (Drawable)Activator.CreateInstance(type); + + Debug.Assert(instance != null); + + return new ToolboxComponent(instance); + } + catch + { + } + + return null; + } + + private class ToolboxComponent : CompositeDrawable + { + public ToolboxComponent(Drawable instance) + { + Container innerContainer; + + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + InternalChild = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new OsuSpriteText { Text = instance.GetType().Name }, + innerContainer = new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Masking = true, + CornerRadius = 10, + Children = new[] + { + new Box + { + Colour = Color4.Black, + Alpha = 0.5f, + RelativeSizeAxes = Axes.Both, + }, + instance + } + }, + } + }; + + // adjust provided component to fit / display in a known state. + + instance.Anchor = Anchor.Centre; + instance.Origin = Anchor.Centre; + + if (instance.RelativeSizeAxes != Axes.None) + { + innerContainer.AutoSizeAxes = Axes.None; + innerContainer.Height = 100; + } + + switch (instance) + { + case IScoreCounter score: + score.Current.Value = 133773; + break; + + case IComboCounter combo: + combo.Current.Value = 727; + break; + } + } + } + } +} From ae9d1dc40b800708e7f0f904f18acc2c4ecbf757 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Apr 2021 12:35:58 +0900 Subject: [PATCH 03/12] Add component list to main editor interface and enable basic placement --- .../Visual/Gameplay/TestSceneSkinEditor.cs | 2 + .../Skinning/Editor/SkinComponentToolbox.cs | 67 ++++++++++++++----- osu.Game/Skinning/Editor/SkinEditor.cs | 19 ++++++ .../Skinning/Editor/SkinEditorContainer.cs | 9 ++- 4 files changed, 76 insertions(+), 21 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs index 0c2c6ed454..df481b0558 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using osu.Framework.Graphics; using osu.Framework.Testing; using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; @@ -21,6 +22,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("add editor overlay", () => { skinEditor?.Expire(); + Player.ScaleTo(SkinEditorContainer.VISIBLE_TARGET_SCALE); LoadComponentAsync(skinEditor = new SkinEditor(Player), Add); }); } diff --git a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs index 5b2b9a8608..f616366336 100644 --- a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs +++ b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs @@ -8,6 +8,8 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Play.HUD; @@ -18,10 +20,12 @@ namespace osu.Game.Skinning.Editor { public class SkinComponentToolbox : CompositeDrawable { + public Action RequestPlacement; + public SkinComponentToolbox() { RelativeSizeAxes = Axes.Y; - Width = 500; + Width = 200; } [BackgroundDependencyLoader] @@ -36,9 +40,6 @@ namespace osu.Game.Skinning.Editor { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Width = 0.5f, Direction = FillDirection.Vertical, Spacing = new Vector2(20) } @@ -48,13 +49,17 @@ namespace osu.Game.Skinning.Editor foreach (var type in skinnableTypes) { - var container = attemptAddComponent(type); - if (container != null) - fill.Add(container); + var component = attemptAddComponent(type); + + if (component != null) + { + component.RequestPlacement = t => RequestPlacement?.Invoke(t); + fill.Add(component); + } } } - private static Drawable attemptAddComponent(Type type) + private static ToolboxComponent attemptAddComponent(Type type) { try { @@ -66,15 +71,20 @@ namespace osu.Game.Skinning.Editor } catch { + return null; } - - return null; } private class ToolboxComponent : CompositeDrawable { - public ToolboxComponent(Drawable instance) + private readonly Drawable component; + private readonly Box box; + + public Action RequestPlacement; + + public ToolboxComponent(Drawable component) { + this.component = component; Container innerContainer; RelativeSizeAxes = Axes.X; @@ -86,7 +96,7 @@ namespace osu.Game.Skinning.Editor AutoSizeAxes = Axes.Y, Children = new Drawable[] { - new OsuSpriteText { Text = instance.GetType().Name }, + new OsuSpriteText { Text = component.GetType().Name }, innerContainer = new Container { RelativeSizeAxes = Axes.X, @@ -95,13 +105,13 @@ namespace osu.Game.Skinning.Editor CornerRadius = 10, Children = new[] { - new Box + box = new Box { Colour = Color4.Black, Alpha = 0.5f, RelativeSizeAxes = Axes.Both, }, - instance + component } }, } @@ -109,16 +119,16 @@ namespace osu.Game.Skinning.Editor // adjust provided component to fit / display in a known state. - instance.Anchor = Anchor.Centre; - instance.Origin = Anchor.Centre; + component.Anchor = Anchor.Centre; + component.Origin = Anchor.Centre; - if (instance.RelativeSizeAxes != Axes.None) + if (component.RelativeSizeAxes != Axes.None) { innerContainer.AutoSizeAxes = Axes.None; innerContainer.Height = 100; } - switch (instance) + switch (component) { case IScoreCounter score: score.Current.Value = 133773; @@ -129,6 +139,27 @@ namespace osu.Game.Skinning.Editor break; } } + + [Resolved] + private OsuColour colours { get; set; } + + protected override bool OnClick(ClickEvent e) + { + RequestPlacement?.Invoke(component.GetType()); + return true; + } + + protected override bool OnHover(HoverEvent e) + { + box.FadeColour(colours.Yellow, 100); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + box.FadeColour(Color4.Black, 100); + base.OnHoverLost(e); + } } } } diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index 562dd23224..885d41043c 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -1,13 +1,17 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; +using osu.Framework.Testing; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; +using osu.Game.Screens.Play; namespace osu.Game.Skinning.Editor { @@ -45,6 +49,12 @@ namespace osu.Game.Skinning.Editor RelativeSizeAxes = Axes.X }, new SkinBlueprintContainer(target), + new SkinComponentToolbox + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RequestPlacement = placeComponent + } } }; @@ -56,6 +66,15 @@ namespace osu.Game.Skinning.Editor }); } + private void placeComponent(Type type) + { + var instance = (Drawable)Activator.CreateInstance(type); + + var targetContainer = target.ChildrenOfType().FirstOrDefault(); + + targetContainer?.Add(instance); + } + protected override void LoadComplete() { base.LoadComplete(); diff --git a/osu.Game/Skinning/Editor/SkinEditorContainer.cs b/osu.Game/Skinning/Editor/SkinEditorContainer.cs index adb1abefd1..06bf278010 100644 --- a/osu.Game/Skinning/Editor/SkinEditorContainer.cs +++ b/osu.Game/Skinning/Editor/SkinEditorContainer.cs @@ -20,7 +20,7 @@ namespace osu.Game.Skinning.Editor private readonly ScalingContainer target; private SkinEditor skinEditor; - private const float visible_target_scale = 0.8f; + public const float VISIBLE_TARGET_SCALE = 0.8f; [Resolved] private OsuColour colours { get; set; } @@ -63,12 +63,14 @@ namespace osu.Game.Skinning.Editor { if (visibility.NewValue == Visibility.Visible) { - target.ScaleTo(visible_target_scale, SkinEditor.TRANSITION_DURATION, Easing.OutQuint); - target.Masking = true; target.BorderThickness = 5; target.BorderColour = colours.Yellow; target.AllowScaling = false; + target.RelativePositionAxes = Axes.Both; + + target.ScaleTo(VISIBLE_TARGET_SCALE, SkinEditor.TRANSITION_DURATION, Easing.OutQuint); + target.MoveToX(0.1f, SkinEditor.TRANSITION_DURATION, Easing.OutQuint); } else { @@ -76,6 +78,7 @@ namespace osu.Game.Skinning.Editor target.AllowScaling = true; target.ScaleTo(1, SkinEditor.TRANSITION_DURATION, Easing.OutQuint).OnComplete(_ => target.Masking = false); + target.MoveToX(0f, SkinEditor.TRANSITION_DURATION, Easing.OutQuint); } } From 5585a7d4380cb6a7070f7f8dbaa6a9fe3c0caaad Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Apr 2021 12:41:18 +0900 Subject: [PATCH 04/12] Add basic interfaces for skinnable target containers --- .../Screens/Play/HUD/IDefaultSkinnableTarget.cs | 12 ++++++++++++ osu.Game/Screens/Play/HUD/ISkinnableTarget.cs | 15 +++++++++++++++ osu.Game/Screens/Play/HUDOverlay.cs | 2 +- osu.Game/Skinning/Editor/SkinEditor.cs | 4 ++-- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Screens/Play/HUD/IDefaultSkinnableTarget.cs create mode 100644 osu.Game/Screens/Play/HUD/ISkinnableTarget.cs diff --git a/osu.Game/Screens/Play/HUD/IDefaultSkinnableTarget.cs b/osu.Game/Screens/Play/HUD/IDefaultSkinnableTarget.cs new file mode 100644 index 0000000000..208d920dec --- /dev/null +++ b/osu.Game/Screens/Play/HUD/IDefaultSkinnableTarget.cs @@ -0,0 +1,12 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Screens.Play.HUD +{ + /// + /// The default placement location for new s. + /// + public interface IDefaultSkinnableTarget : ISkinnableTarget + { + } +} diff --git a/osu.Game/Screens/Play/HUD/ISkinnableTarget.cs b/osu.Game/Screens/Play/HUD/ISkinnableTarget.cs new file mode 100644 index 0000000000..61a173ed02 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/ISkinnableTarget.cs @@ -0,0 +1,15 @@ +// 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.Framework.Graphics.Containers; + +namespace osu.Game.Screens.Play.HUD +{ + /// + /// Denotes a container which can house s. + /// + public interface ISkinnableTarget : IContainerCollection + { + } +} diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 669c920017..eb6e599a19 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -22,7 +22,7 @@ using osuTK; namespace osu.Game.Screens.Play { [Cached] - public class HUDOverlay : Container, IKeyBindingHandler + public class HUDOverlay : Container, IKeyBindingHandler, IDefaultSkinnableTarget { public const float FADE_DURATION = 300; diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index 885d41043c..6d189dc027 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -11,7 +11,7 @@ using osu.Framework.Testing; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; -using osu.Game.Screens.Play; +using osu.Game.Screens.Play.HUD; namespace osu.Game.Skinning.Editor { @@ -70,7 +70,7 @@ namespace osu.Game.Skinning.Editor { var instance = (Drawable)Activator.CreateInstance(type); - var targetContainer = target.ChildrenOfType().FirstOrDefault(); + var targetContainer = target.ChildrenOfType().FirstOrDefault(); targetContainer?.Add(instance); } From 8b82a07914cfb531f01f2c75c8d0b27da83eb5c4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Apr 2021 12:42:32 +0900 Subject: [PATCH 05/12] Move skin-related interfaces out of HUD namespace --- osu.Game/Screens/Play/HUD/DefaultAccuracyCounter.cs | 1 + osu.Game/Screens/Play/HUD/DefaultComboCounter.cs | 1 + osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs | 1 + osu.Game/Screens/Play/HUD/DefaultScoreCounter.cs | 1 + osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs | 1 + osu.Game/Screens/Play/HUDOverlay.cs | 1 + osu.Game/Screens/Play/SongProgress.cs | 2 +- osu.Game/Skinning/Editor/SkinBlueprint.cs | 1 - osu.Game/Skinning/Editor/SkinBlueprintContainer.cs | 1 - osu.Game/Skinning/Editor/SkinEditor.cs | 1 - osu.Game/Skinning/Editor/SkinSelectionHandler.cs | 1 - .../{Screens/Play/HUD => Skinning}/IDefaultSkinnableTarget.cs | 2 +- osu.Game/{Screens/Play/HUD => Skinning}/ISkinnableComponent.cs | 2 +- osu.Game/{Screens/Play/HUD => Skinning}/ISkinnableTarget.cs | 2 +- osu.Game/Skinning/LegacyScoreCounter.cs | 1 - 15 files changed, 10 insertions(+), 9 deletions(-) rename osu.Game/{Screens/Play/HUD => Skinning}/IDefaultSkinnableTarget.cs (90%) rename osu.Game/{Screens/Play/HUD => Skinning}/ISkinnableComponent.cs (91%) rename osu.Game/{Screens/Play/HUD => Skinning}/ISkinnableTarget.cs (92%) diff --git a/osu.Game/Screens/Play/HUD/DefaultAccuracyCounter.cs b/osu.Game/Screens/Play/HUD/DefaultAccuracyCounter.cs index b8a43708b4..5db1e96dc9 100644 --- a/osu.Game/Screens/Play/HUD/DefaultAccuracyCounter.cs +++ b/osu.Game/Screens/Play/HUD/DefaultAccuracyCounter.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; +using osu.Game.Skinning; using osuTK; namespace osu.Game.Screens.Play.HUD diff --git a/osu.Game/Screens/Play/HUD/DefaultComboCounter.cs b/osu.Game/Screens/Play/HUD/DefaultComboCounter.cs index 959766ecd1..a6bd95b36c 100644 --- a/osu.Game/Screens/Play/HUD/DefaultComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/DefaultComboCounter.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Skinning; using osuTK; namespace osu.Game.Screens.Play.HUD diff --git a/osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs b/osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs index e3cd71691d..f99428d07e 100644 --- a/osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs @@ -13,6 +13,7 @@ using osuTK; using osuTK.Graphics; using osu.Framework.Graphics.Shapes; using osu.Framework.Utils; +using osu.Game.Skinning; namespace osu.Game.Screens.Play.HUD { diff --git a/osu.Game/Screens/Play/HUD/DefaultScoreCounter.cs b/osu.Game/Screens/Play/HUD/DefaultScoreCounter.cs index dde5c18b38..1f154fe168 100644 --- a/osu.Game/Screens/Play/HUD/DefaultScoreCounter.cs +++ b/osu.Game/Screens/Play/HUD/DefaultScoreCounter.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; +using osu.Game.Skinning; namespace osu.Game.Screens.Play.HUD { diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs index 3b24c8cc9e..26d5e622f7 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs @@ -13,6 +13,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; +using osu.Game.Skinning; using osuTK; using osuTK.Graphics; diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index eb6e599a19..621d604278 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -17,6 +17,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Screens.Play.HUD; +using osu.Game.Skinning; using osuTK; namespace osu.Game.Screens.Play diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 2e94421f36..d85f3538e4 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -14,7 +14,7 @@ using osu.Framework.Timing; using osu.Game.Configuration; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.UI; -using osu.Game.Screens.Play.HUD; +using osu.Game.Skinning; namespace osu.Game.Screens.Play { diff --git a/osu.Game/Skinning/Editor/SkinBlueprint.cs b/osu.Game/Skinning/Editor/SkinBlueprint.cs index 491a403325..b82b861e3e 100644 --- a/osu.Game/Skinning/Editor/SkinBlueprint.cs +++ b/osu.Game/Skinning/Editor/SkinBlueprint.cs @@ -10,7 +10,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Screens.Play.HUD; using osuTK; namespace osu.Game.Skinning.Editor diff --git a/osu.Game/Skinning/Editor/SkinBlueprintContainer.cs b/osu.Game/Skinning/Editor/SkinBlueprintContainer.cs index f2bc8ecddf..9c0327df00 100644 --- a/osu.Game/Skinning/Editor/SkinBlueprintContainer.cs +++ b/osu.Game/Skinning/Editor/SkinBlueprintContainer.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Testing; using osu.Game.Rulesets.Edit; using osu.Game.Screens.Edit.Compose.Components; -using osu.Game.Screens.Play.HUD; namespace osu.Game.Skinning.Editor { diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index 6d189dc027..902cb389e6 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -11,7 +11,6 @@ using osu.Framework.Testing; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; -using osu.Game.Screens.Play.HUD; namespace osu.Game.Skinning.Editor { diff --git a/osu.Game/Skinning/Editor/SkinSelectionHandler.cs b/osu.Game/Skinning/Editor/SkinSelectionHandler.cs index 0408ce74a6..e95bd5f8a3 100644 --- a/osu.Game/Skinning/Editor/SkinSelectionHandler.cs +++ b/osu.Game/Skinning/Editor/SkinSelectionHandler.cs @@ -10,7 +10,6 @@ using osu.Game.Extensions; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Edit; using osu.Game.Screens.Edit.Compose.Components; -using osu.Game.Screens.Play.HUD; using osuTK; namespace osu.Game.Skinning.Editor diff --git a/osu.Game/Screens/Play/HUD/IDefaultSkinnableTarget.cs b/osu.Game/Skinning/IDefaultSkinnableTarget.cs similarity index 90% rename from osu.Game/Screens/Play/HUD/IDefaultSkinnableTarget.cs rename to osu.Game/Skinning/IDefaultSkinnableTarget.cs index 208d920dec..24fb454af8 100644 --- a/osu.Game/Screens/Play/HUD/IDefaultSkinnableTarget.cs +++ b/osu.Game/Skinning/IDefaultSkinnableTarget.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -namespace osu.Game.Screens.Play.HUD +namespace osu.Game.Skinning { /// /// The default placement location for new s. diff --git a/osu.Game/Screens/Play/HUD/ISkinnableComponent.cs b/osu.Game/Skinning/ISkinnableComponent.cs similarity index 91% rename from osu.Game/Screens/Play/HUD/ISkinnableComponent.cs rename to osu.Game/Skinning/ISkinnableComponent.cs index 6d4558443f..f6b0a182b4 100644 --- a/osu.Game/Screens/Play/HUD/ISkinnableComponent.cs +++ b/osu.Game/Skinning/ISkinnableComponent.cs @@ -3,7 +3,7 @@ using osu.Framework.Graphics; -namespace osu.Game.Screens.Play.HUD +namespace osu.Game.Skinning { /// /// Denotes a drawable which, as a drawable, can be adjusted via skinning specifications. diff --git a/osu.Game/Screens/Play/HUD/ISkinnableTarget.cs b/osu.Game/Skinning/ISkinnableTarget.cs similarity index 92% rename from osu.Game/Screens/Play/HUD/ISkinnableTarget.cs rename to osu.Game/Skinning/ISkinnableTarget.cs index 61a173ed02..607e89fdec 100644 --- a/osu.Game/Screens/Play/HUD/ISkinnableTarget.cs +++ b/osu.Game/Skinning/ISkinnableTarget.cs @@ -4,7 +4,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -namespace osu.Game.Screens.Play.HUD +namespace osu.Game.Skinning { /// /// Denotes a container which can house s. diff --git a/osu.Game/Skinning/LegacyScoreCounter.cs b/osu.Game/Skinning/LegacyScoreCounter.cs index cae8044242..c270ce7e69 100644 --- a/osu.Game/Skinning/LegacyScoreCounter.cs +++ b/osu.Game/Skinning/LegacyScoreCounter.cs @@ -5,7 +5,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Play.HUD; using osuTK; namespace osu.Game.Skinning From 20ff05c9ffacd5ebc129c1ffe4239a65c3a02bc3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Apr 2021 13:03:54 +0900 Subject: [PATCH 06/12] Fix crosstalk between notification/setting overlay nudge padding and skin overlay position adjust --- osu.Game/OsuGame.cs | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 77fb9c3b63..b7824a01a4 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -595,28 +595,35 @@ namespace osu.Game ActionRequested = action => volume.Adjust(action), ScrollActionRequested = (action, amount, isPrecise) => volume.Adjust(action, amount, isPrecise), }, - screenContainer = new ScalingContainer(ScalingMode.ExcludeOverlays) + screenOffsetContainer = new Container { RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, Children = new Drawable[] { - receptor = new BackButton.Receptor(), - ScreenStack = new OsuScreenStack { RelativeSizeAxes = Axes.Both }, - BackButton = new BackButton(receptor) + screenContainer = new ScalingContainer(ScalingMode.ExcludeOverlays) { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Action = () => + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] { - var currentScreen = ScreenStack.CurrentScreen as IOsuScreen; + receptor = new BackButton.Receptor(), + ScreenStack = new OsuScreenStack { RelativeSizeAxes = Axes.Both }, + BackButton = new BackButton(receptor) + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Action = () => + { + var currentScreen = ScreenStack.CurrentScreen as IOsuScreen; - if (currentScreen?.AllowBackButton == true && !currentScreen.OnBackButton()) - ScreenStack.Exit(); + if (currentScreen?.AllowBackButton == true && !currentScreen.OnBackButton()) + ScreenStack.Exit(); + } + }, + logoContainer = new Container { RelativeSizeAxes = Axes.Both }, } }, - logoContainer = new Container { RelativeSizeAxes = Axes.Both }, } }, overlayContent = new Container { RelativeSizeAxes = Axes.Both }, @@ -766,7 +773,7 @@ namespace osu.Game if (notifications.State.Value == Visibility.Visible) offset -= Toolbar.HEIGHT / 2; - screenContainer.MoveToX(offset, SettingsPanel.TRANSITION_LENGTH, Easing.OutQuint); + screenOffsetContainer.MoveToX(offset, SettingsPanel.TRANSITION_LENGTH, Easing.OutQuint); } Settings.State.ValueChanged += _ => updateScreenOffset(); @@ -946,6 +953,8 @@ namespace osu.Game private ScalingContainer screenContainer; + private Container screenOffsetContainer; + private SkinEditorContainer skinEditor; protected override bool OnExiting() @@ -966,7 +975,7 @@ namespace osu.Game { base.UpdateAfterChildren(); - screenContainer.Padding = new MarginPadding { Top = ToolbarOffset }; + screenOffsetContainer.Padding = new MarginPadding { Top = ToolbarOffset }; overlayContent.Padding = new MarginPadding { Top = ToolbarOffset }; MenuCursorContainer.CanShowCursor = (ScreenStack.CurrentScreen as IOsuScreen)?.CursorVisible ?? false; From bde72faa7ccf81f74b9fbd16538f954ce9488edf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Apr 2021 13:04:10 +0900 Subject: [PATCH 07/12] Limit components list height to better align with actual viewport --- osu.Game/Skinning/Editor/SkinEditor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index 902cb389e6..298976c39b 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -52,6 +52,7 @@ namespace osu.Game.Skinning.Editor { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, + Height = SkinEditorContainer.VISIBLE_TARGET_SCALE, RequestPlacement = placeComponent } } From a1e64f4e3cc9faae55d3891d6850e1fb17d0767f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Apr 2021 14:37:49 +0900 Subject: [PATCH 08/12] Use the existing toolbox design --- .../TestSceneSkinEditorComponentsList.cs | 2 +- .../Rulesets/Edit/ScrollingToolboxGroup.cs | 32 +++++++++++++++++++ .../Skinning/Editor/SkinComponentToolbox.cs | 23 ++++++------- osu.Game/Skinning/Editor/SkinEditor.cs | 3 +- 4 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 osu.Game/Rulesets/Edit/ScrollingToolboxGroup.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs index 2fd40f5d7c..14bd62b98a 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorComponentsList.cs @@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestToggleEditor() { - AddStep("show available components", () => SetContents(() => new SkinComponentToolbox + AddStep("show available components", () => SetContents(() => new SkinComponentToolbox(300) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, diff --git a/osu.Game/Rulesets/Edit/ScrollingToolboxGroup.cs b/osu.Game/Rulesets/Edit/ScrollingToolboxGroup.cs new file mode 100644 index 0000000000..a54f574bff --- /dev/null +++ b/osu.Game/Rulesets/Edit/ScrollingToolboxGroup.cs @@ -0,0 +1,32 @@ +// 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.Framework.Graphics.Containers; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Rulesets.Edit +{ + public class ScrollingToolboxGroup : ToolboxGroup + { + protected readonly OsuScrollContainer Scroll; + + protected override Container Content { get; } + + public ScrollingToolboxGroup(string title, float scrollAreaHeight) + : base(title) + { + base.Content.Add(Scroll = new OsuScrollContainer + { + RelativeSizeAxes = Axes.X, + Height = scrollAreaHeight, + Child = Content = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + }, + }); + } + } +} diff --git a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs index f616366336..6b7439c229 100644 --- a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs +++ b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs @@ -10,21 +10,22 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Edit; using osu.Game.Screens.Play.HUD; using osuTK; using osuTK.Graphics; namespace osu.Game.Skinning.Editor { - public class SkinComponentToolbox : CompositeDrawable + public class SkinComponentToolbox : ScrollingToolboxGroup { public Action RequestPlacement; - public SkinComponentToolbox() + public SkinComponentToolbox(float height) + : base("Components", height) { - RelativeSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.None; Width = 200; } @@ -33,16 +34,12 @@ namespace osu.Game.Skinning.Editor { FillFlowContainer fill; - InternalChild = new OsuScrollContainer + Child = fill = new FillFlowContainer { - RelativeSizeAxes = Axes.Both, - Child = fill = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(20) - } + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(20) }; var skinnableTypes = typeof(OsuGame).Assembly.GetTypes().Where(t => typeof(ISkinnableComponent).IsAssignableFrom(t)).ToArray(); diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index 298976c39b..18a8b220df 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -48,11 +48,10 @@ namespace osu.Game.Skinning.Editor RelativeSizeAxes = Axes.X }, new SkinBlueprintContainer(target), - new SkinComponentToolbox + new SkinComponentToolbox(600) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Height = SkinEditorContainer.VISIBLE_TARGET_SCALE, RequestPlacement = placeComponent } } From e663629bc64ceedb95fda5adbf26c2a6c1be99cd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Apr 2021 15:22:51 +0900 Subject: [PATCH 09/12] Match button appearance to that of the beatmap editor --- .../Skinning/Editor/SkinComponentToolbox.cs | 107 +++++++++--------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs index 6b7439c229..46b8d5d5ea 100644 --- a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs +++ b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs @@ -5,12 +5,14 @@ using System; using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Effects; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Edit; using osu.Game.Screens.Play.HUD; using osuTK; @@ -22,6 +24,8 @@ namespace osu.Game.Skinning.Editor { public Action RequestPlacement; + private const float component_display_scale = 0.8f; + public SkinComponentToolbox(float height) : base("Components", height) { @@ -56,7 +60,7 @@ namespace osu.Game.Skinning.Editor } } - private static ToolboxComponent attemptAddComponent(Type type) + private static ToolboxComponentButton attemptAddComponent(Type type) { try { @@ -64,7 +68,7 @@ namespace osu.Game.Skinning.Editor Debug.Assert(instance != null); - return new ToolboxComponent(instance); + return new ToolboxComponentButton(instance); } catch { @@ -72,59 +76,60 @@ namespace osu.Game.Skinning.Editor } } - private class ToolboxComponent : CompositeDrawable + private class ToolboxComponentButton : OsuButton { private readonly Drawable component; - private readonly Box box; public Action RequestPlacement; - public ToolboxComponent(Drawable component) + private Container innerContainer; + + public ToolboxComponentButton(Drawable component) { this.component = component; - Container innerContainer; + + Enabled.Value = true; RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; + Height = 70; + } - InternalChild = new FillFlowContainer + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = colours.Gray3; + Content.EdgeEffect = new EdgeEffectParameters { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] - { - new OsuSpriteText { Text = component.GetType().Name }, - innerContainer = new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Masking = true, - CornerRadius = 10, - Children = new[] - { - box = new Box - { - Colour = Color4.Black, - Alpha = 0.5f, - RelativeSizeAxes = Axes.Both, - }, - component - } - }, - } + Type = EdgeEffectType.Shadow, + Radius = 2, + Offset = new Vector2(0, 1), + Colour = Color4.Black.Opacity(0.5f) }; - // adjust provided component to fit / display in a known state. + AddRange(new Drawable[] + { + new OsuSpriteText + { + Text = component.GetType().Name, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }, + innerContainer = new Container + { + Y = 10, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Scale = new Vector2(component_display_scale), + Masking = true, + Child = component + } + }); + // adjust provided component to fit / display in a known state. component.Anchor = Anchor.Centre; component.Origin = Anchor.Centre; - if (component.RelativeSizeAxes != Axes.None) - { - innerContainer.AutoSizeAxes = Axes.None; - innerContainer.Height = 100; - } - switch (component) { case IScoreCounter score: @@ -137,26 +142,22 @@ namespace osu.Game.Skinning.Editor } } - [Resolved] - private OsuColour colours { get; set; } + protected override void LoadComplete() + { + base.LoadComplete(); + + if (component.RelativeSizeAxes != Axes.None) + { + innerContainer.AutoSizeAxes = Axes.None; + innerContainer.Height = 100; + } + } protected override bool OnClick(ClickEvent e) { RequestPlacement?.Invoke(component.GetType()); return true; } - - protected override bool OnHover(HoverEvent e) - { - box.FadeColour(colours.Yellow, 100); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - box.FadeColour(Color4.Black, 100); - base.OnHoverLost(e); - } } } } From 1b701adfef5a20c1cd008449fe4a4eed503f2be6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 May 2021 18:15:39 +0900 Subject: [PATCH 10/12] Add score/health processors to fill in default values --- osu.Game/Skinning/Editor/SkinComponentToolbox.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs index 1953fdc8fe..a000204062 100644 --- a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs +++ b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs @@ -14,6 +14,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Scoring; using osuTK; using osuTK.Graphics; @@ -25,6 +26,16 @@ namespace osu.Game.Skinning.Editor private const float component_display_scale = 0.8f; + [Cached] + private ScoreProcessor scoreProcessor = new ScoreProcessor + { + Combo = { Value = 727 }, + TotalScore = { Value = 1337377 } + }; + + [Cached(typeof(HealthProcessor))] + private HealthProcessor healthProcessor = new DrainingHealthProcessor(0); + public SkinComponentToolbox(float height) : base("Components", height) { From 4bee8c23f0f8b6d502d31d877cda12261790d881 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 10 May 2021 21:40:29 -0700 Subject: [PATCH 11/12] Fix idle tracker not accounting global actions --- osu.Game/Input/IdleTracker.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Input/IdleTracker.cs b/osu.Game/Input/IdleTracker.cs index 2d6a21d1cf..f3d531cf6c 100644 --- a/osu.Game/Input/IdleTracker.cs +++ b/osu.Game/Input/IdleTracker.cs @@ -6,13 +6,14 @@ using osu.Framework.Graphics; using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; +using osu.Game.Input.Bindings; namespace osu.Game.Input { /// /// Track whether the end-user is in an idle state, based on their last interaction with the game. /// - public class IdleTracker : Component, IKeyBindingHandler, IHandleGlobalKeyboardInput + public class IdleTracker : Component, IKeyBindingHandler, IKeyBindingHandler, IHandleGlobalKeyboardInput { private readonly double timeToIdle; @@ -58,6 +59,10 @@ namespace osu.Game.Input public void OnReleased(PlatformAction action) => updateLastInteractionTime(); + public bool OnPressed(GlobalAction action) => updateLastInteractionTime(); + + public void OnReleased(GlobalAction action) => updateLastInteractionTime(); + protected override bool Handle(UIEvent e) { switch (e) From 048677846bfd5cb7ef8a8e186b9821e03ebca5d1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 May 2021 12:21:31 +0900 Subject: [PATCH 12/12] Change `HealthDisplay` to be a `CompositeDrawable` --- osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs | 6 ++++-- osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs | 2 +- osu.Game/Screens/Play/HUD/FailingLayer.cs | 2 +- osu.Game/Screens/Play/HUD/HealthDisplay.cs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs index fb4c9d713a..c335f7c99e 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs @@ -1,11 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Testing; using osu.Game.Configuration; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play.HUD; @@ -50,9 +52,9 @@ namespace osu.Game.Tests.Visual.Gameplay }); AddStep("set health to 0.10", () => layer.Current.Value = 0.1); - AddUntilStep("layer fade is visible", () => layer.Child.Alpha > 0.1f); + AddUntilStep("layer fade is visible", () => layer.ChildrenOfType().First().Alpha > 0.1f); AddStep("set health to 1", () => layer.Current.Value = 1f); - AddUntilStep("layer fade is invisible", () => !layer.Child.IsPresent); + AddUntilStep("layer fade is invisible", () => !layer.ChildrenOfType().First().IsPresent); } [Test] diff --git a/osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs b/osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs index 37bd289aee..241777244b 100644 --- a/osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/DefaultHealthDisplay.cs @@ -78,7 +78,7 @@ namespace osu.Game.Screens.Play.HUD RelativeSizeAxes = Axes.X; Margin = new MarginPadding { Top = 20 }; - Children = new Drawable[] + InternalChildren = new Drawable[] { new Box { diff --git a/osu.Game/Screens/Play/HUD/FailingLayer.cs b/osu.Game/Screens/Play/HUD/FailingLayer.cs index e071337f34..424ee55766 100644 --- a/osu.Game/Screens/Play/HUD/FailingLayer.cs +++ b/osu.Game/Screens/Play/HUD/FailingLayer.cs @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play.HUD public FailingLayer() { RelativeSizeAxes = Axes.Both; - Children = new Drawable[] + InternalChildren = new Drawable[] { boxes = new Container { diff --git a/osu.Game/Screens/Play/HUD/HealthDisplay.cs b/osu.Game/Screens/Play/HUD/HealthDisplay.cs index 6c2571cc28..b970ecd1c7 100644 --- a/osu.Game/Screens/Play/HUD/HealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/HealthDisplay.cs @@ -14,7 +14,7 @@ namespace osu.Game.Screens.Play.HUD /// A container for components displaying the current player health. /// Gets bound automatically to the when inserted to hierarchy. /// - public abstract class HealthDisplay : Container + public abstract class HealthDisplay : CompositeDrawable { [Resolved] protected HealthProcessor HealthProcessor { get; private set; }