summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/ApplicationControl.java
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-08 16:29:13 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-08 16:29:13 +0200
commit3ff911ab930cb87f90307b9a82dafc4d0b5fe305 (patch)
tree5019f591188fd57d07c16a3e03820876f2e08f48 /src/jrummikub/control/ApplicationControl.java
parentce1b716e128bef53b140344bf1e58960fa32cba6 (diff)
downloadJRummikub-3ff911ab930cb87f90307b9a82dafc4d0b5fe305.tar
JRummikub-3ff911ab930cb87f90307b9a82dafc4d0b5fe305.zip
man kann speichern und laden, nur nicht während eines laufenden spiels laden
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@386 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/ApplicationControl.java')
-rw-r--r--src/jrummikub/control/ApplicationControl.java46
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();
+ }
+ });
+ }
}