mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Change ComboColours type to IReadOnlyList<Color4>
Also exposes functions to modify the internal list (AddComboColours, ClearComboColours)
This commit is contained in:
@ -95,7 +95,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestGlobalLookup()
|
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]
|
[Test]
|
||||||
@ -121,19 +121,19 @@ namespace osu.Game.Tests.Skins
|
|||||||
[TestCase(true)]
|
[TestCase(true)]
|
||||||
public void TestEmptyComboColours(bool allowFallback)
|
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(100, 150, 200, 255),
|
||||||
new Color4(55, 110, 166, 255),
|
new Color4(55, 110, 166, 255),
|
||||||
new Color4(75, 125, 175, 255),
|
new Color4(75, 125, 175, 255),
|
||||||
});
|
});
|
||||||
AddStep("Clear combo colours from source", () => source2.Configuration.ComboColours.Clear());
|
AddStep("Clear combo colours from source2", () => source2.Configuration.ClearComboColours());
|
||||||
AddStep("Disable default fallback in source", () => source2.AllowColoursFallback = allowFallback);
|
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;
|
var expectedColours = allowFallback ? SkinConfiguration.DefaultComboColours : source1.Configuration.ComboColours;
|
||||||
return requester.GetConfig<GlobalSkinConfiguration, List<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value?.SequenceEqual(expectedColours) ?? false;
|
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 class SkinSource : LegacySkin
|
||||||
{
|
{
|
||||||
public bool AllowColoursFallback = true;
|
|
||||||
protected override bool AllowDefaultColoursFallback => AllowColoursFallback;
|
|
||||||
|
|
||||||
public SkinSource()
|
public SkinSource()
|
||||||
: base(new SkinInfo(), null, null, string.Empty)
|
: base(new SkinInfo(), null, null, string.Empty)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,19 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
public interface IHasComboColours
|
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;
|
if (!(output is IHasComboColours tHasComboColours)) return;
|
||||||
|
|
||||||
tHasComboColours.ComboColours.Add(colour);
|
tHasComboColours.AddComboColours(colour);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -265,7 +265,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
{
|
{
|
||||||
if (HitObject is IHasComboInformation combo)
|
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;
|
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)
|
: base(Info, storage, audioManager, string.Empty)
|
||||||
{
|
{
|
||||||
Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
|
Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
|
||||||
Configuration.ComboColours.AddRange(new[]
|
Configuration.AddComboColours(
|
||||||
{
|
|
||||||
new Color4(255, 192, 0, 255),
|
new Color4(255, 192, 0, 255),
|
||||||
new Color4(0, 202, 0, 255),
|
new Color4(0, 202, 0, 255),
|
||||||
new Color4(18, 124, 255, 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
|
public static SkinInfo Info { get; } = new SkinInfo
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Skinning
|
|||||||
switch (global)
|
switch (global)
|
||||||
{
|
{
|
||||||
case GlobalSkinConfiguration.ComboColours:
|
case GlobalSkinConfiguration.ComboColours:
|
||||||
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(Configuration.ComboColours));
|
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(Configuration.ComboColours));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -72,7 +72,7 @@ namespace osu.Game.Skinning
|
|||||||
case GlobalSkinConfiguration.ComboColours:
|
case GlobalSkinConfiguration.ComboColours:
|
||||||
var comboColours = Configuration.ComboColours;
|
var comboColours = Configuration.ComboColours;
|
||||||
if (comboColours != null)
|
if (comboColours != null)
|
||||||
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(comboColours));
|
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(comboColours));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
private List<Color4> comboColours = new List<Color4>();
|
private List<Color4> comboColours = new List<Color4>();
|
||||||
|
|
||||||
public List<Color4> ComboColours
|
public IReadOnlyList<Color4> ComboColours
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -38,9 +40,13 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
return null;
|
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 Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
|
||||||
|
|
||||||
public readonly Dictionary<string, string> ConfigDictionary = new Dictionary<string, string>();
|
public readonly Dictionary<string, string> ConfigDictionary = new Dictionary<string, string>();
|
||||||
|
Reference in New Issue
Block a user