From 3ff911ab930cb87f90307b9a82dafc4d0b5fe305 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Wed, 8 Jun 2011 16:29:13 +0200 Subject: =?UTF-8?q?man=20kann=20speichern=20und=20laden,=20nur=20nicht=20w?= =?UTF-8?q?=C3=A4hrend=20eines=20laufenden=20spiels=20laden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@386 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/ApplicationControl.java | 46 +++++++++++++++++++++------ 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'src/jrummikub/control/ApplicationControl.java') diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java index a0bdf35..068b898 100644 --- a/src/jrummikub/control/ApplicationControl.java +++ b/src/jrummikub/control/ApplicationControl.java @@ -1,8 +1,11 @@ package jrummikub.control; import jrummikub.model.GameSettings; +import jrummikub.model.GameState; +import jrummikub.model.IRoundState; import jrummikub.util.IListener; import jrummikub.util.IListener1; +import jrummikub.util.IListener3; import jrummikub.view.IView; import jrummikub.view.IView.BottomPanelType; @@ -18,7 +21,7 @@ public class ApplicationControl { * Creates a new application control * * @param view - * the view to use + * the view to use */ public ApplicationControl(IView view) { this.view = view; @@ -38,25 +41,48 @@ public class ApplicationControl { public void startApplication() { view.showScorePanel(false); view.setBottomPanel(BottomPanelType.START_GAME_PANEL); - SettingsControl settingsControl = new SettingsControl(view, + saveControl.setGameSettings(null); + saveControl.setGameState(null); + final SettingsControl settingsControl = new SettingsControl(view, new GameSettings()); + saveControl.getLoadEvent().add( + new IListener3() { + + @Override + public void handle(GameSettings settings, + GameState gameState, IRoundState roundState) { + settingsControl.abort(); + // TODO alles ordentlich beenden (controls) + GameControl gameControl = new GameControl(settings, + saveControl, view); + addGameControlListeners(gameControl); + gameControl.continueGame(gameState, roundState); + + } + }); + settingsControl.getStartGameEvent().add(new IListener1() { @Override public void handle(GameSettings settings) { saveControl.setGameSettings(settings); - GameControl gameControl = new GameControl(settings, saveControl, view); - gameControl.getEndOfGameEvent().add(new IListener() { - @Override - public void handle() { - startApplication(); - } - }); - gameControl.startGame(); + GameControl gameControl = new GameControl(settings, + saveControl, view); + addGameControlListeners(gameControl); + gameControl.startGame(); } }); settingsControl.startSettings(); } + + private void addGameControlListeners(GameControl gameControl) { + gameControl.getEndOfGameEvent().add(new IListener() { + @Override + public void handle() { + startApplication(); + } + }); + } } -- cgit v1.2.3