diff options
Diffstat (limited to 'src/jrummikub/control/ApplicationControl.java')
-rw-r--r-- | src/jrummikub/control/ApplicationControl.java | 46 |
1 files changed, 36 insertions, 10 deletions
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<GameSettings, GameState, IRoundState>() { + + @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<GameSettings>() { @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(); + } + }); + } } |