mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Some more minor fixes for GUI refactoring (restores full playback control).
This commit is contained in:
@@ -30,9 +30,9 @@ import forge.control.FControl;
|
||||
import forge.deck.CardPool;
|
||||
import forge.error.BugReportDialog;
|
||||
import forge.events.UiEvent;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.GameType;
|
||||
import forge.game.Match;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
@@ -153,8 +153,8 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public <T> T showInputDialog(String message, String title, FSkinProp icon, T initialInput, T[] inputOptions) {
|
||||
if (initialInput instanceof Card || (inputOptions != null && inputOptions.length > 0 && inputOptions[0] instanceof Card)) {
|
||||
System.err.println("Warning: Cards passed to GUI! Printing stack trace.");
|
||||
if (initialInput instanceof GameObject || (inputOptions != null && inputOptions.length > 0 && inputOptions[0] instanceof GameObject)) {
|
||||
System.err.println("Warning: GameObject passed to GUI! Printing stack trace.");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
return FOptionPane.showInputDialog(message, title, icon == null ? null : FSkin.getImage(icon), initialInput, inputOptions);
|
||||
@@ -162,8 +162,8 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices, final T selected, final Function<T, String> display) {
|
||||
if ((choices != null && !choices.isEmpty() && choices.iterator().next() instanceof Card) || selected instanceof Card) {
|
||||
System.err.println("Warning: Cards passed to GUI! Printing stack trace.");
|
||||
if ((choices != null && !choices.isEmpty() && choices.iterator().next() instanceof GameObject) || selected instanceof GameObject) {
|
||||
System.err.println("Warning: GameObject passed to GUI! Printing stack trace.");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
return GuiChoose.getChoices(message, min, max, choices, selected, display);
|
||||
@@ -172,9 +172,9 @@ public class GuiDesktop implements IGuiBase {
|
||||
@Override
|
||||
public <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices, final CardView referenceCard, final boolean sideboardingMode) {
|
||||
if ((sourceChoices != null && !sourceChoices.isEmpty() && sourceChoices.iterator().next() instanceof Card)
|
||||
|| (destChoices != null && !destChoices.isEmpty() && destChoices.iterator().next() instanceof Card)) {
|
||||
System.err.println("Warning: Cards passed to GUI! Printing stack trace.");
|
||||
if ((sourceChoices != null && !sourceChoices.isEmpty() && sourceChoices.iterator().next() instanceof GameObject)
|
||||
|| (destChoices != null && !destChoices.isEmpty() && destChoices.iterator().next() instanceof GameObject)) {
|
||||
System.err.println("Warning: GameObject passed to GUI! Printing stack trace.");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
return GuiChoose.order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, referenceCard, sideboardingMode);
|
||||
|
||||
@@ -511,7 +511,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
}
|
||||
|
||||
private FControlGameEventHandler fcVisitor;
|
||||
private FControlGamePlayback playbackControl;// = new FControlGamePlayback();
|
||||
private FControlGamePlayback playbackControl;
|
||||
private void attachToGame(final IGameView game0) {
|
||||
if (game0.getGameType().equals(GameType.Quest)) {
|
||||
QuestController qc = FModel.getQuest();
|
||||
@@ -696,22 +696,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
final ForgePreferences prefs = FModel.getPreferences();
|
||||
final List<VField> fieldViews = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
||||
|
||||
// AI field is at index [0]
|
||||
PhaseIndicator fvAi = fieldViews.get(1).getPhaseIndicator();
|
||||
fvAi.getLblUpkeep().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP));
|
||||
fvAi.getLblDraw().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW));
|
||||
fvAi.getLblMain1().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1));
|
||||
fvAi.getLblBeginCombat().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_BEGINCOMBAT));
|
||||
fvAi.getLblDeclareAttackers().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREATTACKERS));
|
||||
fvAi.getLblDeclareBlockers().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREBLOCKERS));
|
||||
fvAi.getLblFirstStrike().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_FIRSTSTRIKE));
|
||||
fvAi.getLblCombatDamage().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_COMBATDAMAGE));
|
||||
fvAi.getLblEndCombat().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_ENDCOMBAT));
|
||||
fvAi.getLblMain2().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN2));
|
||||
fvAi.getLblEndTurn().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_EOT));
|
||||
fvAi.getLblCleanup().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP));
|
||||
|
||||
// Human field is at index [1]
|
||||
// Human field is at index [0]
|
||||
PhaseIndicator fvHuman = fieldViews.get(0).getPhaseIndicator();
|
||||
fvHuman.getLblUpkeep().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_UPKEEP));
|
||||
fvHuman.getLblDraw().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_DRAW));
|
||||
@@ -726,6 +711,23 @@ public enum FControl implements KeyEventDispatcher {
|
||||
fvHuman.getLblEndTurn().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_EOT));
|
||||
fvHuman.getLblCleanup().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_CLEANUP));
|
||||
|
||||
// AI field is at index [1], ...
|
||||
for (int i = 1; i < fieldViews.size(); i++) {
|
||||
PhaseIndicator fvAi = fieldViews.get(i).getPhaseIndicator();
|
||||
fvAi.getLblUpkeep().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP));
|
||||
fvAi.getLblDraw().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW));
|
||||
fvAi.getLblMain1().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1));
|
||||
fvAi.getLblBeginCombat().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_BEGINCOMBAT));
|
||||
fvAi.getLblDeclareAttackers().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREATTACKERS));
|
||||
fvAi.getLblDeclareBlockers().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREBLOCKERS));
|
||||
fvAi.getLblFirstStrike().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_FIRSTSTRIKE));
|
||||
fvAi.getLblCombatDamage().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_COMBATDAMAGE));
|
||||
fvAi.getLblEndCombat().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_ENDCOMBAT));
|
||||
fvAi.getLblMain2().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN2));
|
||||
fvAi.getLblEndTurn().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_EOT));
|
||||
fvAi.getLblCleanup().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP));
|
||||
}
|
||||
|
||||
//Singletons.getView().getViewMatch().setLayoutParams(prefs.getPref(FPref.UI_LAYOUT_PARAMS));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.control;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
@@ -11,6 +10,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
@@ -129,12 +129,12 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
|
||||
@Override
|
||||
public Void visit(GameEventAnteCardsSelected ev) {
|
||||
final List<Card> options = new ArrayList<Card>();
|
||||
final List<CardView> options = Lists.newArrayList();
|
||||
for (final Entry<Player, Card> kv : ev.cards.entries()) {
|
||||
final Card fakeCard = new Card(-1); //use fake card so real cards appear with proper formatting
|
||||
fakeCard.setName(" -- From " + Lang.getPossesive(kv.getKey().getName()) + " deck --");
|
||||
final CardView fakeCard = new CardView(true); //use fake card so real cards appear with proper formatting
|
||||
fakeCard.getOriginal().setName(" -- From " + Lang.getPossesive(kv.getKey().getName()) + " deck --");
|
||||
options.add(fakeCard);
|
||||
options.add(kv.getValue());
|
||||
options.add(gameView.getCardView(kv.getValue()));
|
||||
}
|
||||
SGuiChoose.reveal(gui, "These cards were chosen to ante", options);
|
||||
return null;
|
||||
|
||||
@@ -20,7 +20,9 @@ public class InputPlaybackControl extends InputSyncronizedBase implements InputS
|
||||
this.gui = gui;
|
||||
this.game = game;
|
||||
control = fControlGamePlayback;
|
||||
setPause(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiBase getGui() {
|
||||
return gui;
|
||||
|
||||
@@ -1640,16 +1640,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
* @return
|
||||
* @see forge.view.LocalGameView#getCardViews(java.util.List)
|
||||
*/
|
||||
public final List<CardView> getCardViews(List<Card> cards) {
|
||||
return gameView.getCardViews(cards);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cards
|
||||
* @return
|
||||
* @see forge.view.LocalGameView#getCardViews(java.lang.Iterable)
|
||||
*/
|
||||
public final List<CardView> getCardViews(Iterable<Card> cards) {
|
||||
public final List<CardView> getCardViews(final Iterable<Card> cards) {
|
||||
return gameView.getCardViews(cards);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ import forge.properties.ForgeConstants;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
import forge.util.gui.SGuiDialog;
|
||||
import forge.util.gui.SOptionPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public final class DevModeUtil {
|
||||
|
||||
@@ -247,7 +249,8 @@ public final class DevModeUtil {
|
||||
}
|
||||
|
||||
final List<Card> lib = pPriority.getCardsIn(ZoneType.Library);
|
||||
final Card card = SGuiChoose.oneOrNone(controller.getGui(), "Choose a card", lib);
|
||||
final CardView cardView = SGuiChoose.oneOrNone(controller.getGui(), "Choose a card", controller.getCardViews(lib));
|
||||
final Card card = controller.getCard(cardView);
|
||||
if (card == null) { return; }
|
||||
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@@ -266,7 +269,9 @@ public final class DevModeUtil {
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static void devModeAddCounter(final Game game, final PlayerControllerHuman controller) {
|
||||
final Card card = SGuiChoose.oneOrNone(controller.getGui(), "Add counters to which card?", game.getCardsIn(ZoneType.Battlefield));
|
||||
final List<Card> cards = game.getCardsIn(ZoneType.Battlefield);
|
||||
final CardView cardView = SGuiChoose.oneOrNone(controller.getGui(), "Add counters to which card?", controller.getCardViews(cards));
|
||||
final Card card = controller.getCard(cardView);
|
||||
if (card == null) { return; }
|
||||
|
||||
final CounterType counter = SGuiChoose.oneOrNone(controller.getGui(), "Which type of counter?", CounterType.values());
|
||||
@@ -335,7 +340,8 @@ public final class DevModeUtil {
|
||||
*/
|
||||
public static void devModeSetLife(final Game game, final PlayerControllerHuman controller) {
|
||||
final List<Player> players = game.getPlayers();
|
||||
final Player player = SGuiChoose.oneOrNone(controller.getGui(), "Set life for which player?", players);
|
||||
final PlayerView playerView = SGuiChoose.oneOrNone(controller.getGui(), "Set life for which player?", controller.getPlayerViews(players));
|
||||
final Player player = controller.getPlayer(playerView);
|
||||
if (player == null) { return; }
|
||||
|
||||
final Integer life = SGuiChoose.getInteger(controller.getGui(), "Set life to what?", 0);
|
||||
@@ -380,7 +386,8 @@ public final class DevModeUtil {
|
||||
*/
|
||||
public static void devModeCardToHand(final Game game, final PlayerControllerHuman controller) {
|
||||
final List<Player> players = game.getPlayers();
|
||||
final Player p = SGuiChoose.oneOrNone(controller.getGui(), "Put card in hand for which player?", players);
|
||||
final PlayerView pView = SGuiChoose.oneOrNone(controller.getGui(), "Put card in hand for which player?", controller.getPlayerViews(players));
|
||||
final Player p = controller.getPlayer(pView);
|
||||
if (null == p) {
|
||||
return;
|
||||
}
|
||||
@@ -401,7 +408,8 @@ public final class DevModeUtil {
|
||||
|
||||
public static void devModeCardToBattlefield(final Game game, final PlayerControllerHuman controller) {
|
||||
final List<Player> players = game.getPlayers();
|
||||
final Player p = SGuiChoose.oneOrNone(controller.getGui(), "Put card in play for which player?", players);
|
||||
final PlayerView pView = SGuiChoose.oneOrNone(controller.getGui(), "Put card in play for which player?", controller.getPlayerViews(players));
|
||||
final Player p = controller.getPlayer(pView);
|
||||
if (null == p) {
|
||||
return;
|
||||
}
|
||||
@@ -444,7 +452,8 @@ public final class DevModeUtil {
|
||||
|
||||
public static void devModeRiggedPlanarRoll(final Game game, final PlayerControllerHuman controller) {
|
||||
final List<Player> players = game.getPlayers();
|
||||
final Player player = SGuiChoose.oneOrNone(controller.getGui(), "Which player should roll?", players);
|
||||
final PlayerView playerView = SGuiChoose.oneOrNone(controller.getGui(), "Which player should roll?", controller.getPlayerViews(players));
|
||||
final Player player = controller.getPlayer(playerView);
|
||||
if (player == null) { return; }
|
||||
|
||||
final PlanarDice res = SGuiChoose.oneOrNone(controller.getGui(), "Choose result", PlanarDice.values());
|
||||
@@ -452,12 +461,6 @@ public final class DevModeUtil {
|
||||
|
||||
System.out.println("Rigging planar dice roll: " + res.toString());
|
||||
|
||||
//DBG
|
||||
//System.out.println("ActivePlanes: " + getGame().getActivePlanes());
|
||||
//System.out.println("CommandPlanes: " + getGame().getCardsIn(ZoneType.Command));
|
||||
|
||||
|
||||
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user