From 7460018cd3775394d3eca84e282bb0b165633b41 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Feb 2020 14:58:07 +0900 Subject: [PATCH] Move combo colours to GlobalSkinColours --- .../TestSceneLegacyBeatmapSkin.cs | 2 +- .../Gameplay/TestSceneHitObjectAccentColour.cs | 4 ++-- .../Skins/TestSceneSkinConfigurationLookup.cs | 6 +++--- .../Objects/Drawables/DrawableHitObject.cs | 2 +- osu.Game/Screens/Menu/LogoVisualisation.cs | 2 +- osu.Game/Screens/Menu/MenuSideFlashes.cs | 2 +- osu.Game/Skinning/DefaultSkin.cs | 4 ++-- .../{GlobalSkinColour.cs => GlobalSkinColours.cs} | 3 ++- osu.Game/Skinning/GlobalSkinConfiguration.cs | 1 - osu.Game/Skinning/LegacySkin.cs | 15 +++++++++------ 10 files changed, 22 insertions(+), 19 deletions(-) rename osu.Game/Skinning/{GlobalSkinColour.cs => GlobalSkinColours.cs} (79%) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyBeatmapSkin.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyBeatmapSkin.cs index bbb50c287b..3ff37c4147 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyBeatmapSkin.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyBeatmapSkin.cs @@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Osu.Tests public IReadOnlyList UsableComboColours => GameplayClockContainer.ChildrenOfType() .First() - .GetConfig>(GlobalSkinConfiguration.ComboColours)?.Value; + .GetConfig>(GlobalSkinColours.ComboColours)?.Value; } private class CustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap diff --git a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs index c6d1f9da29..17dc27543d 100644 --- a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs +++ b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs @@ -126,10 +126,10 @@ namespace osu.Game.Tests.Gameplay { switch (lookup) { - case GlobalSkinConfiguration global: + case GlobalSkinColours global: switch (global) { - case GlobalSkinConfiguration.ComboColours: + case GlobalSkinColours.ComboColours: return SkinUtils.As(new Bindable>(ComboColours)); } diff --git a/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs b/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs index ed54cc982d..35313ee858 100644 --- a/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs +++ b/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs @@ -95,7 +95,7 @@ namespace osu.Game.Tests.Skins [Test] public void TestGlobalLookup() { - AddAssert("Check combo colours", () => requester.GetConfig>(GlobalSkinConfiguration.ComboColours)?.Value?.Count > 0); + AddAssert("Check combo colours", () => requester.GetConfig>(GlobalSkinColours.ComboColours)?.Value?.Count > 0); } [Test] @@ -121,7 +121,7 @@ namespace osu.Game.Tests.Skins public void TestEmptyComboColours() { AddAssert("Check retrieved combo colours is skin default colours", () => - requester.GetConfig>(GlobalSkinConfiguration.ComboColours)?.Value?.SequenceEqual(SkinConfiguration.DefaultComboColours) ?? false); + requester.GetConfig>(GlobalSkinColours.ComboColours)?.Value?.SequenceEqual(SkinConfiguration.DefaultComboColours) ?? false); } [Test] @@ -136,7 +136,7 @@ namespace osu.Game.Tests.Skins AddStep("Disallow default colours fallback in source2", () => source2.Configuration.AllowDefaultComboColoursFallback = false); AddAssert("Check retrieved combo colours from source1", () => - requester.GetConfig>(GlobalSkinConfiguration.ComboColours)?.Value?.SequenceEqual(source1.Configuration.ComboColours) ?? false); + requester.GetConfig>(GlobalSkinColours.ComboColours)?.Value?.SequenceEqual(source1.Configuration.ComboColours) ?? false); } [Test] diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 4ac30fe7fb..e391157b5b 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -349,7 +349,7 @@ namespace osu.Game.Rulesets.Objects.Drawables { if (HitObject is IHasComboInformation combo) { - var comboColours = CurrentSkin.GetConfig>(GlobalSkinConfiguration.ComboColours)?.Value; + var comboColours = CurrentSkin.GetConfig>(GlobalSkinColours.ComboColours)?.Value; AccentColour.Value = comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White; } } diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index 8fc07f5989..06ca161fed 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -123,7 +123,7 @@ namespace osu.Game.Screens.Menu Color4 defaultColour = Color4.White.Opacity(0.2f); if (user.Value?.IsSupporter ?? false) - AccentColour = skin.Value.GetConfig(GlobalSkinColour.MenuGlow)?.Value ?? defaultColour; + AccentColour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? defaultColour; else AccentColour = defaultColour; } diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index 3a88cda4ef..321381ac8d 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -112,7 +112,7 @@ namespace osu.Game.Screens.Menu Color4 baseColour = colours.Blue; if (user.Value?.IsSupporter ?? false) - baseColour = skin.Value.GetConfig(GlobalSkinColour.MenuGlow)?.Value ?? baseColour; + baseColour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? baseColour; // linear colour looks better in this case, so let's use it for now. Color4 gradientDark = baseColour.Opacity(0).ToLinear(); diff --git a/osu.Game/Skinning/DefaultSkin.cs b/osu.Game/Skinning/DefaultSkin.cs index 2a065ea3d7..6b4af21b37 100644 --- a/osu.Game/Skinning/DefaultSkin.cs +++ b/osu.Game/Skinning/DefaultSkin.cs @@ -31,10 +31,10 @@ namespace osu.Game.Skinning { // todo: this code is pulled from LegacySkin and should not exist. // will likely change based on how databased storage of skin configuration goes. - case GlobalSkinConfiguration global: + case GlobalSkinColours global: switch (global) { - case GlobalSkinConfiguration.ComboColours: + case GlobalSkinColours.ComboColours: return SkinUtils.As(new Bindable>(Configuration.ComboColours)); } diff --git a/osu.Game/Skinning/GlobalSkinColour.cs b/osu.Game/Skinning/GlobalSkinColours.cs similarity index 79% rename from osu.Game/Skinning/GlobalSkinColour.cs rename to osu.Game/Skinning/GlobalSkinColours.cs index d039be98ce..f889371b98 100644 --- a/osu.Game/Skinning/GlobalSkinColour.cs +++ b/osu.Game/Skinning/GlobalSkinColours.cs @@ -3,8 +3,9 @@ namespace osu.Game.Skinning { - public enum GlobalSkinColour + public enum GlobalSkinColours { + ComboColours, MenuGlow } } diff --git a/osu.Game/Skinning/GlobalSkinConfiguration.cs b/osu.Game/Skinning/GlobalSkinConfiguration.cs index 66dc9a9395..0532e64546 100644 --- a/osu.Game/Skinning/GlobalSkinConfiguration.cs +++ b/osu.Game/Skinning/GlobalSkinConfiguration.cs @@ -5,6 +5,5 @@ namespace osu.Game.Skinning { public enum GlobalSkinConfiguration { - ComboColours } } diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 671d37fda4..609fb79d9a 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -1,6 +1,7 @@ // 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.Collections.Generic; using System.IO; using System.Linq; @@ -68,22 +69,22 @@ namespace osu.Game.Skinning { switch (lookup) { - case GlobalSkinConfiguration global: - switch (global) + case GlobalSkinColours colour: + switch (colour) { - case GlobalSkinConfiguration.ComboColours: + case GlobalSkinColours.ComboColours: var comboColours = Configuration.ComboColours; if (comboColours != null) return SkinUtils.As(new Bindable>(comboColours)); break; + + default: + return SkinUtils.As(getCustomColour(colour.ToString())); } break; - case GlobalSkinColour colour: - return SkinUtils.As(getCustomColour(colour.ToString())); - case LegacySkinConfiguration.LegacySetting legacy: switch (legacy) { @@ -100,6 +101,8 @@ namespace osu.Game.Skinning return SkinUtils.As(getCustomColour(customColour.Lookup.ToString())); default: + // handles lookups like GlobalSkinConfiguration + try { if (Configuration.ConfigDictionary.TryGetValue(lookup.ToString(), out var val))