mirror of https://github.com/ppy/osu
Disable alpha component parsing in beatmap / skin colour sections
This commit is contained in:
parent
1e9b60f07f
commit
992441b9de
|
@ -306,7 +306,7 @@ public void TestDecodeBeatmapColours()
|
|||
new Color4(128, 255, 128, 255),
|
||||
new Color4(255, 187, 255, 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);
|
||||
for (int i = 0; i < expectedColors.Length; i++)
|
||||
|
|
|
@ -29,7 +29,7 @@ public void TestDecodeSkinColours()
|
|||
new Color4(142, 199, 255, 255),
|
||||
new Color4(255, 128, 128, 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);
|
||||
|
|
|
@ -79,7 +79,7 @@ protected virtual void ParseLine(T output, Section section, string line)
|
|||
switch (section)
|
||||
{
|
||||
case Section.Colours:
|
||||
HandleColours(output, line);
|
||||
HandleColours(output, line, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ protected string StripComments(string 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);
|
||||
|
||||
|
@ -108,7 +108,7 @@ protected void HandleColours<TModel>(TModel output, string line)
|
|||
|
||||
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);
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -121,7 +121,7 @@ private void flushPendingLines()
|
|||
break;
|
||||
|
||||
case string when pair.Key.StartsWith("Colour", StringComparison.Ordinal):
|
||||
HandleColours(currentConfig, line);
|
||||
HandleColours(currentConfig, line, true);
|
||||
break;
|
||||
|
||||
// Custom sprite paths
|
||||
|
|
|
@ -48,7 +48,7 @@ protected override void ParseLine(SkinConfiguration skin, Section section, strin
|
|||
// osu!catch section only has colour settings
|
||||
// so no harm in handling the entire section
|
||||
case Section.CatchTheBeat:
|
||||
HandleColours(skin, line);
|
||||
HandleColours(skin, line, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue