Der zurück-Button tut was
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@429 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
fc07d3bca6
commit
8e0669a737
3 changed files with 63 additions and 17 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue