diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-19 22:27:21 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-19 22:27:21 +0200 |
commit | fc6d3d46db69c639557462a49ccb16463df91617 (patch) | |
tree | 3d1021e1e806dfb2e9649d689d0fd7eaa6984dde /src/jrummikub/control | |
parent | 45656861ab2e618938764f0c46f830184099a71d (diff) | |
download | JRummikub-fc6d3d46db69c639557462a49ccb16463df91617.tar JRummikub-fc6d3d46db69c639557462a49ccb16463df91617.zip |
quit warnings funktionieren
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@492 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r-- | src/jrummikub/control/ApplicationControl.java | 55 | ||||
-rw-r--r-- | src/jrummikub/control/SaveControl.java | 26 |
2 files changed, 74 insertions, 7 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) { diff --git a/src/jrummikub/control/SaveControl.java b/src/jrummikub/control/SaveControl.java index 86aaac6..31e7a12 100644 --- a/src/jrummikub/control/SaveControl.java +++ b/src/jrummikub/control/SaveControl.java @@ -9,10 +9,13 @@ import java.io.ObjectOutputStream; import jrummikub.model.GameSettings; import jrummikub.model.GameState; import jrummikub.model.IRoundState; +import jrummikub.util.Connection; import jrummikub.util.Event; import jrummikub.util.Event3; import jrummikub.util.IEvent3; +import jrummikub.util.IListener; import jrummikub.util.IListener1; +import jrummikub.view.IQuitWarningPanel.QuitMode; import jrummikub.view.IView; /** @@ -24,6 +27,7 @@ public class SaveControl { private IRoundState roundState; private Event3<GameSettings, GameState, IRoundState> loadEvent = new Event3<GameSettings, GameState, IRoundState>(); private Event loadErrorEvent = new Event(); + private Connection tempConnection; /** * Creates a new SaveControl @@ -31,7 +35,7 @@ public class SaveControl { * @param view * the view to use */ - public SaveControl(IView view) { + public SaveControl(final IView view) { view.getSaveEvent().add(new IListener1<File>() { @Override public void handle(File file) { @@ -39,9 +43,25 @@ public class SaveControl { } }); - view.getLoadEvent().add(new IListener1<File>() { + view.getLoadEvent().add(new IListener() { @Override - public void handle(File file) { + public void handle() { + view.getQuitWarningPanel().setMode(QuitMode.QUIT_GAME); + view.showQuitWarningPanel(true); + + tempConnection=view.getQuitWarningPanel().getQuitEvent().add(new IListener() { + @Override + public void handle() { + view.showQuitWarningPanel(false); + view.load(); + tempConnection.remove(); + } + }); + } + }); + view.getLoadFileEvent().add(new IListener1<File>() { + @Override + public void handle(final File file) { load(file); } }); |