summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-14 00:11:34 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-14 00:11:34 +0200
commit8e0669a737af19cbcb1d6a1cf64ffcbc6acf2394 (patch)
tree6df76c316be40ecc9e81f8c4f964340fca353e51 /src
parentfc07d3bca67099d20e705b6aa7541e0e16646fdd (diff)
downloadJRummikub-8e0669a737af19cbcb1d6a1cf64ffcbc6acf2394.tar
JRummikub-8e0669a737af19cbcb1d6a1cf64ffcbc6acf2394.zip
Der zurück-Button tut was
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@429 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src')
-rw-r--r--src/jrummikub/control/SettingsControl.java10
-rw-r--r--src/jrummikub/control/network/NetworkControl.java32
-rw-r--r--src/jrummikub/control/network/NetworkSettingsControl.java38
3 files changed, 63 insertions, 17 deletions
diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java
index 6d736a6..a3fad13 100644
--- a/src/jrummikub/control/SettingsControl.java
+++ b/src/jrummikub/control/SettingsControl.java
@@ -121,14 +121,4 @@ public class SettingsControl extends AbstractSettingsControl {
abort();
startGameEvent.emit(settings);
}
-
- /**
- * Abort settings control once settings are set
- */
- public void abort() {
- view.showSettingsPanel(false);
- for (Connection c : connections) {
- c.remove();
- }
- }
}
diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java
index 4f4dad6..bb60556 100644
--- a/src/jrummikub/control/network/NetworkControl.java
+++ b/src/jrummikub/control/network/NetworkControl.java
@@ -56,13 +56,7 @@ public class NetworkControl {
.add(new IListener() {
@Override
public void handle() {
- if (settingsControl == null) {
- view.showGameListPanel(false);
-
- settingsControl = new NetworkSettingsControl(
- connectionControl.getNickname(), view, new GameSettings());
- settingsControl.startSettings();
- }
+ createSettingsControl();
}
}));
@@ -162,4 +156,28 @@ public class NetworkControl {
return stopNetworkEvent;
}
+ 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();
+ }
+ }
+
}
diff --git a/src/jrummikub/control/network/NetworkSettingsControl.java b/src/jrummikub/control/network/NetworkSettingsControl.java
index 8afe49e..9c989c6 100644
--- a/src/jrummikub/control/network/NetworkSettingsControl.java
+++ b/src/jrummikub/control/network/NetworkSettingsControl.java
@@ -9,6 +9,9 @@ import jrummikub.control.AbstractSettingsControl;
import jrummikub.model.GameSettings;
import jrummikub.model.PlayerSettings;
import jrummikub.model.PlayerSettings.Type;
+import jrummikub.util.Event;
+import jrummikub.util.Event1;
+import jrummikub.util.IListener;
import jrummikub.view.ISettingsPanel;
import jrummikub.view.IView;
@@ -17,6 +20,8 @@ import jrummikub.view.IView;
*/
public class NetworkSettingsControl extends AbstractSettingsControl {
private String nickname;
+ private Event1<GameSettings> offerGameEvent = new Event1<GameSettings>();
+ private Event backEvent = new Event();
/**
* Creates a new network settings control
@@ -41,6 +46,39 @@ public class NetworkSettingsControl extends AbstractSettingsControl {
addPlayer();
addListeners();
+
+ connections.add(view.getSettingsPanel().getOfferGameEvent()
+ .add(new IListener() {
+ @Override
+ public void handle() {
+ offerGame();
+ }
+ }));
+
+ connections.add(view.getSettingsPanel().getBackEvent()
+ .add(new IListener() {
+ @Override
+ public void handle() {
+ abort();
+ backEvent.emit();
+ }
+ }));
+ }
+
+ public Event1<GameSettings> getOfferGameEvent() {
+ return offerGameEvent;
+ }
+
+ public Event getBackEvent() {
+ return backEvent;
+ }
+
+ private void offerGame(){
+ if (!checkSettings()) {
+ return;
+ }
+ abort();
+ offerGameEvent.emit(settings);
}
@Override