summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/ApplicationControl.java10
-rw-r--r--src/jrummikub/control/network/ConnectionControl.java4
-rw-r--r--src/jrummikub/control/network/GameJoinControl.java19
-rw-r--r--src/jrummikub/control/network/GameOfferControl.java5
-rw-r--r--src/jrummikub/control/network/NetworkControl.java7
5 files changed, 28 insertions, 17 deletions
diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java
index 85fb663..3e429d2 100644
--- a/src/jrummikub/control/ApplicationControl.java
+++ b/src/jrummikub/control/ApplicationControl.java
@@ -70,14 +70,8 @@ public class ApplicationControl {
view.getNetworkGameEvent().add(new IListener() {
@Override
public void handle() {
- if (settingsControl != null) {
- settingsControl.abort();
- }
-
- if (gameControl != null) {
- gameControl.abortGame();
- }
-
+ abortControls();
+
loginControl = new LoginControl(view);
loginControl.getLoginEvent().add(new IListener1<LoginData>() {
@Override
diff --git a/src/jrummikub/control/network/ConnectionControl.java b/src/jrummikub/control/network/ConnectionControl.java
index 6dc1bb5..57e0cc6 100644
--- a/src/jrummikub/control/network/ConnectionControl.java
+++ b/src/jrummikub/control/network/ConnectionControl.java
@@ -125,8 +125,8 @@ class ConnectionControl {
void withdrawGame() {
offeredGame = null;
- currentGame = null;
final UUID uuid = currentGame.getGameID();
+ currentGame = null;
new Thread(new SendRunner() {
@Override
public Message send() {
@@ -137,7 +137,7 @@ class ConnectionControl {
return createMessage(extension);
}
- });
+ }).start();
}
GameData getCurrentGame() {
diff --git a/src/jrummikub/control/network/GameJoinControl.java b/src/jrummikub/control/network/GameJoinControl.java
index 1d29df4..d4a31d3 100644
--- a/src/jrummikub/control/network/GameJoinControl.java
+++ b/src/jrummikub/control/network/GameJoinControl.java
@@ -1,5 +1,7 @@
package jrummikub.control.network;
+import java.util.UUID;
+
import jrummikub.model.GameSettings;
import jrummikub.model.PlayerSettings;
import jrummikub.model.PlayerSettings.Type;
@@ -10,7 +12,6 @@ import jrummikub.view.ISettingsPanel.SettingsMode;
import jrummikub.view.IView;
public class GameJoinControl extends AbstractGameBeginControl {
- private Event backEvent = new Event();
public GameJoinControl(final ConnectionControl connectionControl,
final GameData gameData, final IView view) {
@@ -31,6 +32,16 @@ public class GameJoinControl extends AbstractGameBeginControl {
}
}
}));
+ connections.add(connectionControl.getGameWithdrawalEvent().add(
+ new IListener1<UUID>() {
+ @Override
+ public void handle(UUID uuid) {
+ if (uuid.equals(gameData.getGameID())) {
+ abort();
+ backEvent.emit();
+ }
+ }
+ }));
}
private void fixGameSettings(GameSettings settings) {
@@ -44,10 +55,6 @@ public class GameJoinControl extends AbstractGameBeginControl {
}
}
- public Event getBackEvent() {
- return backEvent;
- }
-
public void startGameJoin() {
view.showSettingsPanel(true);
}
@@ -55,10 +62,10 @@ public class GameJoinControl extends AbstractGameBeginControl {
/**
* Aborts joining and goes back to game list
*/
+ @Override
protected void goBack() {
abort();
connectionControl.leaveGame();
- view.showSettingsPanel(false);
backEvent.emit();
}
diff --git a/src/jrummikub/control/network/GameOfferControl.java b/src/jrummikub/control/network/GameOfferControl.java
index f09eb6e..7e3241f 100644
--- a/src/jrummikub/control/network/GameOfferControl.java
+++ b/src/jrummikub/control/network/GameOfferControl.java
@@ -64,7 +64,10 @@ public class GameOfferControl extends AbstractGameBeginControl {
}
+ @Override
protected void goBack() {
- // TODO
+ abort();
+ connectionControl.withdrawGame();
+ backEvent.emit();
}
}
diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java
index 0e8381b..0a7ea8d 100644
--- a/src/jrummikub/control/network/NetworkControl.java
+++ b/src/jrummikub/control/network/NetworkControl.java
@@ -243,6 +243,13 @@ public class NetworkControl {
return;
}
gameOfferControl = new GameOfferControl(connectionControl, settings, view);
+ gameOfferControl.getBackEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ gameOfferControl=null;
+ view.showGameListPanel(true);
+ }
+ });
gameOfferControl.startGameOffer();
}