From dbd57d42188aa8499211f9a0461fd3511c80f578 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 11 Jun 2011 03:15:12 +0200 Subject: Add NetworkSettingsControl git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@409 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/network/NetworkControl.java | 11 +++++-- .../control/network/NetworkSettingsControl.java | 38 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/jrummikub/control/network/NetworkSettingsControl.java (limited to 'src/jrummikub/control/network') diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java index 013c866..b6dc27e 100644 --- a/src/jrummikub/control/network/NetworkControl.java +++ b/src/jrummikub/control/network/NetworkControl.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import jrummikub.model.GameSettings; import jrummikub.util.Connection; import jrummikub.util.Event; import jrummikub.util.IEvent; @@ -22,6 +23,8 @@ public class NetworkControl { private List connections = new ArrayList(); private Event stopNetworkEvent = new Event(); + private NetworkSettingsControl settingsControl; + private Map gameMap = new HashMap(); public NetworkControl(final LoginData loginData, final IView view) { @@ -38,7 +41,6 @@ public class NetworkControl { testData.setCurrentPlayerCount(2); testData.setMaxPlayerCount(4); - connectionControl.offerGame(testData); } })); @@ -94,8 +96,13 @@ public class NetworkControl { .add(new IListener() { @Override public void handle() { - // TODO Auto-generated method stub + if (settingsControl == null) { + view.showGameListPanel(false); + settingsControl = new NetworkSettingsControl(connectionControl, + view, new GameSettings()); + settingsControl.startSettings(); + } } })); diff --git a/src/jrummikub/control/network/NetworkSettingsControl.java b/src/jrummikub/control/network/NetworkSettingsControl.java new file mode 100644 index 0000000..d1a56e6 --- /dev/null +++ b/src/jrummikub/control/network/NetworkSettingsControl.java @@ -0,0 +1,38 @@ +package jrummikub.control.network; + +import java.util.UUID; + +import jrummikub.control.SettingsControl; +import jrummikub.model.GameSettings; +import jrummikub.view.IGameListPanel.GameData; +import jrummikub.view.IView; + +public class NetworkSettingsControl extends SettingsControl { + private GameData gameData = new GameData(UUID.randomUUID()); + private ConnectionControl connectionControl; + + public NetworkSettingsControl(ConnectionControl connectionControl, IView view, GameSettings settings) { + super(view, settings); + this.connectionControl = connectionControl; + } + + @Override + public void startSettings() { + super.startSettings(); + } + + @Override + protected void update() { + super.update(); + + gameData.setMaxPlayerCount(settings.getPlayerList().size()); + + connectionControl.offerGame(gameData); + } + + @Override + public void abort() { + super.abort(); + connectionControl.withdrawGame(gameData.getGameID()); + } +} -- cgit v1.2.3