mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Fix crash when starting next game of match
This commit is contained in:
@@ -488,7 +488,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public void endCurrentGame() {
|
||||
FControl.instance.endCurrentGame();
|
||||
FControl.instance.endCurrentGame(false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -562,7 +562,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public void continueMatch(Match match) {
|
||||
Singletons.getControl().endCurrentGame();
|
||||
Singletons.getControl().endCurrentGame(false, false);
|
||||
if (match == null) {
|
||||
Singletons.getControl().setCurrentScreen(FScreen.HOME_SCREEN);
|
||||
}
|
||||
|
||||
@@ -450,16 +450,6 @@ public enum FControl implements KeyEventDispatcher {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void startGameInSameMatch() {
|
||||
startGameWithUi(game.getMatch());
|
||||
}
|
||||
public final void startGameAndClearMatch() {
|
||||
if (game != null) {
|
||||
game.getMatch().clearGamesPlayed();
|
||||
}
|
||||
startGameInSameMatch();
|
||||
}
|
||||
|
||||
public final void startGameWithUi(final Match match) {
|
||||
if (game != null) {
|
||||
setCurrentScreen(FScreen.MATCH_SCREEN);
|
||||
@@ -561,12 +551,21 @@ public enum FControl implements KeyEventDispatcher {
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
|
||||
public final void endCurrentGame() {
|
||||
public final void endCurrentGame(boolean nextGame, boolean restart) {
|
||||
if (game == null) { return; }
|
||||
|
||||
Match match = game.getMatch();
|
||||
game = null;
|
||||
|
||||
Singletons.getView().getNavigationBar().closeTab(FScreen.MATCH_SCREEN);
|
||||
|
||||
game = null;
|
||||
if (nextGame) {
|
||||
startGameWithUi(match);
|
||||
}
|
||||
else if (restart) {
|
||||
match.clearGamesPlayed();
|
||||
startGameWithUi(match);
|
||||
}
|
||||
}
|
||||
|
||||
private FControlGamePlayback playbackControl;
|
||||
|
||||
@@ -58,23 +58,21 @@ public class ControlWinLose {
|
||||
SOverlayUtils.hideOverlay();
|
||||
saveOptions();
|
||||
|
||||
Singletons.getControl().endCurrentGame();
|
||||
Singletons.getControl().startGameInSameMatch();
|
||||
Singletons.getControl().endCurrentGame(true, false);
|
||||
}
|
||||
|
||||
/** Action performed when "restart" button is pressed in default win/lose UI. */
|
||||
public void actionOnRestart() {
|
||||
SOverlayUtils.hideOverlay();
|
||||
saveOptions();
|
||||
Singletons.getControl().endCurrentGame();
|
||||
Singletons.getControl().startGameAndClearMatch();
|
||||
Singletons.getControl().endCurrentGame(false, true);
|
||||
}
|
||||
|
||||
/** Action performed when "quit" button is pressed in default win/lose UI. */
|
||||
public void actionOnQuit() {
|
||||
// Reset other stuff
|
||||
saveOptions();
|
||||
Singletons.getControl().endCurrentGame();
|
||||
Singletons.getControl().endCurrentGame(false, false);
|
||||
Singletons.getControl().setCurrentScreen(FScreen.HOME_SCREEN);
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
FModel.getQuestPreferences().save();
|
||||
Singletons.getControl().writeMatchPreferences();
|
||||
|
||||
Singletons.getControl().endCurrentGame();
|
||||
Singletons.getControl().endCurrentGame(false, false);
|
||||
Singletons.getControl().setCurrentScreen(FScreen.HOME_SCREEN);
|
||||
|
||||
SOverlayUtils.hideOverlay();
|
||||
|
||||
Reference in New Issue
Block a user