Finished network game setup (without starting)
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@456 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
626f4bd9ab
commit
caa49d174b
8 changed files with 31 additions and 20 deletions
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,10 @@ public class GameOfferControl extends AbstractGameBeginControl {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void goBack() {
|
||||
// TODO
|
||||
abort();
|
||||
connectionControl.withdrawGame();
|
||||
backEvent.emit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public class Event1<T> implements IEvent1<T> {
|
|||
* the event parameter
|
||||
*/
|
||||
public void emit(T value) {
|
||||
for (IListener1<T> listener : listeners) {
|
||||
for (IListener1<T> listener : new HashSet<IListener1<T>>(listeners)) {
|
||||
listener.handle(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class Event2<T1, T2> implements IEvent2<T1, T2> {
|
|||
* the second event parameter
|
||||
*/
|
||||
public void emit(T1 value1, T2 value2) {
|
||||
for (IListener2<T1, T2> listener : listeners) {
|
||||
for (IListener2<T1, T2> listener : new HashSet<IListener2<T1, T2>>(listeners)) {
|
||||
listener.handle(value1, value2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class Event3<T1, T2, T3> implements IEvent3<T1, T2, T3> {
|
|||
* the third event parameter
|
||||
*/
|
||||
public void emit(T1 value1, T2 value2, T3 value3) {
|
||||
for (IListener3<T1, T2, T3> listener : listeners) {
|
||||
for (IListener3<T1, T2, T3> listener : new HashSet<IListener3<T1, T2, T3>>(listeners)) {
|
||||
listener.handle(value1, value2, value3);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue