Added Utils.parseBoolean() method to parse 0/1 booleans.
Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
91b78b4add
commit
fe8c6a6f02
|
@ -282,13 +282,13 @@ public class OsuParser {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "LetterboxInBreaks":
|
case "LetterboxInBreaks":
|
||||||
beatmap.letterboxInBreaks = (Integer.parseInt(tokens[1]) == 1);
|
beatmap.letterboxInBreaks = Utils.parseBoolean(tokens[1]);
|
||||||
break;
|
break;
|
||||||
case "WidescreenStoryboard":
|
case "WidescreenStoryboard":
|
||||||
beatmap.widescreenStoryboard = (Integer.parseInt(tokens[1]) == 1);
|
beatmap.widescreenStoryboard = Utils.parseBoolean(tokens[1]);
|
||||||
break;
|
break;
|
||||||
case "EpilepsyWarning":
|
case "EpilepsyWarning":
|
||||||
beatmap.epilepsyWarning = (Integer.parseInt(tokens[1]) == 1);
|
beatmap.epilepsyWarning = Utils.parseBoolean(tokens[1]);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -691,4 +691,14 @@ public class Utils {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the integer string argument as a boolean:
|
||||||
|
* {@code 1} is {@code true}, and all other values are {@code false}.
|
||||||
|
* @param s the {@code String} containing the boolean representation to be parsed
|
||||||
|
* @return the boolean represented by the string argument
|
||||||
|
*/
|
||||||
|
public static boolean parseBoolean(String s) {
|
||||||
|
return (Integer.parseInt(s) == 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
package itdelatrisu.opsu.beatmap;
|
package itdelatrisu.opsu.beatmap;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.Utils;
|
||||||
|
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,9 +66,9 @@ public class TimingPoint {
|
||||||
this.sampleType = Byte.parseByte(tokens[3]);
|
this.sampleType = Byte.parseByte(tokens[3]);
|
||||||
this.sampleTypeCustom = Byte.parseByte(tokens[4]);
|
this.sampleTypeCustom = Byte.parseByte(tokens[4]);
|
||||||
this.sampleVolume = Integer.parseInt(tokens[5]);
|
this.sampleVolume = Integer.parseInt(tokens[5]);
|
||||||
// this.inherited = (Integer.parseInt(tokens[6]) == 1);
|
// this.inherited = Utils.parseBoolean(tokens[6]);
|
||||||
if (tokens.length > 7)
|
if (tokens.length > 7)
|
||||||
this.kiai = (Integer.parseInt(tokens[7]) == 1);
|
this.kiai = Utils.parseBoolean(tokens[7]);
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
Log.debug(String.format("Error parsing timing point: '%s'", line));
|
Log.debug(String.format("Error parsing timing point: '%s'", line));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user