mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add support for parsing mania skin colours
This commit is contained in:
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.IO;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Skins
|
namespace osu.Game.Tests.Skins
|
||||||
{
|
{
|
||||||
@ -83,5 +84,20 @@ namespace osu.Game.Tests.Skins
|
|||||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
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)
|
switch (section)
|
||||||
{
|
{
|
||||||
case Section.Colours:
|
case Section.Colours:
|
||||||
handleColours(output, line);
|
HandleColours(output, line);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleColours(T output, string line)
|
protected void HandleColours<TModel>(TModel output, string line)
|
||||||
{
|
{
|
||||||
var pair = SplitKeyVal(line);
|
var pair = SplitKeyVal(line);
|
||||||
|
|
||||||
|
@ -2,13 +2,18 @@
|
|||||||
// 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;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.Beatmaps.Formats;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
public class LegacyManiaSkinConfiguration
|
public class LegacyManiaSkinConfiguration : IHasCustomColours
|
||||||
{
|
{
|
||||||
public readonly int Keys;
|
public readonly int Keys;
|
||||||
|
|
||||||
|
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
|
||||||
|
|
||||||
public readonly float[] ColumnLineWidth;
|
public readonly float[] ColumnLineWidth;
|
||||||
public readonly float[] ColumnSpacing;
|
public readonly float[] ColumnSpacing;
|
||||||
public readonly float[] ColumnWidth;
|
public readonly float[] ColumnWidth;
|
||||||
|
@ -73,6 +73,12 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
var pair = SplitKeyVal(line);
|
var pair = SplitKeyVal(line);
|
||||||
|
|
||||||
|
if (pair.Key.StartsWith("Colour"))
|
||||||
|
{
|
||||||
|
HandleColours(currentConfig, line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (pair.Key)
|
switch (pair.Key)
|
||||||
{
|
{
|
||||||
case "ColumnLineWidth":
|
case "ColumnLineWidth":
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -112,7 +113,7 @@ namespace osu.Game.Skinning
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return SkinUtils.As<TValue>(getCustomColour(colour.ToString()));
|
return SkinUtils.As<TValue>(getCustomColour(Configuration, colour.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -130,7 +131,7 @@ namespace osu.Game.Skinning
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SkinCustomColourLookup customColour:
|
case SkinCustomColourLookup customColour:
|
||||||
return SkinUtils.As<TValue>(getCustomColour(customColour.Lookup.ToString()));
|
return SkinUtils.As<TValue>(getCustomColour(Configuration, customColour.Lookup.ToString()));
|
||||||
|
|
||||||
case LegacyManiaSkinConfigurationLookup maniaLookup:
|
case LegacyManiaSkinConfigurationLookup maniaLookup:
|
||||||
if (!AllowManiaSkin)
|
if (!AllowManiaSkin)
|
||||||
@ -197,7 +198,8 @@ namespace osu.Game.Skinning
|
|||||||
return null;
|
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)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user