From fc6d3d46db69c639557462a49ccb16463df91617 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Sun, 19 Jun 2011 22:27:21 +0200 Subject: quit warnings funktionieren git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@492 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/ApplicationControl.java | 55 +++++++++++++++++++++++++-- src/jrummikub/control/SaveControl.java | 26 +++++++++++-- 2 files changed, 74 insertions(+), 7 deletions(-) (limited to 'src/jrummikub/control') 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() { - @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 loadEvent = new Event3(); 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() { @Override public void handle(File file) { @@ -39,9 +43,25 @@ public class SaveControl { } }); - view.getLoadEvent().add(new IListener1() { + 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() { + @Override + public void handle(final File file) { load(file); } }); -- cgit v1.2.3