From 0b16f0e1578cfca2169419becafd531221af7cfa Mon Sep 17 00:00:00 2001 From: fd Date: Thu, 12 Mar 2015 21:34:37 -0400 Subject: [PATCH] More General scaling Font Scaling. Hit Error Bar scaling. --- src/itdelatrisu/opsu/GameData.java | 29 +++-- src/itdelatrisu/opsu/GameImage.java | 187 +++++----------------------- src/itdelatrisu/opsu/Utils.java | 13 +- 3 files changed, 52 insertions(+), 177 deletions(-) diff --git a/src/itdelatrisu/opsu/GameData.java b/src/itdelatrisu/opsu/GameData.java index a0a16908..3d10dbd1 100644 --- a/src/itdelatrisu/opsu/GameData.java +++ b/src/itdelatrisu/opsu/GameData.java @@ -592,31 +592,36 @@ public class GameData { hitErrorAlpha = (HIT_ERROR_FADE_TIME - (trackPosition - hitErrorList.getFirst().time)) / (HIT_ERROR_FADE_TIME * 0.1f); // draw bar - int hitErrorY = height - margin - 30, hitErrorX = width / 2; + float hitErrorY = height/GameImage.getUIscale() - margin - 10, hitErrorX = width/GameImage.getUIscale() / 2; float oldAlphaBlack = Utils.COLOR_BLACK_ALPHA.a; Utils.COLOR_BLACK_ALPHA.a = hitErrorAlpha; g.setColor(Utils.COLOR_BLACK_ALPHA); - g.fillRect(hitErrorX - 3 - hitResultOffset[HIT_50], - hitErrorY - 10, hitResultOffset[HIT_50] * 2, 20); + g.fillRect((hitErrorX - 3 - hitResultOffset[HIT_50] ) * GameImage.getUIscale(), + (hitErrorY - 10 ) * GameImage.getUIscale(), + (hitResultOffset[HIT_50] * 2 ) * GameImage.getUIscale(), 20 * GameImage.getUIscale()); Utils.COLOR_BLACK_ALPHA.a = oldAlphaBlack; Utils.COLOR_LIGHT_ORANGE.a = hitErrorAlpha; g.setColor(Utils.COLOR_LIGHT_ORANGE); - g.fillRect(hitErrorX - 3 - hitResultOffset[HIT_50], - hitErrorY - 3, hitResultOffset[HIT_50] * 2, 6); + g.fillRect((hitErrorX - 3 - hitResultOffset[HIT_50]) * GameImage.getUIscale(), + (hitErrorY - 3) * GameImage.getUIscale(), + (hitResultOffset[HIT_50] * 2) * GameImage.getUIscale(), 6 * GameImage.getUIscale()); Utils.COLOR_LIGHT_ORANGE.a = 1f; Utils.COLOR_LIGHT_GREEN.a = hitErrorAlpha; g.setColor(Utils.COLOR_LIGHT_GREEN); - g.fillRect(hitErrorX - 3 - hitResultOffset[HIT_100], - hitErrorY - 3, hitResultOffset[HIT_100] * 2, 6); + g.fillRect((hitErrorX - 3 - hitResultOffset[HIT_100]) * GameImage.getUIscale(), + (hitErrorY - 3) * GameImage.getUIscale(), + (hitResultOffset[HIT_100] * 2) * GameImage.getUIscale(), 6 * GameImage.getUIscale()); Utils.COLOR_LIGHT_GREEN.a = 1f; Utils.COLOR_LIGHT_BLUE.a = hitErrorAlpha; g.setColor(Utils.COLOR_LIGHT_BLUE); - g.fillRect(hitErrorX - 3 - hitResultOffset[HIT_300], - hitErrorY - 3, hitResultOffset[HIT_300] * 2, 6); + g.fillRect((hitErrorX - 3 - hitResultOffset[HIT_300]) * GameImage.getUIscale(), + (hitErrorY - 3) * GameImage.getUIscale(), + (hitResultOffset[HIT_300] * 2) * GameImage.getUIscale(), 6 * GameImage.getUIscale()); Utils.COLOR_LIGHT_BLUE.a = 1f; white.a = hitErrorAlpha; g.setColor(white); - g.fillRect(hitErrorX - 1.5f, hitErrorY - 10, 3, 20); + g.fillRect((hitErrorX - 1.5f) * GameImage.getUIscale(), (hitErrorY - 10) * GameImage.getUIscale(), + 3 * GameImage.getUIscale(), 20 * GameImage.getUIscale()); // draw ticks for (HitErrorInfo info : hitErrorList) { @@ -624,7 +629,9 @@ public class GameData { float alpha = 1 - ((float) (trackPosition - time) / HIT_ERROR_FADE_TIME); white.a = alpha * hitErrorAlpha; g.setColor(white); - g.fillRect(hitErrorX + info.timeDiff - 1, hitErrorY - 10, 2, 20); + g.fillRect((hitErrorX + info.timeDiff - 1) * GameImage.getUIscale(), + (hitErrorY - 10) * GameImage.getUIscale(), + 2 * GameImage.getUIscale(), 20 * GameImage.getUIscale()); } } diff --git a/src/itdelatrisu/opsu/GameImage.java b/src/itdelatrisu/opsu/GameImage.java index 96d6b9d4..904105e1 100644 --- a/src/itdelatrisu/opsu/GameImage.java +++ b/src/itdelatrisu/opsu/GameImage.java @@ -114,16 +114,11 @@ public enum GameImage { SLIDER_TICK ("sliderscorepoint", "png"), // Spinner - SPINNER_CIRCLE ("spinner-circle", "png") { - @Override - protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy(h * 9 / 10, h * 9 / 10); - } - }, + SPINNER_CIRCLE ("spinner-circle", "png"), SPINNER_APPROACHCIRCLE ("spinner-approachcircle", "png") { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy(h * 9 / 10, h * 9 / 10); + return img.getScaledCopy(1.8f); } }, SPINNER_METRE ("spinner-metre", "png") { @@ -138,7 +133,7 @@ public enum GameImage { SPINNER_RPM ("spinner-rpm", "png") { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy((SCORE_0.getImage().getHeight() * 1.05f) / img.getHeight()); + return img.getScaledCopy(0.8f); } }, @@ -208,128 +203,28 @@ public enum GameImage { LIGHTING1 ("lighting1", "png"), // Game Mods - MOD_EASY ("selection-mod-easy", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy((h / 12f) / img.getHeight()); - } - }, - MOD_NO_FAIL ("selection-mod-nofail", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_HARD_ROCK ("selection-mod-hardrock", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_SUDDEN_DEATH ("selection-mod-suddendeath", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_SPUN_OUT ("selection-mod-spunout", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_AUTO ("selection-mod-autoplay", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_HALF_TIME ("selection-mod-halftime", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_DOUBLE_TIME ("selection-mod-doubletime", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_HIDDEN ("selection-mod-hidden", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_FLASHLIGHT ("selection-mod-flashlight", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_RELAX ("selection-mod-relax", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, - MOD_AUTOPILOT ("selection-mod-relax2", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MOD_EASY.process_sub(img, w, h); - } - }, + MOD_EASY ("selection-mod-easy", "png", false, false), + MOD_NO_FAIL ("selection-mod-nofail", "png", false, false), + MOD_HARD_ROCK ("selection-mod-hardrock", "png", false, false), + MOD_SUDDEN_DEATH ("selection-mod-suddendeath", "png", false, false), + MOD_SPUN_OUT ("selection-mod-spunout", "png", false, false), + MOD_AUTO ("selection-mod-autoplay", "png", false, false), + MOD_HALF_TIME ("selection-mod-halftime", "png", false, false), + MOD_DOUBLE_TIME ("selection-mod-doubletime", "png", false, false), + MOD_HIDDEN ("selection-mod-hidden", "png", false, false), + MOD_FLASHLIGHT ("selection-mod-flashlight", "png", false, false), + MOD_RELAX ("selection-mod-relax", "png", false, false), + MOD_AUTOPILOT ("selection-mod-relax2", "png", false, false), // Selection Buttons - SELECTION_MODS ("selection-mods", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy((h * 0.115f) / img.getHeight()); - } - }, - SELECTION_MODS_OVERLAY ("selection-mods-over", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return SELECTION_MODS.process_sub(img, w, h); - } - }, - SELECTION_RANDOM ("selection-random", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return SELECTION_MODS.process_sub(img, w, h); - } - }, - SELECTION_RANDOM_OVERLAY ("selection-random-over", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return SELECTION_MODS.process_sub(img, w, h); - } - }, - SELECTION_OPTIONS ("selection-options", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return SELECTION_MODS.process_sub(img, w, h); - } - }, - SELECTION_OPTIONS_OVERLAY ("selection-options-over", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return SELECTION_MODS.process_sub(img, w, h); - } - }, - SELECTION_OTHER_OPTIONS ("selection-selectoptions", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return SELECTION_MODS.process_sub(img, w, h); - } - }, - SELECTION_OTHER_OPTIONS_OVERLAY ("selection-selectoptions-over", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return SELECTION_MODS.process_sub(img, w, h); - } - }, + SELECTION_MODS ("selection-mods", "png", false, false), + SELECTION_MODS_OVERLAY ("selection-mods-over", "png", false, false), + SELECTION_RANDOM ("selection-random", "png", false, false), + SELECTION_RANDOM_OVERLAY ("selection-random-over", "png", false, false), + SELECTION_OPTIONS ("selection-options", "png", false, false), + SELECTION_OPTIONS_OVERLAY ("selection-options-over", "png", false, false), + SELECTION_OTHER_OPTIONS ("selection-selectoptions", "png", false, false), + SELECTION_OTHER_OPTIONS_OVERLAY ("selection-selectoptions-over", "png", false, false), // Non-Game Components VOLUME ("volume-bg", "png", false, false) { @@ -370,19 +265,19 @@ public enum GameImage { MENU_LOGO ("logo", "png", false, true) { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy((h / 1.2f) / img.getHeight()); + return img.getScaledCopy(0.8f); } }, MENU_PlAY ("menu-play", "png", false, false) { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy(MENU_LOGO.getImage().getWidth() * 0.83f / img.getWidth()); - } + return img.getScaledCopy(0.8f); + } }, MENU_EXIT ("menu-exit", "png", false, false) { @Override protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy(MENU_LOGO.getImage().getWidth() * 0.66f / img.getWidth()); + return img.getScaledCopy(0.8f); } }, MENU_BUTTON_MID ("button-middle", "png", false, false), @@ -390,30 +285,10 @@ public enum GameImage { MENU_BUTTON_RIGHT ("button-right", "png", false, false), // Music Player Buttons - MUSIC_PLAY ("music-play", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return img.getScaledCopy((h / 18f) / img.getHeight()); - } - }, - MUSIC_PAUSE ("music-pause", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MUSIC_PLAY.process_sub(img, w, h); - } - }, - MUSIC_NEXT ("music-next", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MUSIC_PLAY.process_sub(img, w, h); - } - }, - MUSIC_PREVIOUS ("music-previous", "png", false, false) { - @Override - protected Image process_sub(Image img, int w, int h) { - return MUSIC_PLAY.process_sub(img, w, h); - } - }, + MUSIC_PLAY ("music-play", "png", false, false), + MUSIC_PAUSE ("music-pause", "png", false, false), + MUSIC_NEXT ("music-next", "png", false, false), + MUSIC_PREVIOUS ("music-previous", "png", false, false), RANKING_RETRY ("ranking-retry", "png", false, false), RANKING_EXIT ("ranking-back", "png", false, false), DOWNLOADS ("downloads", "png", false, false) { diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java index 0b4d631e..1c945438 100644 --- a/src/itdelatrisu/opsu/Utils.java +++ b/src/itdelatrisu/opsu/Utils.java @@ -154,16 +154,10 @@ public class Utils { ErrorHandler.error("Failed to set the cursor.", e, true); } + GameImage.init(width, height); + // create fonts - float fontBase; - if (height <= 600) - fontBase = 10f; - else if (height < 800) - fontBase = 11f; - else if (height <= 900) - fontBase = 13f; - else - fontBase = 15f; + float fontBase = 12f * GameImage.getUIscale(); try { Font javaFont = Font.createFont(Font.TRUETYPE_FONT, ResourceLoader.getResourceAsStream(Options.FONT_NAME)); @@ -186,7 +180,6 @@ public class Utils { } // initialize game images - GameImage.init(width, height); for (GameImage img : GameImage.values()) { if (img.isPreload()) img.setDefaultImage();