From 07075c094b3e8e70bf12a73f8bc5ddd264482354 Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Sat, 4 Apr 2015 12:30:23 -0400 Subject: [PATCH] Mod difficulty multipliers are now reflected in displayed song info. Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/GameMod.java | 32 ++++++++++++++++++----- src/itdelatrisu/opsu/OsuGroupNode.java | 9 ++++--- src/itdelatrisu/opsu/states/Game.java | 25 ++++-------------- src/itdelatrisu/opsu/states/SongMenu.java | 5 +++- 4 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/itdelatrisu/opsu/GameMod.java b/src/itdelatrisu/opsu/GameMod.java index 5440bb2e..74c4608c 100644 --- a/src/itdelatrisu/opsu/GameMod.java +++ b/src/itdelatrisu/opsu/GameMod.java @@ -176,6 +176,9 @@ public enum GameMod { /** The last calculated track speed multiplier, or -1f if it must be recalculated. */ private static float speedMultiplier = -1f; + /** The last calculated difficulty multiplier, or -1f if it must be recalculated. */ + private static float difficultyMultiplier = -1f; + /** * Initializes the game mods. * @param width the container width @@ -201,7 +204,7 @@ public enum GameMod { mod.active = false; } - scoreMultiplier = speedMultiplier = -1f; + scoreMultiplier = speedMultiplier = difficultyMultiplier = -1f; } /** @@ -224,16 +227,31 @@ public enum GameMod { */ public static float getSpeedMultiplier() { if (speedMultiplier < 0f) { - float multiplier = 1f; if (DOUBLE_TIME.isActive()) - multiplier = 1.5f; + speedMultiplier = 1.5f; else if (HALF_TIME.isActive()) - multiplier = 0.75f; - speedMultiplier = multiplier; + speedMultiplier = 0.75f; + else + speedMultiplier = 1f; } return speedMultiplier; } + /** + * Returns the current difficulty multiplier from all active mods. + */ + public static float getDifficultyMultiplier() { + if (difficultyMultiplier < 0f) { + if (HARD_ROCK.isActive()) + difficultyMultiplier = 1.4f; + else if (EASY.isActive()) + difficultyMultiplier = 0.5f; + else + difficultyMultiplier = 1f; + } + return difficultyMultiplier; + } + /** * Returns the current game mod state (bitwise OR of active mods). */ @@ -251,7 +269,7 @@ public enum GameMod { * @param state the state (bitwise OR of active mods) */ public static void loadModState(int state) { - scoreMultiplier = speedMultiplier = -1f; + scoreMultiplier = speedMultiplier = difficultyMultiplier = -1f; for (GameMod mod : GameMod.values()) mod.active = ((state & mod.getBit()) > 0); } @@ -371,7 +389,7 @@ public enum GameMod { return; active = !active; - scoreMultiplier = speedMultiplier = -1f; + scoreMultiplier = speedMultiplier = difficultyMultiplier = -1f; if (checkInverse) { if (AUTO.isActive()) { diff --git a/src/itdelatrisu/opsu/OsuGroupNode.java b/src/itdelatrisu/opsu/OsuGroupNode.java index 07058c64..9988f1de 100644 --- a/src/itdelatrisu/opsu/OsuGroupNode.java +++ b/src/itdelatrisu/opsu/OsuGroupNode.java @@ -122,10 +122,10 @@ public class OsuGroupNode { long endTime = (long) (osu.endTime / speedModifier); int bpmMin = (int) (osu.bpmMin * speedModifier); int bpmMax = (int) (osu.bpmMax * speedModifier); + float multiplier = GameMod.getDifficultyMultiplier(); String[] info = new String[5]; info[0] = osu.toString(); - info[1] = String.format("Mapped by %s", - osu.creator); + info[1] = String.format("Mapped by %s", osu.creator); info[2] = String.format("Length: %d:%02d BPM: %s Objects: %d", TimeUnit.MILLISECONDS.toMinutes(endTime), TimeUnit.MILLISECONDS.toSeconds(endTime) - @@ -135,7 +135,10 @@ public class OsuGroupNode { info[3] = String.format("Circles: %d Sliders: %d Spinners: %d", osu.hitObjectCircle, osu.hitObjectSlider, osu.hitObjectSpinner); info[4] = String.format("CS:%.1f HP:%.1f AR:%.1f OD:%.1f", - osu.circleSize, osu.HPDrainRate, osu.approachRate, osu.overallDifficulty); + Math.min(osu.circleSize * multiplier, 10f), + Math.min(osu.HPDrainRate * multiplier, 10f), + Math.min(osu.approachRate * multiplier, 10f), + Math.min(osu.overallDifficulty * multiplier, 10f)); return info; } diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 9d513763..1e052b7c 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -1358,26 +1358,11 @@ public class Game extends BasicGameState { */ private void setMapModifiers() { // map-based properties, re-initialized each game - float circleSize = osu.circleSize; - float approachRate = osu.approachRate; - float overallDifficulty = osu.overallDifficulty; - float HPDrainRate = osu.HPDrainRate; - - // "Hard Rock" modifiers - if (GameMod.HARD_ROCK.isActive()) { - circleSize = Math.min(circleSize * 1.4f, 10); - approachRate = Math.min(approachRate * 1.4f, 10); - overallDifficulty = Math.min(overallDifficulty * 1.4f, 10); - HPDrainRate = Math.min(HPDrainRate * 1.4f, 10); - } - - // "Easy" modifiers - else if (GameMod.EASY.isActive()) { - circleSize /= 2f; - approachRate /= 2f; - overallDifficulty /= 2f; - HPDrainRate /= 2f; - } + float multiplier = GameMod.getDifficultyMultiplier(); + float circleSize = Math.min(osu.circleSize * multiplier, 10f); + float approachRate = Math.min(osu.approachRate * multiplier, 10f); + float overallDifficulty = Math.min(osu.overallDifficulty * multiplier, 10f); + float HPDrainRate = Math.min(osu.HPDrainRate * multiplier, 10f); // fixed difficulty overrides if (Options.getFixedCS() > 0f) diff --git a/src/itdelatrisu/opsu/states/SongMenu.java b/src/itdelatrisu/opsu/states/SongMenu.java index b9151f78..03b23627 100644 --- a/src/itdelatrisu/opsu/states/SongMenu.java +++ b/src/itdelatrisu/opsu/states/SongMenu.java @@ -356,7 +356,10 @@ public class SongMenu extends BasicGameState { 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); + float multiplier = GameMod.getDifficultyMultiplier(); + Color color4 = (multiplier == 1f) ? Color.white : + (multiplier > 1f) ? Utils.COLOR_RED_HIGHLIGHT : Utils.COLOR_BLUE_HIGHLIGHT; + Utils.FONT_SMALL.drawString(marginX, headerTextY, songInfo[4], color4); } // score buttons