From 8c72feda09feeac72b91542081cf745eaf5fbd97 Mon Sep 17 00:00:00 2001 From: PowerDaniex <140076282+u4vh3@users.noreply.github.com> Date: Wed, 10 Jul 2024 18:36:01 +0200 Subject: [PATCH 01/13] Add colour customization to the layout editor --- .../Configuration/SettingSourceAttribute.cs | 13 +++ osu.Game/Overlays/Settings/SettingsColour.cs | 79 +++++++++++++++++++ osu.Game/Overlays/SkinEditor/SkinEditor.cs | 5 ++ 3 files changed, 97 insertions(+) create mode 100644 osu.Game/Overlays/Settings/SettingsColour.cs diff --git a/osu.Game/Configuration/SettingSourceAttribute.cs b/osu.Game/Configuration/SettingSourceAttribute.cs index 1e425c88a6c3..3ba46144ca1c 100644 --- a/osu.Game/Configuration/SettingSourceAttribute.cs +++ b/osu.Game/Configuration/SettingSourceAttribute.cs @@ -186,6 +186,16 @@ public static IEnumerable CreateSettingsControls(this object obj) break; + case BindableColour4 bColour: + yield return new SettingsColour + { + LabelText = attr.Label, + TooltipText = attr.Description, + Current = bColour + }; + + break; + case IBindable bindable: var dropdownType = typeof(ModSettingsEnumDropdown<>).MakeGenericType(bindable.GetType().GetGenericArguments()[0]); var dropdown = (Drawable)Activator.CreateInstance(dropdownType)!; @@ -227,6 +237,9 @@ public static object GetUnderlyingSettingValue(this object setting) case Bindable b: return b.Value; + case BindableColour4 c: + return c.Value.ToHex(); + case IBindable u: // An unknown (e.g. enum) generic type. var valueMethod = u.GetType().GetProperty(nameof(IBindable.Value)); diff --git a/osu.Game/Overlays/Settings/SettingsColour.cs b/osu.Game/Overlays/Settings/SettingsColour.cs new file mode 100644 index 000000000000..a58c20adea7f --- /dev/null +++ b/osu.Game/Overlays/Settings/SettingsColour.cs @@ -0,0 +1,79 @@ +// 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.Bindables; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterfaceV2; + +namespace osu.Game.Overlays.Settings +{ + public partial class SettingsColour : SettingsItem + { + protected override Drawable CreateControl() => new ColourControl(); + + public partial class ColourControl : OsuClickableContainer, IHasPopover, IHasCurrentValue + { + private readonly BindableWithCurrent current = new BindableWithCurrent(); + + public Bindable Current + { + get => current.Current; + set => current.Current = value; + } + + private readonly Box fill; + private readonly OsuSpriteText colourHexCode; + + public ColourControl() + { + RelativeSizeAxes = Axes.X; + Height = 40; + CornerRadius = 20; + Masking = true; + Action = this.ShowPopover; + + Children = new Drawable[] + { + fill = new Box + { + RelativeSizeAxes = Axes.Both + }, + colourHexCode = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.Default.With(size: 20) + } + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + Current.BindValueChanged(_ => updateColour(), true); + } + + private void updateColour() + { + fill.Colour = Current.Value; + colourHexCode.Text = Current.Value.ToHex(); + colourHexCode.Colour = OsuColour.ForegroundTextColourFor(Current.Value); + } + + public Popover GetPopover() => new OsuPopover(false) + { + Child = new OsuColourPicker + { + Current = { BindTarget = Current } + } + }; + } + } +} diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index d1e9676de7fe..b8e859bd63dc 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -33,6 +33,7 @@ using osu.Game.Screens.Edit.Components; using osu.Game.Screens.Edit.Components.Menus; using osu.Game.Skinning; +using osu.Framework.Graphics.Cursor; namespace osu.Game.Overlays.SkinEditor { @@ -117,6 +118,9 @@ private void load(EditorClipboard clipboard) InternalChild = new OsuContextMenuContainer { + RelativeSizeAxes = Axes.Both, + Child = new PopoverContainer + { RelativeSizeAxes = Axes.Both, Child = new GridContainer { @@ -221,6 +225,7 @@ private void load(EditorClipboard clipboard) }, } } + } }; clipboardContent = clipboard.Content.GetBoundCopy(); From 6ec3f715d2a796413ab4e29b11d76413356725d8 Mon Sep 17 00:00:00 2001 From: PowerDaniex <140076282+u4vh3@users.noreply.github.com> Date: Wed, 10 Jul 2024 18:39:10 +0200 Subject: [PATCH 02/13] Fix formatting --- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 160 ++++++++++----------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index b8e859bd63dc..6f7781ee9c07 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -120,112 +120,112 @@ private void load(EditorClipboard clipboard) { RelativeSizeAxes = Axes.Both, Child = new PopoverContainer - { - RelativeSizeAxes = Axes.Both, - Child = new GridContainer { RelativeSizeAxes = Axes.Both, - RowDimensions = new[] + Child = new GridContainer { - new Dimension(GridSizeMode.AutoSize), - new Dimension(GridSizeMode.AutoSize), - new Dimension(), - }, + RelativeSizeAxes = Axes.Both, + RowDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), + new Dimension(), + }, - Content = new[] - { - new Drawable[] + Content = new[] { - new Container + new Drawable[] { - Name = @"Menu container", - RelativeSizeAxes = Axes.X, - Depth = float.MinValue, - Height = MENU_HEIGHT, - Children = new Drawable[] + new Container { - new EditorMenuBar + Name = @"Menu container", + RelativeSizeAxes = Axes.X, + Depth = float.MinValue, + Height = MENU_HEIGHT, + Children = new Drawable[] { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - RelativeSizeAxes = Axes.Both, - Items = new[] + new EditorMenuBar { - new MenuItem(CommonStrings.MenuBarFile) + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Both, + Items = new[] { - Items = new OsuMenuItem[] + new MenuItem(CommonStrings.MenuBarFile) { - new EditorMenuItem(Web.CommonStrings.ButtonsSave, MenuItemType.Standard, () => Save()), - new EditorMenuItem(CommonStrings.Export, MenuItemType.Standard, () => skins.ExportCurrentSkin()) { Action = { Disabled = !RuntimeInfo.IsDesktop } }, - new OsuMenuItemSpacer(), - new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, () => dialogOverlay?.Push(new RevertConfirmDialog(revert))), - new OsuMenuItemSpacer(), - new EditorMenuItem(CommonStrings.Exit, MenuItemType.Standard, () => skinEditorOverlay?.Hide()), + Items = new OsuMenuItem[] + { + new EditorMenuItem(Web.CommonStrings.ButtonsSave, MenuItemType.Standard, () => Save()), + new EditorMenuItem(CommonStrings.Export, MenuItemType.Standard, () => skins.ExportCurrentSkin()) { Action = { Disabled = !RuntimeInfo.IsDesktop } }, + new OsuMenuItemSpacer(), + new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, () => dialogOverlay?.Push(new RevertConfirmDialog(revert))), + new OsuMenuItemSpacer(), + new EditorMenuItem(CommonStrings.Exit, MenuItemType.Standard, () => skinEditorOverlay?.Hide()), + }, }, - }, - new MenuItem(CommonStrings.MenuBarEdit) - { - Items = new OsuMenuItem[] + new MenuItem(CommonStrings.MenuBarEdit) { - undoMenuItem = new EditorMenuItem(CommonStrings.Undo, MenuItemType.Standard, Undo), - redoMenuItem = new EditorMenuItem(CommonStrings.Redo, MenuItemType.Standard, Redo), - new OsuMenuItemSpacer(), - cutMenuItem = new EditorMenuItem(CommonStrings.Cut, MenuItemType.Standard, Cut), - copyMenuItem = new EditorMenuItem(CommonStrings.Copy, MenuItemType.Standard, Copy), - pasteMenuItem = new EditorMenuItem(CommonStrings.Paste, MenuItemType.Standard, Paste), - cloneMenuItem = new EditorMenuItem(CommonStrings.Clone, MenuItemType.Standard, Clone), - } - }, - } - }, - headerText = new OsuTextFlowContainer - { - TextAnchor = Anchor.TopRight, - Padding = new MarginPadding(5), - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.X, - RelativeSizeAxes = Axes.Y, + Items = new OsuMenuItem[] + { + undoMenuItem = new EditorMenuItem(CommonStrings.Undo, MenuItemType.Standard, Undo), + redoMenuItem = new EditorMenuItem(CommonStrings.Redo, MenuItemType.Standard, Redo), + new OsuMenuItemSpacer(), + cutMenuItem = new EditorMenuItem(CommonStrings.Cut, MenuItemType.Standard, Cut), + copyMenuItem = new EditorMenuItem(CommonStrings.Copy, MenuItemType.Standard, Copy), + pasteMenuItem = new EditorMenuItem(CommonStrings.Paste, MenuItemType.Standard, Paste), + cloneMenuItem = new EditorMenuItem(CommonStrings.Clone, MenuItemType.Standard, Clone), + } + }, + } + }, + headerText = new OsuTextFlowContainer + { + TextAnchor = Anchor.TopRight, + Padding = new MarginPadding(5), + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + }, }, }, }, - }, - new Drawable[] - { - new SkinEditorSceneLibrary + new Drawable[] { - RelativeSizeAxes = Axes.X, - }, - }, - new Drawable[] - { - new GridContainer - { - RelativeSizeAxes = Axes.Both, - ColumnDimensions = new[] + new SkinEditorSceneLibrary { - new Dimension(GridSizeMode.AutoSize), - new Dimension(), - new Dimension(GridSizeMode.AutoSize), + RelativeSizeAxes = Axes.X, }, - Content = new[] + }, + new Drawable[] + { + new GridContainer { - new Drawable[] + RelativeSizeAxes = Axes.Both, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize), + new Dimension(), + new Dimension(GridSizeMode.AutoSize), + }, + Content = new[] { - componentsSidebar = new EditorSidebar(), - content = new Container + new Drawable[] { - Depth = float.MaxValue, - RelativeSizeAxes = Axes.Both, - }, - settingsSidebar = new EditorSidebar(), + componentsSidebar = new EditorSidebar(), + content = new Container + { + Depth = float.MaxValue, + RelativeSizeAxes = Axes.Both, + }, + settingsSidebar = new EditorSidebar(), + } } } - } - }, + }, + } } } - } }; clipboardContent = clipboard.Content.GetBoundCopy(); From e81e356d59afc04d13e6d1738ef1c1fe8445879e Mon Sep 17 00:00:00 2001 From: Daniel Cios Date: Tue, 6 Aug 2024 11:06:08 +0200 Subject: [PATCH 03/13] Add colour customisation to skin components --- .../SkinnableComponentStrings.cs | 20 +++++++++++++++++++ .../Screens/Play/HUD/ArgonSongProgress.cs | 4 ++++ osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs | 7 ++++++- .../Screens/Play/HUD/DefaultSongProgress.cs | 5 +++++ .../Components/BeatmapAttributeText.cs | 2 ++ osu.Game/Skinning/Components/BoxElement.cs | 4 ++++ osu.Game/Skinning/Components/PlayerName.cs | 2 ++ osu.Game/Skinning/Components/TextElement.cs | 2 ++ .../Skinning/FontAdjustableSkinComponent.cs | 8 ++++++++ 9 files changed, 53 insertions(+), 1 deletion(-) diff --git a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs index d5c8d5ccece5..bd22527f6785 100644 --- a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs +++ b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs @@ -59,6 +59,26 @@ public static class SkinnableComponentStrings /// public static LocalisableString ShowLabelDescription => new TranslatableString(getKey(@"show_label_description"), @"Whether the component's label should be shown."); + /// + /// "Colour" + /// + public static LocalisableString Colour => new TranslatableString(getKey(@"colour"), @"Colour"); + + /// + /// "The colour of the component." + /// + public static LocalisableString ColourDescription => new TranslatableString(getKey(@"colour_description"), @"The colour of the component."); + + /// + /// "Font colour" + /// + public static LocalisableString FontColour => new TranslatableString(getKey(@"font_colour"), @"Font colour"); + + /// + /// "The colour of the font." + /// + public static LocalisableString FontColourDescription => new TranslatableString(getKey(@"font_colour_description"), @"The colour of the font."); + private static string getKey(string key) => $@"{prefix}:{key}"; } } diff --git a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs index ebebfebfb3f9..696369921a23 100644 --- a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs @@ -9,6 +9,7 @@ using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Localisation.HUD; +using osu.Game.Localisation.SkinComponents; using osu.Game.Rulesets.Objects; namespace osu.Game.Screens.Play.HUD @@ -28,6 +29,8 @@ public partial class ArgonSongProgress : SongProgress [SettingSource(typeof(SongProgressStrings), nameof(SongProgressStrings.ShowTime), nameof(SongProgressStrings.ShowTimeDescription))] public Bindable ShowTime { get; } = new BindableBool(true); + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] + public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White); [Resolved] private Player? player { get; set; } @@ -114,6 +117,7 @@ protected override void Update() base.Update(); content.Height = bar.Height + bar_height + info.Height; graphContainer.Height = bar.Height; + base.Colour = Colour.Value; } protected override void UpdateProgress(double progress, bool isIntro) diff --git a/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs b/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs index 3c2e3e05eaa9..837e9547f088 100644 --- a/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs +++ b/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Configuration; +using osu.Game.Localisation.SkinComponents; using osu.Game.Skinning; using osuTK; @@ -21,6 +22,9 @@ public partial class ArgonWedgePiece : CompositeDrawable, ISerialisableDrawable [SettingSource("Inverted shear")] public BindableBool InvertShear { get; } = new BindableBool(); + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] + public new BindableColour4 Colour { get; } = new BindableColour4(Color4Extensions.FromHex("#66CCFF")); + public ArgonWedgePiece() { CornerRadius = 10f; @@ -37,7 +41,7 @@ private void load() InternalChild = new Box { RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(Color4Extensions.FromHex("#66CCFF").Opacity(0.0f), Color4Extensions.FromHex("#66CCFF").Opacity(0.25f)), + Colour = ColourInfo.GradientVertical(Colour.Value.Opacity(0.0f), Colour.Value.Opacity(0.25f)), }; } @@ -46,6 +50,7 @@ protected override void LoadComplete() base.LoadComplete(); InvertShear.BindValueChanged(v => Shear = new Vector2(0.8f, 0f) * (v.NewValue ? -1 : 1), true); + Colour.BindValueChanged(c => InternalChild.Colour = ColourInfo.GradientVertical(Colour.Value.Opacity(0.0f), Colour.Value.Opacity(0.25f))); } } } diff --git a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs index 6b2bb2b71836..512edd7106e8 100644 --- a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs @@ -10,6 +10,7 @@ using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Localisation.HUD; +using osu.Game.Localisation.SkinComponents; using osu.Game.Rulesets.Objects; using osuTK; @@ -35,6 +36,8 @@ public partial class DefaultSongProgress : SongProgress [SettingSource(typeof(SongProgressStrings), nameof(SongProgressStrings.ShowTime), nameof(SongProgressStrings.ShowTimeDescription))] public Bindable ShowTime { get; } = new BindableBool(true); + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] + public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White); [Resolved] private Player? player { get; set; } @@ -114,6 +117,8 @@ protected override void Update() if (!Precision.AlmostEquals(Height, newHeight, 5f)) content.Height = newHeight; + + base.Colour = Colour.Value; } private void updateBarVisibility() diff --git a/osu.Game/Skinning/Components/BeatmapAttributeText.cs b/osu.Game/Skinning/Components/BeatmapAttributeText.cs index c467b2e94621..06f0d9cea9af 100644 --- a/osu.Game/Skinning/Components/BeatmapAttributeText.cs +++ b/osu.Game/Skinning/Components/BeatmapAttributeText.cs @@ -123,6 +123,8 @@ private void updateLabel() } protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40); + + protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour; } // WARNING: DO NOT ADD ANY VALUES TO THIS ENUM ANYWHERE ELSE THAN AT THE END. diff --git a/osu.Game/Skinning/Components/BoxElement.cs b/osu.Game/Skinning/Components/BoxElement.cs index 34d389728cb1..e49ec0cc4d20 100644 --- a/osu.Game/Skinning/Components/BoxElement.cs +++ b/osu.Game/Skinning/Components/BoxElement.cs @@ -27,6 +27,9 @@ public partial class BoxElement : CompositeDrawable, ISerialisableDrawable Precision = 0.01f }; + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] + public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White); + public BoxElement() { Size = new Vector2(400, 80); @@ -48,6 +51,7 @@ protected override void Update() base.Update(); base.CornerRadius = CornerRadius.Value * Math.Min(DrawWidth, DrawHeight); + base.Colour = Colour.Value; } } } diff --git a/osu.Game/Skinning/Components/PlayerName.cs b/osu.Game/Skinning/Components/PlayerName.cs index 21bf615bc61c..70672a1f5801 100644 --- a/osu.Game/Skinning/Components/PlayerName.cs +++ b/osu.Game/Skinning/Components/PlayerName.cs @@ -53,5 +53,7 @@ private void load() } protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40); + + protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour; } } diff --git a/osu.Game/Skinning/Components/TextElement.cs b/osu.Game/Skinning/Components/TextElement.cs index 936f6a529b4b..9d66c58ae845 100644 --- a/osu.Game/Skinning/Components/TextElement.cs +++ b/osu.Game/Skinning/Components/TextElement.cs @@ -36,5 +36,7 @@ public TextElement() } protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40); + + protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour; } } diff --git a/osu.Game/Skinning/FontAdjustableSkinComponent.cs b/osu.Game/Skinning/FontAdjustableSkinComponent.cs index 8f3a1d41c610..e3052aee5ca7 100644 --- a/osu.Game/Skinning/FontAdjustableSkinComponent.cs +++ b/osu.Game/Skinning/FontAdjustableSkinComponent.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Configuration; @@ -20,11 +21,16 @@ public abstract partial class FontAdjustableSkinComponent : Container, ISerialis [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Font), nameof(SkinnableComponentStrings.FontDescription))] public Bindable Font { get; } = new Bindable(Typeface.Torus); + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.FontColour), nameof(SkinnableComponentStrings.FontColourDescription))] + public BindableColour4 FontColour { get; } = new BindableColour4(Colour4.White); + /// /// Implement to apply the user font selection to one or more components. /// protected abstract void SetFont(FontUsage font); + protected abstract void SetFontColour(Colour4 fontColour); + protected override void LoadComplete() { base.LoadComplete(); @@ -37,6 +43,8 @@ protected override void LoadComplete() FontUsage f = OsuFont.GetFont(e.NewValue, weight: fontWeight); SetFont(f); }, true); + + FontColour.BindValueChanged(e => SetFontColour(e.NewValue), true); } } } From 67f04f75a6c7a05c3135ea8328747669d4237624 Mon Sep 17 00:00:00 2001 From: Daniel Cios Date: Thu, 19 Sep 2024 15:26:27 +0200 Subject: [PATCH 04/13] Fix default color --- osu.Game/Overlays/Settings/SettingsColour.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsColour.cs b/osu.Game/Overlays/Settings/SettingsColour.cs index a58c20adea7f..db248331d365 100644 --- a/osu.Game/Overlays/Settings/SettingsColour.cs +++ b/osu.Game/Overlays/Settings/SettingsColour.cs @@ -19,7 +19,7 @@ public partial class SettingsColour : SettingsItem public partial class ColourControl : OsuClickableContainer, IHasPopover, IHasCurrentValue { - private readonly BindableWithCurrent current = new BindableWithCurrent(); + private readonly BindableWithCurrent current = new BindableWithCurrent(Colour4.White); public Bindable Current { From c77afe2a132e22162be34d3703076c2f57a63f34 Mon Sep 17 00:00:00 2001 From: Daniel Cios Date: Thu, 19 Sep 2024 16:04:42 +0200 Subject: [PATCH 05/13] Add tests --- .../Settings/TestSceneSettingsSource.cs | 28 +++++-- .../UserInterface/TestSceneSettingsColour.cs | 75 +++++++++++++++++++ 2 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs diff --git a/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs b/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs index 309438e51cbf..f589a3baa1b9 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs @@ -5,6 +5,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Localisation; using osu.Game.Configuration; using osu.Game.Overlays.Settings; @@ -19,16 +20,20 @@ public TestSceneSettingsSource() { Children = new Drawable[] { - new FillFlowContainer + new PopoverContainer() { RelativeSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Spacing = new Vector2(20), - Width = 0.5f, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Padding = new MarginPadding(50), - ChildrenEnumerable = new TestTargetClass().CreateSettingsControls() + Child = new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(20), + Width = 0.5f, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Padding = new MarginPadding(50), + ChildrenEnumerable = new TestTargetClass().CreateSettingsControls() + }, }, }; } @@ -66,6 +71,13 @@ private class TestTargetClass [SettingSource("Sample number textbox", "Textbox number entry", SettingControlType = typeof(SettingsNumberBox))] public Bindable IntTextBoxBindable { get; } = new Bindable(); + + [SettingSource("Sample colour", "Change the colour", SettingControlType = typeof(SettingsColour))] + public BindableColour4 ColourBindable { get; } = new BindableColour4() + { + Default = Colour4.White, + Value = Colour4.Red + }; } private enum TestEnum diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs new file mode 100644 index 000000000000..d3de5a83194c --- /dev/null +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs @@ -0,0 +1,75 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +#nullable disable + +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Testing; +using osu.Framework.Utils; +using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Overlays.Settings; +using osuTK.Graphics; +using osuTK.Input; + +namespace osu.Game.Tests.Visual.UserInterface +{ + public partial class TestSceneSettingsColour : OsuManualInputManagerTestScene + { + private SettingsColour component; + + [Test] + public void TestColour() + { + createContent(); + + AddRepeatStep("set random colour", () => component.Current.Value = randomColour(), 4); + } + + [Test] + public void TestUserInteractions() + { + createContent(); + + AddStep("click colour", () => + { + InputManager.MoveMouseTo(component); + InputManager.Click(MouseButton.Left); + }); + + AddAssert("colour picker spawned", () => this.ChildrenOfType().Any()); + } + + private void createContent() + { + Child = new PopoverContainer + { + RelativeSizeAxes = Axes.Both, + Child = new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 500, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + component = new SettingsColour + { + LabelText = "a sample component", + }, + }, + }, + }; + } + + private Colour4 randomColour() => new Color4( + RNG.NextSingle(), + RNG.NextSingle(), + RNG.NextSingle(), + 1); + } +} From 94c2f522ffa735bac22d91a07e0a92d04d9d5bff Mon Sep 17 00:00:00 2001 From: Daniel Cios Date: Thu, 19 Sep 2024 17:31:33 +0200 Subject: [PATCH 06/13] Fix spacing --- osu.Game/Screens/Play/HUD/ArgonSongProgress.cs | 1 + osu.Game/Screens/Play/HUD/DefaultSongProgress.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs index 696369921a23..3a4dc42484a7 100644 --- a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs @@ -29,6 +29,7 @@ public partial class ArgonSongProgress : SongProgress [SettingSource(typeof(SongProgressStrings), nameof(SongProgressStrings.ShowTime), nameof(SongProgressStrings.ShowTimeDescription))] public Bindable ShowTime { get; } = new BindableBool(true); + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White); diff --git a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs index 512edd7106e8..25d3c5588def 100644 --- a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs @@ -36,6 +36,7 @@ public partial class DefaultSongProgress : SongProgress [SettingSource(typeof(SongProgressStrings), nameof(SongProgressStrings.ShowTime), nameof(SongProgressStrings.ShowTimeDescription))] public Bindable ShowTime { get; } = new BindableBool(true); + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White); From b86f246095fb79b9b67df4b0ec3b16155e997dd7 Mon Sep 17 00:00:00 2001 From: Daniel Cios Date: Thu, 19 Sep 2024 19:24:05 +0200 Subject: [PATCH 07/13] Fix code inspection failure --- osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs | 4 ++-- .../Visual/UserInterface/TestSceneSettingsColour.cs | 1 - osu.Game/Overlays/Settings/SettingsColour.cs | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs b/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs index f589a3baa1b9..9544f7794077 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs @@ -20,7 +20,7 @@ public TestSceneSettingsSource() { Children = new Drawable[] { - new PopoverContainer() + new PopoverContainer { RelativeSizeAxes = Axes.Both, Child = new FillFlowContainer @@ -73,7 +73,7 @@ private class TestTargetClass public Bindable IntTextBoxBindable { get; } = new Bindable(); [SettingSource("Sample colour", "Change the colour", SettingControlType = typeof(SettingsColour))] - public BindableColour4 ColourBindable { get; } = new BindableColour4() + public BindableColour4 ColourBindable { get; } = new BindableColour4 { Default = Colour4.White, Value = Colour4.Red diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs index d3de5a83194c..75ddacc1102d 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs @@ -3,7 +3,6 @@ #nullable disable -using System.Diagnostics.CodeAnalysis; using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; diff --git a/osu.Game/Overlays/Settings/SettingsColour.cs b/osu.Game/Overlays/Settings/SettingsColour.cs index db248331d365..7a091f1a54d6 100644 --- a/osu.Game/Overlays/Settings/SettingsColour.cs +++ b/osu.Game/Overlays/Settings/SettingsColour.cs @@ -1,5 +1,6 @@ // 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.Bindables; using osu.Framework.Extensions; using osu.Framework.Graphics; From 1a48b46536537eb050dc888b61c59e6c6e1eb851 Mon Sep 17 00:00:00 2001 From: Daniel Cios Date: Thu, 19 Sep 2024 21:50:59 +0200 Subject: [PATCH 08/13] Fix test failures --- .../UserInterface/TestSceneSettingsColour.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs index 75ddacc1102d..6bed5f91c5e2 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs @@ -45,24 +45,27 @@ public void TestUserInteractions() private void createContent() { - Child = new PopoverContainer + AddStep("create component", () => { - RelativeSizeAxes = Axes.Both, - Child = new FillFlowContainer + Child = new PopoverContainer { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Width = 500, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] + RelativeSizeAxes = Axes.Both, + Child = new FillFlowContainer { - component = new SettingsColour + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 500, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] { - LabelText = "a sample component", + component = new SettingsColour + { + LabelText = "a sample component", + }, }, }, - }, - }; + }; + }); } private Colour4 randomColour() => new Color4( From ec575e9de4a8a5ffc87afe58ea954443a3aa0ba3 Mon Sep 17 00:00:00 2001 From: Daniel Cios Date: Fri, 20 Sep 2024 16:38:26 +0200 Subject: [PATCH 09/13] Rename Colour to AccentColour --- osu.Game/Screens/Play/HUD/ArgonSongProgress.cs | 4 ++-- osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs | 6 +++--- osu.Game/Screens/Play/HUD/DefaultSongProgress.cs | 4 ++-- osu.Game/Skinning/Components/BoxElement.cs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs index 3a4dc42484a7..1a1846674384 100644 --- a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs @@ -31,7 +31,7 @@ public partial class ArgonSongProgress : SongProgress public Bindable ShowTime { get; } = new BindableBool(true); [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] - public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White); + public BindableColour4 AccentColour { get; } = new BindableColour4(Colour4.White); [Resolved] private Player? player { get; set; } @@ -118,7 +118,7 @@ protected override void Update() base.Update(); content.Height = bar.Height + bar_height + info.Height; graphContainer.Height = bar.Height; - base.Colour = Colour.Value; + Colour = AccentColour.Value; } protected override void UpdateProgress(double progress, bool isIntro) diff --git a/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs b/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs index 837e9547f088..fb2e93b62bd9 100644 --- a/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs +++ b/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs @@ -23,7 +23,7 @@ public partial class ArgonWedgePiece : CompositeDrawable, ISerialisableDrawable public BindableBool InvertShear { get; } = new BindableBool(); [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] - public new BindableColour4 Colour { get; } = new BindableColour4(Color4Extensions.FromHex("#66CCFF")); + public BindableColour4 AccentColour { get; } = new BindableColour4(Color4Extensions.FromHex("#66CCFF")); public ArgonWedgePiece() { @@ -41,7 +41,7 @@ private void load() InternalChild = new Box { RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(Colour.Value.Opacity(0.0f), Colour.Value.Opacity(0.25f)), + Colour = ColourInfo.GradientVertical(AccentColour.Value.Opacity(0.0f), AccentColour.Value.Opacity(0.25f)), }; } @@ -50,7 +50,7 @@ protected override void LoadComplete() base.LoadComplete(); InvertShear.BindValueChanged(v => Shear = new Vector2(0.8f, 0f) * (v.NewValue ? -1 : 1), true); - Colour.BindValueChanged(c => InternalChild.Colour = ColourInfo.GradientVertical(Colour.Value.Opacity(0.0f), Colour.Value.Opacity(0.25f))); + AccentColour.BindValueChanged(c => InternalChild.Colour = ColourInfo.GradientVertical(AccentColour.Value.Opacity(0.0f), AccentColour.Value.Opacity(0.25f))); } } } diff --git a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs index 25d3c5588def..93d75a22ba5d 100644 --- a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs @@ -38,7 +38,7 @@ public partial class DefaultSongProgress : SongProgress public Bindable ShowTime { get; } = new BindableBool(true); [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] - public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White); + public BindableColour4 AccentColour { get; } = new BindableColour4(Colour4.White); [Resolved] private Player? player { get; set; } @@ -119,7 +119,7 @@ protected override void Update() if (!Precision.AlmostEquals(Height, newHeight, 5f)) content.Height = newHeight; - base.Colour = Colour.Value; + Colour = AccentColour.Value; } private void updateBarVisibility() diff --git a/osu.Game/Skinning/Components/BoxElement.cs b/osu.Game/Skinning/Components/BoxElement.cs index e49ec0cc4d20..633fb0c32744 100644 --- a/osu.Game/Skinning/Components/BoxElement.cs +++ b/osu.Game/Skinning/Components/BoxElement.cs @@ -28,7 +28,7 @@ public partial class BoxElement : CompositeDrawable, ISerialisableDrawable }; [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))] - public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White); + public BindableColour4 AccentColour { get; } = new BindableColour4(Colour4.White); public BoxElement() { @@ -51,7 +51,7 @@ protected override void Update() base.Update(); base.CornerRadius = CornerRadius.Value * Math.Min(DrawWidth, DrawHeight); - base.Colour = Colour.Value; + Colour = AccentColour.Value; } } } From 73b6744a97ed3ca36db2c9ca99a1f451320f962c Mon Sep 17 00:00:00 2001 From: Daniel Cios Date: Fri, 20 Sep 2024 16:50:17 +0200 Subject: [PATCH 10/13] Rename FontColour to TextColour --- .../SkinComponents/SkinnableComponentStrings.cs | 8 ++++---- osu.Game/Skinning/Components/BeatmapAttributeText.cs | 2 +- osu.Game/Skinning/Components/PlayerName.cs | 2 +- osu.Game/Skinning/Components/TextElement.cs | 2 +- osu.Game/Skinning/FontAdjustableSkinComponent.cs | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs index bd22527f6785..33fda23cb07b 100644 --- a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs +++ b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs @@ -70,14 +70,14 @@ public static class SkinnableComponentStrings public static LocalisableString ColourDescription => new TranslatableString(getKey(@"colour_description"), @"The colour of the component."); /// - /// "Font colour" + /// "Text colour" /// - public static LocalisableString FontColour => new TranslatableString(getKey(@"font_colour"), @"Font colour"); + public static LocalisableString TextColour => new TranslatableString(getKey(@"text_colour"), @"Text colour"); /// - /// "The colour of the font." + /// "The colour of the text." /// - public static LocalisableString FontColourDescription => new TranslatableString(getKey(@"font_colour_description"), @"The colour of the font."); + public static LocalisableString TextColourDescription => new TranslatableString(getKey(@"text_colour_description"), @"The colour of the text."); private static string getKey(string key) => $@"{prefix}:{key}"; } diff --git a/osu.Game/Skinning/Components/BeatmapAttributeText.cs b/osu.Game/Skinning/Components/BeatmapAttributeText.cs index 06f0d9cea9af..6e1d655cef6f 100644 --- a/osu.Game/Skinning/Components/BeatmapAttributeText.cs +++ b/osu.Game/Skinning/Components/BeatmapAttributeText.cs @@ -124,7 +124,7 @@ private void updateLabel() protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40); - protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour; + protected override void SetTextColour(Colour4 textColour) => text.Colour = textColour; } // WARNING: DO NOT ADD ANY VALUES TO THIS ENUM ANYWHERE ELSE THAN AT THE END. diff --git a/osu.Game/Skinning/Components/PlayerName.cs b/osu.Game/Skinning/Components/PlayerName.cs index 70672a1f5801..5b6ded0cc5f7 100644 --- a/osu.Game/Skinning/Components/PlayerName.cs +++ b/osu.Game/Skinning/Components/PlayerName.cs @@ -54,6 +54,6 @@ private void load() protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40); - protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour; + protected override void SetTextColour(Colour4 textColour) => text.Colour = textColour; } } diff --git a/osu.Game/Skinning/Components/TextElement.cs b/osu.Game/Skinning/Components/TextElement.cs index 9d66c58ae845..6e875c559094 100644 --- a/osu.Game/Skinning/Components/TextElement.cs +++ b/osu.Game/Skinning/Components/TextElement.cs @@ -37,6 +37,6 @@ public TextElement() protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40); - protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour; + protected override void SetTextColour(Colour4 textColour) => text.Colour = textColour; } } diff --git a/osu.Game/Skinning/FontAdjustableSkinComponent.cs b/osu.Game/Skinning/FontAdjustableSkinComponent.cs index e3052aee5ca7..0821edf7fcde 100644 --- a/osu.Game/Skinning/FontAdjustableSkinComponent.cs +++ b/osu.Game/Skinning/FontAdjustableSkinComponent.cs @@ -21,15 +21,15 @@ public abstract partial class FontAdjustableSkinComponent : Container, ISerialis [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Font), nameof(SkinnableComponentStrings.FontDescription))] public Bindable Font { get; } = new Bindable(Typeface.Torus); - [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.FontColour), nameof(SkinnableComponentStrings.FontColourDescription))] - public BindableColour4 FontColour { get; } = new BindableColour4(Colour4.White); + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.TextColour), nameof(SkinnableComponentStrings.TextColourDescription))] + public BindableColour4 TextColour { get; } = new BindableColour4(Colour4.White); /// /// Implement to apply the user font selection to one or more components. /// protected abstract void SetFont(FontUsage font); - protected abstract void SetFontColour(Colour4 fontColour); + protected abstract void SetTextColour(Colour4 textColour); protected override void LoadComplete() { @@ -44,7 +44,7 @@ protected override void LoadComplete() SetFont(f); }, true); - FontColour.BindValueChanged(e => SetFontColour(e.NewValue), true); + TextColour.BindValueChanged(e => SetTextColour(e.NewValue), true); } } } From 59df9cbf0ff76e1bdf3d3b391600fe6444aeba71 Mon Sep 17 00:00:00 2001 From: Daniel Cios Date: Fri, 20 Sep 2024 18:07:26 +0200 Subject: [PATCH 11/13] Remove nullable disable --- .../Visual/UserInterface/TestSceneSettingsColour.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs index 6bed5f91c5e2..8d28116950dd 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneSettingsColour.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; @@ -19,14 +17,14 @@ namespace osu.Game.Tests.Visual.UserInterface { public partial class TestSceneSettingsColour : OsuManualInputManagerTestScene { - private SettingsColour component; + private SettingsColour? component; [Test] public void TestColour() { createContent(); - AddRepeatStep("set random colour", () => component.Current.Value = randomColour(), 4); + AddRepeatStep("set random colour", () => component!.Current.Value = randomColour(), 4); } [Test] @@ -36,7 +34,7 @@ public void TestUserInteractions() AddStep("click colour", () => { - InputManager.MoveMouseTo(component); + InputManager.MoveMouseTo(component!); InputManager.Click(MouseButton.Left); }); From 4c2ebdb2dbb3250b4f05d98bfda869e341916519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 24 Sep 2024 12:53:54 +0200 Subject: [PATCH 12/13] Simplify accent colour assignment in argon wedge piece --- osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs b/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs index fb2e93b62bd9..46a658cd1c3f 100644 --- a/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs +++ b/osu.Game/Screens/Play/HUD/ArgonWedgePiece.cs @@ -41,7 +41,6 @@ private void load() InternalChild = new Box { RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(AccentColour.Value.Opacity(0.0f), AccentColour.Value.Opacity(0.25f)), }; } @@ -50,7 +49,7 @@ protected override void LoadComplete() base.LoadComplete(); InvertShear.BindValueChanged(v => Shear = new Vector2(0.8f, 0f) * (v.NewValue ? -1 : 1), true); - AccentColour.BindValueChanged(c => InternalChild.Colour = ColourInfo.GradientVertical(AccentColour.Value.Opacity(0.0f), AccentColour.Value.Opacity(0.25f))); + AccentColour.BindValueChanged(c => InternalChild.Colour = ColourInfo.GradientVertical(AccentColour.Value.Opacity(0.0f), AccentColour.Value.Opacity(0.25f)), true); } } } From 9f4e48dde78eb1b76c6131999aa21aeb4dc42843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 24 Sep 2024 15:15:28 +0200 Subject: [PATCH 13/13] Actually use bindables rather than stick things in `Update()` --- osu.Game/Screens/Play/HUD/ArgonSongProgress.cs | 2 +- osu.Game/Screens/Play/HUD/DefaultSongProgress.cs | 3 +-- osu.Game/Skinning/Components/BoxElement.cs | 8 +++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs index 1a1846674384..92ac863e983f 100644 --- a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs @@ -98,6 +98,7 @@ protected override void LoadComplete() Interactive.BindValueChanged(_ => bar.Interactive = Interactive.Value, true); ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true); ShowTime.BindValueChanged(_ => info.FadeTo(ShowTime.Value ? 1 : 0, 200, Easing.In), true); + AccentColour.BindValueChanged(_ => Colour = AccentColour.Value, true); } protected override void UpdateObjects(IEnumerable objects) @@ -118,7 +119,6 @@ protected override void Update() base.Update(); content.Height = bar.Height + bar_height + info.Height; graphContainer.Height = bar.Height; - Colour = AccentColour.Value; } protected override void UpdateProgress(double progress, bool isIntro) diff --git a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs index 93d75a22ba5d..4e41901ee3b4 100644 --- a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs @@ -90,6 +90,7 @@ protected override void LoadComplete() Interactive.BindValueChanged(_ => updateBarVisibility(), true); ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true); ShowTime.BindValueChanged(_ => updateTimeVisibility(), true); + AccentColour.BindValueChanged(_ => Colour = AccentColour.Value, true); base.LoadComplete(); } @@ -118,8 +119,6 @@ protected override void Update() if (!Precision.AlmostEquals(Height, newHeight, 5f)) content.Height = newHeight; - - Colour = AccentColour.Value; } private void updateBarVisibility() diff --git a/osu.Game/Skinning/Components/BoxElement.cs b/osu.Game/Skinning/Components/BoxElement.cs index 633fb0c32744..7f052a8523ae 100644 --- a/osu.Game/Skinning/Components/BoxElement.cs +++ b/osu.Game/Skinning/Components/BoxElement.cs @@ -46,12 +46,18 @@ public BoxElement() Masking = true; } + protected override void LoadComplete() + { + base.LoadComplete(); + + AccentColour.BindValueChanged(_ => Colour = AccentColour.Value, true); + } + protected override void Update() { base.Update(); base.CornerRadius = CornerRadius.Value * Math.Min(DrawWidth, DrawHeight); - Colour = AccentColour.Value; } } }