diff options
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r-- | src/jrummikub/control/ApplicationControl.java | 36 | ||||
-rw-r--r-- | src/jrummikub/control/SaveControl.java | 10 |
2 files changed, 38 insertions, 8 deletions
diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java index 6909ce1..c0c3dad 100644 --- a/src/jrummikub/control/ApplicationControl.java +++ b/src/jrummikub/control/ApplicationControl.java @@ -43,14 +43,7 @@ public class ApplicationControl { addQuitGameHandlers(); - view.getNetworkGameEvent().add(new IListener() { - @Override - public void handle() { - abortControls(); - - createLoginControl(true); - } - }); + addNewNetworkGameHandler(); saveControl.getLoadEvent().add( new IListener3<GameSettings, GameState, IRoundState>() { @@ -72,6 +65,33 @@ public class ApplicationControl { }); } + private void addNewNetworkGameHandler() { + view.getNetworkGameEvent().add(new IListener() { + @Override + public void handle() { + if (gameControl == null) { + abortControls(); + createLoginControl(true); + } else { + showQuitWarning(); + } + view.getQuitWarningPanel().setMode(QuitMode.QUIT_PROCESS); + view.showQuitWarningPanel(true); + tempConnection = view.getQuitWarningPanel().getQuitEvent() + .add(new IListener() { + @Override + public void handle() { + abortControls(); + createLoginControl(true); + tempConnection.remove(); + tempConnection = null; + } + }); + + } + }); + } + private void addQuitGameHandlers() { view.getMenuNewGameEvent().add(new IListener() { @Override diff --git a/src/jrummikub/control/SaveControl.java b/src/jrummikub/control/SaveControl.java index 1b88d1c..5ecbb45 100644 --- a/src/jrummikub/control/SaveControl.java +++ b/src/jrummikub/control/SaveControl.java @@ -60,6 +60,16 @@ public class SaveControl { }); } }); + view.getQuitWarningPanel().getCancelEvent().add(new IListener() { + @Override + public void handle() { + view.showQuitWarningPanel(false); + if (tempConnection != null) { + tempConnection.remove(); + tempConnection = null; + } + } + }); view.getLoadFileEvent().add(new IListener1<File>() { @Override public void handle(final File file) { |