mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:52:55 +08:00
Merge pull request #3545 from smoogipoo/fix-alpha-colours
Fix colours with alpha components not being parsed
This commit is contained in:
commit
4ea4a0797f
@ -165,7 +165,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeBeatmapColors()
|
||||
public void TestDecodeBeatmapColours()
|
||||
{
|
||||
var decoder = new LegacySkinDecoder();
|
||||
using (var resStream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||
@ -181,6 +181,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
new Color4(128, 255, 128, 255),
|
||||
new Color4(255, 187, 255, 255),
|
||||
new Color4(255, 177, 140, 255),
|
||||
new Color4(100, 100, 100, 100),
|
||||
};
|
||||
Assert.AreEqual(expectedColors.Length, comboColors.Count);
|
||||
for (int i = 0; i < expectedColors.Length; i++)
|
||||
|
@ -101,6 +101,7 @@ Combo3 : 128,255,255
|
||||
Combo4 : 128,255,128
|
||||
Combo5 : 255,187,255
|
||||
Combo6 : 255,177,140
|
||||
Combo7 : 100,100,100,100
|
||||
|
||||
[HitObjects]
|
||||
192,168,956,6,0,P|184:128|200:80,1,90,4|0,1:2|0:0,0:0:0:0:
|
||||
|
@ -85,13 +85,19 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
string[] split = pair.Value.Split(',');
|
||||
|
||||
if (split.Length != 3)
|
||||
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {pair.Value}");
|
||||
if (split.Length != 3 && split.Length != 4)
|
||||
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B or R,G,B,A): {pair.Value}");
|
||||
|
||||
if (!byte.TryParse(split[0], out var r) || !byte.TryParse(split[1], out var g) || !byte.TryParse(split[2], out var b))
|
||||
Color4 colour;
|
||||
|
||||
try
|
||||
{
|
||||
colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), split.Length == 4 ? byte.Parse(split[3]) : (byte)255);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
|
||||
|
||||
Color4 colour = new Color4(r, g, b, 255);
|
||||
}
|
||||
|
||||
if (isCombo)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user