From da90c98fce40f6d40e93cabc76472e055e4e1fe9 Mon Sep 17 00:00:00 2001 From: yugecin Date: Sun, 20 Nov 2016 13:49:53 +0100 Subject: [PATCH] ability to change map offset while playing (- and + keys) --- src/itdelatrisu/opsu/audio/MusicController.java | 5 +++-- src/itdelatrisu/opsu/states/Game.java | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/itdelatrisu/opsu/audio/MusicController.java b/src/itdelatrisu/opsu/audio/MusicController.java index 369eddaf..76b95f83 100644 --- a/src/itdelatrisu/opsu/audio/MusicController.java +++ b/src/itdelatrisu/opsu/audio/MusicController.java @@ -22,6 +22,7 @@ import itdelatrisu.opsu.ErrorHandler; import itdelatrisu.opsu.Options; import itdelatrisu.opsu.beatmap.Beatmap; import itdelatrisu.opsu.beatmap.BeatmapParser; +import itdelatrisu.opsu.states.Game; import itdelatrisu.opsu.ui.UI; import java.io.File; @@ -252,9 +253,9 @@ public class MusicController { */ public static int getPosition() { if (isPlaying()) - return (int) (player.getPosition() * 1000 + Options.getMusicOffset()); + return (int) (player.getPosition() * 1000 + Options.getMusicOffset() + Game.currentMapMusicOffset); else if (isPaused()) - return Math.max((int) (pauseTime * 1000 + Options.getMusicOffset()), 0); + return Math.max((int) (pauseTime * 1000 + Options.getMusicOffset() + Game.currentMapMusicOffset), 0); else return 0; } diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 946371f2..fe6e6147 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -256,6 +256,8 @@ public class Game extends BasicGameState { /** Music position bar coordinates and dimensions (for replay seeking). */ private float musicBarX, musicBarY, musicBarWidth, musicBarHeight; + public static int currentMapMusicOffset; + private int mirrorFrom; private int mirrorTo; @@ -1143,6 +1145,14 @@ public class Game extends BasicGameState { Dancer.mirror = true; } break; + case Input.KEY_MINUS: + currentMapMusicOffset += 5; + UI.sendBarNotification("Current map offset: " + currentMapMusicOffset); + break; + } + if (key == Input.KEY_ADD || c == '+') { + currentMapMusicOffset -= 5; + UI.sendBarNotification("Current map offset: " + currentMapMusicOffset); } } @@ -1654,6 +1664,9 @@ public class Game extends BasicGameState { * @param beatmap the beatmap to load */ public void loadBeatmap(Beatmap beatmap) { + if (this.beatmap == null || this.beatmap.beatmapID != beatmap.beatmapID) { + currentMapMusicOffset = 0; + } this.beatmap = beatmap; Display.setTitle(String.format("%s - %s", game.getTitle(), beatmap.toString())); if (beatmap.timingPoints == null)