Cleaned up implementation of beatmap combo colors.
Added getComboColors() method to Beatmap class, and the 'combo' field is now null if no combo is provided. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
b1b1664e11
commit
e712d57a2c
|
@ -179,12 +179,9 @@ public class Beatmap implements Comparable<Beatmap> {
|
||||||
* [Colours]
|
* [Colours]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Combo colors (max 8). */
|
/** Combo colors (max 8). If null, the skin value is used. */
|
||||||
public Color[] combo;
|
public Color[] combo;
|
||||||
|
|
||||||
/** Whether the combo is the default skin combo (true) or a beatmap combo (false). */
|
|
||||||
public boolean isDefaultCombo = true;
|
|
||||||
|
|
||||||
/** Slider border color. If null, the skin value is used. */
|
/** Slider border color. If null, the skin value is used. */
|
||||||
public Color sliderBorder;
|
public Color sliderBorder;
|
||||||
|
|
||||||
|
@ -260,6 +257,15 @@ public class Beatmap implements Comparable<Beatmap> {
|
||||||
return (Options.useUnicodeMetadata() && !artistUnicode.isEmpty()) ? artistUnicode : artist;
|
return (Options.useUnicodeMetadata() && !artistUnicode.isEmpty()) ? artistUnicode : artist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of combo colors (max 8).
|
||||||
|
* If the beatmap does not provide colors, the skin colors will be returned instead.
|
||||||
|
* @return the combo colors
|
||||||
|
*/
|
||||||
|
public Color[] getComboColors() {
|
||||||
|
return (combo != null) ? combo : Options.getSkin().getComboColors();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the slider border color.
|
* Returns the slider border color.
|
||||||
* If the beatmap does not provide a color, the skin color will be returned instead.
|
* If the beatmap does not provide a color, the skin color will be returned instead.
|
||||||
|
@ -414,7 +420,7 @@ public class Beatmap implements Comparable<Beatmap> {
|
||||||
* or null if the field is null or the default combo.
|
* or null if the field is null or the default combo.
|
||||||
*/
|
*/
|
||||||
public String comboToString() {
|
public String comboToString() {
|
||||||
if (combo == null || isDefaultCombo)
|
if (combo == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -437,8 +443,6 @@ public class Beatmap implements Comparable<Beatmap> {
|
||||||
* @param s the string
|
* @param s the string
|
||||||
*/
|
*/
|
||||||
public void comboFromString(String s) {
|
public void comboFromString(String s) {
|
||||||
this.combo = Options.getSkin().getComboColors();
|
|
||||||
this.isDefaultCombo = true;
|
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -448,10 +452,8 @@ public class Beatmap implements Comparable<Beatmap> {
|
||||||
String[] rgb = tokens[i].split(",");
|
String[] rgb = tokens[i].split(",");
|
||||||
colors.add(new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2])));
|
colors.add(new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2])));
|
||||||
}
|
}
|
||||||
if (!colors.isEmpty()) {
|
if (!colors.isEmpty())
|
||||||
this.combo = colors.toArray(new Color[colors.size()]);
|
this.combo = colors.toArray(new Color[colors.size()]);
|
||||||
this.isDefaultCombo = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package itdelatrisu.opsu.beatmap;
|
package itdelatrisu.opsu.beatmap;
|
||||||
|
|
||||||
import itdelatrisu.opsu.ErrorHandler;
|
import itdelatrisu.opsu.ErrorHandler;
|
||||||
import itdelatrisu.opsu.Options;
|
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import itdelatrisu.opsu.db.BeatmapDB;
|
import itdelatrisu.opsu.db.BeatmapDB;
|
||||||
|
|
||||||
|
@ -532,10 +531,8 @@ public class BeatmapParser {
|
||||||
line, file.getAbsolutePath()), e);
|
line, file.getAbsolutePath()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!colors.isEmpty()) {
|
if (!colors.isEmpty())
|
||||||
beatmap.combo = colors.toArray(new Color[colors.size()]);
|
beatmap.combo = colors.toArray(new Color[colors.size()]);
|
||||||
beatmap.isDefaultCombo = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "[HitObjects]":
|
case "[HitObjects]":
|
||||||
int type = 0;
|
int type = 0;
|
||||||
|
@ -589,12 +586,6 @@ public class BeatmapParser {
|
||||||
if (beatmap.audioFilename == null)
|
if (beatmap.audioFilename == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// if no custom colors, use the default color scheme
|
|
||||||
if (beatmap.combo == null) {
|
|
||||||
beatmap.combo = Options.getSkin().getComboColors();
|
|
||||||
beatmap.isDefaultCombo = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse hit objects now?
|
// parse hit objects now?
|
||||||
if (parseObjects)
|
if (parseObjects)
|
||||||
parseHitObjects(beatmap);
|
parseHitObjects(beatmap);
|
||||||
|
@ -627,6 +618,7 @@ public class BeatmapParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// combo info
|
// combo info
|
||||||
|
Color[] combo = beatmap.getComboColors();
|
||||||
int comboIndex = 0; // color index
|
int comboIndex = 0; // color index
|
||||||
int comboNumber = 1; // combo number
|
int comboNumber = 1; // combo number
|
||||||
|
|
||||||
|
@ -654,7 +646,7 @@ public class BeatmapParser {
|
||||||
if (hitObject.isNewCombo() || first) {
|
if (hitObject.isNewCombo() || first) {
|
||||||
int skip = (hitObject.isSpinner() ? 0 : 1) + hitObject.getComboSkip();
|
int skip = (hitObject.isSpinner() ? 0 : 1) + hitObject.getComboSkip();
|
||||||
for (int i = 0; i < skip; i++) {
|
for (int i = 0; i < skip; i++) {
|
||||||
comboIndex = (comboIndex + 1) % beatmap.combo.length;
|
comboIndex = (comboIndex + 1) % combo.length;
|
||||||
comboNumber = 1;
|
comboNumber = 1;
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
|
@ -1057,6 +1057,7 @@ public class Game extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize object maps
|
// initialize object maps
|
||||||
|
Color[] combo = beatmap.getComboColors();
|
||||||
for (int i = 0; i < beatmap.objects.length; i++) {
|
for (int i = 0; i < beatmap.objects.length; i++) {
|
||||||
HitObject hitObject = beatmap.objects[i];
|
HitObject hitObject = beatmap.objects[i];
|
||||||
|
|
||||||
|
@ -1065,7 +1066,7 @@ public class Game extends BasicGameState {
|
||||||
if (i + 1 < beatmap.objects.length && beatmap.objects[i + 1].isNewCombo())
|
if (i + 1 < beatmap.objects.length && beatmap.objects[i + 1].isNewCombo())
|
||||||
comboEnd = true;
|
comboEnd = true;
|
||||||
|
|
||||||
Color color = beatmap.combo[hitObject.getComboIndex()];
|
Color color = combo[hitObject.getComboIndex()];
|
||||||
|
|
||||||
// pass beatLength to hit objects
|
// pass beatLength to hit objects
|
||||||
int hitObjectTime = hitObject.getTime();
|
int hitObjectTime = hitObject.getTime();
|
||||||
|
@ -1267,7 +1268,7 @@ public class Game extends BasicGameState {
|
||||||
public void loadBeatmap(Beatmap beatmap) {
|
public void loadBeatmap(Beatmap beatmap) {
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
Display.setTitle(String.format("%s - %s", game.getTitle(), beatmap.toString()));
|
Display.setTitle(String.format("%s - %s", game.getTitle(), beatmap.toString()));
|
||||||
if (beatmap.timingPoints == null || beatmap.combo == null)
|
if (beatmap.timingPoints == null)
|
||||||
BeatmapDB.load(beatmap, BeatmapDB.LOAD_ARRAY);
|
BeatmapDB.load(beatmap, BeatmapDB.LOAD_ARRAY);
|
||||||
BeatmapParser.parseHitObjects(beatmap);
|
BeatmapParser.parseHitObjects(beatmap);
|
||||||
HitSound.setDefaultSampleSet(beatmap.sampleSet);
|
HitSound.setDefaultSampleSet(beatmap.sampleSet);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user