added a method to launch game by a single call to FControl (removed duplicate code from controllers specific to game modes)

This commit is contained in:
Maxmtg
2013-07-20 20:37:25 +00:00
parent ab9092d53e
commit b4f6dbdeb6
13 changed files with 20 additions and 27 deletions

View File

@@ -38,6 +38,7 @@ import forge.Singletons;
import forge.control.KeyboardShortcuts.Shortcut;
import forge.game.Game;
import forge.game.GameType;
import forge.game.Match;
import forge.game.player.LobbyPlayer;
import forge.game.player.Player;
import forge.gui.GuiDialog;
@@ -401,9 +402,14 @@ public enum FControl {
}
public final void startGameWithUi(Match match) {
attachToGame(match.createGame());
match.startGame();
}
private final FControlGameEventHandler fcVisitor = new FControlGameEventHandler(this);
private final FControlGamePlayback playbackControl = new FControlGamePlayback(this);
public void attachToGame(Game game0) {
private void attachToGame(Game game0) {
// TODO: Detach from other game we might be looking at

View File

@@ -169,8 +169,7 @@ public class GauntletMini {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
SOverlayUtils.hideOverlay();
}
});

View File

@@ -127,8 +127,7 @@ public enum CSubmenuGauntletContests implements ICDoc {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
SOverlayUtils.hideOverlay();
}
});

View File

@@ -118,8 +118,7 @@ public enum CSubmenuGauntletLoad implements ICDoc {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
SOverlayUtils.hideOverlay();
}
});

View File

@@ -152,8 +152,7 @@ public enum CSubmenuGauntletQuick implements ICDoc {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
SOverlayUtils.hideOverlay();
}
});

View File

@@ -444,8 +444,7 @@ public class SSubmenuQuestUtil {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
// no overlays here?
}
});

View File

@@ -127,8 +127,7 @@ public enum CSubmenuConstructed implements ICDoc {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
SOverlayUtils.hideOverlay();
}
});

View File

@@ -140,8 +140,7 @@ public enum CSubmenuDraft implements ICDoc {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
SOverlayUtils.hideOverlay();
}
});

View File

@@ -238,8 +238,7 @@ public enum CSubmenuArchenemy implements ICDoc {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
SOverlayUtils.hideOverlay();
}
});

View File

@@ -219,8 +219,7 @@ public enum CSubmenuPlanechase implements ICDoc {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
SOverlayUtils.hideOverlay();
}
});

View File

@@ -181,8 +181,7 @@ public enum CSubmenuVanguard implements ICDoc {
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
SOverlayUtils.hideOverlay();
}
});

View File

@@ -78,8 +78,7 @@ public class ControlWinLose {
executeAnte();
}
Singletons.getControl().attachToGame(match.createGame());
match.startGame();
Singletons.getControl().startGameWithUi(match);
}
/** Action performed when "restart" button is pressed in default win/lose UI. */
@@ -87,8 +86,7 @@ public class ControlWinLose {
SOverlayUtils.hideOverlay();
saveOptions();
match.clearGamesPlayed();
Singletons.getControl().attachToGame(match.createGame());
match.startGame();
Singletons.getControl().startGameWithUi(match);
}
/** Action performed when "quit" button is pressed in default win/lose UI. */

View File

@@ -206,8 +206,7 @@ public class GauntletWinLose extends ControlWinLose {
SOverlayUtils.hideOverlay();
saveOptions();
Singletons.getControl().attachToGame(mc.createGame());
mc.startGame();
Singletons.getControl().startGameWithUi(mc);
} else {
super.actionOnContinue();
}