skip through objects

This commit is contained in:
yugecin 2016-11-12 23:13:41 +01:00
parent b584dcaf68
commit f466fafa03
3 changed files with 87 additions and 3 deletions

View File

@ -277,7 +277,54 @@ public class Game extends BasicGameState {
public Game(int state) { public Game(int state) {
this.state = state; this.state = state;
mirrorCursor = new Cursor(true); mirrorCursor = new Cursor(true);
sbOverlay = new SBOverlay(); sbOverlay = new SBOverlay(this);
}
public void setObjectIndex(int newObjIndex) {
try {
/*
restart = Restart.MANUAL;
enter(container, game);
checkpointLoaded = true;
if (isLeadIn()) {
leadInTime = 0;
MusicController.resume();
}
SoundController.playSound(SoundEffect.MENUHIT);
UI.sendBarNotification("Checkpoint loaded.");
// skip to checkpoint
MusicController.setPosition(checkpoint);
MusicController.setPitch(GameMod.getSpeedMultiplier() * playbackSpeed.getModifier());
while (objectIndex < gameObjects.length &&
beatmap.objects[objectIndex++].getTime() <= checkpoint)
;
objectIndex--;
lastReplayTime = beatmap.objects[objectIndex].getTime();
} catch (SlickException e) {
ErrorHandler.error("Failed to load checkpoint.", e, false);
}
*/
restart = Restart.MANUAL;
enter(container, game);
checkpointLoaded = true;
if (isLeadIn()) {
leadInTime = 0;
MusicController.resume();
}
int checkpoint = gameObjects[newObjIndex].getTime();
// skip to checkpoint
MusicController.setPosition(checkpoint);
while (objectIndex < gameObjects.length && beatmap.objects[objectIndex].getTime() <= checkpoint) {
objectIndex++;
}
objectIndex--;
sbOverlay.updateIndex(objectIndex);
lastReplayTime = beatmap.objects[objectIndex].getTime();
} catch (SlickException e) {
e.printStackTrace();
}
} }
@Override @Override
@ -918,6 +965,7 @@ public class Game extends BasicGameState {
// update hit object and check completion status // update hit object and check completion status
if (gameObjects[objectIndex].update(overlap, delta, mouseX, mouseY, keyPressed, trackPosition)) { if (gameObjects[objectIndex].update(overlap, delta, mouseX, mouseY, keyPressed, trackPosition)) {
objectIndex++; // done, so increment object index objectIndex++; // done, so increment object index
sbOverlay.updateIndex(objectIndex);
if (objectIndex >= mirrorTo) { if (objectIndex >= mirrorTo) {
Dancer.mirror = false; Dancer.mirror = false;
} }
@ -1249,6 +1297,11 @@ public class Game extends BasicGameState {
// grab the mouse (not working for touchscreen) // grab the mouse (not working for touchscreen)
// container.setMouseGrabbed(true); // container.setMouseGrabbed(true);
if (!checkpointLoaded) {
sbOverlay.updateIndex(0);
}
// restart the game // restart the game
if (restart != Restart.FALSE) { if (restart != Restart.FALSE) {
// load mods // load mods

View File

@ -53,7 +53,6 @@ public class OptionsOverlay {
Options.GameOption.DANCE_REMOVE_BG, Options.GameOption.DANCE_REMOVE_BG,
Options.GameOption.DANCE_HIDE_OBJECTS, Options.GameOption.DANCE_HIDE_OBJECTS,
Options.GameOption.DANCE_HIDE_UI, Options.GameOption.DANCE_HIDE_UI,
Options.GameOption.DANCE_HIDE_WATERMARK,
Options.GameOption.PIPPI_ENABLE, Options.GameOption.PIPPI_ENABLE,
Options.GameOption.PIPPI_ANGLE_INC_MUL, Options.GameOption.PIPPI_ANGLE_INC_MUL,
Options.GameOption.PIPPI_ANGLE_INC_MUL_SLIDER, Options.GameOption.PIPPI_ANGLE_INC_MUL_SLIDER,

View File

@ -19,6 +19,7 @@ package yugecin.opsudance.ui;
import itdelatrisu.opsu.audio.MusicController; import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.objects.GameObject; import itdelatrisu.opsu.objects.GameObject;
import itdelatrisu.opsu.states.Game;
import itdelatrisu.opsu.ui.Fonts; import itdelatrisu.opsu.ui.Fonts;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
@ -40,9 +41,13 @@ public class SBOverlay {
private GameObject[] gameObjects; private GameObject[] gameObjects;
private HashMap[] optionsMap; private HashMap[] optionsMap;
private int index;
private final Game game;
private final OptionsOverlay options; private final OptionsOverlay options;
public SBOverlay() { public SBOverlay(Game game) {
this.game = game;
options = new OptionsOverlay(); options = new OptionsOverlay();
} }
@ -62,6 +67,7 @@ public class SBOverlay {
Fonts.SMALL.drawString(10, height - 50, "speed: C " + (speed / 10f) + " V", Color.cyan); Fonts.SMALL.drawString(10, height - 50, "speed: C " + (speed / 10f) + " V", Color.cyan);
Fonts.SMALL.drawString(10, height - 50 - lh, "Menu: N", Color.cyan); Fonts.SMALL.drawString(10, height - 50 - lh, "Menu: N", Color.cyan);
Fonts.SMALL.drawString(10, height - 50 - lh * 2, "HIDE: H", Color.cyan); Fonts.SMALL.drawString(10, height - 50 - lh * 2, "HIDE: H", Color.cyan);
Fonts.SMALL.drawString(10, height - 50 - lh * 3, "obj: J " + index + " K", Color.cyan);
if (menu) { if (menu) {
options.render(g); options.render(g);
} }
@ -97,10 +103,31 @@ public class SBOverlay {
hide = !hide; hide = !hide;
} else if (key == Input.KEY_N) { } else if (key == Input.KEY_N) {
menu = !menu; menu = !menu;
if (menu && speed != 0) {
MusicController.pause();
} else if (!menu && speed != 0) {
MusicController.resume();
}
} else if (key == Input.KEY_J && index > 0) {
index--;
setMusicPosition();
} else if (key == Input.KEY_K && index < gameObjects.length - 1) {
index++;
setMusicPosition();
} }
return false; return false;
} }
private void setMusicPosition() {
game.setObjectIndex(index);
if (speed != 0) {
MusicController.setPitch(speed / 10f);
MusicController.resume();
} else {
MusicController.pause();
}
}
public void setGameObjects(GameObject[] gameObjects) { public void setGameObjects(GameObject[] gameObjects) {
if (this.gameObjects.length != gameObjects.length) { if (this.gameObjects.length != gameObjects.length) {
optionsMap = new HashMap[gameObjects.length]; optionsMap = new HashMap[gameObjects.length];
@ -115,4 +142,9 @@ public class SBOverlay {
public void mouseDragged(int oldx, int oldy, int newx, int newy) { public void mouseDragged(int oldx, int oldy, int newx, int newy) {
if (menu) options.mouseDragged(oldx, oldy, newx, newy); if (menu) options.mouseDragged(oldx, oldy, newx, newy);
} }
public void updateIndex(int index) {
this.index = index;
}
} }