summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/network
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-14 00:55:58 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-14 00:55:58 +0200
commiteee80d605c95bac3a2489f0dbadadd81ec1ad753 (patch)
tree4ffce7c17267fbc209ffc147fcd1799e8836f9b8 /src/jrummikub/control/network
parent8e0669a737af19cbcb1d6a1cf64ffcbc6acf2394 (diff)
downloadJRummikub-eee80d605c95bac3a2489f0dbadadd81ec1ad753.tar
JRummikub-eee80d605c95bac3a2489f0dbadadd81ec1ad753.zip
neue GameOfferControl
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@430 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/network')
-rw-r--r--src/jrummikub/control/network/GameOfferControl.java27
-rw-r--r--src/jrummikub/control/network/NetworkControl.java50
-rw-r--r--src/jrummikub/control/network/NetworkSettingsControl.java3
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());