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.control.KeyboardShortcuts.Shortcut;
import forge.game.Game; import forge.game.Game;
import forge.game.GameType; import forge.game.GameType;
import forge.game.Match;
import forge.game.player.LobbyPlayer; import forge.game.player.LobbyPlayer;
import forge.game.player.Player; import forge.game.player.Player;
import forge.gui.GuiDialog; 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 FControlGameEventHandler fcVisitor = new FControlGameEventHandler(this);
private final FControlGamePlayback playbackControl = new FControlGamePlayback(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 // TODO: Detach from other game we might be looking at

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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