support prefixes (HitCirclePrefix, ScorePrefix), and use dummy instead of complaining when image can't be found

This commit is contained in:
yugecin 2016-09-30 15:54:07 +02:00
parent da3dbfa702
commit 19f4e5f11d
3 changed files with 82 additions and 53 deletions

View File

@ -180,31 +180,31 @@ public enum GameImage {
RANKING_TITLE ("ranking-title", "png"),
RANKING_MAXCOMBO ("ranking-maxcombo", "png"),
RANKING_ACCURACY ("ranking-accuracy", "png"),
DEFAULT_0 ("default-0", "png"),
DEFAULT_1 ("default-1", "png"),
DEFAULT_2 ("default-2", "png"),
DEFAULT_3 ("default-3", "png"),
DEFAULT_4 ("default-4", "png"),
DEFAULT_5 ("default-5", "png"),
DEFAULT_6 ("default-6", "png"),
DEFAULT_7 ("default-7", "png"),
DEFAULT_8 ("default-8", "png"),
DEFAULT_9 ("default-9", "png"),
SCORE_0 ("score-0", "png"),
SCORE_1 ("score-1", "png"),
SCORE_2 ("score-2", "png"),
SCORE_3 ("score-3", "png"),
SCORE_4 ("score-4", "png"),
SCORE_5 ("score-5", "png"),
SCORE_6 ("score-6", "png"),
SCORE_7 ("score-7", "png"),
SCORE_8 ("score-8", "png"),
SCORE_9 ("score-9", "png"),
SCORE_COMMA ("score-comma", "png"),
SCORE_DOT ("score-dot", "png"),
SCORE_PERCENT ("score-percent", "png"),
SCORE_X ("score-x", "png"),
LIGHTING ("lighting", "png"),
DEFAULT_0 ("default-0", "png", true, "0"),
DEFAULT_1 ("default-1", "png", true, "1"),
DEFAULT_2 ("default-2", "png", true, "2"),
DEFAULT_3 ("default-3", "png", true, "3"),
DEFAULT_4 ("default-4", "png", true, "4"),
DEFAULT_5 ("default-5", "png", true, "5"),
DEFAULT_6 ("default-6", "png", true, "6"),
DEFAULT_7 ("default-7", "png", true, "7"),
DEFAULT_8 ("default-8", "png", true, "8"),
DEFAULT_9 ("default-9", "png", true, "9"),
SCORE_0 ("score-0", "png", true, "0"),
SCORE_1 ("score-1", "png", true, "1"),
SCORE_2 ("score-2", "png", true, "2"),
SCORE_3 ("score-3", "png", true, "3"),
SCORE_4 ("score-4", "png", true, "4"),
SCORE_5 ("score-5", "png", true, "5"),
SCORE_6 ("score-6", "png", true, "6"),
SCORE_7 ("score-7", "png", true, "7"),
SCORE_8 ("score-8", "png", true, "8"),
SCORE_9 ("score-9", "png", true, "9"),
SCORE_COMMA ("score-comma", "png", true, "comma"),
SCORE_DOT ("score-dot", "png", true, "dot"),
SCORE_PERCENT ("score-percent", "png", true, "percent"),
SCORE_X ("score-x", "png", true, "x"),
LIGHTING ("lighting", "png", true, "0"),
// Game Mods
MOD_EASY ("selection-mod-easy", "png", false, false),
@ -374,7 +374,7 @@ public enum GameImage {
IMG_JPG = 2;
/** The file name. */
private final String filename;
private String filename;
/** The formatted file name string (for loading multiple images). */
private String filenameFormat;
@ -506,6 +506,11 @@ public enum GameImage {
return null;
}
/**
* used for when prefixes change
*/
public void update() { }
/**
* Returns an array of HD/SD file name suffixes based on the current options
* and UI scale.
@ -514,6 +519,23 @@ public enum GameImage {
return (Options.loadHDImages() && uiscale >= 1) ? SUFFIXES_HD : SUFFIXES_SD;
}
private String suffix;
private boolean isPrefixable;
GameImage(String filename, String type, boolean isPrefixable, String suffix) {
this(filename, type, true, false);
this.isPrefixable = isPrefixable;
this.suffix = suffix;
}
public void updatePrefix(String prefix) {
if (isPrefixable) {
this.filename = prefix + "-" + suffix;
}
}
/**
* Constructor for game-related images (beatmap-skinnable and preloaded).
* @param filename the image file name
@ -652,6 +674,14 @@ public enum GameImage {
process();
return;
}
String filenamebackup = filename;
filename = "dummy";
if ((defaultImage = loadImageSingle(null)) != null) {
isSkinned = false;
process();
filename = filenamebackup;
return;
}
ErrorHandler.error(String.format("Could not find default image '%s'.", filename), null, false);
}

View File

@ -167,21 +167,12 @@ public class Skin {
* [Fonts]
*/
/** The prefix for the hitcircle font sprites. */
protected String hitCirclePrefix = "default";
/** How much should the hitcircle font sprites overlap? */
protected int hitCircleOverlap = -2;
/** The prefix for the score font sprites. */
protected String scorePrefix = "score";
/** How much should the score font sprites overlap? */
protected int scoreOverlap = 0;
/** The prefix for the combo font sprites. */
protected String comboPrefix = "score";
/** How much should the combo font sprites overlap? */
protected int comboOverlap = 0;
@ -342,31 +333,16 @@ public class Skin {
*/
public Color getStarBreakAdditiveColor() { return starBreakAdditive; }
/**
* Returns the prefix for the hit circle font sprites.
*/
public String getHitCircleFontPrefix() { return hitCirclePrefix; }
/**
* Returns the amount of overlap between the hit circle font sprites.
*/
public int getHitCircleFontOverlap() { return hitCircleOverlap; }
/**
* Returns the prefix for the score font sprites.
*/
public String getScoreFontPrefix() { return scorePrefix; }
/**
* Returns the amount of overlap between the score font sprites.
*/
public int getScoreFontOverlap() { return scoreOverlap; }
/**
* Returns the prefix for the combo font sprites.
*/
public String getComboFontPrefix() { return comboPrefix; }
/**
* Returns the amount of overlap between the combo font sprites.
*/

View File

@ -19,6 +19,7 @@
package itdelatrisu.opsu.skins;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Utils;
import java.io.BufferedReader;
@ -235,19 +236,41 @@ public class SkinLoader {
try {
switch (tokens[0]) {
case "HitCirclePrefix":
skin.hitCirclePrefix = tokens[1];
GameImage.DEFAULT_0.updatePrefix(tokens[1]);
GameImage.DEFAULT_1.updatePrefix(tokens[1]);
GameImage.DEFAULT_2.updatePrefix(tokens[1]);
GameImage.DEFAULT_3.updatePrefix(tokens[1]);
GameImage.DEFAULT_4.updatePrefix(tokens[1]);
GameImage.DEFAULT_5.updatePrefix(tokens[1]);
GameImage.DEFAULT_6.updatePrefix(tokens[1]);
GameImage.DEFAULT_7.updatePrefix(tokens[1]);
GameImage.DEFAULT_8.updatePrefix(tokens[1]);
GameImage.DEFAULT_9.updatePrefix(tokens[1]);
break;
case "HitCircleOverlap":
skin.hitCircleOverlap = Integer.parseInt(tokens[1]);
break;
case "ScorePrefix":
skin.scorePrefix = tokens[1];
GameImage.SCORE_0.updatePrefix(tokens[1]);
GameImage.SCORE_1.updatePrefix(tokens[1]);
GameImage.SCORE_2.updatePrefix(tokens[1]);
GameImage.SCORE_3.updatePrefix(tokens[1]);
GameImage.SCORE_4.updatePrefix(tokens[1]);
GameImage.SCORE_5.updatePrefix(tokens[1]);
GameImage.SCORE_6.updatePrefix(tokens[1]);
GameImage.SCORE_7.updatePrefix(tokens[1]);
GameImage.SCORE_8.updatePrefix(tokens[1]);
GameImage.SCORE_9.updatePrefix(tokens[1]);
GameImage.SCORE_COMMA.updatePrefix(tokens[1]);
GameImage.SCORE_PERCENT.updatePrefix(tokens[1]);
GameImage.SCORE_X.updatePrefix(tokens[1]);
GameImage.SCORE_DOT.updatePrefix(tokens[1]);
break;
case "ScoreOverlap":
skin.scoreOverlap = Integer.parseInt(tokens[1]);
break;
case "ComboPrefix":
skin.comboPrefix = tokens[1];
// TODO: seems like this uses the score images
break;
case "ComboOverlap":
skin.comboOverlap = Integer.parseInt(tokens[1]);