diff options
Diffstat (limited to 'src/jrummikub/control/network')
-rw-r--r-- | src/jrummikub/control/network/GameOfferControl.java | 27 | ||||
-rw-r--r-- | src/jrummikub/control/network/NetworkControl.java | 50 | ||||
-rw-r--r-- | src/jrummikub/control/network/NetworkSettingsControl.java | 3 |
3 files changed, 59 insertions, 21 deletions
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<UUID, GameData> gameMap = new HashMap<UUID, GameData>(); @@ -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<GameSettings>() { - @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<GameSettings>() { + @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.<Boolean> emptyList()); |