From 531fe57b17394c931ee968a66104429e69cf60c6 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Fri, 27 May 2011 15:00:28 +0200 Subject: =?UTF-8?q?Test=20f=C3=BCr=20SettingsControl,=203=20neue=20Klassen?= =?UTF-8?q?,=20Mocks=20f=C3=BCr=20SettingPanel,=20lauter=20fixes?= 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@285 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/ApplicationControl.java | 42 +++++---------------- src/jrummikub/control/SettingsControl.java | 54 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 src/jrummikub/control/SettingsControl.java (limited to 'src/jrummikub/control') diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java index b3d432c..8e09853 100644 --- a/src/jrummikub/control/ApplicationControl.java +++ b/src/jrummikub/control/ApplicationControl.java @@ -15,7 +15,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; @@ -25,39 +25,17 @@ public class ApplicationControl { * Starts the application by showing the game settings dialog panel */ public void startApplication() { - view.getSettingsPanel().getSettingsChangeEvent() - .add(new IListener1() { - @Override - public void handle(GameSettings settings) { - checkSettings(settings); - } - }); - view.getSettingsPanel().getStartGameEvent() - .add(new IListener1() { - @Override - public void handle(GameSettings settings) { - startGame(settings); - } - }); + SettingsControl settingsControl = new SettingsControl(view); + settingsControl.getStartGameEvent().add(new IListener1() { - view.showSettingsPanel(true); - } - - private boolean checkSettings(GameSettings settings) { - // TODO Check - // TODO Show error + @Override + public void handle(GameSettings settings) { + GameControl gameControl = new GameControl(settings, view); + gameControl.startGame(); - return true; + } + }); + settingsControl.startSettings(); } - private void startGame(GameSettings settings) { - if (!checkSettings(settings)) { - return; - } - - view.showSettingsPanel(false); - - GameControl gameControl = new GameControl(settings, view); - gameControl.startGame(); - } } diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java new file mode 100644 index 0000000..7b96e77 --- /dev/null +++ b/src/jrummikub/control/SettingsControl.java @@ -0,0 +1,54 @@ +package jrummikub.control; + +import jrummikub.model.GameSettings; +import jrummikub.util.Event1; +import jrummikub.util.IEvent1; +import jrummikub.util.IListener1; +import jrummikub.view.IView; + +public class SettingsControl { + private IView view; + private Event1 startGameEvent = new Event1(); + + public SettingsControl(IView view) { + this.view = view; + } + + public IEvent1 getStartGameEvent() { + return startGameEvent; + } + + public void startSettings() { + /* + * view.getSettingsPanel().getSettingsChangeEvent() .add(new + * IListener1() { + * + * @Override public void handle(GameSettings settings) { + * checkSettings(settings); } }); + * view.getSettingsPanel().getStartGameEvent() .add(new + * IListener1() { + * + * @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); + + startGameEvent.emit(settings); + } +} -- cgit v1.2.3