From 8e0669a737af19cbcb1d6a1cf64ffcbc6acf2394 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Tue, 14 Jun 2011 00:11:34 +0200 Subject: =?UTF-8?q?Der=20zur=C3=BCck-Button=20tut=20was?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@429 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/SettingsControl.java | 10 ------ src/jrummikub/control/network/NetworkControl.java | 32 ++++++++++++++---- .../control/network/NetworkSettingsControl.java | 38 ++++++++++++++++++++++ 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() { + @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 offerGameEvent = new Event1(); + 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 getOfferGameEvent() { + return offerGameEvent; + } + + public Event getBackEvent() { + return backEvent; + } + + private void offerGame(){ + if (!checkSettings()) { + return; + } + abort(); + offerGameEvent.emit(settings); } @Override -- cgit v1.2.3