Use Regex to only care about colors and commas when parsing a color.

This commit is contained in:
Criminalllz 2018-07-12 20:36:57 +02:00
parent 89bf811fad
commit a9f8c2acb8
1 changed files with 5 additions and 2 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using osu.Framework.Logging;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints;
@ -73,10 +74,12 @@ private void handleColours(T output, string line)
bool isCombo = pair.Key.StartsWith(@"Combo");
string[] split = pair.Value.Split(',');
line = Regex.Replace(pair.Value, "[^0-9,]", "");
string[] split = line.Split(',');
if (split.Length != 3)
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {pair.Value}");
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {line}");
if (!byte.TryParse(split[0], out var r) || !byte.TryParse(split[1], out var g) || !byte.TryParse(split[2], out var b))
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");