mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Add support for parsing mania skin colours
This commit is contained in:
parent
7c428011a2
commit
a77933f5e0
3
osu.Game.Tests/Resources/mania-skin-colours.ini
Normal file
3
osu.Game.Tests/Resources/mania-skin-colours.ini
Normal file
@ -0,0 +1,3 @@
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColourBarline: 50,50,50,50
|
@ -5,6 +5,7 @@ using NUnit.Framework;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Skins
|
||||
{
|
||||
@ -83,5 +84,20 @@ namespace osu.Game.Tests.Skins
|
||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseColours()
|
||||
{
|
||||
var decoder = new LegacyManiaSkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("mania-skin-colours.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var configs = decoder.Decode(stream);
|
||||
|
||||
Assert.That(configs.Count, Is.EqualTo(1));
|
||||
Assert.That(configs[0].CustomColours, Contains.Key("ColourBarline").And.ContainValue(new Color4(50, 50, 50, 50)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
switch (section)
|
||||
{
|
||||
case Section.Colours:
|
||||
handleColours(output, line);
|
||||
HandleColours(output, line);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -87,7 +87,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
return line;
|
||||
}
|
||||
|
||||
private void handleColours(T output, string line)
|
||||
protected void HandleColours<TModel>(TModel output, string line)
|
||||
{
|
||||
var pair = SplitKeyVal(line);
|
||||
|
||||
|
@ -2,13 +2,18 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class LegacyManiaSkinConfiguration
|
||||
public class LegacyManiaSkinConfiguration : IHasCustomColours
|
||||
{
|
||||
public readonly int Keys;
|
||||
|
||||
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
|
||||
|
||||
public readonly float[] ColumnLineWidth;
|
||||
public readonly float[] ColumnSpacing;
|
||||
public readonly float[] ColumnWidth;
|
||||
|
@ -73,6 +73,12 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
var pair = SplitKeyVal(line);
|
||||
|
||||
if (pair.Key.StartsWith("Colour"))
|
||||
{
|
||||
HandleColours(currentConfig, line);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (pair.Key)
|
||||
{
|
||||
case "ColumnLineWidth":
|
||||
|
@ -14,6 +14,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK.Graphics;
|
||||
@ -112,7 +113,7 @@ namespace osu.Game.Skinning
|
||||
break;
|
||||
|
||||
default:
|
||||
return SkinUtils.As<TValue>(getCustomColour(colour.ToString()));
|
||||
return SkinUtils.As<TValue>(getCustomColour(Configuration, colour.ToString()));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -130,7 +131,7 @@ namespace osu.Game.Skinning
|
||||
break;
|
||||
|
||||
case SkinCustomColourLookup customColour:
|
||||
return SkinUtils.As<TValue>(getCustomColour(customColour.Lookup.ToString()));
|
||||
return SkinUtils.As<TValue>(getCustomColour(Configuration, customColour.Lookup.ToString()));
|
||||
|
||||
case LegacyManiaSkinConfigurationLookup maniaLookup:
|
||||
if (!AllowManiaSkin)
|
||||
@ -197,7 +198,8 @@ namespace osu.Game.Skinning
|
||||
return null;
|
||||
}
|
||||
|
||||
private IBindable<Color4> getCustomColour(string lookup) => Configuration.CustomColours.TryGetValue(lookup, out var col) ? new Bindable<Color4>(col) : null;
|
||||
private IBindable<Color4> getCustomColour(IHasCustomColours source, string lookup)
|
||||
=> source.CustomColours.TryGetValue(lookup, out var col) ? new Bindable<Color4>(col) : null;
|
||||
|
||||
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user