summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/ApplicationControl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control/ApplicationControl.java')
-rw-r--r--src/jrummikub/control/ApplicationControl.java55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java
index 2271526..87516c0 100644
--- a/src/jrummikub/control/ApplicationControl.java
+++ b/src/jrummikub/control/ApplicationControl.java
@@ -5,10 +5,12 @@ import jrummikub.control.network.NetworkControl;
import jrummikub.model.GameSettings;
import jrummikub.model.GameState;
import jrummikub.model.IRoundState;
+import jrummikub.util.Connection;
import jrummikub.util.IListener;
import jrummikub.util.IListener1;
import jrummikub.util.IListener3;
import jrummikub.util.LoginData;
+import jrummikub.view.IQuitWarningPanel.QuitMode;
import jrummikub.view.IView;
import jrummikub.view.IView.BottomPanelType;
@@ -22,6 +24,7 @@ public class ApplicationControl {
private NetworkControl networkControl;
private SaveControl saveControl;
private GameControl gameControl;
+ private Connection tempConnection;
private IView view;
@@ -38,14 +41,59 @@ public class ApplicationControl {
view.getMenuNewGameEvent().add(new IListener() {
@Override
public void handle() {
- abortControls();
- startApplication();
+ view.getQuitWarningPanel().setMode(QuitMode.QUIT_GAME);
+ view.showQuitWarningPanel(true);
+ tempConnection = view.getQuitWarningPanel().getQuitEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ abortControls();
+ startApplication();
+ view.showQuitWarningPanel(false);
+ tempConnection.remove();
+ }
+ });
}
});
view.getMenuQuitEvent().add(new IListener() {
@Override
public void handle() {
- System.exit(0);
+ if (gameControl == null) {
+ System.exit(0);
+ } else {
+ view.getQuitWarningPanel().setMode(QuitMode.QUIT_PROCESS);
+ view.showQuitWarningPanel(true);
+ view.getQuitWarningPanel().getQuitEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ System.exit(0);
+ }
+ });
+ }
+ }
+ });
+
+ view.getQuitEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ if (gameControl == null) {
+ System.exit(0);
+ } else {
+ view.getQuitWarningPanel().setMode(QuitMode.QUIT_PROCESS);
+ view.showQuitWarningPanel(true);
+ view.getQuitWarningPanel().getQuitEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ System.exit(0);
+ }
+ });
+ }
+ }
+ });
+
+ view.getQuitWarningPanel().getCancelEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ view.showQuitWarningPanel(false);
}
});
@@ -53,7 +101,6 @@ public class ApplicationControl {
saveControl.getLoadEvent().add(
new IListener3<GameSettings, GameState, IRoundState>() {
-
@Override
public void handle(GameSettings settings,
GameState gameState, IRoundState roundState) {