Follow-up to 516e628: Fix resetting game data too soon.
Instead of resetting immediately, set a variable in SongMenu to reset data when entering the state. Fixes some weird behaviors, and also allows resetting in more scenarios. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -139,6 +139,11 @@ public class SongMenu extends BasicGameState {
|
||||
*/
|
||||
private Animation loader;
|
||||
|
||||
/**
|
||||
* Whether or not to reset game data upon entering the state.
|
||||
*/
|
||||
private boolean resetGame = false;
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
@@ -586,8 +591,12 @@ public class SongMenu extends BasicGameState {
|
||||
else if (MusicController.isPaused())
|
||||
MusicController.resume();
|
||||
|
||||
// destroy skin images, if any
|
||||
GameImage.destroySkinImages();
|
||||
// reset game data
|
||||
if (resetGame) {
|
||||
((Game) game.getState(Opsu.STATE_GAME)).resetGameData();
|
||||
GameImage.destroySkinImages(); // destroy skin images, if any
|
||||
resetGame = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -703,6 +712,11 @@ public class SongMenu extends BasicGameState {
|
||||
return oldFocus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a reset of game data upon entering this state.
|
||||
*/
|
||||
public void resetGameDataOnLoad() { resetGame = true; }
|
||||
|
||||
/**
|
||||
* Starts the game.
|
||||
* @param osu the OsuFile to send to the game
|
||||
|
||||
Reference in New Issue
Block a user