mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 07:22:54 +08:00
Change ComboColours type to IReadOnlyList<Color4>
Also exposes functions to modify the internal list (AddComboColours, ClearComboColours)
This commit is contained in:
parent
41515e9e6c
commit
808543885f
@ -95,7 +95,7 @@ namespace osu.Game.Tests.Skins
|
||||
[Test]
|
||||
public void TestGlobalLookup()
|
||||
{
|
||||
AddAssert("Check combo colours", () => requester.GetConfig<GlobalSkinConfiguration, List<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value?.Count > 0);
|
||||
AddAssert("Check combo colours", () => requester.GetConfig<GlobalSkinConfiguration, IReadOnlyList<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value?.Count > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -121,19 +121,19 @@ namespace osu.Game.Tests.Skins
|
||||
[TestCase(true)]
|
||||
public void TestEmptyComboColours(bool allowFallback)
|
||||
{
|
||||
AddStep("Add custom combo colours to fallback source", () => source1.Configuration.ComboColours = new List<Color4>
|
||||
AddStep("Add custom combo colours to source1", () => source1.Configuration.ComboColours = new List<Color4>
|
||||
{
|
||||
new Color4(100, 150, 200, 255),
|
||||
new Color4(55, 110, 166, 255),
|
||||
new Color4(75, 125, 175, 255),
|
||||
});
|
||||
AddStep("Clear combo colours from source", () => source2.Configuration.ComboColours.Clear());
|
||||
AddStep("Disable default fallback in source", () => source2.AllowColoursFallback = allowFallback);
|
||||
AddStep("Clear combo colours from source2", () => source2.Configuration.ClearComboColours());
|
||||
AddStep("Disallow default colours fallback in source2", () => source2.Configuration.AllowDefaultComboColoursFallback = allowFallback);
|
||||
|
||||
AddAssert($"Check retrieved combo colours from {(allowFallback ? "default skin" : "fallback source")}", () =>
|
||||
AddAssert($"Check retrieved combo colours from {(allowFallback ? "source1" : "fallback source")}", () =>
|
||||
{
|
||||
var expectedColours = allowFallback ? new DefaultSkinConfiguration().ComboColours : source1.Configuration.ComboColours;
|
||||
return requester.GetConfig<GlobalSkinConfiguration, List<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value?.SequenceEqual(expectedColours) ?? false;
|
||||
var expectedColours = allowFallback ? SkinConfiguration.DefaultComboColours : source1.Configuration.ComboColours;
|
||||
return requester.GetConfig<GlobalSkinConfiguration, IReadOnlyList<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value?.SequenceEqual(expectedColours) ?? false;
|
||||
});
|
||||
}
|
||||
|
||||
@ -151,9 +151,6 @@ namespace osu.Game.Tests.Skins
|
||||
|
||||
public class SkinSource : LegacySkin
|
||||
{
|
||||
public bool AllowColoursFallback = true;
|
||||
protected override bool AllowDefaultColoursFallback => AllowColoursFallback;
|
||||
|
||||
public SkinSource()
|
||||
: base(new SkinInfo(), null, null, string.Empty)
|
||||
{
|
||||
|
@ -8,6 +8,19 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public interface IHasComboColours
|
||||
{
|
||||
List<Color4> ComboColours { get; set; }
|
||||
/// <summary>
|
||||
/// Retrieves the list of combo colours for presentation only.
|
||||
/// </summary>
|
||||
IReadOnlyList<Color4> ComboColours { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds combo colours to the list.
|
||||
/// </summary>
|
||||
void AddComboColours(params Color4[] colours);
|
||||
|
||||
/// <summary>
|
||||
/// Clear current combo colours from the list.
|
||||
/// </summary>
|
||||
void ClearComboColours();
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
if (!(output is IHasComboColours tHasComboColours)) return;
|
||||
|
||||
tHasComboColours.ComboColours.Add(colour);
|
||||
tHasComboColours.AddComboColours(colour);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -265,7 +265,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
{
|
||||
if (HitObject is IHasComboInformation combo)
|
||||
{
|
||||
var comboColours = CurrentSkin.GetConfig<GlobalSkinConfiguration, List<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value;
|
||||
var comboColours = CurrentSkin.GetConfig<GlobalSkinConfiguration, IReadOnlyList<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value;
|
||||
AccentColour.Value = comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White;
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,12 @@ namespace osu.Game.Skinning
|
||||
: base(Info, storage, audioManager, string.Empty)
|
||||
{
|
||||
Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
|
||||
Configuration.ComboColours.AddRange(new[]
|
||||
{
|
||||
Configuration.AddComboColours(
|
||||
new Color4(255, 192, 0, 255),
|
||||
new Color4(0, 202, 0, 255),
|
||||
new Color4(18, 124, 255, 255),
|
||||
new Color4(242, 24, 57, 255),
|
||||
});
|
||||
new Color4(242, 24, 57, 255)
|
||||
);
|
||||
}
|
||||
|
||||
public static SkinInfo Info { get; } = new SkinInfo
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Skinning
|
||||
switch (global)
|
||||
{
|
||||
case GlobalSkinConfiguration.ComboColours:
|
||||
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(Configuration.ComboColours));
|
||||
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(Configuration.ComboColours));
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -72,7 +72,7 @@ namespace osu.Game.Skinning
|
||||
case GlobalSkinConfiguration.ComboColours:
|
||||
var comboColours = Configuration.ComboColours;
|
||||
if (comboColours != null)
|
||||
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(comboColours));
|
||||
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(comboColours));
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -26,7 +28,7 @@ namespace osu.Game.Skinning
|
||||
|
||||
private List<Color4> comboColours = new List<Color4>();
|
||||
|
||||
public List<Color4> ComboColours
|
||||
public IReadOnlyList<Color4> ComboColours
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -38,9 +40,13 @@ namespace osu.Game.Skinning
|
||||
|
||||
return null;
|
||||
}
|
||||
set => comboColours = value;
|
||||
set => comboColours = value.ToList();
|
||||
}
|
||||
|
||||
public void AddComboColours(params Color4[] colours) => colours.ForEach(c => comboColours.Add(c));
|
||||
|
||||
public void ClearComboColours() => comboColours.Clear();
|
||||
|
||||
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
|
||||
|
||||
public readonly Dictionary<string, string> ConfigDictionary = new Dictionary<string, string>();
|
||||
|
Loading…
Reference in New Issue
Block a user