diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-26 16:12:44 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-26 16:12:44 +0200 |
commit | df79c78dec6d9db0c60709fcb6728b5fab170379 (patch) | |
tree | c4f66bf52c89d11a05371cd48698c3ae2718a844 /src/jrummikub/control | |
parent | 3d74d1197419cde195be31de2b2d798abb171291 (diff) | |
download | JRummikub-df79c78dec6d9db0c60709fcb6728b5fab170379.tar JRummikub-df79c78dec6d9db0c60709fcb6728b5fab170379.zip |
Add application control, use game settings from settings panel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@284 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r-- | src/jrummikub/control/ApplicationControl.java | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java new file mode 100644 index 0000000..b3d432c --- /dev/null +++ b/src/jrummikub/control/ApplicationControl.java @@ -0,0 +1,63 @@ +package jrummikub.control; + +import jrummikub.model.GameSettings; +import jrummikub.util.IListener1; +import jrummikub.view.IView; + +/** + * The application control controls the settings for a new games and create the + * game control + */ +public class ApplicationControl { + private IView view; + + /** + * Creates a new application control + * + * @param view + * the view to use + */ + public ApplicationControl(IView view) { + this.view = view; + } + + /** + * Starts the application by showing the game settings dialog panel + */ + public void startApplication() { + view.getSettingsPanel().getSettingsChangeEvent() + .add(new IListener1<GameSettings>() { + @Override + public void handle(GameSettings settings) { + checkSettings(settings); + } + }); + view.getSettingsPanel().getStartGameEvent() + .add(new IListener1<GameSettings>() { + @Override + public void handle(GameSettings settings) { + startGame(settings); + } + }); + + view.showSettingsPanel(true); + } + + private boolean checkSettings(GameSettings settings) { + // TODO Check + // TODO Show error + + return true; + } + + private void startGame(GameSettings settings) { + if (!checkSettings(settings)) { + return; + } + + view.showSettingsPanel(false); + + GameControl gameControl = new GameControl(settings, view); + gameControl.startGame(); + } +} |