From eee80d605c95bac3a2489f0dbadadd81ec1ad753 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Tue, 14 Jun 2011 00:55:58 +0200 Subject: neue GameOfferControl git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@430 72836036-5685-4462-b002-a69064685172 --- .../control/network/GameOfferControl.java | 27 ++++++++++++ src/jrummikub/control/network/NetworkControl.java | 50 +++++++++++++--------- .../control/network/NetworkSettingsControl.java | 3 +- 3 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 src/jrummikub/control/network/GameOfferControl.java (limited to 'src/jrummikub/control/network') diff --git a/src/jrummikub/control/network/GameOfferControl.java b/src/jrummikub/control/network/GameOfferControl.java new file mode 100644 index 0000000..0e90078 --- /dev/null +++ b/src/jrummikub/control/network/GameOfferControl.java @@ -0,0 +1,27 @@ +package jrummikub.control.network; + +import jrummikub.model.GameSettings; +import jrummikub.view.ISettingsPanel.SettingsMode; +import jrummikub.view.IView; + +public class GameOfferControl { + private ConnectionControl connectionControl; + private GameSettings settings; + private IView view; + + public GameOfferControl(ConnectionControl connectionControl, + GameSettings settings, IView view) { + this.connectionControl = connectionControl; + this.settings = settings; + this.view = view; + + view.getSettingsPanel().setSettingsMode(SettingsMode.NETWORK_OFFER); + view.getSettingsPanel().setGameSettings(settings); + } + + public void startGameOffer() { + view.showSettingsPanel(true); + + } + +} diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java index bb60556..e09cdc0 100644 --- a/src/jrummikub/control/network/NetworkControl.java +++ b/src/jrummikub/control/network/NetworkControl.java @@ -26,6 +26,7 @@ public class NetworkControl { private Event stopNetworkEvent = new Event(); private NetworkSettingsControl settingsControl; + private GameOfferControl gameOfferControl; private Map gameMap = new HashMap(); @@ -157,27 +158,36 @@ public class NetworkControl { } private void createSettingsControl() { - if (settingsControl == null) { - view.showGameListPanel(false); - - settingsControl = new NetworkSettingsControl( - connectionControl.getNickname(), view, new GameSettings()); - settingsControl.getOfferGameEvent().add(new IListener1() { - @Override - public void handle(GameSettings value) { - // TODO Auto-generated method stub - - } - }); - settingsControl.getBackEvent().add(new IListener() { - @Override - public void handle() { - settingsControl=null; - view.showGameListPanel(true); - } - }); - settingsControl.startSettings(); + if (settingsControl != null) { + return; } + view.showGameListPanel(false); + + settingsControl = new NetworkSettingsControl( + connectionControl.getNickname(), view, new GameSettings()); + settingsControl.getOfferGameEvent().add(new IListener1() { + @Override + public void handle(GameSettings settings) { + settingsControl = null; + createGameOfferControl(settings); + } + }); + settingsControl.getBackEvent().add(new IListener() { + @Override + public void handle() { + settingsControl = null; + view.showGameListPanel(true); + } + }); + settingsControl.startSettings(); + } + + private void createGameOfferControl(GameSettings settings) { + if (gameOfferControl != null) { + return; + } + gameOfferControl = new GameOfferControl(connectionControl, settings, view); + gameOfferControl.startGameOffer(); } } diff --git a/src/jrummikub/control/network/NetworkSettingsControl.java b/src/jrummikub/control/network/NetworkSettingsControl.java index 9c989c6..ca8c74b 100644 --- a/src/jrummikub/control/network/NetworkSettingsControl.java +++ b/src/jrummikub/control/network/NetworkSettingsControl.java @@ -13,6 +13,7 @@ import jrummikub.util.Event; import jrummikub.util.Event1; import jrummikub.util.IListener; import jrummikub.view.ISettingsPanel; +import jrummikub.view.ISettingsPanel.SettingsMode; import jrummikub.view.IView; /** @@ -38,7 +39,7 @@ public class NetworkSettingsControl extends AbstractSettingsControl { super(view, settings); this.nickname = nickname; - view.getSettingsPanel().enableNetworkMode(true); + view.getSettingsPanel().setSettingsMode(SettingsMode.NETWORK_SETUP); view.getSettingsPanel().setPlayerNamesEditable( Collections. emptyList()); -- cgit v1.2.3