Combo Color ordering

General Image scaling
Score fixed size width

Spinner centering (slick has bad centering)

Broke Ranking Panel
This commit is contained in:
fd 2015-02-15 18:51:07 -05:00
parent 4826798fba
commit fff0080ddc
7 changed files with 1701 additions and 80 deletions

View File

@ -457,6 +457,35 @@ public class GameData {
} }
} }
} }
/**
* Draws a string of scoreSymbols.
* @param str the string to draw
* @param x the starting x coordinate
* @param y the y coordinate
* @param scale the scale to apply
* @param rightAlign align right (true) or left (false)
*/
private void drawFixedSizeSymbolString(String str, int x, int y, float scale, float fixedsize, boolean rightAlign) {
char[] c = str.toCharArray();
int cx = x;
if (rightAlign) {
for (int i = c.length - 1; i >= 0; i--) {
Image digit = getScoreSymbolImage(c[i]);
if (scale != 1.0f)
digit = digit.getScaledCopy(scale);
cx -= fixedsize;
digit.draw(cx + (fixedsize-digit.getWidth())/2, y);
}
} else {
for (int i = 0; i < c.length; i++) {
Image digit = getScoreSymbolImage(c[i]);
if (scale != 1.0f)
digit = digit.getScaledCopy(scale);
digit.draw(cx + (fixedsize-digit.getWidth())/2, y);
cx += fixedsize;
}
}
}
/** /**
* Draws game elements: * Draws game elements:
@ -470,28 +499,28 @@ public class GameData {
int marginX = (int) (width * 0.008f); int marginX = (int) (width * 0.008f);
// score // score
drawSymbolString((scoreDisplay < 100000000) ? String.format("%08d", scoreDisplay) : Long.toString(scoreDisplay), drawFixedSizeSymbolString((scoreDisplay < 100000000) ? String.format("%08d", scoreDisplay) : Long.toString(scoreDisplay),
width - marginX, 0, 1.0f, true); width - marginX, 0, 1.0f, getScoreSymbolImage('0').getWidth()-2, true);
// score percentage // score percentage
int symbolHeight = getScoreSymbolImage('0').getHeight(); int symbolHeight = getScoreSymbolImage('0').getHeight();
float scorePercent = getScorePercent(); float scorePercent = getScorePercent();
drawSymbolString( drawSymbolString(
String.format((scorePercent < 10f) ? "0%.2f%%" : "%.2f%%", scorePercent), String.format((scorePercent < 10f) ? "0%.2f%%" : "%.2f%%", scorePercent),
width - marginX, symbolHeight, 0.75f, true width - marginX, symbolHeight, 0.60f, true
); );
// map progress circle // map progress circle
g.setAntiAlias(true); g.setAntiAlias(true);
g.setLineWidth(2f); g.setLineWidth(2f);
g.setColor(Color.white); g.setColor(Color.white);
int circleX = width - marginX - ( // max width: "100.00%" float circleDiameter = symbolHeight * 0.60f;
int circleX = (int) (width - marginX - ( // max width: "100.00%"
getScoreSymbolImage('1').getWidth() + getScoreSymbolImage('1').getWidth() +
getScoreSymbolImage('0').getWidth() * 4 + getScoreSymbolImage('0').getWidth() * 4 +
getScoreSymbolImage('.').getWidth() + getScoreSymbolImage('.').getWidth() +
getScoreSymbolImage('%').getWidth() getScoreSymbolImage('%').getWidth()
); ) * 0.60f - circleDiameter);
float circleDiameter = symbolHeight * 0.75f;
g.drawOval(circleX, symbolHeight, circleDiameter, circleDiameter); g.drawOval(circleX, symbolHeight, circleDiameter, circleDiameter);
OsuFile osu = MusicController.getOsuFile(); OsuFile osu = MusicController.getOsuFile();
@ -621,18 +650,16 @@ public class GameData {
* @param osu the OsuFile * @param osu the OsuFile
*/ */
public void drawRankingElements(Graphics g, OsuFile osu) { public void drawRankingElements(Graphics g, OsuFile osu) {
// grade
Grade grade = getGrade();
if (grade != Grade.NULL)
grade.getLargeImage().draw(width * 0.985f - grade.getLargeImage().getWidth(), height * 0.09f);
float marginX = width * 0.01f, marginY = height * 0.025f;
// header & "Ranking" text // header & "Ranking" text
Image rankingTitle = GameImage.RANKING_TITLE.getImage(); Image rankingTitle = GameImage.RANKING_TITLE.getImage();
float rankingHeight = (rankingTitle.getHeight() * 0.75f) + 3; float rankingHeight = (rankingTitle.getHeight() * 0.75f) + 3;
g.setColor(Utils.COLOR_BLACK_ALPHA); g.setColor(Utils.COLOR_BLACK_ALPHA);
g.fillRect(0, 0, width, rankingHeight); g.fillRect(0, 0, width, rankingHeight);
rankingTitle.draw((width * 0.97f) - rankingTitle.getWidth(), 0); rankingTitle.draw((width * 0.97f) - rankingTitle.getWidth(), 0);
float marginX = width * 0.01f, marginY = height * 0.01f;
Utils.FONT_LARGE.drawString(marginX, marginY, Utils.FONT_LARGE.drawString(marginX, marginY,
String.format("%s - %s [%s]", osu.getArtist(), osu.getTitle(), osu.version), Color.white); String.format("%s - %s [%s]", osu.getArtist(), osu.getTitle(), osu.version), Color.white);
Utils.FONT_MEDIUM.drawString(marginX, marginY + Utils.FONT_LARGE.getLineHeight() - 6, Utils.FONT_MEDIUM.drawString(marginX, marginY + Utils.FONT_LARGE.getLineHeight() - 6,
@ -645,19 +672,20 @@ public class GameData {
Image rankingPanel = GameImage.RANKING_PANEL.getImage(); Image rankingPanel = GameImage.RANKING_PANEL.getImage();
int rankingPanelWidth = rankingPanel.getWidth(); int rankingPanelWidth = rankingPanel.getWidth();
int rankingPanelHeight = rankingPanel.getHeight(); int rankingPanelHeight = rankingPanel.getHeight();
rankingPanel.draw(0, rankingHeight - (rankingHeight / 10f)); rankingPanel.draw(0, rankingHeight);//rankingHeight - (rankingHeight / 10f));
float symbolTextScale = (height / 15f) / getScoreSymbolImage('0').getHeight(); float scoreTextScale = 1.2f; //(height / 15f) / getScoreSymbolImage('0').getHeight();
float rankResultScale = (height * 0.03f) / hitResults[HIT_300].getHeight(); float symbolTextScale = 1.2f; //(height / 15f) / getScoreSymbolImage('0').getHeight();
float rankResultScale = 0.5f;//(height * 0.03f) / hitResults[HIT_300].getHeight();
// score // score
drawSymbolString((score < 100000000) ? String.format("%08d", score) : Long.toString(score), drawFixedSizeSymbolString((score < 100000000) ? String.format("%08d", score) : Long.toString(score),
(int) (width * 0.18f), height / 6, symbolTextScale, false); (int) (width * 0.18f), (int) (rankingHeight+50), scoreTextScale, getScoreSymbolImage('0').getWidth()*scoreTextScale-2, false);
// result counts // result counts
float resultInitialX = rankingPanelWidth * 0.20f; float resultInitialX = 150;// rankingPanelWidth * 0.20f;
float resultInitialY = rankingHeight + (rankingPanelHeight * 0.27f) + (rankingHeight / 10f); float resultInitialY = rankingHeight + (rankingPanelHeight * 0.20f) + (rankingHeight / 10f);
float resultHitInitialX = rankingPanelWidth * 0.05f; float resultHitInitialX = 0;//rankingPanelWidth * 0.05f;
float resultHitInitialY = resultInitialY + (getScoreSymbolImage('0').getHeight() * symbolTextScale); float resultHitInitialY = resultInitialY + (getScoreSymbolImage('0').getHeight() * symbolTextScale);
float resultOffsetX = rankingPanelWidth / 2f; float resultOffsetX = rankingPanelWidth / 2f;
float resultOffsetY = rankingPanelHeight * 0.2f; float resultOffsetY = rankingPanelHeight * 0.2f;
@ -700,6 +728,10 @@ public class GameData {
(height * 0.99f) - GameImage.RANKING_PERFECT.getImage().getHeight() (height * 0.99f) - GameImage.RANKING_PERFECT.getImage().getHeight()
); );
} }
// grade
Grade grade = getGrade();
if (grade != Grade.NULL)
grade.getLargeImage().draw(width * 0.985f - grade.getLargeImage().getWidth(), rankingHeight+marginY);
// mod icons // mod icons
int modWidth = GameMod.AUTO.getImage().getWidth(); int modWidth = GameMod.AUTO.getImage().getWidth();

View File

@ -35,31 +35,31 @@ public enum GameImage {
CURSOR ("cursor", "png") { CURSOR ("cursor", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(1 + ((h - 600) / 1000f)); return img.getScaledCopy(h / 768f);
} }
}, },
CURSOR_MIDDLE ("cursormiddle", "png") { CURSOR_MIDDLE ("cursormiddle", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(1 + ((h - 600) / 1000f)); return img.getScaledCopy(h / 768f);
} }
}, },
CURSOR_TRAIL ("cursortrail", "png") { CURSOR_TRAIL ("cursortrail", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(1 + ((h - 600) / 1000f)); return img.getScaledCopy(h / 768f);
} }
}, },
CURSOR_OLD ("cursor2", "png", false, false) { CURSOR_OLD ("cursor2", "png", false, false) {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(1 + ((h - 600) / 1000f)); return img.getScaledCopy(h / 768f);
} }
}, },
CURSOR_TRAIL_OLD ("cursortrail2", "png", false, false) { CURSOR_TRAIL_OLD ("cursortrail2", "png", false, false) {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(1 + ((h - 600) / 1000f)); return img.getScaledCopy(h / 768f);
} }
}, },
@ -183,125 +183,280 @@ public enum GameImage {
SCOREBAR_KI ("scorebar-ki", "png"), SCOREBAR_KI ("scorebar-ki", "png"),
SCOREBAR_KI_DANGER ("scorebar-kidanger", "png"), SCOREBAR_KI_DANGER ("scorebar-kidanger", "png"),
SCOREBAR_KI_DANGER2 ("scorebar-kidanger2", "png"), SCOREBAR_KI_DANGER2 ("scorebar-kidanger2", "png"),
HIT_MISS ("hit0", "png"), HIT_MISS ("hit0", "png") {
HIT_50 ("hit50", "png"), @Override
HIT_100 ("hit100", "png"), protected Image process_sub(Image img, int w, int h) {
HIT_300 ("hit300", "png"), return img.getScaledCopy(h / 768f);
HIT_100K ("hit100k", "png"), }
HIT_300K ("hit300k", "png"), },
HIT_300G ("hit300g", "png"), HIT_50 ("hit50", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
HIT_100 ("hit100", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
HIT_300 ("hit300", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
HIT_100K ("hit100k", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
HIT_300K ("hit300k", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
HIT_300G ("hit300g", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
HIT_SLIDER10 ("sliderpoint10", "png"), HIT_SLIDER10 ("sliderpoint10", "png"),
HIT_SLIDER30 ("sliderpoint30", "png"), HIT_SLIDER30 ("sliderpoint30", "png"),
RANKING_SS ("ranking-X", "png") { RANKING_SS ("ranking-X", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h / 2f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_SS_SMALL ("ranking-X-small", "png"), RANKING_SS_SMALL ("ranking-X-small", "png"),
RANKING_SSH ("ranking-XH", "png") { RANKING_SSH ("ranking-XH", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h / 2f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_SSH_SMALL ("ranking-XH-small", "png"), RANKING_SSH_SMALL ("ranking-XH-small", "png"),
RANKING_S ("ranking-S", "png") { RANKING_S ("ranking-S", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h / 2f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_S_SMALL ("ranking-S-small", "png"), RANKING_S_SMALL ("ranking-S-small", "png"),
RANKING_SH ("ranking-SH", "png") { RANKING_SH ("ranking-SH", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h / 2f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_SH_SMALL ("ranking-SH-small", "png"), RANKING_SH_SMALL ("ranking-SH-small", "png"),
RANKING_A ("ranking-A", "png") { RANKING_A ("ranking-A", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h / 2f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_A_SMALL ("ranking-A-small", "png"), RANKING_A_SMALL ("ranking-A-small", "png"),
RANKING_B ("ranking-B", "png") { RANKING_B ("ranking-B", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h / 2f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_B_SMALL ("ranking-B-small", "png"), RANKING_B_SMALL ("ranking-B-small", "png"),
RANKING_C ("ranking-C", "png") { RANKING_C ("ranking-C", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h / 2f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_C_SMALL ("ranking-C-small", "png"), RANKING_C_SMALL ("ranking-C-small", "png"),
RANKING_D ("ranking-D", "png") { RANKING_D ("ranking-D", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h / 2f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_D_SMALL ("ranking-D-small", "png"), RANKING_D_SMALL ("ranking-D-small", "png"),
RANKING_PANEL ("ranking-panel", "png") { RANKING_PANEL ("ranking-panel", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h * 0.63f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_PERFECT ("ranking-perfect", "png") { RANKING_PERFECT ("ranking-perfect", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h * 0.16f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_TITLE ("ranking-title", "png") { RANKING_TITLE ("ranking-title", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h * 0.15f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_MAXCOMBO ("ranking-maxcombo", "png") { RANKING_MAXCOMBO ("ranking-maxcombo", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h * 0.05f) / img.getHeight()); return img.getScaledCopy(h / 768f);
} }
}, },
RANKING_ACCURACY ("ranking-accuracy", "png") { RANKING_ACCURACY ("ranking-accuracy", "png") {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h * 0.05f) / img.getHeight()); return img.getScaledCopy(h / 768f);
}
},
DEFAULT_0 ("default-0", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
DEFAULT_1 ("default-1", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
DEFAULT_2 ("default-2", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
DEFAULT_3 ("default-3", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
DEFAULT_4 ("default-4", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
DEFAULT_5 ("default-5", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
DEFAULT_6 ("default-6", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
DEFAULT_7 ("default-7", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
DEFAULT_8 ("default-8", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
DEFAULT_9 ("default-9", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_0 ("score-0", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_1 ("score-1", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_2 ("score-2", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_3 ("score-3", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_4 ("score-4", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_5 ("score-5", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_6 ("score-6", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_7 ("score-7", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_8 ("score-8", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_9 ("score-9", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_COMMA ("score-comma", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_DOT ("score-dot", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_PERCENT ("score-percent", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
}
},
SCORE_X ("score-x", "png") {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy(h / 768f);
} }
}, },
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"), LIGHTING ("lighting", "png"),
LIGHTING1 ("lighting1", "png"), LIGHTING1 ("lighting1", "png"),

View File

@ -102,6 +102,11 @@ public class Opsu extends StateBasedGame {
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
Log.error(e); Log.error(e);
} }
try {
System.setOut(new PrintStream(new FileOutputStream("jnlog.txt", false)));
} catch (FileNotFoundException e) {
Log.error(e);
}
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override @Override
public void uncaughtException(Thread t, Throwable e) { public void uncaughtException(Thread t, Throwable e) {
@ -113,12 +118,12 @@ public class Opsu extends StateBasedGame {
Options.parseOptions(); Options.parseOptions();
// only allow a single instance // only allow a single instance
try { /*try {
SERVER_SOCKET = new ServerSocket(Options.getPort()); SERVER_SOCKET = new ServerSocket(Options.getPort());
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error(String.format("Another program is already running on port %d.", Options.getPort()), e, false); ErrorHandler.error(String.format("Another program is already running on port %d.", Options.getPort()), e, false);
System.exit(1); System.exit(1);
} }*/
// set path for lwjgl natives - NOT NEEDED if using JarSplice // set path for lwjgl natives - NOT NEEDED if using JarSplice
File nativeDir = new File("./target/natives/"); File nativeDir = new File("./target/natives/");

View File

@ -296,4 +296,9 @@ public class OsuHitObject {
* @return true if new combo * @return true if new combo
*/ */
public boolean isNewCombo() { return (type & TYPE_NEWCOMBO) > 0; } public boolean isNewCombo() { return (type & TYPE_NEWCOMBO) > 0; }
public int getComboSkip() {
return (type>>4);
}
} }

View File

@ -139,11 +139,12 @@ public class OsuParser {
private static OsuFile parseFile(File file, File dir, ArrayList<OsuFile> osuFiles, boolean parseObjects) { private static OsuFile parseFile(File file, File dir, ArrayList<OsuFile> osuFiles, boolean parseObjects) {
OsuFile osu = new OsuFile(file); OsuFile osu = new OsuFile(file);
String version ="";
try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"))) { try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"))) {
// initialize timing point list // initialize timing point list
osu.timingPoints = new ArrayList<OsuTimingPoint>(); osu.timingPoints = new ArrayList<OsuTimingPoint>();
version = in.readLine();
String line = in.readLine(); String line = in.readLine();
String tokens[] = null; String tokens[] = null;
while (line != null) { while (line != null) {
@ -491,6 +492,8 @@ public class OsuParser {
} }
break; break;
default: default:
//System.out.println("Dead: "+line+" "+file);
line = in.readLine(); line = in.readLine();
break; break;
} }
@ -500,8 +503,10 @@ public class OsuParser {
} }
// if no custom colors, use the default color scheme // if no custom colors, use the default color scheme
if (osu.combo == null) if (osu.combo == null){
System.out.println("Default Combo "+version+" "+file+" "+osu.combo);
osu.combo = Utils.DEFAULT_COMBO; osu.combo = Utils.DEFAULT_COMBO;
}
// parse hit objects now? // parse hit objects now?
if (parseObjects) if (parseObjects)
@ -526,6 +531,7 @@ public class OsuParser {
+ osu.hitObjectSlider + osu.hitObjectSpinner)]; + osu.hitObjectSlider + osu.hitObjectSpinner)];
try (BufferedReader in = new BufferedReader(new FileReader(osu.getFile()))) { try (BufferedReader in = new BufferedReader(new FileReader(osu.getFile()))) {
String version = in.readLine();
String line = in.readLine(); String line = in.readLine();
while (line != null) { while (line != null) {
line = line.trim(); line = line.trim();
@ -544,18 +550,25 @@ public class OsuParser {
int comboNumber = 1; // combo number int comboNumber = 1; // combo number
int objectIndex = 0; int objectIndex = 0;
boolean first = true;
while ((line = in.readLine()) != null && objectIndex < osu.objects.length) { while ((line = in.readLine()) != null && objectIndex < osu.objects.length) {
line = line.trim(); line = line.trim();
if (!isValidLine(line)) if (!isValidLine(line)){
System.out.println("Not Valid :"+line);
continue; continue;
}
if (line.charAt(0) == '[') if (line.charAt(0) == '[')
break; break;
// lines must have at minimum 5 parameters // lines must have at minimum 5 parameters
int tokenCount = line.length() - line.replace(",", "").length(); int tokenCount = line.length() - line.replace(",", "").length();
if (tokenCount < 4) if (tokenCount < 4){
System.out.println("(tokenCount < 4 :"+line);
continue; continue;
}
try { try {
// create a new OsuHitObject for each line // create a new OsuHitObject for each line
OsuHitObject hitObject = new OsuHitObject(line); OsuHitObject hitObject = new OsuHitObject(line);
@ -563,9 +576,17 @@ public class OsuParser {
// set combo info // set combo info
// - new combo: get next combo index, reset combo number // - new combo: get next combo index, reset combo number
// - else: maintain combo index, increase combo number // - else: maintain combo index, increase combo number
if ((hitObject.isNewCombo() && !hitObject.isSpinner()) || objectIndex == 0) { if (((hitObject.isNewCombo()|| first) && !hitObject.isSpinner()) ) {
comboIndex = (comboIndex + 1) % osu.combo.length; int skip = 1 + hitObject.getComboSkip();
comboNumber = 1;
for(int i=0; i < skip; i++){
comboIndex = (comboIndex + 1) % osu.combo.length;
comboNumber = 1;
}
first=false;
}
if(hitObject.getType()>15){
System.out.println(line+" "+hitObject.isCircle()+" "+hitObject.isSlider()+" "+hitObject.isSpinner());
} }
hitObject.setComboIndex(comboIndex); hitObject.setComboIndex(comboIndex);
hitObject.setComboNumber(comboNumber++); hitObject.setComboNumber(comboNumber++);

View File

@ -86,8 +86,8 @@ public class Utils {
/** The default map colors, used when a map does not provide custom colors. */ /** The default map colors, used when a map does not provide custom colors. */
public static final Color[] DEFAULT_COMBO = { public static final Color[] DEFAULT_COMBO = {
COLOR_GREEN_OBJECT, COLOR_BLUE_OBJECT, COLOR_ORANGE_OBJECT, COLOR_GREEN_OBJECT,
COLOR_RED_OBJECT, COLOR_ORANGE_OBJECT COLOR_BLUE_OBJECT, COLOR_RED_OBJECT,
}; };
/** Game fonts. */ /** Game fonts. */

File diff suppressed because it is too large Load Diff