Move colours fallback logic to SkinConfiguration.ComboColours getter

This commit is contained in:
iiSaLMaN 2019-11-06 23:20:36 +03:00
parent 8d40c1b733
commit cef6e2a26b
3 changed files with 32 additions and 14 deletions

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osuTK.Graphics;
namespace osu.Game.Skinning
{
/// <summary>
@ -12,13 +10,7 @@ namespace osu.Game.Skinning
{
public DefaultSkinConfiguration()
{
ComboColours.AddRange(new[]
{
new Color4(255, 192, 0, 255),
new Color4(0, 202, 0, 255),
new Color4(18, 124, 255, 255),
new Color4(242, 24, 57, 255),
});
ComboColours = DefaultComboColours;
}
}
}

View File

@ -46,6 +46,8 @@ namespace osu.Game.Skinning
else
Configuration = new SkinConfiguration();
Configuration.AllowDefaultColoursFallback = AllowDefaultColoursFallback;
if (storage != null)
{
Samples = audioManager?.GetSampleStore(storage);
@ -68,10 +70,9 @@ namespace osu.Game.Skinning
switch (global)
{
case GlobalSkinConfiguration.ComboColours:
if (Configuration.ComboColours.Any())
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(Configuration.ComboColours));
else if (AllowDefaultColoursFallback)
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(new DefaultSkinConfiguration().ComboColours));
var comboColours = Configuration.ComboColours;
if (comboColours != null)
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(comboColours));
break;
}

View File

@ -14,7 +14,32 @@ namespace osu.Game.Skinning
{
public readonly SkinInfo SkinInfo = new SkinInfo();
public List<Color4> ComboColours { get; set; } = new List<Color4>();
internal bool AllowDefaultColoursFallback;
public static List<Color4> DefaultComboColours = new List<Color4>
{
new Color4(255, 192, 0, 255),
new Color4(0, 202, 0, 255),
new Color4(18, 124, 255, 255),
new Color4(242, 24, 57, 255),
};
private List<Color4> comboColours = new List<Color4>();
public List<Color4> ComboColours
{
get
{
if (comboColours.Count > 0)
return comboColours;
if (AllowDefaultColoursFallback)
return DefaultComboColours;
return null;
}
set => comboColours = value;
}
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();