summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control/network')
-rw-r--r--src/jrummikub/control/network/NetworkControl.java32
-rw-r--r--src/jrummikub/control/network/NetworkSettingsControl.java38
2 files changed, 63 insertions, 7 deletions
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