mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
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:
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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?
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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. */
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user