1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 13:32:54 +08:00

Disable alpha component parsing in beatmap / skin colour sections

This commit is contained in:
Dean Herbert 2022-09-21 16:04:32 +09:00
parent 1e9b60f07f
commit 992441b9de
5 changed files with 7 additions and 7 deletions

View File

@ -306,7 +306,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
new Color4(128, 255, 128, 255), new Color4(128, 255, 128, 255),
new Color4(255, 187, 255, 255), new Color4(255, 187, 255, 255),
new Color4(255, 177, 140, 255), new Color4(255, 177, 140, 255),
new Color4(100, 100, 100, 100), new Color4(100, 100, 100, 255), // alpha is specified as 100, but should be ignored.
}; };
Assert.AreEqual(expectedColors.Length, comboColors.Count); Assert.AreEqual(expectedColors.Length, comboColors.Count);
for (int i = 0; i < expectedColors.Length; i++) for (int i = 0; i < expectedColors.Length; i++)

View File

@ -29,7 +29,7 @@ namespace osu.Game.Tests.Skins
new Color4(142, 199, 255, 255), new Color4(142, 199, 255, 255),
new Color4(255, 128, 128, 255), new Color4(255, 128, 128, 255),
new Color4(128, 255, 255, 255), new Color4(128, 255, 255, 255),
new Color4(100, 100, 100, 100), new Color4(100, 100, 100, 255), // alpha is specified as 100, but should be ignored.
}; };
Assert.AreEqual(expectedColors.Count, comboColors.Count); Assert.AreEqual(expectedColors.Count, comboColors.Count);

View File

@ -79,7 +79,7 @@ namespace osu.Game.Beatmaps.Formats
switch (section) switch (section)
{ {
case Section.Colours: case Section.Colours:
HandleColours(output, line); HandleColours(output, line, false);
return; return;
} }
} }
@ -93,7 +93,7 @@ namespace osu.Game.Beatmaps.Formats
return line; return line;
} }
protected void HandleColours<TModel>(TModel output, string line) protected void HandleColours<TModel>(TModel output, string line, bool allowAlpha)
{ {
var pair = SplitKeyVal(line); var pair = SplitKeyVal(line);
@ -108,7 +108,7 @@ namespace osu.Game.Beatmaps.Formats
try try
{ {
byte alpha = split.Length == 4 ? byte.Parse(split[3]) : (byte)255; byte alpha = allowAlpha && split.Length == 4 ? byte.Parse(split[3]) : (byte)255;
colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), alpha); colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), alpha);
} }
catch catch

View File

@ -121,7 +121,7 @@ namespace osu.Game.Skinning
break; break;
case string when pair.Key.StartsWith("Colour", StringComparison.Ordinal): case string when pair.Key.StartsWith("Colour", StringComparison.Ordinal):
HandleColours(currentConfig, line); HandleColours(currentConfig, line, true);
break; break;
// Custom sprite paths // Custom sprite paths

View File

@ -48,7 +48,7 @@ namespace osu.Game.Skinning
// osu!catch section only has colour settings // osu!catch section only has colour settings
// so no harm in handling the entire section // so no harm in handling the entire section
case Section.CatchTheBeat: case Section.CatchTheBeat:
HandleColours(skin, line); HandleColours(skin, line, true);
return; return;
} }