diff --git a/src/itdelatrisu/opsu/GameData.java b/src/itdelatrisu/opsu/GameData.java index 97495730..526dc861 100644 --- a/src/itdelatrisu/opsu/GameData.java +++ b/src/itdelatrisu/opsu/GameData.java @@ -456,8 +456,9 @@ public class GameData { } } } + /** - * Draws a string of scoreSymbols. + * Draws a string of scoreSymbols of fixed width. * @param str the string to draw * @param x the starting x coordinate * @param y the y coordinate @@ -474,14 +475,14 @@ public class GameData { if (scale != 1.0f) digit = digit.getScaledCopy(scale); cx -= fixedsize; - digit.draw(cx + (fixedsize-digit.getWidth())/2, y); + 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); + digit.draw(cx + (fixedsize - digit.getWidth()) / 2, y); cx += fixedsize; } } @@ -495,12 +496,13 @@ public class GameData { * @param breakPeriod if true, will not draw scorebar and combo elements, and will draw grade * @param firstObject true if the first hit object's start time has not yet passed */ + @SuppressWarnings("deprecation") public void drawGameElements(Graphics g, boolean breakPeriod, boolean firstObject) { int marginX = (int) (width * 0.008f); // score drawFixedSizeSymbolString((scoreDisplay < 100000000) ? String.format("%08d", scoreDisplay) : Long.toString(scoreDisplay), - width - marginX, 0, 1.0f, getScoreSymbolImage('0').getWidth()-2, true); + width - marginX, 0, 1.0f, getScoreSymbolImage('0').getWidth() - 2, true); // score percentage int symbolHeight = getScoreSymbolImage('0').getHeight(); @@ -564,19 +566,18 @@ public class GameData { } Image scorebar = GameImage.SCOREBAR_BG.getImage(); Image colour; - if (scorebarColour != null){ - scorebarColour.updateNoDraw(); //TODO deprecated method + if (scorebarColour != null) { + scorebarColour.updateNoDraw(); // TODO deprecated method colour = scorebarColour.getCurrentFrame(); - } else { + } else colour = GameImage.SCOREBAR_COLOUR.getImage(); - } - float colourX = 4 * GameImage.uiscale, colourY = 15 * GameImage.uiscale; - Image colourCropped = colour.getSubImage(0, 0, (int) (645 * GameImage.uiscale * healthRatio), colour.getHeight()); - + float colourX = 4 * GameImage.getUIscale(), colourY = 15 * GameImage.getUIscale(); + Image colourCropped = colour.getSubImage(0, 0, (int) (645 * GameImage.getUIscale() * healthRatio), colour.getHeight()); + scorebar.setAlpha(1f); scorebar.draw(0, 0); colourCropped.draw(colourX, colourY); - + Image ki = null; if (health >= 50f) ki = GameImage.SCOREBAR_KI.getImage(); @@ -655,36 +656,28 @@ public class GameData { * @param osu the OsuFile */ public void drawRankingElements(Graphics g, OsuFile osu) { - - float marginX = width * 0.01f, marginY = height * 0.025f; - // header & "Ranking" text - Image rankingTitle = GameImage.RANKING_TITLE.getImage(); - // ranking panel - Image rankingPanel = GameImage.RANKING_PANEL.getImage(); - - - //TODO Version 2 skins + // TODO Version 2 skins float rankingHeight = 75; - - rankingPanel.draw(0, (int) (rankingHeight * GameImage.uiscale)); - float scoreTextScale = 1.0f; float symbolTextScale = 1.15f; float rankResultScale = 0.5f; + // ranking panel + GameImage.RANKING_PANEL.getImage().draw(0, (int) (rankingHeight * GameImage.getUIscale())); + // score drawFixedSizeSymbolString( (score < 100000000) ? String.format("%08d", score) : Long.toString(score), - (int) (210 * GameImage.uiscale), - (int) ((rankingHeight + 50) * GameImage.uiscale), - scoreTextScale, + (int) (210 * GameImage.getUIscale()), + (int) ((rankingHeight + 50) * GameImage.getUIscale()), + scoreTextScale, getScoreSymbolImage('0').getWidth() * scoreTextScale - 2, false); // result counts float resultInitialX = 130; float resultInitialY = rankingHeight + 140; float resultHitInitialX = 65; - float resultHitInitialY = rankingHeight + 182 ; + float resultHitInitialY = rankingHeight + 182; float resultOffsetX = 320; float resultOffsetY = 96; @@ -697,42 +690,37 @@ public class GameData { for (int i = 0; i < rankDrawOrder.length; i += 2) { hitResults[rankDrawOrder[i]].getScaledCopy(rankResultScale).drawCentered( - (resultHitInitialX * GameImage.uiscale), - ((resultHitInitialY + (resultOffsetY * (i / 2))) * GameImage.uiscale) - ); + (resultHitInitialX * GameImage.getUIscale()), + ((resultHitInitialY + (resultOffsetY * (i / 2))) * GameImage.getUIscale())); hitResults[rankDrawOrder[i+1]].getScaledCopy(rankResultScale).drawCentered( - ((resultHitInitialX + resultOffsetX) * GameImage.uiscale), - ((resultHitInitialY + (resultOffsetY * (i / 2))) * GameImage.uiscale) - ); + ((resultHitInitialX + resultOffsetX) * GameImage.getUIscale()), + ((resultHitInitialY + (resultOffsetY * (i / 2))) * GameImage.getUIscale())); drawSymbolString(String.format("%dx", rankResultOrder[i]), - (int) (resultInitialX * GameImage.uiscale), - (int) ((resultInitialY + (resultOffsetY * (i / 2))) * GameImage.uiscale), + (int) (resultInitialX * GameImage.getUIscale()), + (int) ((resultInitialY + (resultOffsetY * (i / 2))) * GameImage.getUIscale()), symbolTextScale, false); drawSymbolString(String.format("%dx", rankResultOrder[i+1]), - (int) ((resultInitialX + resultOffsetX) * GameImage.uiscale), - (int) ((resultInitialY + (resultOffsetY * (i / 2))) * GameImage.uiscale), + (int) ((resultInitialX + resultOffsetX) * GameImage.getUIscale()), + (int) ((resultInitialY + (resultOffsetY * (i / 2))) * GameImage.getUIscale()), symbolTextScale, false); } // combo and accuracy - Image rankingMaxCombo = GameImage.RANKING_MAXCOMBO.getImage(); - Image rankingAccuracy = GameImage.RANKING_ACCURACY.getImage(); float accuracyX = 295; float textY = rankingHeight + 425; float numbersY = textY + 30; drawSymbolString(String.format("%dx", comboMax), - (int) (25 * GameImage.uiscale), - (int) (numbersY * GameImage.uiscale), symbolTextScale, false); + (int) (25 * GameImage.getUIscale()), + (int) (numbersY * GameImage.getUIscale()), symbolTextScale, false); drawSymbolString(String.format("%02.2f%%", getScorePercent()), - (int) ((accuracyX + 20) * GameImage.uiscale), - (int) (numbersY * GameImage.uiscale), symbolTextScale, false); - rankingMaxCombo.draw( - (int) (10 * GameImage.uiscale), - (int) (textY * GameImage.uiscale)); - rankingAccuracy.draw( - (int) (accuracyX * GameImage.uiscale), - (int) (textY * GameImage.uiscale)); - + (int) ((accuracyX + 20) * GameImage.getUIscale()), + (int) (numbersY * GameImage.getUIscale()), symbolTextScale, false); + GameImage.RANKING_MAXCOMBO.getImage().draw( + (int) (10 * GameImage.getUIscale()), + (int) (textY * GameImage.getUIscale())); + GameImage.RANKING_ACCURACY.getImage().draw( + (int) (accuracyX * GameImage.getUIscale()), + (int) (textY * GameImage.getUIscale())); // full combo if (comboMax == fullObjectCount) { @@ -741,24 +729,26 @@ public class GameData { (height * 0.99f) - GameImage.RANKING_PERFECT.getImage().getHeight() ); } + // grade Grade grade = getGrade(); if (grade != Grade.NULL) - grade.getLargeImage().draw(width-grade.getLargeImage().getWidth(), rankingHeight); + grade.getLargeImage().draw(width - grade.getLargeImage().getWidth(), rankingHeight); - //Header + // header + Image rankingTitle = GameImage.RANKING_TITLE.getImage(); g.setColor(Utils.COLOR_BLACK_ALPHA); - g.fillRect(0, 0, width, 100 * GameImage.uiscale); + g.fillRect(0, 0, width, 100 * GameImage.getUIscale()); rankingTitle.draw((width * 0.97f) - rankingTitle.getWidth(), 0); - Utils.FONT_LARGE.drawString(marginX, marginY, + float c = width * 0.01f; + Utils.FONT_LARGE.drawString(c, c, 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(c, c + Utils.FONT_LARGE.getLineHeight() - 6, String.format("Beatmap by %s", osu.creator), Color.white); Utils.FONT_MEDIUM.drawString( - marginX, marginY + Utils.FONT_LARGE.getLineHeight() + Utils.FONT_MEDIUM.getLineHeight() - 10, + c, c + Utils.FONT_LARGE.getLineHeight() + Utils.FONT_MEDIUM.getLineHeight() - 10, String.format("Played on %s.", scoreData.getTimeString()), Color.white); - // mod icons int modWidth = GameMod.AUTO.getImage().getWidth(); float modX = (width * 0.98f) - modWidth; diff --git a/src/itdelatrisu/opsu/GameImage.java b/src/itdelatrisu/opsu/GameImage.java index 23034fe0..b000861b 100644 --- a/src/itdelatrisu/opsu/GameImage.java +++ b/src/itdelatrisu/opsu/GameImage.java @@ -41,7 +41,7 @@ public enum GameImage { SECTION_PASS ("section-pass", "png"), SECTION_FAIL ("section-fail", "png"), WARNINGARROW ("play-warningarrow", "png"), - SKIP ("play-skip", "play-skip-%d","png"), + SKIP ("play-skip", "play-skip-%d", "png"), COUNTDOWN_READY ("ready", "png") { @Override protected Image process_sub(Image img, int w, int h) { @@ -51,19 +51,19 @@ public enum GameImage { COUNTDOWN_3 ("count3", "png") { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy((h / 3f) / img.getHeight()); + return COUNTDOWN_READY.process_sub(img, w, h); } }, COUNTDOWN_2 ("count2", "png") { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy((h / 3f) / img.getHeight()); + return COUNTDOWN_READY.process_sub(img, w, h); } }, COUNTDOWN_1 ("count1", "png") { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy((h / 3f) / img.getHeight()); + return COUNTDOWN_READY.process_sub(img, w, h); } }, COUNTDOWN_GO ("go", "png") { @@ -135,7 +135,7 @@ public enum GameImage { SPINNER_CLEAR ("spinner-clear", "png"), SPINNER_OSU ("spinner-osu", "png"), - // Score Data + // Game Data COMBO_BURST ("comboburst", "comboburst-%d", "png"), SCOREBAR_BG ("scorebar-bg", "png"), SCOREBAR_COLOUR ("scorebar-colour", "scorebar-colour-%d", "png"), @@ -331,7 +331,7 @@ public enum GameImage { return img.getScaledCopy((h * 0.3f) / img.getHeight()); } }, - MENU_BACK ("menu-back", "menu-back-%d","png"), + MENU_BACK ("menu-back", "menu-back-%d", "png"), MENU_BUTTON_BG ("menu-button-background", "png", false, false), MENU_TAB ("selection-tab", "png", false, false) { @Override @@ -342,14 +342,14 @@ public enum GameImage { MENU_MUSICNOTE ("music-note", "png", false, false) { @Override protected Image process_sub(Image img, int w, int h) { - int r = (int) (Utils.FONT_LARGE.getLineHeight() * 0.75f + Utils.FONT_DEFAULT.getLineHeight()); + int r = (int) ((Utils.FONT_LARGE.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() - 8) / getUIscale()); return img.getScaledCopy(r, r); } }, MENU_LOADER ("loader", "png", false, false) { @Override protected Image process_sub(Image img, int w, int h) { - int r = (int) (Utils.FONT_LARGE.getLineHeight() * 0.75f + Utils.FONT_DEFAULT.getLineHeight()); + int r = (int) ((Utils.FONT_LARGE.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() - 8) / getUIscale()); return img.getScaledCopy(r / 48f); } }, @@ -479,9 +479,12 @@ public enum GameImage { /** Container dimensions. */ private static int containerWidth, containerHeight; - - /** value ui should be scaled by */ - public static float uiscale; + + /** Value to scale UI components by. */ + private static float uiscale; + + /** The unscaled container height that uiscale is based on. */ + private static final int UNSCALED_HEIGHT = 768; /** * Initializes the GameImage class with container dimensions. @@ -491,9 +494,14 @@ public enum GameImage { public static void init(int width, int height) { containerWidth = width; containerHeight = height; - uiscale = containerHeight / 768f; + uiscale = (float) containerHeight / UNSCALED_HEIGHT; } + /** + * Returns the UI scale. + */ + public static float getUIscale() { return uiscale; } + /** * Clears all image references. * This does NOT destroy images, so be careful of memory leaks! @@ -589,15 +597,16 @@ public enum GameImage { setDefaultImage(); return (skinImage != null) ? skinImage : defaultImage; } - + /** * Returns an Animation based on the image array. - * If no image array exist, returns the single image as an animation. + * If no image array exists, returns the single image as an animation. + * @param duration the duration to show each frame in the animation */ public Animation getAnimation(int duration){ Image[] images = getImages(); if (images == null) - images = new Image[]{ getImage() }; + images = new Image[] { getImage() }; return new Animation(images, duration); } @@ -813,14 +822,14 @@ public enum GameImage { * Performs individual post-loading actions on the image. */ private void process() { - int fakeWid = 768*containerWidth/containerHeight; + int unscaledWidth = UNSCALED_HEIGHT * containerWidth / containerHeight; if (skinImages != null) { for (int i = 0; i < skinImages.length; i++) - setImage(process_sub(getImages()[i], fakeWid, 768).getScaledCopy(uiscale), i); + setImage(process_sub(getImages()[i], unscaledWidth, UNSCALED_HEIGHT).getScaledCopy(getUIscale()), i); } else if (defaultImages != null && skinImage == null) { for (int i = 0; i < defaultImages.length; i++) - setImage(process_sub(getImages()[i], fakeWid, 768).getScaledCopy(uiscale), i); + setImage(process_sub(getImages()[i], unscaledWidth, UNSCALED_HEIGHT).getScaledCopy(getUIscale()), i); } else - setImage(process_sub(getImage(), fakeWid, 768).getScaledCopy(uiscale)); + setImage(process_sub(getImage(), unscaledWidth, UNSCALED_HEIGHT).getScaledCopy(getUIscale())); } } \ No newline at end of file diff --git a/src/itdelatrisu/opsu/MenuButton.java b/src/itdelatrisu/opsu/MenuButton.java index f8340f07..249dd189 100644 --- a/src/itdelatrisu/opsu/MenuButton.java +++ b/src/itdelatrisu/opsu/MenuButton.java @@ -365,24 +365,24 @@ public class MenuButton { * and expansion direction. */ private void setHoverRadius() { + if (img == null) + return; + int xOffset = 0, yOffset = 0; - if(img != null){ - if (dir != Expand.CENTER) { - // offset by difference between normal/scaled image dimensions - xOffset = (int) ((scale - 1f) * img.getWidth()); - yOffset = (int) ((scale - 1f) * img.getHeight()); - if (dir == Expand.UP || dir == Expand.DOWN) - xOffset = 0; // no horizontal offset - if (dir == Expand.RIGHT || dir == Expand.LEFT) - yOffset = 0; // no vertical offset - if (dir == Expand.RIGHT || dir == Expand.DOWN_RIGHT || dir == Expand.UP_RIGHT) - xOffset *= -1; // flip x for right - if (dir == Expand.DOWN || dir == Expand.DOWN_LEFT || dir == Expand.DOWN_RIGHT) - yOffset *= -1; // flip y for down - } - this.xRadius = ((img.getWidth() * scale) + xOffset) / 2f; - this.yRadius = ((img.getHeight() * scale) + yOffset) / 2f; - + if (dir != Expand.CENTER) { + // offset by difference between normal/scaled image dimensions + xOffset = (int) ((scale - 1f) * img.getWidth()); + yOffset = (int) ((scale - 1f) * img.getHeight()); + if (dir == Expand.UP || dir == Expand.DOWN) + xOffset = 0; // no horizontal offset + if (dir == Expand.RIGHT || dir == Expand.LEFT) + yOffset = 0; // no vertical offset + if (dir == Expand.RIGHT || dir == Expand.DOWN_RIGHT || dir == Expand.UP_RIGHT) + xOffset *= -1; // flip x for right + if (dir == Expand.DOWN || dir == Expand.DOWN_LEFT || dir == Expand.DOWN_RIGHT) + yOffset *= -1; // flip y for down } + this.xRadius = ((img.getWidth() * scale) + xOffset) / 2f; + this.yRadius = ((img.getHeight() * scale) + yOffset) / 2f; } } diff --git a/src/itdelatrisu/opsu/OsuGroupNode.java b/src/itdelatrisu/opsu/OsuGroupNode.java index 29918ec6..e41e52bb 100644 --- a/src/itdelatrisu/opsu/OsuGroupNode.java +++ b/src/itdelatrisu/opsu/OsuGroupNode.java @@ -61,13 +61,13 @@ public class OsuGroupNode { */ public void draw(float x, float y, float headerY, float footerY, Grade grade, boolean focus) { boolean expanded = (osuFileIndex > -1); - float xOffset = 0f; OsuFile osu; Image bg = GameImage.MENU_BUTTON_BG.getImage(); bg.setAlpha(0.9f); Color bgColor; Color textColor = Color.lightGray; - + + // get drawing parameters if (expanded) { // expanded x -= bg.getWidth() / 10f; if (focus) { @@ -80,6 +80,7 @@ public class OsuGroupNode { bgColor = Utils.COLOR_ORANGE_BUTTON; osu = osuFiles.get(0); } + // crop image if necessary if (y < headerY) { int cropHeight = (int) (headerY - y); diff --git a/src/itdelatrisu/opsu/OsuHitObject.java b/src/itdelatrisu/opsu/OsuHitObject.java index 59eb9678..6d6a2f63 100644 --- a/src/itdelatrisu/opsu/OsuHitObject.java +++ b/src/itdelatrisu/opsu/OsuHitObject.java @@ -298,10 +298,7 @@ public class OsuHitObject { public boolean isNewCombo() { return (type & TYPE_NEWCOMBO) > 0; } /** - * Returns the number of extra skips on the combo colours + * Returns the number of extra skips on the combo colors. */ - public int getComboSkip() { - return (type >> 4); - } - + public int getComboSkip() { return (type >> TYPE_NEWCOMBO); } } diff --git a/src/itdelatrisu/opsu/OsuParser.java b/src/itdelatrisu/opsu/OsuParser.java index 188a6acb..40a460e6 100644 --- a/src/itdelatrisu/opsu/OsuParser.java +++ b/src/itdelatrisu/opsu/OsuParser.java @@ -564,14 +564,13 @@ public class OsuParser { // set combo info // - new combo: get next combo index, reset combo number // - else: maintain combo index, increase combo number - if (((hitObject.isNewCombo()|| first) && !hitObject.isSpinner()) ) { + if (((hitObject.isNewCombo() || first) && !hitObject.isSpinner())) { int skip = 1 + hitObject.getComboSkip(); - - for(int i=0; i < skip; i++){ + for (int i = 0; i < skip; i++) { comboIndex = (comboIndex + 1) % osu.combo.length; comboNumber = 1; } - first=false; + first = false; } hitObject.setComboIndex(comboIndex); diff --git a/src/itdelatrisu/opsu/ScoreData.java b/src/itdelatrisu/opsu/ScoreData.java index ece9e71b..e96da489 100644 --- a/src/itdelatrisu/opsu/ScoreData.java +++ b/src/itdelatrisu/opsu/ScoreData.java @@ -287,8 +287,6 @@ public class ScoreData implements Comparable { // time since if (getTimeSince() != null) { Image clock = GameImage.HISTORY.getImage(); - g.setColor((focus) ? BG_FOCUS : BG_NORMAL); - g.fillRect(baseX + buttonWidth, y, Utils.FONT_DEFAULT.getWidth(" "),buttonHeight); clock.drawCentered(baseX + buttonWidth * 1.02f + clock.getWidth() / 2f, midY); Utils.FONT_DEFAULT.drawString( baseX + buttonWidth * 1.03f + clock.getWidth(), diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java index 0bde121f..ae4ee02c 100644 --- a/src/itdelatrisu/opsu/Utils.java +++ b/src/itdelatrisu/opsu/Utils.java @@ -87,8 +87,8 @@ public class Utils { /** The default map colors, used when a map does not provide custom colors. */ public static final Color[] DEFAULT_COMBO = { - COLOR_ORANGE_OBJECT, COLOR_GREEN_OBJECT, - COLOR_BLUE_OBJECT, COLOR_RED_OBJECT, + COLOR_ORANGE_OBJECT, COLOR_GREEN_OBJECT, + COLOR_BLUE_OBJECT, COLOR_RED_OBJECT, }; /** Game fonts. */ @@ -222,21 +222,14 @@ public class Utils { DownloadNode.init(width, height); // back button - //TODO: this is annoying perhaps we can just pass in GameImage to MenuButton? - if (GameImage.MENU_BACK.getImages() != null){ + if (GameImage.MENU_BACK.getImages() != null) { Animation back = GameImage.MENU_BACK.getAnimation(200); - backButton = new MenuButton(back, - back.getWidth() / 2f, - height - (back.getHeight() / 2f)); - }else{ + backButton = new MenuButton(back, back.getWidth() / 2f, height - (back.getHeight() / 2f)); + } else { Image back = GameImage.MENU_BACK.getImage(); - backButton = new MenuButton(GameImage.MENU_BACK.getImage(), - back.getWidth() / 2f, - height - (back.getHeight() / 2f)); + backButton = new MenuButton(back, back.getWidth() / 2f, height - (back.getHeight() / 2f)); } backButton.setHoverExpand(MenuButton.Expand.UP_RIGHT); - - } /** diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 2bfdbed6..66d0e2cc 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -809,20 +809,15 @@ public class Game extends BasicGameState { } // skip button - //TODO: this is annoying perhaps we can just pass in GameImage to MenuButton? - if (GameImage.SKIP.getImages() != null){ - Animation back = GameImage.SKIP.getAnimation(200); - skipButton = new MenuButton(back, - width - back.getWidth() / 2f, - height - (back.getHeight() / 2f)); - }else{ - Image back = GameImage.SKIP.getImage(); - skipButton = new MenuButton(GameImage.SKIP.getImage(), - width - back.getWidth() / 2f, - height - (back.getHeight() / 2f)); + if (GameImage.SKIP.getImages() != null) { + Animation skip = GameImage.SKIP.getAnimation(200); + skipButton = new MenuButton(skip, width - skip.getWidth() / 2f, height - (skip.getHeight() / 2f)); + } else { + Image skip = GameImage.SKIP.getImage(); + skipButton = new MenuButton(skip, width - skip.getWidth() / 2f, height - (skip.getHeight() / 2f)); } - skipButton.setHoverExpand(MenuButton.Expand.UP_LEFT); - + skipButton.setHoverExpand(1.1f, MenuButton.Expand.UP_LEFT); + // load other images... ((GamePauseMenu) game.getState(Opsu.STATE_GAMEPAUSEMENU)).loadImages(); data.loadImages(); diff --git a/src/itdelatrisu/opsu/states/GameRanking.java b/src/itdelatrisu/opsu/states/GameRanking.java index c1a1b315..4a228070 100644 --- a/src/itdelatrisu/opsu/states/GameRanking.java +++ b/src/itdelatrisu/opsu/states/GameRanking.java @@ -95,10 +95,8 @@ public class GameRanking extends BasicGameState { OsuFile osu = MusicController.getOsuFile(); // background - if (!osu.drawBG(width, height, 0.7f, true)) { + if (!osu.drawBG(width, height, 0.7f, true)) GameImage.MENU_BG.getImage().draw(0,0); - //g.setBackground(Utils.COLOR_BLACK_ALPHA); - } // ranking screen elements data.drawRankingElements(g, osu); diff --git a/src/itdelatrisu/opsu/states/OptionsMenu.java b/src/itdelatrisu/opsu/states/OptionsMenu.java index 53beaee2..f0821175 100644 --- a/src/itdelatrisu/opsu/states/OptionsMenu.java +++ b/src/itdelatrisu/opsu/states/OptionsMenu.java @@ -172,17 +172,17 @@ public class OptionsMenu extends BasicGameState { // option tabs Image tabImage = GameImage.MENU_TAB.getImage(); - int subtextWidth = Utils.FONT_DEFAULT.getWidth("Click or drag an option to change it."); float tabX = (width / 50) + (tabImage.getWidth() / 2f); - float tabY = 15 + Utils.FONT_XLARGE.getLineHeight() + (tabImage.getHeight() / 2f); - int tabOffset = Math.min(tabImage.getWidth(), - (width/2) / OptionTab.SIZE); + float tabY = Utils.FONT_LARGE.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() + + height * 0.03f + (tabImage.getHeight() / 2f); + int tabOffset = Math.min(tabImage.getWidth(), (width / 2) / OptionTab.SIZE); for (OptionTab tab : OptionTab.values()) tab.button = new MenuButton(tabImage, tabX + (tab.ordinal() * tabOffset), tabY); // game option coordinate modifiers textY = (int) (tabY + tabImage.getHeight()); - offsetY = (height - textY - GameImage.MENU_BACK.getAnimation(1).getHeight()) / maxOptionsScreen; + int backHeight = GameImage.MENU_BACK.getAnimation(1).getHeight(); + offsetY = (height - textY - (backHeight * 4 / 5)) / maxOptionsScreen; } @Override @@ -195,15 +195,10 @@ public class OptionsMenu extends BasicGameState { int mouseX = input.getMouseX(), mouseY = input.getMouseY(); // title - Utils.FONT_XLARGE.drawString( - (width - Utils.FONT_XLARGE.getWidth("GAME OPTIONS")) / 2, 10, - "GAME OPTIONS", Color.white - ); - Utils.FONT_DEFAULT.drawString( - (width - Utils.FONT_DEFAULT.getWidth("Click or drag an option to change it.")) / 2, - 10 + Utils.FONT_XLARGE.getLineHeight(), - "Click or drag an option to change it.", Color.white - ); + float c = container.getWidth() * 0.02f; + Utils.FONT_LARGE.drawString(c, c, "Game Options", Color.white); + Utils.FONT_DEFAULT.drawString(c, c + Utils.FONT_LARGE.getLineHeight() * 0.9f, + "Click or drag an option to change it.", Color.white); // game options g.setLineWidth(1f); diff --git a/src/itdelatrisu/opsu/states/SongMenu.java b/src/itdelatrisu/opsu/states/SongMenu.java index 3153d141..bc69798b 100644 --- a/src/itdelatrisu/opsu/states/SongMenu.java +++ b/src/itdelatrisu/opsu/states/SongMenu.java @@ -310,16 +310,17 @@ public class SongMenu extends BasicGameState { else musicNote.draw(marginX, marginY); int iconWidth = musicNote.getWidth(); - int iconHeight = musicNote.getHeight(); if (songInfo == null) songInfo = focusNode.getInfo(); marginX += 5; - Utils.FONT_LARGE.drawString(marginX + iconWidth * 1.05f, marginY, songInfo[0], Color.white); - Utils.FONT_DEFAULT.drawString(marginX + iconWidth * 1.05f, marginY + Utils.FONT_LARGE.getLineHeight() * 0.75f, songInfo[1], Color.white); - float headerTextY = marginY + iconHeight; + float headerTextY = marginY; + Utils.FONT_LARGE.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[0], Color.white); + headerTextY += Utils.FONT_LARGE.getLineHeight() - 8; + Utils.FONT_DEFAULT.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[1], Color.white); + headerTextY += Utils.FONT_DEFAULT.getLineHeight() - 2; Utils.FONT_BOLD.drawString(marginX, headerTextY, songInfo[2], Color.white); - headerTextY += Utils.FONT_BOLD.getLineHeight() - 6; + headerTextY += Utils.FONT_BOLD.getLineHeight() - 4; Utils.FONT_DEFAULT.drawString(marginX, headerTextY, songInfo[3], Color.white); headerTextY += Utils.FONT_DEFAULT.getLineHeight() - 4; Utils.FONT_SMALL.drawString(marginX, headerTextY, songInfo[4], Color.white); @@ -630,7 +631,7 @@ public class SongMenu extends BasicGameState { (y > buttonY + (i * buttonOffset) && y < buttonY + (i * buttonOffset) + buttonHeight)) { float oldHoverOffset = hoverOffset; int oldHoverIndex = hoverIndex; - + // clicked node is already expanded if (node.index == expandedIndex) { if (node.osuFileIndex == focusNode.osuFileIndex) { @@ -645,21 +646,21 @@ public class SongMenu extends BasicGameState { setFocus(node, 0, false); } } - + // clicked node is a new group else { SoundController.playSound(SoundEffect.MENUCLICK); setFocus(node, -1, false); } - + // restore hover data hoverOffset = oldHoverOffset; hoverIndex = oldHoverIndex; - + // open beatmap menu if (button == Input.MOUSE_RIGHT_BUTTON) beatmapMenuTimer = (node.index == expandedIndex) ? BEATMAP_MENU_DELAY * 4 / 5 : 0; - + return; } } diff --git a/src/org/newdawn/slick/Image.java b/src/org/newdawn/slick/Image.java index c2480ff4..c3a1947e 100644 --- a/src/org/newdawn/slick/Image.java +++ b/src/org/newdawn/slick/Image.java @@ -45,6 +45,7 @@ import org.newdawn.slick.util.Log; * * @author kevin */ +@SuppressWarnings("unused") public class Image implements Renderable { /** The top left corner identifier */ public static final int TOP_LEFT = 0; @@ -570,6 +571,7 @@ public class Image implements Renderable { * @param x The x location to draw the image at * @param y The y location to draw the image at */ + @Override public void draw(float x, float y) { init(); draw(x,y,width,height); @@ -1316,9 +1318,7 @@ public class Image implements Renderable { GL.glBegin(SGL.GL_QUADS); } - /** - * @see java.lang.Object#toString() - */ + @Override public String toString() { init();