mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 18:13:09 +08:00
Add a way to change custom combo colours via IHasComboColours
`IHasComboColours` was already mutable (via a strange `AddComboColours()` method) and exposing a straight list is easier to work with. `IHasCustomColours` is also similarly externally mutable (in a way which is not easily removable).
This commit is contained in:
parent
f49c9673cc
commit
7c88a1c6de
@ -133,11 +133,12 @@ namespace osu.Game.Tests.Skins
|
||||
[Test]
|
||||
public void TestEmptyComboColoursNoFallback()
|
||||
{
|
||||
AddStep("Add custom combo colours to user skin", () => userSource.Configuration.AddComboColours(
|
||||
AddStep("Add custom combo colours to user skin", () => userSource.Configuration.CustomComboColours = new List<Color4>
|
||||
{
|
||||
new Color4(100, 150, 200, 255),
|
||||
new Color4(55, 110, 166, 255),
|
||||
new Color4(75, 125, 175, 255)
|
||||
));
|
||||
});
|
||||
|
||||
AddStep("Disallow default colours fallback in beatmap skin", () => beatmapSource.Configuration.AllowDefaultComboColoursFallback = false);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -13,9 +14,17 @@ namespace osu.Game.Beatmaps.Formats
|
||||
/// </summary>
|
||||
IReadOnlyList<Color4> ComboColours { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of custom combo colours.
|
||||
/// If non-empty, <see cref="ComboColours"/> will return these colours;
|
||||
/// if empty, <see cref="ComboColours"/> will fall back to default combo colours.
|
||||
/// </summary>
|
||||
List<Color4> CustomComboColours { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds combo colours to the list.
|
||||
/// </summary>
|
||||
[Obsolete("Use SkinConfiguration.ComboColours directly.")] // can be removed 20220215
|
||||
void AddComboColours(params Color4[] colours);
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
if (!(output is IHasComboColours tHasComboColours)) return;
|
||||
|
||||
tHasComboColours.AddComboColours(colour);
|
||||
tHasComboColours.CustomComboColours.Add(colour);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Extensions;
|
||||
@ -21,12 +22,13 @@ namespace osu.Game.Skinning
|
||||
: base(skin, new NamespacedResourceStore<byte[]>(resources.Resources, "Skins/Legacy"), resources, string.Empty)
|
||||
{
|
||||
Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
|
||||
Configuration.AddComboColours(
|
||||
Configuration.CustomComboColours = 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)
|
||||
);
|
||||
};
|
||||
|
||||
Configuration.LegacyVersion = 2.7m;
|
||||
}
|
||||
|
@ -27,14 +27,14 @@ namespace osu.Game.Skinning
|
||||
new Color4(242, 24, 57, 255),
|
||||
};
|
||||
|
||||
private readonly List<Color4> comboColours = new List<Color4>();
|
||||
public List<Color4> CustomComboColours { get; set; } = new List<Color4>();
|
||||
|
||||
public IReadOnlyList<Color4> ComboColours
|
||||
{
|
||||
get
|
||||
{
|
||||
if (comboColours.Count > 0)
|
||||
return comboColours;
|
||||
if (CustomComboColours.Count > 0)
|
||||
return CustomComboColours;
|
||||
|
||||
if (AllowDefaultComboColoursFallback)
|
||||
return DefaultComboColours;
|
||||
@ -43,7 +43,7 @@ namespace osu.Game.Skinning
|
||||
}
|
||||
}
|
||||
|
||||
public void AddComboColours(params Color4[] colours) => comboColours.AddRange(colours);
|
||||
void IHasComboColours.AddComboColours(params Color4[] colours) => CustomComboColours.AddRange(colours);
|
||||
|
||||
public Dictionary<string, Color4> CustomColours { get; } = new Dictionary<string, Color4>();
|
||||
|
||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
{
|
||||
if (hasColours)
|
||||
{
|
||||
Configuration.AddComboColours(Colours);
|
||||
Configuration.CustomComboColours = Colours.ToList();
|
||||
Configuration.CustomColours.Add("HyperDash", HYPER_DASH_COLOUR);
|
||||
Configuration.CustomColours.Add("HyperDashAfterImage", HYPER_DASH_AFTER_IMAGE_COLOUR);
|
||||
Configuration.CustomColours.Add("HyperDashFruit", HYPER_DASH_FRUIT_COLOUR);
|
||||
@ -145,7 +145,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
{
|
||||
if (hasCustomColours)
|
||||
{
|
||||
Configuration.AddComboColours(Colours);
|
||||
Configuration.CustomComboColours = Colours.ToList();
|
||||
Configuration.CustomColours.Add("HyperDash", HYPER_DASH_COLOUR);
|
||||
Configuration.CustomColours.Add("HyperDashAfterImage", HYPER_DASH_AFTER_IMAGE_COLOUR);
|
||||
Configuration.CustomColours.Add("HyperDashFruit", HYPER_DASH_FRUIT_COLOUR);
|
||||
|
Loading…
Reference in New Issue
Block a user