return to songmenu when closing game ranking screen

This commit is contained in:
yugecin 2017-01-19 19:52:13 +01:00
parent 2d0e2143d1
commit 0af6bc8c09
3 changed files with 18 additions and 3 deletions

View File

@ -1894,7 +1894,9 @@ public class Game extends ComplexOpsuState {
* Resets all game data and structures. * Resets all game data and structures.
*/ */
public void resetGameData() { public void resetGameData() {
data.clear(); if (data != null) {
data.clear();
}
objectIndex = 0; objectIndex = 0;
breakIndex = 0; breakIndex = 0;
breakTime = 0; breakTime = 0;
@ -1916,7 +1918,9 @@ public class Game extends ComplexOpsuState {
autoMousePosition = new Vec2f(); autoMousePosition = new Vec2f();
autoMousePressed = false; autoMousePressed = false;
flashlightRadius = displayContainer.height * 2 / 3; flashlightRadius = displayContainer.height * 2 / 3;
scoreboardStarStream.clear(); if (scoreboardStarStream != null) {
scoreboardStarStream.clear();
}
gameFinished = false; gameFinished = false;
gameFinishedTimer.setTime(0); gameFinishedTimer.setTime(0);

View File

@ -220,6 +220,17 @@ public class GameRanking extends BaseOpsuState {
} }
} }
@Override
public boolean onCloseRequest() {
SongMenu songmenu = instanceContainer.provide(SongMenu.class);
if (data != null && data.isGameplay()) {
songmenu.resetTrackOnLoad();
}
songmenu.resetGameDataOnLoad();
displayContainer.switchState(SongMenu.class);
return false;
}
/** /**
* Returns to the song menu. * Returns to the song menu.
*/ */

View File

@ -1025,7 +1025,7 @@ public class SongMenu extends ComplexOpsuState {
if (button != Input.MOUSE_RIGHT_BUTTON) { if (button != Input.MOUSE_RIGHT_BUTTON) {
// view score // view score
instanceContainer.provide(GameRanking.class).setGameData(new GameData(focusScores[rank], displayContainer.width, displayContainer.height)); instanceContainer.provide(GameRanking.class).setGameData(new GameData(focusScores[rank], displayContainer.width, displayContainer.height));
// TODO d displayContainer.switchState(GameRanking.class); displayContainer.switchState(GameRanking.class);
} else { } else {
// score management // score management
instanceContainer.provide(ButtonMenu.class).setMenuState(MenuState.SCORE, focusScores[rank]); instanceContainer.provide(ButtonMenu.class).setMenuState(MenuState.SCORE, focusScores[rank]);