From 366b7fca657904d6a14f6f3b6927ed614361ecf9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Mar 2018 18:50:19 +0900 Subject: [PATCH] Remove GetColour method --- .../Objects/Drawables/DrawableHitObject.cs | 2 +- osu.Game/Skinning/ISkinSource.cs | 7 ++---- .../Skinning/LocalSkinOverrideContainer.cs | 11 +++----- osu.Game/Skinning/Skin.cs | 25 ++----------------- osu.Game/Skinning/SkinManager.cs | 7 ++---- 5 files changed, 11 insertions(+), 41 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index b8852bb141..bbd6c15d0b 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -107,7 +107,7 @@ protected override void SkinChanged(ISkinSource skin, bool allowFallback) base.SkinChanged(skin, allowFallback); if (HitObject is IHasComboInformation combo) - AccentColour = skin.GetColour($"Play/Combo/{combo.ComboIndex}") ?? Color4.White; + AccentColour = skin.GetValue(s => s.ComboColours?.Count > 0 ? s.ComboColours[combo.ComboIndex % s.ComboColours.Count] : (Color4?)null) ?? Color4.White; } protected override void LoadComplete() diff --git a/osu.Game/Skinning/ISkinSource.cs b/osu.Game/Skinning/ISkinSource.cs index ae2909327e..d8f259b4ea 100644 --- a/osu.Game/Skinning/ISkinSource.cs +++ b/osu.Game/Skinning/ISkinSource.cs @@ -5,7 +5,6 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; -using OpenTK.Graphics; namespace osu.Game.Skinning { @@ -22,10 +21,8 @@ public interface ISkinSource SampleChannel GetSample(string sampleName); - Color4? GetColour(string colourName); + TValue GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : class; - TValue GetConfiguration(Func query) where TConfiguration : SkinConfiguration where TValue : class; - - TValue? GetConfiguration(Func query) where TConfiguration : SkinConfiguration where TValue : struct; + TValue? GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : struct; } } diff --git a/osu.Game/Skinning/LocalSkinOverrideContainer.cs b/osu.Game/Skinning/LocalSkinOverrideContainer.cs index 8181ec0ea1..b7e2bd0daf 100644 --- a/osu.Game/Skinning/LocalSkinOverrideContainer.cs +++ b/osu.Game/Skinning/LocalSkinOverrideContainer.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Textures; -using OpenTK.Graphics; namespace osu.Game.Skinning { @@ -21,26 +20,24 @@ public class LocalSkinOverrideContainer : Container, ISkinSource public SampleChannel GetSample(string sampleName) => source.GetSample(sampleName) ?? fallbackSource?.GetSample(sampleName); - public Color4? GetColour(string colourName) => source.GetColour(colourName) ?? fallbackSource?.GetColour(colourName); - - public TValue? GetConfiguration(Func query) where TConfiguration : SkinConfiguration where TValue : struct + public TValue? GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : struct { TValue? val = null; var conf = (source as Skin)?.Configuration as TConfiguration; if (conf != null) val = query?.Invoke(conf); - return val ?? fallbackSource?.GetConfiguration(query); + return val ?? fallbackSource?.GetValue(query); } - public TValue GetConfiguration(Func query) where TConfiguration : SkinConfiguration where TValue : class + public TValue GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : class { TValue val = null; var conf = (source as Skin)?.Configuration as TConfiguration; if (conf != null) val = query?.Invoke(conf); - return val ?? fallbackSource?.GetConfiguration(query); + return val ?? fallbackSource?.GetValue(query); } private readonly ISkinSource source; diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 1c175ea4e9..02fb84a4a2 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -5,7 +5,6 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; -using OpenTK.Graphics; namespace osu.Game.Skinning { @@ -23,30 +22,10 @@ public abstract class Skin : IDisposable, ISkinSource public abstract Texture GetTexture(string componentName); - public virtual Color4? GetColour(string colourName) - { - var namespaces = colourName.Split('/'); - - switch (namespaces[0]) - { - case "Play": - switch (namespaces[1]) - { - case "Combo": - int index = int.Parse(namespaces[2]); - return GetConfiguration(s => s.ComboColours.Count == 0 ? (Color4?)null : Configuration.ComboColours[index % Configuration.ComboColours.Count]); - } - - break; - } - - return null; - } - - public TValue GetConfiguration(Func query) where TConfiguration : SkinConfiguration where TValue : class + public TValue GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : class => Configuration is TConfiguration conf ? query?.Invoke(conf) : null; - public TValue? GetConfiguration(Func query) where TConfiguration : SkinConfiguration where TValue : struct + public TValue? GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : struct => Configuration is TConfiguration conf ? query?.Invoke(conf) : null; protected Skin(SkinInfo skin) diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index ba6f5b4774..f965a77cce 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -14,7 +14,6 @@ using osu.Framework.Platform; using osu.Game.Database; using osu.Game.IO.Archives; -using OpenTK.Graphics; namespace osu.Game.Skinning { @@ -123,10 +122,8 @@ public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcH public SampleChannel GetSample(string sampleName) => CurrentSkin.Value.GetSample(sampleName); - public Color4? GetColour(string colourName) => CurrentSkin.Value.GetColour(colourName); + public TValue GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : class => CurrentSkin.Value.GetValue(query); - public TValue GetConfiguration(Func query) where TConfiguration : SkinConfiguration where TValue : class => CurrentSkin.Value.GetConfiguration(query); - - public TValue? GetConfiguration(Func query) where TConfiguration : SkinConfiguration where TValue : struct => CurrentSkin.Value.GetConfiguration(query); + public TValue? GetValue(Func query) where TConfiguration : SkinConfiguration where TValue : struct => CurrentSkin.Value.GetValue(query); } }