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,13 +70,7 @@ public class ApplicationControl {
|
||||||
view.getNetworkGameEvent().add(new IListener() {
|
view.getNetworkGameEvent().add(new IListener() {
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
if (settingsControl != null) {
|
abortControls();
|
||||||
settingsControl.abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gameControl != null) {
|
|
||||||
gameControl.abortGame();
|
|
||||||
}
|
|
||||||
|
|
||||||
loginControl = new LoginControl(view);
|
loginControl = new LoginControl(view);
|
||||||
loginControl.getLoginEvent().add(new IListener1<LoginData>() {
|
loginControl.getLoginEvent().add(new IListener1<LoginData>() {
|
||||||
|
|
|
@ -125,8 +125,8 @@ class ConnectionControl {
|
||||||
|
|
||||||
void withdrawGame() {
|
void withdrawGame() {
|
||||||
offeredGame = null;
|
offeredGame = null;
|
||||||
currentGame = null;
|
|
||||||
final UUID uuid = currentGame.getGameID();
|
final UUID uuid = currentGame.getGameID();
|
||||||
|
currentGame = null;
|
||||||
new Thread(new SendRunner() {
|
new Thread(new SendRunner() {
|
||||||
@Override
|
@Override
|
||||||
public Message send() {
|
public Message send() {
|
||||||
|
@ -137,7 +137,7 @@ class ConnectionControl {
|
||||||
|
|
||||||
return createMessage(extension);
|
return createMessage(extension);
|
||||||
}
|
}
|
||||||
});
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameData getCurrentGame() {
|
GameData getCurrentGame() {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package jrummikub.control.network;
|
package jrummikub.control.network;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import jrummikub.model.GameSettings;
|
import jrummikub.model.GameSettings;
|
||||||
import jrummikub.model.PlayerSettings;
|
import jrummikub.model.PlayerSettings;
|
||||||
import jrummikub.model.PlayerSettings.Type;
|
import jrummikub.model.PlayerSettings.Type;
|
||||||
|
@ -10,7 +12,6 @@ import jrummikub.view.ISettingsPanel.SettingsMode;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
|
||||||
public class GameJoinControl extends AbstractGameBeginControl {
|
public class GameJoinControl extends AbstractGameBeginControl {
|
||||||
private Event backEvent = new Event();
|
|
||||||
|
|
||||||
public GameJoinControl(final ConnectionControl connectionControl,
|
public GameJoinControl(final ConnectionControl connectionControl,
|
||||||
final GameData gameData, final IView view) {
|
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) {
|
private void fixGameSettings(GameSettings settings) {
|
||||||
|
@ -44,10 +55,6 @@ public class GameJoinControl extends AbstractGameBeginControl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Event getBackEvent() {
|
|
||||||
return backEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startGameJoin() {
|
public void startGameJoin() {
|
||||||
view.showSettingsPanel(true);
|
view.showSettingsPanel(true);
|
||||||
}
|
}
|
||||||
|
@ -55,10 +62,10 @@ public class GameJoinControl extends AbstractGameBeginControl {
|
||||||
/**
|
/**
|
||||||
* Aborts joining and goes back to game list
|
* Aborts joining and goes back to game list
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void goBack() {
|
protected void goBack() {
|
||||||
abort();
|
abort();
|
||||||
connectionControl.leaveGame();
|
connectionControl.leaveGame();
|
||||||
view.showSettingsPanel(false);
|
|
||||||
backEvent.emit();
|
backEvent.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,10 @@ public class GameOfferControl extends AbstractGameBeginControl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void goBack() {
|
protected void goBack() {
|
||||||
// TODO
|
abort();
|
||||||
|
connectionControl.withdrawGame();
|
||||||
|
backEvent.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,6 +243,13 @@ public class NetworkControl {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gameOfferControl = new GameOfferControl(connectionControl, settings, view);
|
gameOfferControl = new GameOfferControl(connectionControl, settings, view);
|
||||||
|
gameOfferControl.getBackEvent().add(new IListener() {
|
||||||
|
@Override
|
||||||
|
public void handle() {
|
||||||
|
gameOfferControl=null;
|
||||||
|
view.showGameListPanel(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
gameOfferControl.startGameOffer();
|
gameOfferControl.startGameOffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class Event1<T> implements IEvent1<T> {
|
||||||
* the event parameter
|
* the event parameter
|
||||||
*/
|
*/
|
||||||
public void emit(T value) {
|
public void emit(T value) {
|
||||||
for (IListener1<T> listener : listeners) {
|
for (IListener1<T> listener : new HashSet<IListener1<T>>(listeners)) {
|
||||||
listener.handle(value);
|
listener.handle(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class Event2<T1, T2> implements IEvent2<T1, T2> {
|
||||||
* the second event parameter
|
* the second event parameter
|
||||||
*/
|
*/
|
||||||
public void emit(T1 value1, T2 value2) {
|
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);
|
listener.handle(value1, value2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class Event3<T1, T2, T3> implements IEvent3<T1, T2, T3> {
|
||||||
* the third event parameter
|
* the third event parameter
|
||||||
*/
|
*/
|
||||||
public void emit(T1 value1, T2 value2, T3 value3) {
|
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);
|
listener.handle(value1, value2, value3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue