summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/network
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-14 02:43:55 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-14 02:43:55 +0200
commit4879b7b93eaff1f80056d78e19271d6418ec6534 (patch)
treeafcc617cdefeff9d2fe264d377a4412660b23e3d /src/jrummikub/control/network
parentf6b1c638a17a9e3c9c1dcbac0fd748a3f13d70f3 (diff)
downloadJRummikub-4879b7b93eaff1f80056d78e19271d6418ec6534.tar
JRummikub-4879b7b93eaff1f80056d78e19271d6418ec6534.zip
Display open games correctly
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@433 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/network')
-rw-r--r--src/jrummikub/control/network/GameOfferControl.java15
-rw-r--r--src/jrummikub/control/network/NetworkControl.java34
-rw-r--r--src/jrummikub/control/network/NetworkSettingsControl.java6
3 files changed, 36 insertions, 19 deletions
diff --git a/src/jrummikub/control/network/GameOfferControl.java b/src/jrummikub/control/network/GameOfferControl.java
index 8d3e8c8..0db5110 100644
--- a/src/jrummikub/control/network/GameOfferControl.java
+++ b/src/jrummikub/control/network/GameOfferControl.java
@@ -1,10 +1,14 @@
package jrummikub.control.network;
+import java.util.UUID;
+
import jrummikub.model.GameSettings;
+import jrummikub.util.GameData;
import jrummikub.view.ISettingsPanel.SettingsMode;
import jrummikub.view.IView;
public class GameOfferControl {
+ private GameData gameData;
private ConnectionControl connectionControl;
private GameSettings settings;
private IView view;
@@ -14,15 +18,22 @@ public class GameOfferControl {
this.connectionControl = connectionControl;
this.settings = settings;
this.view = view;
-
+
+ gameData = new GameData(UUID.randomUUID(), settings);
+
view.getSettingsPanel().setSettingsMode(SettingsMode.NETWORK_OFFER);
view.getSettingsPanel().enableAddPlayerButton(false);
view.getSettingsPanel().setGameSettings(settings);
}
public void startGameOffer() {
+ connectionControl.offerGame(gameData);
+
view.showSettingsPanel(true);
-
+
}
+ public void abort() {
+ connectionControl.withdrawGame(gameData.getGameID());
+ }
}
diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java
index e09cdc0..7435839 100644
--- a/src/jrummikub/control/network/NetworkControl.java
+++ b/src/jrummikub/control/network/NetworkControl.java
@@ -34,9 +34,9 @@ public class NetworkControl {
* Creates a new network control
*
* @param loginData
- * user's login data
+ * user's login data
* @param view
- * for events and handlers
+ * for events and handlers
*/
public NetworkControl(final LoginData loginData, final IView view) {
this.view = view;
@@ -75,21 +75,19 @@ public class NetworkControl {
* Adds the listeners for connection control events
*
* @param loginData
- * player's login data
+ * player's login data
* @param view
- * view for events
+ * view for events
*/
public void addConnectionControlListeners(final LoginData loginData,
final IView view) {
- connections.add(connectionControl.getConnectedEvent().add(
- new IListener() {
- @Override
- public void handle() {
- view.getGameListPanel().setChannelName(
- loginData.getChannelName());
- view.showGameListPanel(true);
- }
- }));
+ connections.add(connectionControl.getConnectedEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ view.getGameListPanel().setChannelName(loginData.getChannelName());
+ view.showGameListPanel(true);
+ }
+ }));
connections.add(connectionControl.getConnectionFailedEvent().add(
new IListener() {
@@ -144,8 +142,16 @@ public class NetworkControl {
for (Connection c : connections) {
c.remove();
}
- connectionControl.disconnect();
view.showGameListPanel(false);
+
+ if (settingsControl != null) {
+ settingsControl.abort();
+ }
+ if (gameOfferControl != null) {
+ gameOfferControl.abort();
+ }
+
+ connectionControl.disconnect();
}
/**
diff --git a/src/jrummikub/control/network/NetworkSettingsControl.java b/src/jrummikub/control/network/NetworkSettingsControl.java
index ca8c74b..447bf08 100644
--- a/src/jrummikub/control/network/NetworkSettingsControl.java
+++ b/src/jrummikub/control/network/NetworkSettingsControl.java
@@ -99,7 +99,7 @@ public class NetworkSettingsControl extends AbstractSettingsControl {
choices.add(Collections.singletonList(Type.HUMAN));
enableRemoveButtons.add(false);
} else {
- choices.add(Arrays.asList(Type.NETWORK, Type.COMPUTER));
+ choices.add(Arrays.asList(Type.VACANT, Type.COMPUTER));
enableRemoveButtons.add(settings.getPlayerList().size() > 2);
}
@@ -119,7 +119,7 @@ public class NetworkSettingsControl extends AbstractSettingsControl {
settings.getPlayerList().get(i).setType(type);
- if (type == Type.NETWORK) {
+ if (type == Type.VACANT) {
settings.getPlayerList().get(i).setName("Offen");
} else if (oldType != Type.COMPUTER && type == Type.COMPUTER) {
// Find unused player name
@@ -158,7 +158,7 @@ public class NetworkSettingsControl extends AbstractSettingsControl {
PlayerSettings playerSettings = new PlayerSettings("Offen",
findUnusedColor());
- playerSettings.setType(Type.NETWORK);
+ playerSettings.setType(Type.VACANT);
settings.getPlayerList().add(playerSettings);
update();