Added missing "SliderBorder" field to BeatmapParser.
Use beatmap.getSliderBorderColor() to get the slider border color for a beatmap. Also adds the field to the beatmap cache, and fixes a bug where format changes would cause an exception when preparing statements in the new format. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
b6f208a47d
commit
447a0f371a
|
@ -185,6 +185,9 @@ public class Beatmap implements Comparable<Beatmap> {
|
||||||
/** Whether the combo is the default skin combo (true) or a beatmap combo (false). */
|
/** Whether the combo is the default skin combo (true) or a beatmap combo (false). */
|
||||||
public boolean isDefaultCombo = true;
|
public boolean isDefaultCombo = true;
|
||||||
|
|
||||||
|
/** Slider border color. If null, the skin value is used. */
|
||||||
|
public Color sliderBorder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [HitObjects]
|
* [HitObjects]
|
||||||
*/
|
*/
|
||||||
|
@ -257,6 +260,15 @@ public class Beatmap implements Comparable<Beatmap> {
|
||||||
return (Options.useUnicodeMetadata() && !artistUnicode.isEmpty()) ? artistUnicode : artist;
|
return (Options.useUnicodeMetadata() && !artistUnicode.isEmpty()) ? artistUnicode : artist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the slider border color.
|
||||||
|
* If the beatmap does not provide a color, the skin color will be returned instead.
|
||||||
|
* @return the slider border color
|
||||||
|
*/
|
||||||
|
public Color getSliderBorderColor() {
|
||||||
|
return (sliderBorder != null) ? sliderBorder : Options.getSkin().getSliderBorderColor();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the beatmap background.
|
* Draws the beatmap background.
|
||||||
* @param width the container width
|
* @param width the container width
|
||||||
|
@ -441,4 +453,27 @@ public class Beatmap implements Comparable<Beatmap> {
|
||||||
this.isDefaultCombo = false;
|
this.isDefaultCombo = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link #sliderBorder} field formatted as a string,
|
||||||
|
* or null if the field is null.
|
||||||
|
*/
|
||||||
|
public String sliderBorderToString() {
|
||||||
|
if (sliderBorder == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return String.format("%d,%d,%d", sliderBorder.getRed(), sliderBorder.getGreen(), sliderBorder.getBlue());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link #sliderBorder} field from a string.
|
||||||
|
* @param s the string
|
||||||
|
*/
|
||||||
|
public void sliderBorderFromString(String s) {
|
||||||
|
if (s == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String[] rgb = s.split(",");
|
||||||
|
this.sliderBorder = new Color(new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2])));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -504,6 +504,12 @@ public class BeatmapParser {
|
||||||
if ((tokens = tokenize(line)) == null)
|
if ((tokens = tokenize(line)) == null)
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
|
String[] rgb = tokens[1].split(",");
|
||||||
|
Color color = new Color(
|
||||||
|
Integer.parseInt(rgb[0]),
|
||||||
|
Integer.parseInt(rgb[1]),
|
||||||
|
Integer.parseInt(rgb[2])
|
||||||
|
);
|
||||||
switch (tokens[0]) {
|
switch (tokens[0]) {
|
||||||
case "Combo1":
|
case "Combo1":
|
||||||
case "Combo2":
|
case "Combo2":
|
||||||
|
@ -513,12 +519,11 @@ public class BeatmapParser {
|
||||||
case "Combo6":
|
case "Combo6":
|
||||||
case "Combo7":
|
case "Combo7":
|
||||||
case "Combo8":
|
case "Combo8":
|
||||||
String[] rgb = tokens[1].split(",");
|
colors.add(color);
|
||||||
colors.add(new Color(
|
break;
|
||||||
Integer.parseInt(rgb[0]),
|
case "SliderBorder":
|
||||||
Integer.parseInt(rgb[1]),
|
beatmap.sliderBorder = color;
|
||||||
Integer.parseInt(rgb[2])
|
break;
|
||||||
));
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class BeatmapDB {
|
||||||
* Current database version.
|
* Current database version.
|
||||||
* This value should be changed whenever the database format changes.
|
* This value should be changed whenever the database format changes.
|
||||||
*/
|
*/
|
||||||
private static final String DATABASE_VERSION = "2014-03-08";
|
private static final String DATABASE_VERSION = "2014-06-08";
|
||||||
|
|
||||||
/** Minimum batch size ratio ({@code batchSize/cacheSize}) to invoke batch loading. */
|
/** Minimum batch size ratio ({@code batchSize/cacheSize}) to invoke batch loading. */
|
||||||
private static final float LOAD_BATCH_MIN_RATIO = 0.2f;
|
private static final float LOAD_BATCH_MIN_RATIO = 0.2f;
|
||||||
|
@ -78,16 +78,8 @@ public class BeatmapDB {
|
||||||
// create the database
|
// create the database
|
||||||
createDatabase();
|
createDatabase();
|
||||||
|
|
||||||
// prepare sql statements
|
// prepare sql statements (used below)
|
||||||
try {
|
try {
|
||||||
insertStmt = connection.prepareStatement(
|
|
||||||
"INSERT INTO beatmaps VALUES (" +
|
|
||||||
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " +
|
|
||||||
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
|
||||||
);
|
|
||||||
selectStmt = connection.prepareStatement("SELECT * FROM beatmaps WHERE dir = ? AND file = ?");
|
|
||||||
deleteMapStmt = connection.prepareStatement("DELETE FROM beatmaps WHERE dir = ? AND file = ?");
|
|
||||||
deleteGroupStmt = connection.prepareStatement("DELETE FROM beatmaps WHERE dir = ?");
|
|
||||||
updateSizeStmt = connection.prepareStatement("REPLACE INTO info (key, value) VALUES ('size', ?)");
|
updateSizeStmt = connection.prepareStatement("REPLACE INTO info (key, value) VALUES ('size', ?)");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
ErrorHandler.error("Failed to prepare beatmap statements.", e, true);
|
ErrorHandler.error("Failed to prepare beatmap statements.", e, true);
|
||||||
|
@ -98,6 +90,20 @@ public class BeatmapDB {
|
||||||
|
|
||||||
// check the database version
|
// check the database version
|
||||||
checkVersion();
|
checkVersion();
|
||||||
|
|
||||||
|
// prepare sql statements (not used here)
|
||||||
|
try {
|
||||||
|
insertStmt = connection.prepareStatement(
|
||||||
|
"INSERT INTO beatmaps VALUES (" +
|
||||||
|
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " +
|
||||||
|
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
|
);
|
||||||
|
selectStmt = connection.prepareStatement("SELECT * FROM beatmaps WHERE dir = ? AND file = ?");
|
||||||
|
deleteMapStmt = connection.prepareStatement("DELETE FROM beatmaps WHERE dir = ? AND file = ?");
|
||||||
|
deleteGroupStmt = connection.prepareStatement("DELETE FROM beatmaps WHERE dir = ?");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
ErrorHandler.error("Failed to prepare beatmap statements.", e, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +122,7 @@ public class BeatmapDB {
|
||||||
"bpmMin INTEGER, bpmMax INTEGER, endTime INTEGER, " +
|
"bpmMin INTEGER, bpmMax INTEGER, endTime INTEGER, " +
|
||||||
"audioFile TEXT, audioLeadIn INTEGER, previewTime INTEGER, countdown INTEGER, sampleSet TEXT, stackLeniency REAL, " +
|
"audioFile TEXT, audioLeadIn INTEGER, previewTime INTEGER, countdown INTEGER, sampleSet TEXT, stackLeniency REAL, " +
|
||||||
"mode INTEGER, letterboxInBreaks BOOLEAN, widescreenStoryboard BOOLEAN, epilepsyWarning BOOLEAN, " +
|
"mode INTEGER, letterboxInBreaks BOOLEAN, widescreenStoryboard BOOLEAN, epilepsyWarning BOOLEAN, " +
|
||||||
"bg TEXT, timingPoints TEXT, breaks TEXT, combo TEXT" +
|
"bg TEXT, sliderBorder TEXT, timingPoints TEXT, breaks TEXT, combo TEXT" +
|
||||||
"); " +
|
"); " +
|
||||||
"CREATE TABLE IF NOT EXISTS info (" +
|
"CREATE TABLE IF NOT EXISTS info (" +
|
||||||
"key TEXT NOT NULL UNIQUE, value TEXT" +
|
"key TEXT NOT NULL UNIQUE, value TEXT" +
|
||||||
|
@ -330,9 +336,10 @@ public class BeatmapDB {
|
||||||
stmt.setBoolean(34, beatmap.widescreenStoryboard);
|
stmt.setBoolean(34, beatmap.widescreenStoryboard);
|
||||||
stmt.setBoolean(35, beatmap.epilepsyWarning);
|
stmt.setBoolean(35, beatmap.epilepsyWarning);
|
||||||
stmt.setString(36, beatmap.bg);
|
stmt.setString(36, beatmap.bg);
|
||||||
stmt.setString(37, beatmap.timingPointsToString());
|
stmt.setString(37, beatmap.sliderBorderToString());
|
||||||
stmt.setString(38, beatmap.breaksToString());
|
stmt.setString(38, beatmap.timingPointsToString());
|
||||||
stmt.setString(39, beatmap.comboToString());
|
stmt.setString(39, beatmap.breaksToString());
|
||||||
|
stmt.setString(40, beatmap.comboToString());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -470,6 +477,7 @@ public class BeatmapDB {
|
||||||
beatmap.widescreenStoryboard = rs.getBoolean(34);
|
beatmap.widescreenStoryboard = rs.getBoolean(34);
|
||||||
beatmap.epilepsyWarning = rs.getBoolean(35);
|
beatmap.epilepsyWarning = rs.getBoolean(35);
|
||||||
beatmap.bg = BeatmapParser.getDBString(rs.getString(36));
|
beatmap.bg = BeatmapParser.getDBString(rs.getString(36));
|
||||||
|
beatmap.sliderBorderFromString(rs.getString(37));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -485,9 +493,9 @@ public class BeatmapDB {
|
||||||
*/
|
*/
|
||||||
private static void setBeatmapArrayFields(ResultSet rs, Beatmap beatmap) throws SQLException {
|
private static void setBeatmapArrayFields(ResultSet rs, Beatmap beatmap) throws SQLException {
|
||||||
try {
|
try {
|
||||||
beatmap.timingPointsFromString(rs.getString(37));
|
beatmap.timingPointsFromString(rs.getString(38));
|
||||||
beatmap.breaksFromString(rs.getString(38));
|
beatmap.breaksFromString(rs.getString(39));
|
||||||
beatmap.comboFromString(rs.getString(39));
|
beatmap.comboFromString(rs.getString(40));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user