mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Avoid storing and passing IGuiBase instances everywhere since only one IGuiBase instance will ever exist on a single session
This commit is contained in:
@@ -2,7 +2,6 @@ package forge;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.util.ThreadUtil;
|
||||
|
||||
public class FThreads {
|
||||
@@ -15,8 +14,8 @@ public class FThreads {
|
||||
* @param methodName   String, part of the custom exception message.
|
||||
* @param mustBeEDT   boolean: true = exception if not EDT, false = exception if EDT
|
||||
*/
|
||||
public static void assertExecutedByEdt(final IGuiBase gui, final boolean mustBeEDT) {
|
||||
if (isGuiThread(gui) != mustBeEDT) {
|
||||
public static void assertExecutedByEdt(final boolean mustBeEDT) {
|
||||
if (isGuiThread() != mustBeEDT) {
|
||||
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
||||
final String methodName = trace[2].getClassName() + "." + trace[2].getMethodName();
|
||||
String modalOperator = mustBeEDT ? " must be" : " may not be";
|
||||
@@ -24,16 +23,16 @@ public class FThreads {
|
||||
}
|
||||
}
|
||||
|
||||
public static void invokeInEdtLater(final IGuiBase gui, final Runnable runnable) {
|
||||
gui.invokeInEdtLater(runnable);
|
||||
public static void invokeInEdtLater(final Runnable runnable) {
|
||||
GuiBase.getInterface().invokeInEdtLater(runnable);
|
||||
}
|
||||
|
||||
public static void invokeInEdtNowOrLater(final IGuiBase gui, final Runnable proc) {
|
||||
if (isGuiThread(gui)) {
|
||||
public static void invokeInEdtNowOrLater(final Runnable proc) {
|
||||
if (isGuiThread()) {
|
||||
proc.run();
|
||||
}
|
||||
else {
|
||||
invokeInEdtLater(gui, proc);
|
||||
invokeInEdtLater(proc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +48,8 @@ public class FThreads {
|
||||
* the Runnable to run
|
||||
* @see fgd.SwingUtilities#invokeLater(Runnable)
|
||||
*/
|
||||
public static void invokeInEdtAndWait(final IGuiBase gui, final Runnable proc) {
|
||||
gui.invokeInEdtAndWait(proc);
|
||||
public static void invokeInEdtAndWait(final Runnable proc) {
|
||||
GuiBase.getInterface().invokeInEdtAndWait(proc);
|
||||
}
|
||||
|
||||
private static int backgroundThreadCount;
|
||||
@@ -60,31 +59,31 @@ public class FThreads {
|
||||
backgroundThreadCount++;
|
||||
}
|
||||
|
||||
public static boolean isGuiThread(IGuiBase gui) {
|
||||
return gui.isGuiThread();
|
||||
public static boolean isGuiThread() {
|
||||
return GuiBase.getInterface().isGuiThread();
|
||||
}
|
||||
|
||||
public static void delayInEDT(final IGuiBase gui, final int milliseconds, final Runnable inputUpdater) {
|
||||
public static void delayInEDT(final int milliseconds, final Runnable inputUpdater) {
|
||||
Runnable runInEdt = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FThreads.invokeInEdtNowOrLater(gui, inputUpdater);
|
||||
FThreads.invokeInEdtNowOrLater(inputUpdater);
|
||||
}
|
||||
};
|
||||
ThreadUtil.delay(milliseconds, runInEdt);
|
||||
}
|
||||
|
||||
public static String debugGetCurrThreadId(final IGuiBase gui) {
|
||||
return isGuiThread(gui) ? "EDT" : Thread.currentThread().getName();
|
||||
public static String debugGetCurrThreadId() {
|
||||
return isGuiThread() ? "EDT" : Thread.currentThread().getName();
|
||||
}
|
||||
|
||||
public static String prependThreadId(final IGuiBase gui, String message) {
|
||||
return debugGetCurrThreadId(gui) + " > " + message;
|
||||
public static String prependThreadId(String message) {
|
||||
return debugGetCurrThreadId() + " > " + message;
|
||||
}
|
||||
|
||||
public static void dumpStackTrace(final IGuiBase gui, final PrintStream stream) {
|
||||
public static void dumpStackTrace(final PrintStream stream) {
|
||||
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
||||
stream.printf("%s > %s called from %s%n", debugGetCurrThreadId(gui),
|
||||
stream.printf("%s > %s called from %s%n", debugGetCurrThreadId(),
|
||||
trace[2].getClassName() + "." + trace[2].getMethodName(), trace[3].toString());
|
||||
int i = 0;
|
||||
for (StackTraceElement se : trace) {
|
||||
@@ -93,7 +92,7 @@ public class FThreads {
|
||||
}
|
||||
}
|
||||
|
||||
public static String debugGetStackTraceItem(final IGuiBase gui, final int depth, final boolean shorter) {
|
||||
public static String debugGetStackTraceItem(final int depth, final boolean shorter) {
|
||||
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
||||
String lastItem = trace[depth].toString();
|
||||
if (shorter) {
|
||||
@@ -101,13 +100,13 @@ public class FThreads {
|
||||
lastPeriod = lastItem.lastIndexOf('.', lastPeriod-1);
|
||||
lastPeriod = lastItem.lastIndexOf('.', lastPeriod-1);
|
||||
lastItem = lastItem.substring(lastPeriod+1);
|
||||
return String.format("%s > from %s", debugGetCurrThreadId(gui), lastItem);
|
||||
return String.format("%s > from %s", debugGetCurrThreadId(), lastItem);
|
||||
}
|
||||
return String.format("%s > %s called from %s", debugGetCurrThreadId(gui),
|
||||
return String.format("%s > %s called from %s", debugGetCurrThreadId(),
|
||||
trace[2].getClassName() + "." + trace[2].getMethodName(), lastItem);
|
||||
}
|
||||
|
||||
public static String debugGetStackTraceItem(final IGuiBase gui, final int depth) {
|
||||
return debugGetStackTraceItem(gui, depth, false);
|
||||
public static String debugGetStackTraceItem(final int depth) {
|
||||
return debugGetStackTraceItem(depth, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import forge.assets.FSkinProp;
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.game.Game;
|
||||
import forge.game.player.Player;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.Lang;
|
||||
@@ -153,7 +152,7 @@ public abstract class Achievement {
|
||||
image = GuiBase.getInterface().createLayeredImage(background, ForgeConstants.CACHE_ACHIEVEMENTS_DIR + "/" + key + ".png", opacity);
|
||||
}
|
||||
|
||||
public int update(IGuiBase gui, Player player) {
|
||||
public int update(Player player) {
|
||||
int value = evaluate(player, player.getGame());
|
||||
if (checkGreaterThan) {
|
||||
if (value <= best) { return value; }
|
||||
@@ -172,7 +171,7 @@ public abstract class Achievement {
|
||||
if (earnedSpecial()) {
|
||||
if (!hadEarnedSpecial) {
|
||||
updateTrophyImage();
|
||||
gui.showImageDialog(image, displayName + "\n" + sharedDesc + "\n" + mythicDesc, "Achievement Earned");
|
||||
GuiBase.getInterface().showImageDialog(image, displayName + "\n" + sharedDesc + "\n" + mythicDesc, "Achievement Earned");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -208,7 +207,7 @@ public abstract class Achievement {
|
||||
if (sharedDesc != null) {
|
||||
desc = sharedDesc + " " + desc;
|
||||
}
|
||||
gui.showImageDialog(image, displayName + " (" + type + ")\n" + desc, "Achievement Earned");
|
||||
GuiBase.getInterface().showImageDialog(image, displayName + " (" + type + ")\n" + desc, "Achievement Earned");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import forge.game.Game;
|
||||
import forge.game.GameType;
|
||||
import forge.game.player.Player;
|
||||
import forge.interfaces.IComboBox;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
@@ -42,7 +41,6 @@ public abstract class AchievementCollection implements Iterable<Achievement> {
|
||||
return;
|
||||
}
|
||||
|
||||
final IGuiBase gui = controller.getGui();
|
||||
final Game game = controller.getGame();
|
||||
final Player player = controller.getPlayer();
|
||||
|
||||
@@ -50,10 +48,10 @@ public abstract class AchievementCollection implements Iterable<Achievement> {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FModel.getAchievements(game.getRules().getGameType()).updateAll(gui, player);
|
||||
AltWinAchievements.instance.updateAll(gui, player);
|
||||
PlaneswalkerAchievements.instance.updateAll(gui, player);
|
||||
ChallengeAchievements.instance.updateAll(gui, player);
|
||||
FModel.getAchievements(game.getRules().getGameType()).updateAll(player);
|
||||
AltWinAchievements.instance.updateAll(player);
|
||||
PlaneswalkerAchievements.instance.updateAll(player);
|
||||
ChallengeAchievements.instance.updateAll(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -109,9 +107,9 @@ public abstract class AchievementCollection implements Iterable<Achievement> {
|
||||
achievements.put(achievement.getKey(), achievement);
|
||||
}
|
||||
|
||||
public void updateAll(IGuiBase gui, Player player) {
|
||||
public void updateAll(Player player) {
|
||||
for (Achievement achievement : achievements.values()) {
|
||||
achievement.update(gui, player);
|
||||
achievement.update(player);
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.player.Player;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
@@ -49,7 +48,7 @@ public class AltWinAchievements extends AchievementCollection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAll(IGuiBase gui, Player player) {
|
||||
public void updateAll(Player player) {
|
||||
//only call update achievement for alternate win condition (if any)
|
||||
if (player.getOutcome().hasWon()) {
|
||||
String altWinCondition = player.getOutcome().altWinSourceName;
|
||||
@@ -65,7 +64,7 @@ public class AltWinAchievements extends AchievementCollection {
|
||||
|
||||
Achievement achievement = achievements.get(altWinCondition);
|
||||
if (achievement != null) {
|
||||
achievement.update(gui, player);
|
||||
achievement.update(player);
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.achievement;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.player.Player;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
@@ -79,14 +78,14 @@ public class PlaneswalkerAchievements extends AchievementCollection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAll(IGuiBase gui, Player player) {
|
||||
public void updateAll(Player player) {
|
||||
//only call update achievements for any ultimates activated during the game
|
||||
if (player.getOutcome().hasWon()) {
|
||||
boolean needSave = false;
|
||||
for (String ultimate : player.getAchievementTracker().activatedUltimates) {
|
||||
Achievement achievement = achievements.get(ultimate);
|
||||
if (achievement != null) {
|
||||
achievement.update(gui, player);
|
||||
achievement.update(player);
|
||||
needSave = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
options.add(fakeCard);
|
||||
options.add(gameView.getCardView(kv.getValue(), true));
|
||||
}
|
||||
SGuiChoose.reveal(gameView.getGui(), "These cards were chosen to ante", options);
|
||||
SGuiChoose.reveal("These cards were chosen to ante", options);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.game.Game;
|
||||
import forge.game.event.GameEvent;
|
||||
import forge.game.event.GameEventBlockersDeclared;
|
||||
@@ -18,7 +19,6 @@ import forge.game.event.GameEventSpellAbilityCast;
|
||||
import forge.game.event.GameEventSpellResolved;
|
||||
import forge.game.event.GameEventTurnPhase;
|
||||
import forge.game.event.IGameEventVisitor;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.input.InputPlaybackControl;
|
||||
import forge.view.LocalGameView;
|
||||
@@ -29,11 +29,9 @@ public class FControlGamePlayback extends IGameEventVisitor.Base<Void> {
|
||||
|
||||
private final CyclicBarrier gameThreadPauser = new CyclicBarrier(2);
|
||||
|
||||
private final IGuiBase gui;
|
||||
private final LocalGameView gameView;
|
||||
public FControlGamePlayback(final IGuiBase gui, final LocalGameView gameView) {
|
||||
this.gui = gui;
|
||||
this.gameView = gameView;
|
||||
public FControlGamePlayback(final LocalGameView gameView0) {
|
||||
gameView = gameView0;
|
||||
}
|
||||
|
||||
private Game game;
|
||||
@@ -42,9 +40,9 @@ public class FControlGamePlayback extends IGameEventVisitor.Base<Void> {
|
||||
return game;
|
||||
}
|
||||
|
||||
public void setGame(Game game) {
|
||||
this.game = game;
|
||||
this.inputPlayback = new InputPlaybackControl(gui, game, this);
|
||||
public void setGame(Game game0) {
|
||||
game = game0;
|
||||
inputPlayback = new InputPlaybackControl(game, this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -121,10 +119,10 @@ public class FControlGamePlayback extends IGameEventVisitor.Base<Void> {
|
||||
|
||||
@Override
|
||||
public Void visit(final GameEventSpellResolved event) {
|
||||
FThreads.invokeInEdtNowOrLater(gui, new Runnable() {
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
gui.setCard(gameView.getCardView(event.spell.getHostCard(), true));
|
||||
GuiBase.getInterface().setCard(gameView.getCardView(event.spell.getHostCard(), true));
|
||||
}
|
||||
});
|
||||
pauseForEvent(resolveDelay);
|
||||
@@ -136,10 +134,10 @@ public class FControlGamePlayback extends IGameEventVisitor.Base<Void> {
|
||||
*/
|
||||
@Override
|
||||
public Void visit(final GameEventSpellAbilityCast event) {
|
||||
FThreads.invokeInEdtNowOrLater(gui, new Runnable() {
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
gui.setCard(gameView.getCardView(event.sa.getHostCard(), true));
|
||||
GuiBase.getInterface().setCard(gameView.getCardView(event.sa.getHostCard(), true));
|
||||
}
|
||||
});
|
||||
pauseForEvent(castDelay);
|
||||
|
||||
@@ -3,20 +3,17 @@ package forge.deck;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.itemmanager.IItemManager;
|
||||
|
||||
|
||||
public class ColorDeckGenerator extends DeckProxy implements Comparable<ColorDeckGenerator> {
|
||||
private final IGuiBase gui;
|
||||
private String name;
|
||||
private int index;
|
||||
private final IItemManager<DeckProxy> lstDecks;
|
||||
private final boolean isAi;
|
||||
|
||||
public ColorDeckGenerator(final IGuiBase gui, String name0, int index0, IItemManager<DeckProxy> lstDecks0, boolean isAi0) {
|
||||
public ColorDeckGenerator(String name0, int index0, IItemManager<DeckProxy> lstDecks0, boolean isAi0) {
|
||||
super();
|
||||
this.gui = gui;
|
||||
name = name0;
|
||||
index = index0;
|
||||
lstDecks = lstDecks0;
|
||||
@@ -45,7 +42,7 @@ public class ColorDeckGenerator extends DeckProxy implements Comparable<ColorDec
|
||||
for (DeckProxy deck : lstDecks.getSelectedItems()) {
|
||||
selection.add(deck.getName());
|
||||
}
|
||||
if (DeckgenUtil.colorCheck(gui, selection)) {
|
||||
if (DeckgenUtil.colorCheck(selection)) {
|
||||
return DeckgenUtil.buildColorDeck(selection, isAi);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -12,7 +12,6 @@ import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.deck.generation.*;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.PaperCard;
|
||||
import forge.itemmanager.IItemManager;
|
||||
import forge.model.FModel;
|
||||
@@ -187,18 +186,18 @@ public class DeckgenUtil {
|
||||
* @param colors0 String[]
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean colorCheck(final IGuiBase gui, final List<String> colors0) {
|
||||
public static boolean colorCheck(final List<String> colors0) {
|
||||
boolean result = true;
|
||||
|
||||
if (colors0.size() == 4) {
|
||||
SOptionPane.showMessageDialog(gui,
|
||||
SOptionPane.showMessageDialog(
|
||||
"Sorry, four color generated decks aren't supported yet."
|
||||
+ "\n\rPlease use 2, 3, or 5 colors for this deck.",
|
||||
"Generate deck: 4 colors", SOptionPane.ERROR_ICON);
|
||||
result = false;
|
||||
}
|
||||
else if (colors0.size() > 5) {
|
||||
SOptionPane.showMessageDialog(gui,
|
||||
SOptionPane.showMessageDialog(
|
||||
"Generate deck: maximum five colors!",
|
||||
"Generate deck: too many colors", SOptionPane.ERROR_ICON);
|
||||
result = false;
|
||||
|
||||
@@ -19,7 +19,6 @@ package forge.deck.io;
|
||||
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.FileSection;
|
||||
import forge.util.FileUtil;
|
||||
@@ -48,20 +47,8 @@ public class OldDeckParser {
|
||||
}
|
||||
};
|
||||
|
||||
private final IGuiBase gui;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for Constructor.
|
||||
*
|
||||
* @param file the file
|
||||
* @param constructed2 the constructed2
|
||||
* @param draft2 the draft2
|
||||
* @param sealed2 the sealed2
|
||||
* @param cube2 the cube2
|
||||
*/
|
||||
public OldDeckParser(final IGuiBase gui, final IStorage<Deck> constructed2, final IStorage<DeckGroup> draft2,
|
||||
public OldDeckParser(final IStorage<Deck> constructed2, final IStorage<DeckGroup> draft2,
|
||||
final IStorage<DeckGroup> sealed2, final IStorage<Deck> cube2) {
|
||||
this.gui = gui;
|
||||
this.deckDir = new File(ForgeConstants.DECK_BASE_DIR);
|
||||
this.sealed = sealed2;
|
||||
this.constructed = constructed2;
|
||||
@@ -149,7 +136,7 @@ public class OldDeckParser {
|
||||
this.draft.add(d);
|
||||
} else {
|
||||
final String msg = String.format("Draft '%s' lacked some decks.%n%nShould it be deleted?");
|
||||
mayDelete = SOptionPane.showConfirmDialog(gui, msg, "Draft loading error");
|
||||
mayDelete = SOptionPane.showConfirmDialog(msg, "Draft loading error");
|
||||
}
|
||||
|
||||
if (mayDelete) {
|
||||
@@ -185,7 +172,7 @@ public class OldDeckParser {
|
||||
final String msg = String
|
||||
.format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
|
||||
name, ex.getMessage());
|
||||
allowDeleteUnsupportedConstructed = SOptionPane.showConfirmDialog(gui, msg, "Problem converting decks");
|
||||
allowDeleteUnsupportedConstructed = SOptionPane.showConfirmDialog(msg, "Problem converting decks");
|
||||
}
|
||||
}
|
||||
if (importedOk || allowDeleteUnsupportedConstructed) {
|
||||
@@ -204,7 +191,7 @@ public class OldDeckParser {
|
||||
final String msg = String
|
||||
.format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
|
||||
name, ex.getMessage());
|
||||
allowDeleteUnsupportedConstructed = SOptionPane.showConfirmDialog(gui, msg, "Problem converting decks");
|
||||
allowDeleteUnsupportedConstructed = SOptionPane.showConfirmDialog(msg, "Problem converting decks");
|
||||
}
|
||||
}
|
||||
if (importedOk || allowDeleteUnsupportedConstructed) {
|
||||
@@ -256,7 +243,7 @@ public class OldDeckParser {
|
||||
}
|
||||
sb.append(System.getProperty("line.separator"));
|
||||
sb.append("May Forge delete these decks?");
|
||||
if (SOptionPane.showConfirmDialog(gui, sb.toString(), "Some of your sealed decks are orphaned")) {
|
||||
if (SOptionPane.showConfirmDialog(sb.toString(), "Some of your sealed decks are orphaned")) {
|
||||
for (final Pair<DeckGroup, MutablePair<File, File>> s : sealedDecks.values()) {
|
||||
if (s.getRight().getLeft() != null) {
|
||||
s.getRight().getLeft().delete();
|
||||
|
||||
@@ -38,10 +38,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.error.BugReporter;
|
||||
import forge.interfaces.IButton;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.interfaces.IProgressBar;
|
||||
import forge.interfaces.ITextField;
|
||||
import forge.util.FileUtil;
|
||||
@@ -58,13 +58,12 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
private IButton btnStart;
|
||||
private UiCommand cmdClose;
|
||||
private Runnable onUpdate;
|
||||
private IGuiBase gui;
|
||||
|
||||
private final UiCommand cmdStartDownload = new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
//invalidate image cache so newly downloaded images will be loaded
|
||||
gui.clearImageCache();
|
||||
GuiBase.getInterface().clearImageCache();
|
||||
FThreads.invokeInBackgroundThread(GuiDownloadService.this);
|
||||
btnStart.setEnabled(false);
|
||||
}
|
||||
@@ -84,14 +83,13 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
protected GuiDownloadService() {
|
||||
}
|
||||
|
||||
public void initialize(final IGuiBase gui, ITextField txtAddress0, ITextField txtPort0, IProgressBar progressBar0, IButton btnStart0, UiCommand cmdClose0, final Runnable onReadyToStart, Runnable onUpdate0) {
|
||||
public void initialize(ITextField txtAddress0, ITextField txtPort0, IProgressBar progressBar0, IButton btnStart0, UiCommand cmdClose0, final Runnable onReadyToStart, Runnable onUpdate0) {
|
||||
txtAddress = txtAddress0;
|
||||
txtPort = txtPort0;
|
||||
progressBar = progressBar0;
|
||||
btnStart = btnStart0;
|
||||
cmdClose = cmdClose0;
|
||||
onUpdate = onUpdate0;
|
||||
this.gui = gui;
|
||||
|
||||
// Free up the EDT by assembling card list on a background thread
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@@ -103,7 +101,7 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
FThreads.invokeInEdtLater(gui, new Runnable() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (onReadyToStart != null) {
|
||||
@@ -130,7 +128,7 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
}
|
||||
btnStart.setEnabled(true);
|
||||
|
||||
FThreads.invokeInEdtLater(gui, new Runnable() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
btnStart.requestFocusInWindow();
|
||||
@@ -169,7 +167,7 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
}
|
||||
|
||||
private void update(final int count, final File dest) {
|
||||
FThreads.invokeInEdtLater(gui, new Runnable() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (onUpdate != null) {
|
||||
@@ -227,7 +225,7 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
p = new Proxy(TYPES[type], new InetSocketAddress(txtAddress.getText(), Integer.parseInt(txtPort.getText())));
|
||||
}
|
||||
catch (final Exception ex) {
|
||||
BugReporter.reportException(ex, gui,
|
||||
BugReporter.reportException(ex,
|
||||
"Proxy connection could not be established!\nProxy address: %s\nProxy port: %s",
|
||||
txtAddress.getText(), txtPort.getText());
|
||||
return;
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.Map.Entry;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.GuiBase;
|
||||
import forge.util.BuildInfo;
|
||||
import forge.util.gui.SOptionPane;
|
||||
|
||||
@@ -73,22 +73,22 @@ public class BugReporter {
|
||||
* Shows exception information in a format ready to post to the forum as a crash report. Uses the exception's message
|
||||
* as the reason if message is null.
|
||||
*/
|
||||
public static void reportException(final Throwable ex, final IGuiBase gui, final String message) {
|
||||
public static void reportException(final Throwable ex, final String message) {
|
||||
if (ex == null) {
|
||||
return;
|
||||
}
|
||||
if (message != null) {
|
||||
System.err.printf("%s > %s%n", FThreads.debugGetCurrThreadId(gui), message);
|
||||
System.err.printf("%s > %s%n", FThreads.debugGetCurrThreadId(), message);
|
||||
}
|
||||
System.err.print(FThreads.debugGetCurrThreadId(gui) + " > ");
|
||||
System.err.print(FThreads.debugGetCurrThreadId() + " > ");
|
||||
ex.printStackTrace();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Description: [describe what you were doing when the crash occurred]\n\n");
|
||||
buildSpoilerHeader(gui, sb, ex.getClass().getSimpleName());
|
||||
buildSpoilerHeader(sb, ex.getClass().getSimpleName());
|
||||
sb.append("\n\n");
|
||||
if (null != message && !message.isEmpty()) {
|
||||
sb.append(FThreads.debugGetCurrThreadId(gui)).append(" > ").append(message).append("\n");
|
||||
sb.append(FThreads.debugGetCurrThreadId()).append(" > ").append(message).append("\n");
|
||||
}
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
@@ -108,46 +108,46 @@ public class BugReporter {
|
||||
|
||||
buildSpoilerFooter(sb);
|
||||
|
||||
gui.showBugReportDialog("Report a crash", sb.toString(), true);
|
||||
GuiBase.getInterface().showBugReportDialog("Report a crash", sb.toString(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for reportException(ex, null).
|
||||
*/
|
||||
public static void reportException(final Throwable ex, final IGuiBase gui) {
|
||||
reportException(ex, gui, null);
|
||||
public static void reportException(final Throwable ex) {
|
||||
reportException(ex, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for reportException(ex, String.format(format, args)).
|
||||
*/
|
||||
public static void reportException(final Throwable ex, final IGuiBase gui, final String format, final Object... args) {
|
||||
reportException(ex, gui, String.format(format, args));
|
||||
public static void reportException(final Throwable ex, final String format, final Object... args) {
|
||||
reportException(ex, String.format(format, args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a forum post template for reporting a bug.
|
||||
*/
|
||||
public static void reportBug(final IGuiBase gui, final String details) {
|
||||
public static void reportBug(final String details) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Description: [describe the problem]\n\n");
|
||||
buildSpoilerHeader(gui, sb, "General bug report");
|
||||
buildSpoilerHeader(sb, "General bug report");
|
||||
if (null != details && !details.isEmpty()) {
|
||||
sb.append("\n\n");
|
||||
sb.append(details);
|
||||
}
|
||||
buildSpoilerFooter(sb);
|
||||
|
||||
gui.showBugReportDialog("Report a bug", sb.toString(), false);
|
||||
GuiBase.getInterface().showBugReportDialog("Report a bug", sb.toString(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows thread stack information in a format ready to post to the forum.
|
||||
*/
|
||||
public static void reportThreadStacks(final IGuiBase gui,final String message) {
|
||||
public static void reportThreadStacks(final String message) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Description: [describe what you were doing at the time]\n\n");
|
||||
buildSpoilerHeader(gui, sb, "Thread stack dump");
|
||||
buildSpoilerHeader(sb, "Thread stack dump");
|
||||
sb.append("\n\n");
|
||||
if (null != message && !message.isEmpty()) {
|
||||
sb.append(message);
|
||||
@@ -167,7 +167,7 @@ public class BugReporter {
|
||||
|
||||
sb.append(sw.toString());
|
||||
buildSpoilerFooter(sb);
|
||||
gui.showBugReportDialog("Thread stack dump", sb.toString(), false);
|
||||
GuiBase.getInterface().showBugReportDialog("Thread stack dump", sb.toString(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,9 +177,9 @@ public class BugReporter {
|
||||
reportThreadStacks(String.format(format, args));
|
||||
}
|
||||
|
||||
private static StringBuilder buildSpoilerHeader(final IGuiBase gui, final StringBuilder sb, final String reportTitle) {
|
||||
private static StringBuilder buildSpoilerHeader(final StringBuilder sb, final String reportTitle) {
|
||||
sb.append("[spoiler=").append(reportTitle).append("][code]");
|
||||
sb.append("\nForge Version: ").append(gui.getCurrentVersion());
|
||||
sb.append("\nForge Version: ").append(GuiBase.getInterface().getCurrentVersion());
|
||||
sb.append("\nOperating System: ").append(System.getProperty("os.name"))
|
||||
.append(" ").append(System.getProperty("os.version"))
|
||||
.append(" ").append(System.getProperty("os.arch"));
|
||||
@@ -193,19 +193,19 @@ public class BugReporter {
|
||||
return sb;
|
||||
}
|
||||
|
||||
public static void copyAndGoToForums(final IGuiBase gui, final String text) {
|
||||
public static void copyAndGoToForums(final String text) {
|
||||
try {
|
||||
// copy text to clipboard
|
||||
gui.copyToClipboard(text);
|
||||
gui.browseToUrl(FORUM_URL);
|
||||
GuiBase.getInterface().copyToClipboard(text);
|
||||
GuiBase.getInterface().browseToUrl(FORUM_URL);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
SOptionPane.showMessageDialog(gui, "Sorry, a problem occurred while opening the forum in your default browser.",
|
||||
SOptionPane.showMessageDialog("Sorry, a problem occurred while opening the forum in your default browser.",
|
||||
"A problem occurred", SOptionPane.ERROR_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveToFile(final IGuiBase gui, final String text) {
|
||||
public static void saveToFile(final String text) {
|
||||
File f;
|
||||
long curTime = System.currentTimeMillis();
|
||||
for (int i = 0;; i++) {
|
||||
@@ -216,7 +216,7 @@ public class BugReporter {
|
||||
}
|
||||
}
|
||||
|
||||
f = gui.getSaveFile(f);
|
||||
f = GuiBase.getInterface().getSaveFile(f);
|
||||
|
||||
try {
|
||||
final BufferedWriter bw = new BufferedWriter(new FileWriter(f));
|
||||
@@ -224,7 +224,7 @@ public class BugReporter {
|
||||
bw.close();
|
||||
}
|
||||
catch (final IOException ex) {
|
||||
SOptionPane.showMessageDialog(gui, "There was an error during saving. Sorry!\n" + ex,
|
||||
SOptionPane.showMessageDialog("There was an error during saving. Sorry!\n" + ex,
|
||||
"Error saving file", SOptionPane.ERROR_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.FTrace;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.MultiplexOutputStream;
|
||||
|
||||
@@ -48,7 +47,6 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
|
||||
System.setProperty("sun.awt.exception.handler", ExceptionHandler.class.getName());
|
||||
}
|
||||
|
||||
private static IGuiBase gui;
|
||||
private static PrintStream oldSystemOut;
|
||||
private static PrintStream oldSystemErr;
|
||||
private static OutputStream logFileStream;
|
||||
@@ -57,12 +55,10 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
|
||||
* Call this at the beginning to make sure that the class is loaded and the
|
||||
* static initializer has run.
|
||||
*/
|
||||
public static void registerErrorHandling(final IGuiBase gui) {
|
||||
public static void registerErrorHandling() {
|
||||
//initialize log file
|
||||
File logFile = new File(ForgeConstants.LOG_FILE);
|
||||
|
||||
ExceptionHandler.gui = gui;
|
||||
|
||||
int i = 0;
|
||||
while (logFile.exists() && !logFile.delete()) {
|
||||
String pathname = logFile.getPath().replaceAll("[0-9]{0,2}.log$", String.valueOf(i++) + ".log");
|
||||
@@ -108,7 +104,7 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void uncaughtException(final Thread t, final Throwable ex) {
|
||||
BugReporter.reportException(ex, gui);
|
||||
BugReporter.reportException(ex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,6 +115,6 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
|
||||
* a {@link java.lang.Throwable} object.
|
||||
*/
|
||||
public final void handle(final Throwable ex) {
|
||||
BugReporter.reportException(ex, gui);
|
||||
BugReporter.reportException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import forge.card.UnOpenedProduct;
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.card.Card;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.SealedProduct;
|
||||
@@ -67,13 +66,13 @@ public class BoosterDraft implements IBoosterDraft {
|
||||
|
||||
protected final List<Supplier<List<PaperCard>>> product = new ArrayList<Supplier<List<PaperCard>>>();
|
||||
|
||||
public static BoosterDraft createDraft(final IGuiBase gui, final LimitedPoolType draftType) {
|
||||
public static BoosterDraft createDraft(final LimitedPoolType draftType) {
|
||||
BoosterDraft draft = new BoosterDraft(draftType);
|
||||
if (!draft.generateProduct(gui)) { return null; }
|
||||
if (!draft.generateProduct()) { return null; }
|
||||
return draft;
|
||||
}
|
||||
|
||||
protected boolean generateProduct(final IGuiBase gui) {
|
||||
protected boolean generateProduct() {
|
||||
switch (this.draftFormat) {
|
||||
case Full: // Draft from all cards in Forge
|
||||
Supplier<List<PaperCard>> s = new UnOpenedProduct(SealedProduct.Template.genericBooster);
|
||||
@@ -96,12 +95,12 @@ public class BoosterDraft implements IBoosterDraft {
|
||||
}
|
||||
}
|
||||
|
||||
final CardBlock block = SGuiChoose.oneOrNone(gui, "Choose Block", blocks);
|
||||
final CardBlock block = SGuiChoose.oneOrNone("Choose Block", blocks);
|
||||
if (block == null) { return false; }
|
||||
|
||||
final CardEdition[] cardSets = block.getSets();
|
||||
if (cardSets.length == 0) {
|
||||
SOptionPane.showErrorDialog(gui, block.toString() + " does not contain any set combinations.");
|
||||
SOptionPane.showErrorDialog(block.toString() + " does not contain any set combinations.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -119,16 +118,16 @@ public class BoosterDraft implements IBoosterDraft {
|
||||
final int nPacks = block.getCntBoostersDraft();
|
||||
|
||||
if (sets.size() > 1) {
|
||||
final Object p = SGuiChoose.oneOrNone(gui, "Choose Set Combination", getSetCombos(sets));
|
||||
final Object p = SGuiChoose.oneOrNone("Choose Set Combination", getSetCombos(sets));
|
||||
if (p == null) { return false; }
|
||||
|
||||
final String[] pp = p.toString().split("/");
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
this.product.add(block.getBooster(pp[i], gui));
|
||||
this.product.add(block.getBooster(pp[i]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
IUnOpenedProduct product1 = block.getBooster(sets.get(0), gui);
|
||||
IUnOpenedProduct product1 = block.getBooster(sets.get(0));
|
||||
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
this.product.add(product1);
|
||||
@@ -142,10 +141,10 @@ public class BoosterDraft implements IBoosterDraft {
|
||||
final List<CustomLimited> myDrafts = this.loadCustomDrafts();
|
||||
|
||||
if (myDrafts.isEmpty()) {
|
||||
SOptionPane.showMessageDialog(gui, "No custom draft files found.");
|
||||
SOptionPane.showMessageDialog("No custom draft files found.");
|
||||
}
|
||||
else {
|
||||
final CustomLimited customDraft = SGuiChoose.oneOrNone(gui, "Choose Custom Draft", myDrafts);
|
||||
final CustomLimited customDraft = SGuiChoose.oneOrNone("Choose Custom Draft", myDrafts);
|
||||
if (customDraft == null) { return false; }
|
||||
|
||||
this.setupCustomDraft(customDraft);
|
||||
@@ -160,13 +159,13 @@ public class BoosterDraft implements IBoosterDraft {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static BoosterDraft createDraft(final IGuiBase gui, final LimitedPoolType draftType, final CardBlock block, final String[] boosters) {
|
||||
public static BoosterDraft createDraft(final LimitedPoolType draftType, final CardBlock block, final String[] boosters) {
|
||||
BoosterDraft draft = new BoosterDraft(draftType);
|
||||
|
||||
final int nPacks = boosters.length;
|
||||
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
draft.product.add(block.getBooster(boosters[i], gui));
|
||||
draft.product.add(block.getBooster(boosters[i]));
|
||||
}
|
||||
|
||||
IBoosterDraft.LAND_SET_CODE[0] = block.getLandSet();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.limited;
|
||||
|
||||
import forge.interfaces.IButton;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.interfaces.IWinLoseView;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
@@ -14,7 +13,7 @@ public abstract class LimitedWinLoseController {
|
||||
private GauntletMini gauntlet;
|
||||
private boolean nextRound = false;
|
||||
|
||||
public LimitedWinLoseController(IWinLoseView<? extends IButton> view0, final IGameView game0, final IGuiBase gui) {
|
||||
public LimitedWinLoseController(IWinLoseView<? extends IButton> view0, final IGameView game0) {
|
||||
view = view0;
|
||||
lastGame = game0;
|
||||
gauntlet = FModel.getGauntletMini();
|
||||
|
||||
@@ -26,7 +26,6 @@ import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.SealedProduct;
|
||||
import forge.model.CardBlock;
|
||||
@@ -67,12 +66,12 @@ public class SealedCardPoolGenerator {
|
||||
/** The Land set code. */
|
||||
private String landSetCode = null;
|
||||
|
||||
public static DeckGroup generateSealedDeck(final IGuiBase gui, final boolean addBasicLands) {
|
||||
public static DeckGroup generateSealedDeck(final boolean addBasicLands) {
|
||||
final String prompt = "Choose Sealed Deck Format";
|
||||
final LimitedPoolType poolType = SGuiChoose.oneOrNone(gui, prompt, LimitedPoolType.values());
|
||||
final LimitedPoolType poolType = SGuiChoose.oneOrNone(prompt, LimitedPoolType.values());
|
||||
if (poolType == null) { return null; }
|
||||
|
||||
SealedCardPoolGenerator sd = new SealedCardPoolGenerator(gui, poolType);
|
||||
SealedCardPoolGenerator sd = new SealedCardPoolGenerator(poolType);
|
||||
if (sd.isEmpty()) { return null; }
|
||||
|
||||
final CardPool humanPool = sd.getCardPool(true);
|
||||
@@ -83,10 +82,10 @@ public class SealedCardPoolGenerator {
|
||||
// This seems to be limited by the MAX_DRAFT_PLAYERS constant
|
||||
// in DeckGroupSerializer.java. You could create more AI decks
|
||||
// but only the first seven would load. --BBU
|
||||
Integer rounds = SGuiChoose.getInteger(gui, "How many opponents are you willing to face?", 1, 7);
|
||||
Integer rounds = SGuiChoose.getInteger("How many opponents are you willing to face?", 1, 7);
|
||||
if (rounds == null) { return null; }
|
||||
|
||||
final String sDeckName = SOptionPane.showInputDialog(gui,
|
||||
final String sDeckName = SOptionPane.showInputDialog(
|
||||
"Save this card pool as:",
|
||||
"Save Card Pool",
|
||||
FSkinProp.ICO_QUESTION);
|
||||
@@ -97,7 +96,7 @@ public class SealedCardPoolGenerator {
|
||||
|
||||
final IStorage<DeckGroup> sealedDecks = FModel.getDecks().getSealed();
|
||||
if (sealedDecks.contains(sDeckName)) {
|
||||
if (!SOptionPane.showConfirmDialog(gui,
|
||||
if (!SOptionPane.showConfirmDialog(
|
||||
"'" + sDeckName + "' already exists. Do you want to replace it?",
|
||||
"Sealed Deck Game Exists")) {
|
||||
return null;
|
||||
@@ -155,11 +154,11 @@ public class SealedCardPoolGenerator {
|
||||
* @param poolType
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
private SealedCardPoolGenerator(final IGuiBase gui, final LimitedPoolType poolType) {
|
||||
private SealedCardPoolGenerator(final LimitedPoolType poolType) {
|
||||
switch(poolType) {
|
||||
case Full:
|
||||
// Choose number of boosters
|
||||
if (!chooseNumberOfBoosters(gui, new UnOpenedProduct(SealedProduct.Template.genericBooster))) {
|
||||
if (!chooseNumberOfBoosters(new UnOpenedProduct(SealedProduct.Template.genericBooster))) {
|
||||
return;
|
||||
}
|
||||
landSetCode = CardEdition.Predicates.getRandomSetWithAllBasicLands(FModel.getMagicDb().getEditions()).getCode();
|
||||
@@ -173,7 +172,7 @@ public class SealedCardPoolGenerator {
|
||||
blocks.add(b);
|
||||
}
|
||||
|
||||
final CardBlock block = SGuiChoose.oneOrNone(gui, "Choose Block", blocks);
|
||||
final CardBlock block = SGuiChoose.oneOrNone("Choose Block", blocks);
|
||||
if (block == null) { return; }
|
||||
|
||||
final int nPacks = block.getCntBoostersSealed();
|
||||
@@ -193,7 +192,7 @@ public class SealedCardPoolGenerator {
|
||||
throw new RuntimeException("Unsupported amount of packs (" + nPacks + ") in a Sealed Deck block!");
|
||||
}
|
||||
|
||||
final String p = setCombos.size() > 1 ? SGuiChoose.oneOrNone(gui, "Choose packs to play with", setCombos) : setCombos.get(0);
|
||||
final String p = setCombos.size() > 1 ? SGuiChoose.oneOrNone("Choose packs to play with", setCombos) : setCombos.get(0);
|
||||
if (p == null) { return; }
|
||||
|
||||
for (String pz : TextUtil.split(p, ',')) {
|
||||
@@ -201,12 +200,12 @@ public class SealedCardPoolGenerator {
|
||||
String setCode = pps[pps.length - 1];
|
||||
int nBoosters = pps.length > 1 ? Integer.parseInt(pps[0]) : 1;
|
||||
while (nBoosters-- > 0) {
|
||||
this.product.add(block.getBooster(setCode, gui));
|
||||
this.product.add(block.getBooster(setCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
IUnOpenedProduct prod = block.getBooster(sets.get(0), gui);
|
||||
IUnOpenedProduct prod = block.getBooster(sets.get(0));
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
this.product.add(prod);
|
||||
}
|
||||
@@ -244,16 +243,16 @@ public class SealedCardPoolGenerator {
|
||||
|
||||
// present list to user
|
||||
if (customs.isEmpty()) {
|
||||
SOptionPane.showMessageDialog(gui, "No custom sealed files found.");
|
||||
SOptionPane.showMessageDialog("No custom sealed files found.");
|
||||
return;
|
||||
}
|
||||
|
||||
final CustomLimited draft = SGuiChoose.oneOrNone(gui, "Choose Custom Sealed Pool", customs);
|
||||
final CustomLimited draft = SGuiChoose.oneOrNone("Choose Custom Sealed Pool", customs);
|
||||
if (draft == null) { return; }
|
||||
|
||||
UnOpenedProduct toAdd = new UnOpenedProduct(draft.getSealedProductTemplate(), draft.getCardPool());
|
||||
toAdd.setLimitedPool(draft.isSingleton());
|
||||
if (!chooseNumberOfBoosters(gui, toAdd)) {
|
||||
if (!chooseNumberOfBoosters(toAdd)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -262,8 +261,8 @@ public class SealedCardPoolGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean chooseNumberOfBoosters(final IGuiBase gui, final IUnOpenedProduct product1) {
|
||||
Integer boosterCount = SGuiChoose.getInteger(gui, "How many booster packs?", 3, 12);
|
||||
private boolean chooseNumberOfBoosters(final IUnOpenedProduct product1) {
|
||||
Integer boosterCount = SGuiChoose.getInteger("How many booster packs?", 3, 12);
|
||||
if (boosterCount == null) { return false; }
|
||||
|
||||
for (int i = 0; i < boosterCount; i++) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
@@ -20,9 +19,9 @@ public class WinstonDraft extends BoosterDraft {
|
||||
private Stack<PaperCard> deck; // main deck where all cards
|
||||
private List<List<PaperCard>> piles; // 3 piles to draft from
|
||||
|
||||
public static WinstonDraft createDraft(final IGuiBase gui, final LimitedPoolType draftType) {
|
||||
public static WinstonDraft createDraft(final LimitedPoolType draftType) {
|
||||
WinstonDraft draft = new WinstonDraft(draftType);
|
||||
if (!draft.generateProduct(gui)) {
|
||||
if (!draft.generateProduct()) {
|
||||
return null;
|
||||
}
|
||||
draft.initializeWinstonDraft();
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.ai.LobbyPlayerAi;
|
||||
import forge.card.CardCharacteristicName;
|
||||
@@ -190,7 +189,7 @@ public class MatchUtil {
|
||||
}
|
||||
|
||||
if (humanCount == 0) { //watch game but do not participate
|
||||
LocalGameView gameView = new WatchLocalGame(GuiBase.getInterface(), game);
|
||||
LocalGameView gameView = new WatchLocalGame(game);
|
||||
currentPlayer = sortedPlayers.get(0);
|
||||
gameView.setLocalPlayer(currentPlayer);
|
||||
game.subscribeToEvents(new FControlGameEventHandler(gameView));
|
||||
@@ -206,7 +205,7 @@ public class MatchUtil {
|
||||
controller.openView(sortedPlayers);
|
||||
|
||||
if (humanCount == 0) {
|
||||
playbackControl = new FControlGamePlayback(GuiBase.getInterface(), getGameView());
|
||||
playbackControl = new FControlGamePlayback(getGameView());
|
||||
playbackControl.setGame(game);
|
||||
game.subscribeToEvents(playbackControl);
|
||||
}
|
||||
@@ -226,7 +225,7 @@ public class MatchUtil {
|
||||
boolean isPlayerOneHuman = match.getPlayers().get(0).getPlayer() instanceof LobbyPlayerHuman;
|
||||
boolean isPlayerTwoComputer = match.getPlayers().get(1).getPlayer() instanceof LobbyPlayerAi;
|
||||
if (isPlayerOneHuman && isPlayerTwoComputer) {
|
||||
GamePlayerUtil.setPlayerName(GuiBase.getInterface());
|
||||
GamePlayerUtil.setPlayerName();
|
||||
}
|
||||
}
|
||||
match.startGame(game);
|
||||
@@ -349,7 +348,7 @@ public class MatchUtil {
|
||||
String userPrompt =
|
||||
"This will end the current game and you will not be able to resume.\n\n" +
|
||||
"Concede anyway?";
|
||||
if (SOptionPane.showConfirmDialog(GuiBase.getInterface(), userPrompt, "Concede Game?", "Concede", "Cancel")) {
|
||||
if (SOptionPane.showConfirmDialog(userPrompt, "Concede Game?", "Concede", "Cancel")) {
|
||||
if (humanCount == 0) { // no human? then all players surrender!
|
||||
for (Player p : game.getPlayers()) {
|
||||
p.concede();
|
||||
@@ -488,10 +487,10 @@ public class MatchUtil {
|
||||
in.close();
|
||||
}
|
||||
catch (final FileNotFoundException fnfe) {
|
||||
SOptionPane.showErrorDialog(GuiBase.getInterface(), "File not found: " + filename);
|
||||
SOptionPane.showErrorDialog("File not found: " + filename);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
SOptionPane.showErrorDialog(GuiBase.getInterface(), "Error loading battle setup file!");
|
||||
SOptionPane.showErrorDialog("Error loading battle setup file!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,12 @@ package forge.match.input;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public interface Input {
|
||||
PlayerView getOwner();
|
||||
|
||||
IGuiBase getGui();
|
||||
|
||||
void showMessageInitial();
|
||||
|
||||
boolean selectCard(Card card, ITriggerEvent triggerEvent);
|
||||
|
||||
@@ -26,7 +26,6 @@ import forge.game.card.Card;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.util.ITriggerEvent;
|
||||
@@ -58,9 +57,6 @@ public abstract class InputBase implements java.io.Serializable, Input {
|
||||
public PlayerView getOwner() {
|
||||
return controller.getPlayerView(controller.getPlayer());
|
||||
}
|
||||
public IGuiBase getGui() {
|
||||
return controller.getGui();
|
||||
}
|
||||
|
||||
private boolean finished = false;
|
||||
protected final boolean isFinished() { return finished; }
|
||||
@@ -84,7 +80,7 @@ public abstract class InputBase implements java.io.Serializable, Input {
|
||||
awaitNextInputTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
FThreads.invokeInEdtLater(gameView.getGui(), new Runnable() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (awaitNextInputTimer) {
|
||||
@@ -105,7 +101,7 @@ public abstract class InputBase implements java.io.Serializable, Input {
|
||||
if (gameView == null) { return; }
|
||||
|
||||
cancelAwaitNextInput();
|
||||
FThreads.invokeInEdtNowOrLater(gameView.getGui(), new Runnable() {
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updatePromptForAwait(gameView);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class InputBlock extends InputSyncronizedBase {
|
||||
for (final Card attacker : combat.getAttackers()) {
|
||||
for (final Card c : CardLists.filter(defender.getCardsIn(ZoneType.Battlefield), Presets.CREATURES)) {
|
||||
if (CombatUtil.canBlock(attacker, c, combat)) {
|
||||
FThreads.invokeInEdtNowOrLater(getGui(), new Runnable() { //must set current attacker on EDT
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() { //must set current attacker on EDT
|
||||
@Override
|
||||
public void run() {
|
||||
setCurrentAttacker(attacker);
|
||||
@@ -104,7 +104,7 @@ public class InputBlock extends InputSyncronizedBase {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SGuiDialog.message(getGui(), blockErrors);
|
||||
SGuiDialog.message(blockErrors);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class InputConfirmMulligan extends InputSyncronizedBase {
|
||||
}
|
||||
|
||||
final CardView cView = getController().getCardView(c0);
|
||||
if (isSerumPowder && SGuiDialog.confirm(getGui(), cView, "Use " + cView + "'s ability?")) {
|
||||
if (isSerumPowder && SGuiDialog.confirm(cView, "Use " + cView + "'s ability?")) {
|
||||
cardSelectLocked = true;
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
@@ -7,16 +7,14 @@ import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.util.ThreadUtil;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class InputLockUI implements Input {
|
||||
public class InputLockUI implements Input {
|
||||
private final AtomicInteger iCall = new AtomicInteger();
|
||||
|
||||
private IGuiBase gui;
|
||||
private final InputQueue inputQueue;
|
||||
private final Game game;
|
||||
public InputLockUI(final Game game0, final InputQueue inputQueue0) {
|
||||
@@ -29,15 +27,6 @@ public class InputLockUI implements Input {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiBase getGui() {
|
||||
return gui;
|
||||
}
|
||||
|
||||
public void setGui(final IGuiBase gui0) {
|
||||
gui = gui0;
|
||||
}
|
||||
|
||||
public void showMessageInitial() {
|
||||
int ixCall = 1 + iCall.getAndIncrement();
|
||||
ThreadUtil.delay(500, new InputUpdater(ixCall));
|
||||
@@ -59,7 +48,7 @@ public class InputLockUI implements Input {
|
||||
public void run() {
|
||||
if ( ixCall != iCall.get() || !isActive()) // cancel the message if it's not from latest call or input is gone already
|
||||
return;
|
||||
FThreads.invokeInEdtLater(getGui(), showMessageFromEdt);
|
||||
FThreads.invokeInEdtLater(showMessageFromEdt);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public class InputPassPriority extends InputSyncronizedBase {
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_MANABURN)) {
|
||||
message += " You will take mana burn damage equal to the amount of floating mana lost this way.";
|
||||
}
|
||||
if (SOptionPane.showOptionDialog(getGui(), message, "Mana Floating", SOptionPane.WARNING_ICON, new String[]{"OK", "Cancel"}) == 0) {
|
||||
if (SOptionPane.showOptionDialog(message, "Mana Floating", SOptionPane.WARNING_ICON, new String[]{"OK", "Cancel"}) == 0) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
|
||||
final SpellAbility chosen;
|
||||
if (chosenAbility == null) {
|
||||
chosen = abilities.size() > 1 && choice ? SGuiChoose.one(getGui(), "Choose mana ability", abilities) : abilities.get(0);
|
||||
chosen = abilities.size() > 1 && choice ? SGuiChoose.one("Choose mana ability", abilities) : abilities.get(0);
|
||||
}
|
||||
else {
|
||||
chosen = chosenAbility;
|
||||
@@ -414,7 +414,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
stop();
|
||||
}
|
||||
else {
|
||||
FThreads.invokeInEdtNowOrLater(getGui(), new Runnable() {
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateMessage();
|
||||
|
||||
@@ -3,7 +3,6 @@ package forge.match.input;
|
||||
import forge.control.FControlGamePlayback;
|
||||
import forge.game.Game;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.view.LocalGameView;
|
||||
import forge.view.PlayerView;
|
||||
@@ -16,12 +15,10 @@ public class InputPlaybackControl extends InputSyncronizedBase implements InputS
|
||||
private boolean isPaused = false;
|
||||
private boolean isFast = false;
|
||||
|
||||
private final IGuiBase gui;
|
||||
private final Game game;
|
||||
public InputPlaybackControl(final IGuiBase gui, final Game game, final FControlGamePlayback fControlGamePlayback) {
|
||||
public InputPlaybackControl(final Game game0, final FControlGamePlayback fControlGamePlayback) {
|
||||
super(null);
|
||||
this.gui = gui;
|
||||
this.game = game;
|
||||
game = game0;
|
||||
control = fControlGamePlayback;
|
||||
setPause(false);
|
||||
}
|
||||
@@ -34,10 +31,6 @@ public class InputPlaybackControl extends InputSyncronizedBase implements InputS
|
||||
public PlayerView getOwner() {
|
||||
return getGameView().getLocalPlayerView();
|
||||
}
|
||||
@Override
|
||||
public IGuiBase getGui() {
|
||||
return gui;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.input.InputBase#showMessage()
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class InputProliferate extends InputSelectManyBase<GameEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
CounterType toAdd = choices.size() == 1 ? choices.get(0) : SGuiChoose.one(getGui(), "Select counter type", choices);
|
||||
CounterType toAdd = choices.size() == 1 ? choices.get(0) : SGuiChoose.one("Select counter type", choices);
|
||||
chosenCounters.put(card, toAdd);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import forge.FThreads;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.LocalGameView;
|
||||
@@ -52,10 +51,6 @@ public class InputProxy implements Observer {
|
||||
gameView = gameView0;
|
||||
}
|
||||
|
||||
private IGuiBase getGui() {
|
||||
return gameView.getGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void update(final Observable observable, final Object obj) {
|
||||
final Input nextInput = gameView.getInputQueue().getActualInput(gameView);
|
||||
@@ -75,7 +70,7 @@ public class InputProxy implements Observer {
|
||||
}
|
||||
};
|
||||
|
||||
FThreads.invokeInEdtLater(getGui(), showMessage);
|
||||
FThreads.invokeInEdtLater(showMessage);
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@@ -85,7 +85,6 @@ public class InputQueue extends Observable {
|
||||
MatchUtil.setCurrentPlayer(MatchUtil.players.getKey(input.getOwner().getId()));
|
||||
}
|
||||
inputStack.push(input);
|
||||
inputLock.setGui(input.getGui());
|
||||
InputBase.waitForOtherPlayer();
|
||||
syncPoint();
|
||||
updateObservers();
|
||||
|
||||
@@ -178,7 +178,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(apiBasedMessage);
|
||||
sb.append(card.toString());
|
||||
Integer chosen = SGuiChoose.oneOrNone(getGui(), sb.toString(), choices);
|
||||
Integer chosen = SGuiChoose.oneOrNone(sb.toString(), choices);
|
||||
if (chosen == null) {
|
||||
return true; //still return true since there was a valid choice
|
||||
}
|
||||
@@ -222,7 +222,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(apiBasedMessage);
|
||||
sb.append(player.getName());
|
||||
Integer chosen = SGuiChoose.oneOrNone(getGui(), sb.toString(), choices);
|
||||
Integer chosen = SGuiChoose.oneOrNone(sb.toString(), choices);
|
||||
if (null == chosen) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package forge.match.input;
|
||||
|
||||
import forge.interfaces.IGuiBase;
|
||||
|
||||
public interface InputSynchronized extends Input {
|
||||
void awaitLatchRelease();
|
||||
void relaseLatchWhenGameIsOver();
|
||||
IGuiBase getGui();
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
|
||||
}
|
||||
|
||||
public void awaitLatchRelease() {
|
||||
FThreads.assertExecutedByEdt(getGui(), false);
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
try{
|
||||
cdlDone.await();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
BugReporter.reportException(e, getGui());
|
||||
BugReporter.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
|
||||
onStop();
|
||||
|
||||
// ensure input won't accept any user actions.
|
||||
FThreads.invokeInEdtNowOrLater(getGui(), new Runnable() {
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setFinished();
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.google.common.base.Predicate;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.IUnOpenedProduct;
|
||||
import forge.card.UnOpenedProduct;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.TextUtil;
|
||||
@@ -293,15 +292,9 @@ public final class CardBlock implements Comparable<CardBlock> {
|
||||
|
||||
/**
|
||||
* Tries to create a booster for the selected meta-set code.
|
||||
*
|
||||
* @param code
|
||||
* String, the MetaSet code
|
||||
* @param gui
|
||||
* the {@link IGuiBase} resolving any choices to be made.
|
||||
* @return UnOpenedProduct, the created booster.
|
||||
*/
|
||||
public IUnOpenedProduct getBooster(final String code, final IGuiBase gui) {
|
||||
public IUnOpenedProduct getBooster(final String code) {
|
||||
MetaSet ms = metaSets.get(code);
|
||||
return ms == null ? new UnOpenedProduct(FModel.getMagicDb().getBoosters().get(code)) : ms.getBooster(gui);
|
||||
return ms == null ? new UnOpenedProduct(FModel.getMagicDb().getBoosters().get(code)) : ms.getBooster();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import forge.deck.DeckGroup;
|
||||
import forge.deck.io.DeckGroupSerializer;
|
||||
import forge.deck.io.DeckStorage;
|
||||
import forge.deck.io.OldDeckParser;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.storage.IStorage;
|
||||
import forge.util.storage.StorageImmediatelySerialized;
|
||||
@@ -50,7 +49,7 @@ public class CardCollections {
|
||||
*
|
||||
* @param file the file
|
||||
*/
|
||||
public CardCollections(final IGuiBase gui) {
|
||||
public CardCollections() {
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start();
|
||||
this.constructed = new StorageImmediatelySerialized<Deck>("Constructed decks", new DeckStorage(new File(ForgeConstants.DECK_CONSTRUCTED_DIR), true), true);
|
||||
@@ -66,7 +65,7 @@ public class CardCollections {
|
||||
// int sum = constructed.size() + sealed.size() + draft.size() + cube.size() + scheme.size() + plane.size();
|
||||
// FSkin.setProgessBarMessage(String.format("Loaded %d decks in %f sec", sum, sw.getTime() / 1000f ));
|
||||
// remove this after most people have been switched to new layout
|
||||
final OldDeckParser oldParser = new OldDeckParser(gui, this.constructed, this.draft, this.sealed, this.cube);
|
||||
final OldDeckParser oldParser = new OldDeckParser(this.constructed, this.draft, this.sealed, this.cube);
|
||||
oldParser.tryParse();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import forge.game.GameFormat;
|
||||
import forge.game.GameType;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.gauntlet.GauntletData;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.interfaces.IProgressBar;
|
||||
import forge.itemmanager.ItemManagerConfig;
|
||||
import forge.limited.GauntletMini;
|
||||
@@ -86,7 +85,7 @@ public class FModel {
|
||||
private static IStorage<QuestWorld> worlds;
|
||||
private static GameFormat.Collection formats;
|
||||
|
||||
public static void initialize(final IGuiBase gui, final IProgressBar progressBar) {
|
||||
public static void initialize(final IProgressBar progressBar) {
|
||||
|
||||
// Instantiate preferences: quest and regular
|
||||
//Preferences are initialized first so that the splash screen can be translated.
|
||||
@@ -105,7 +104,7 @@ public class FModel {
|
||||
ProgressObserver.emptyObserver : new ProgressObserver() {
|
||||
@Override
|
||||
public void setOperationName(final String name, final boolean usePercents) {
|
||||
FThreads.invokeInEdtLater(gui, new Runnable() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.setDescription(name);
|
||||
@@ -116,7 +115,7 @@ public class FModel {
|
||||
|
||||
@Override
|
||||
public void report(final int current, final int total) {
|
||||
FThreads.invokeInEdtLater(gui, new Runnable() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.setMaximum(total);
|
||||
@@ -153,7 +152,7 @@ public class FModel {
|
||||
loadDynamicGamedata();
|
||||
|
||||
if (progressBar != null) {
|
||||
FThreads.invokeInEdtLater(gui, new Runnable() {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.setDescription(Localizer.getInstance().getMessage("splash.loading.decks"));
|
||||
@@ -161,8 +160,8 @@ public class FModel {
|
||||
});
|
||||
}
|
||||
|
||||
decks = new CardCollections(gui);
|
||||
quest = new QuestController(gui);
|
||||
decks = new CardCollections();
|
||||
quest = new QuestController();
|
||||
|
||||
CardPreferences.load();
|
||||
DeckPreferences.load();
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.card.IUnOpenedProduct;
|
||||
import forge.card.UnOpenedProduct;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.SealedProduct;
|
||||
@@ -163,7 +162,7 @@ public class MetaSet {
|
||||
*
|
||||
* @return UnOpenedProduct, the generated booster.
|
||||
*/
|
||||
public IUnOpenedProduct getBooster(final IGuiBase gui) {
|
||||
public IUnOpenedProduct getBooster() {
|
||||
|
||||
switch(type) {
|
||||
case Full:
|
||||
@@ -182,7 +181,7 @@ public class MetaSet {
|
||||
Predicate<PaperCard> predicate = IPaperCard.Predicates.printedInSets(data.split(" "));
|
||||
return new UnOpenedProduct(SealedProduct.Template.genericBooster, predicate);
|
||||
|
||||
case Choose: return UnOpenedMeta.choose(data, gui);
|
||||
case Choose: return UnOpenedMeta.choose(data);
|
||||
case Random: return UnOpenedMeta.random(data);
|
||||
case Combo: return UnOpenedMeta.selectAll(data);
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package forge.model;
|
||||
|
||||
import forge.card.IUnOpenedProduct;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.TextUtil;
|
||||
@@ -45,7 +44,6 @@ public class UnOpenedMeta implements IUnOpenedProduct {
|
||||
private final ArrayList<MetaSet> metaSets;
|
||||
private final JoinOperation operation;
|
||||
private final Random generator = MyRandom.getRandom();
|
||||
private final IGuiBase gui;
|
||||
|
||||
/**
|
||||
* Constructor for UnOpenedMeta.
|
||||
@@ -55,12 +53,11 @@ public class UnOpenedMeta implements IUnOpenedProduct {
|
||||
* @param choose
|
||||
* sets the random/choice status.
|
||||
* @param gui
|
||||
* the gui.
|
||||
* the GuiBase.getInterface().
|
||||
*/
|
||||
private UnOpenedMeta(final String creationString, final JoinOperation op, final IGuiBase gui) {
|
||||
private UnOpenedMeta(final String creationString, final JoinOperation op) {
|
||||
metaSets = new ArrayList<MetaSet>();
|
||||
operation = op;
|
||||
this.gui = gui;
|
||||
|
||||
for (String m : TextUtil.splitWithParenthesis(creationString, ';')) {
|
||||
metaSets.add(new MetaSet(m, true));
|
||||
@@ -94,39 +91,39 @@ public class UnOpenedMeta implements IUnOpenedProduct {
|
||||
if (isHuman) {
|
||||
final MetaSet ms;
|
||||
if (allowCancel) {
|
||||
ms = SGuiChoose.oneOrNone(gui, "Choose Booster", metaSets);
|
||||
ms = SGuiChoose.oneOrNone("Choose Booster", metaSets);
|
||||
if (ms == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ms = SGuiChoose.one(gui, "Choose Booster", metaSets);
|
||||
ms = SGuiChoose.one("Choose Booster", metaSets);
|
||||
}
|
||||
return ms.getBooster(gui).get();
|
||||
return ms.getBooster().get();
|
||||
}
|
||||
|
||||
case RandomOne: // AI should fall though here from the case above
|
||||
int selected = generator.nextInt(metaSets.size());
|
||||
final IUnOpenedProduct newBooster = metaSets.get(selected).getBooster(gui);
|
||||
final IUnOpenedProduct newBooster = metaSets.get(selected).getBooster();
|
||||
return newBooster.get();
|
||||
|
||||
case SelectAll:
|
||||
List<PaperCard> allCards = new ArrayList<PaperCard>();
|
||||
for (MetaSet ms : metaSets) {
|
||||
allCards.addAll(ms.getBooster(gui).get());
|
||||
allCards.addAll(ms.getBooster().get());
|
||||
}
|
||||
return allCards;
|
||||
}
|
||||
throw new IllegalStateException("Got wrong operation type in unopenedMeta - execution should never reach this point");
|
||||
}
|
||||
|
||||
public static UnOpenedMeta choose(final String desc, final IGuiBase gui) {
|
||||
return new UnOpenedMeta(desc, JoinOperation.ChooseOne, gui);
|
||||
public static UnOpenedMeta choose(final String desc) {
|
||||
return new UnOpenedMeta(desc, JoinOperation.ChooseOne);
|
||||
}
|
||||
public static UnOpenedMeta random(final String desc) {
|
||||
return new UnOpenedMeta(desc, JoinOperation.RandomOne, null);
|
||||
return new UnOpenedMeta(desc, JoinOperation.RandomOne);
|
||||
}
|
||||
public static UnOpenedMeta selectAll(final String desc) {
|
||||
return new UnOpenedMeta(desc, JoinOperation.SelectAll, null);
|
||||
return new UnOpenedMeta(desc, JoinOperation.SelectAll);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import forge.LobbyPlayer;
|
||||
import forge.ai.AiProfileUtil;
|
||||
import forge.ai.LobbyPlayerAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -18,7 +17,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
public final class GamePlayerUtil {
|
||||
private GamePlayerUtil() { };
|
||||
|
||||
private static final LobbyPlayer guiPlayer = new LobbyPlayerHuman("Human", GuiBase.getInterface());
|
||||
private static final LobbyPlayer guiPlayer = new LobbyPlayerHuman("Human");
|
||||
public static final LobbyPlayer getGuiPlayer() {
|
||||
return guiPlayer;
|
||||
}
|
||||
@@ -32,7 +31,7 @@ public final class GamePlayerUtil {
|
||||
return guiPlayer;
|
||||
}
|
||||
//use separate LobbyPlayerHuman instance for human players beyond first
|
||||
return new LobbyPlayerHuman(name, GuiBase.getInterface());
|
||||
return new LobbyPlayerHuman(name);
|
||||
}
|
||||
|
||||
public static final LobbyPlayer getQuestPlayer() {
|
||||
@@ -72,15 +71,15 @@ public final class GamePlayerUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setPlayerName(final IGuiBase gui) {
|
||||
public static void setPlayerName() {
|
||||
String oldPlayerName = FModel.getPreferences().getPref(FPref.PLAYER_NAME);
|
||||
|
||||
String newPlayerName;
|
||||
if (StringUtils.isBlank(oldPlayerName)) {
|
||||
newPlayerName = getVerifiedPlayerName(getPlayerNameUsingFirstTimePrompt(gui), oldPlayerName);
|
||||
newPlayerName = getVerifiedPlayerName(getPlayerNameUsingFirstTimePrompt(), oldPlayerName);
|
||||
}
|
||||
else {
|
||||
newPlayerName = getVerifiedPlayerName(getPlayerNameUsingStandardPrompt(gui, oldPlayerName), oldPlayerName);
|
||||
newPlayerName = getVerifiedPlayerName(getPlayerNameUsingStandardPrompt(oldPlayerName), oldPlayerName);
|
||||
}
|
||||
|
||||
//update name for player in active game if needed
|
||||
@@ -98,27 +97,27 @@ public final class GamePlayerUtil {
|
||||
FModel.getPreferences().save();
|
||||
|
||||
if (StringUtils.isBlank(oldPlayerName) && !newPlayerName.equals("Human")) {
|
||||
showThankYouPrompt(gui, newPlayerName);
|
||||
showThankYouPrompt(newPlayerName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void showThankYouPrompt(final IGuiBase gui, final String playerName) {
|
||||
SOptionPane.showMessageDialog(gui, "Thank you, " + playerName + ". "
|
||||
private static void showThankYouPrompt(final String playerName) {
|
||||
SOptionPane.showMessageDialog("Thank you, " + playerName + ". "
|
||||
+ "You will not be prompted again but you can change\n"
|
||||
+ "your name at any time using the \"Player Name\" setting in Preferences\n"
|
||||
+ "or via the constructed match setup screen\n");
|
||||
}
|
||||
|
||||
private static String getPlayerNameUsingFirstTimePrompt(final IGuiBase gui) {
|
||||
return SOptionPane.showInputDialog(gui,
|
||||
private static String getPlayerNameUsingFirstTimePrompt() {
|
||||
return SOptionPane.showInputDialog(
|
||||
"By default, Forge will refer to you as the \"Human\" during gameplay.\n" +
|
||||
"If you would prefer a different name please enter it now.",
|
||||
"Personalize Forge Gameplay",
|
||||
SOptionPane.QUESTION_ICON);
|
||||
}
|
||||
|
||||
private static String getPlayerNameUsingStandardPrompt(final IGuiBase gui, final String playerName) {
|
||||
return SOptionPane.showInputDialog(gui,
|
||||
private static String getPlayerNameUsingStandardPrompt(final String playerName) {
|
||||
return SOptionPane.showInputDialog(
|
||||
"Please enter a new name. (alpha-numeric only)",
|
||||
"Personalize Forge Gameplay",
|
||||
null,
|
||||
|
||||
@@ -18,7 +18,6 @@ import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.input.InputSelectCardsFromList;
|
||||
import forge.match.input.InputSelectManyBase;
|
||||
import forge.util.Aggregates;
|
||||
@@ -45,10 +44,6 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
private IGuiBase getGui() {
|
||||
return this.controller.getGui();
|
||||
}
|
||||
|
||||
protected int chooseXValue(final int maxValue) {
|
||||
/*final String chosen = sa.getSVar("ChosenX");
|
||||
if (chosen.length() > 0) {
|
||||
@@ -299,7 +294,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
if (nNeeded == 0) {
|
||||
return PaymentDecision.number(0);
|
||||
}
|
||||
final PlayerView view = SGuiChoose.oneOrNone(getGui(), String.format("Exile from whose %s?", cost.getFrom()),
|
||||
final PlayerView view = SGuiChoose.oneOrNone(String.format("Exile from whose %s?", cost.getFrom()),
|
||||
controller.getPlayerViews(payableZone));
|
||||
final Player p = controller.getPlayer(view);
|
||||
if (p == null) {
|
||||
@@ -311,7 +306,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
if(count < nNeeded)
|
||||
return null;
|
||||
|
||||
List<Card> toExile = SGuiChoose.many(getGui(), "Exile from " + cost.getFrom(), "To be exiled", count - nNeeded, typeList, null);
|
||||
List<Card> toExile = SGuiChoose.many("Exile from " + cost.getFrom(), "To be exiled", count - nNeeded, typeList, null);
|
||||
return PaymentDecision.card(toExile);
|
||||
}
|
||||
|
||||
@@ -358,7 +353,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
List<SpellAbility> exiled = new ArrayList<SpellAbility>();
|
||||
for (int i = 0; i < c; i++) {
|
||||
//Have to use the stack descriptions here because some copied spells have no description otherwise
|
||||
final String o = SGuiChoose.oneOrNone(getGui(), "Exile from Stack", descList);
|
||||
final String o = SGuiChoose.oneOrNone("Exile from Stack", descList);
|
||||
|
||||
if (o != null) {
|
||||
final SpellAbility toExile = saList.get(descList.indexOf(o));
|
||||
@@ -392,7 +387,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
|
||||
List<Card> exiled = new ArrayList<Card>();
|
||||
for (int i = 0; i < nNeeded; i++) {
|
||||
final CardView view = SGuiChoose.oneOrNone(getGui(), "Exile from " + cost.getFrom(), controller.getCardViews(typeList));
|
||||
final CardView view = SGuiChoose.oneOrNone("Exile from " + cost.getFrom(), controller.getCardViews(typeList));
|
||||
final Card c = controller.getCard(view);
|
||||
|
||||
if (c != null) {
|
||||
@@ -427,7 +422,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
if (list.size() < c)
|
||||
return null;
|
||||
|
||||
final List<CardView> choice = SGuiChoose.many(getGui(), "Choose an exiled card to put into graveyard", "To graveyard", c,
|
||||
final List<CardView> choice = SGuiChoose.many("Choose an exiled card to put into graveyard", "To graveyard", c,
|
||||
controller.getCardViews(list), controller.getCardView(source));
|
||||
return PaymentDecision.card(controller.getCards(choice));
|
||||
}
|
||||
@@ -500,7 +495,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(source.getName()).append(" - Choose an opponent to gain ").append(c).append(" life:");
|
||||
|
||||
final PlayerView chosenToGainView = SGuiChoose.oneOrNone(getGui(), sb.toString(), controller.getPlayerViews(oppsThatCanGainLife));
|
||||
final PlayerView chosenToGainView = SGuiChoose.oneOrNone(sb.toString(), controller.getPlayerViews(oppsThatCanGainLife));
|
||||
final Player chosenToGain = controller.getPlayer(chosenToGainView);
|
||||
if (null == chosenToGain)
|
||||
return null;
|
||||
@@ -614,7 +609,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
final List<CardView> viewList = controller.getCardViews(typeList);
|
||||
List<Card> chosen = new ArrayList<>();
|
||||
for (int i = 0; i < nNeeded; i++) {
|
||||
final CardView view = SGuiChoose.oneOrNone(getGui(), "Put from " + fromZone + " to library", viewList);
|
||||
final CardView view = SGuiChoose.oneOrNone("Put from " + fromZone + " to library", viewList);
|
||||
final Card c = controller.getCard(view);
|
||||
|
||||
if (c == null)
|
||||
@@ -632,7 +627,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
}
|
||||
|
||||
final List<PlayerView> players = controller.getPlayerViews(payableZone);
|
||||
final PlayerView pView = SGuiChoose.oneOrNone(getGui(), String.format("Put cards from whose %s?", fromZone), players);
|
||||
final PlayerView pView = SGuiChoose.oneOrNone(String.format("Put cards from whose %s?", fromZone), players);
|
||||
final Player p = controller.getPlayer(pView);
|
||||
if (p == null) {
|
||||
return null;
|
||||
@@ -645,7 +640,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
final List<CardView> viewList = controller.getCardViews(typeList);
|
||||
List<Card> chosen = new ArrayList<>();
|
||||
for (int i = 0; i < nNeeded; i++) {
|
||||
final CardView view = SGuiChoose.oneOrNone(getGui(), "Put cards from " + fromZone + " to Library", viewList);
|
||||
final CardView view = SGuiChoose.oneOrNone("Put cards from " + fromZone + " to Library", viewList);
|
||||
final Card c = controller.getCard(view);
|
||||
|
||||
if (c == null)
|
||||
@@ -821,7 +816,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
}
|
||||
|
||||
String prompt = "Select type counters to remove";
|
||||
cost.setCounterType(SGuiChoose.one(getGui(), prompt, typeChoices));
|
||||
cost.setCounterType(SGuiChoose.one(prompt, typeChoices));
|
||||
|
||||
return PaymentDecision.card(selected, cost.getCounter());
|
||||
}
|
||||
@@ -912,7 +907,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
int maxCounters = source.getCounters(cost.counter);
|
||||
if (amount.equals("All")) {
|
||||
final CardView view = controller.getCardView(ability.getHostCard());
|
||||
if (!SGuiDialog.confirm(getGui(), view, "Remove all counters?")) {
|
||||
if (!SGuiDialog.confirm(view, "Remove all counters?")) {
|
||||
return null;
|
||||
}
|
||||
cntRemoved = maxCounters;
|
||||
@@ -968,7 +963,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
}
|
||||
}
|
||||
|
||||
final CardView view = SGuiChoose.oneOrNone(getGui(), "Remove counter(s) from a card in " + cost.zone, suspended);
|
||||
final CardView view = SGuiChoose.oneOrNone("Remove counter(s) from a card in " + cost.zone, suspended);
|
||||
final Card card = controller.getCard(view);
|
||||
return null == card ? null : PaymentDecision.card(card, c);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class HumanPlay {
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
public final static void playSpellAbility(final PlayerControllerHuman controller, final Player p, SpellAbility sa) {
|
||||
FThreads.assertExecutedByEdt(controller.getGui(), false);
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
|
||||
if (sa == Ability.PLAY_LAND_SURROGATE) {
|
||||
p.playLand(sa.getHostCard(), false);
|
||||
@@ -145,7 +145,7 @@ public class HumanPlay {
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static final void playSaWithoutPayingManaCost(final PlayerControllerHuman controller, final Game game, final SpellAbility sa, boolean mayChooseNewTargets) {
|
||||
FThreads.assertExecutedByEdt(controller.getGui(), false);
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
source.setSplitStateToPlayAbility(sa);
|
||||
@@ -447,7 +447,7 @@ public class HumanPlay {
|
||||
}
|
||||
if (typeChoices.size() > 1) {
|
||||
String cprompt = "Select type counters to remove";
|
||||
counterType = SGuiChoose.one(controller.getGui(), cprompt, typeChoices);
|
||||
counterType = SGuiChoose.one(cprompt, typeChoices);
|
||||
}
|
||||
else {
|
||||
counterType = typeChoices.get(0);
|
||||
@@ -488,7 +488,7 @@ public class HumanPlay {
|
||||
}
|
||||
// replace this with input
|
||||
for (int i = 0; i < nNeeded; i++) {
|
||||
final Card c = SGuiChoose.oneOrNone(controller.getGui(), "Exile from " + from, list);
|
||||
final Card c = SGuiChoose.oneOrNone("Exile from " + from, list);
|
||||
if (c == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -522,7 +522,7 @@ public class HumanPlay {
|
||||
payableZone.add(player);
|
||||
}
|
||||
}
|
||||
Player chosen = SGuiChoose.oneOrNone(controller.getGui(), String.format("Put cards from whose %s?", from), payableZone);
|
||||
Player chosen = SGuiChoose.oneOrNone(String.format("Put cards from whose %s?", from), payableZone);
|
||||
if (chosen == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ public class HumanPlay {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card c = SGuiChoose.oneOrNone(controller.getGui(), "Put cards to Library", typeList);
|
||||
final Card c = SGuiChoose.oneOrNone("Put cards to Library", typeList);
|
||||
|
||||
if (c != null) {
|
||||
typeList.remove(c);
|
||||
|
||||
@@ -5,27 +5,23 @@ import forge.game.Game;
|
||||
import forge.game.player.IGameEntitiesFactory;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerController;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.util.GuiDisplayUtil;
|
||||
|
||||
public class LobbyPlayerHuman extends LobbyPlayer implements IGameEntitiesFactory {
|
||||
final IGuiBase gui;
|
||||
|
||||
public LobbyPlayerHuman(final String name, final IGuiBase gui) {
|
||||
public LobbyPlayerHuman(final String name) {
|
||||
super(name);
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerController createControllerFor(Player human) {
|
||||
return new PlayerControllerHuman(human.getGame(), human, this, gui);
|
||||
return new PlayerControllerHuman(human.getGame(), human, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player createIngamePlayer(Game game, final int id) {
|
||||
Player player = new Player(GuiDisplayUtil.personalizeHuman(getName()), game, id);
|
||||
PlayerControllerHuman controller = new PlayerControllerHuman(game, player, this, gui);
|
||||
PlayerControllerHuman controller = new PlayerControllerHuman(game, player, this);
|
||||
player.setFirstController(controller);
|
||||
controller.getGameView().setLocalPlayer(player);
|
||||
return player;
|
||||
@@ -34,8 +30,4 @@ public class LobbyPlayerHuman extends LobbyPlayer implements IGameEntitiesFactor
|
||||
public void hear(LobbyPlayer player, String message) {
|
||||
MatchUtil.getController().hear(player, message);
|
||||
}
|
||||
|
||||
public IGuiBase getGui() {
|
||||
return this.gui;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.achievement.AchievementCollection;
|
||||
import forge.card.CardCharacteristicName;
|
||||
@@ -79,7 +80,6 @@ import forge.game.trigger.WrappedAbility;
|
||||
import forge.game.zone.MagicStack;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.match.MatchUtil;
|
||||
@@ -127,10 +127,10 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
*/
|
||||
private boolean mayLookAtAllCards = false;
|
||||
|
||||
public PlayerControllerHuman(Game game0, Player p, LobbyPlayer lp, IGuiBase gui) {
|
||||
public PlayerControllerHuman(Game game0, Player p, LobbyPlayer lp) {
|
||||
super(game0, p, lp);
|
||||
if (p.getController() == null || p.getLobbyPlayer() == lp) {
|
||||
gameView = new GameView(gui, game0);
|
||||
gameView = new GameView(game0);
|
||||
}
|
||||
else { //handle the case of one player controlling another
|
||||
for (Player p0 : game.getPlayers()) {
|
||||
@@ -143,10 +143,6 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
}
|
||||
|
||||
public IGuiBase getGui() {
|
||||
return gameView.getGui();
|
||||
}
|
||||
|
||||
public LocalGameView getGameView() {
|
||||
return gameView;
|
||||
}
|
||||
@@ -264,11 +260,11 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
else {
|
||||
errMsg = String.format("Too many cards in your sideboard (maximum %d), please make modifications to your deck again.", sbMax);
|
||||
}
|
||||
SOptionPane.showErrorDialog(getGui(), errMsg, "Invalid Deck");
|
||||
SOptionPane.showErrorDialog(errMsg, "Invalid Deck");
|
||||
}
|
||||
// Sideboard rules have changed for M14, just need to consider min maindeck and max sideboard sizes
|
||||
// No longer need 1:1 sideboarding in non-limited formats
|
||||
newMain = getGui().sideboard(sideboard, main);
|
||||
newMain = GuiBase.getInterface().sideboard(sideboard, main);
|
||||
} while (conform && (newMain.size() < deckMinSize || combinedDeckSize - newMain.size() > sbMax));
|
||||
|
||||
return newMain;
|
||||
@@ -305,7 +301,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
private final boolean assignDamageAsIfNotBlocked(final Card attacker) {
|
||||
return attacker.hasKeyword("CARDNAME assigns its combat damage as though it weren't blocked.")
|
||||
|| (attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")
|
||||
&& SGuiDialog.confirm(getGui(), getCardView(attacker), "Do you want to assign its combat damage as though it weren't blocked?"));
|
||||
&& SGuiDialog.confirm(getCardView(attacker), "Do you want to assign its combat damage as though it weren't blocked?"));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -314,7 +310,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
public Integer announceRequirements(SpellAbility ability, String announce, boolean canChooseZero) {
|
||||
int min = canChooseZero ? 0 : 1;
|
||||
return SGuiChoose.getInteger(getGui(), "Choose " + announce + " for " + ability.getHostCard().getName(),
|
||||
return SGuiChoose.getInteger("Choose " + announce + " for " + ability.getHostCard().getName(),
|
||||
min, Integer.MAX_VALUE, min + 9);
|
||||
}
|
||||
|
||||
@@ -383,7 +379,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
|
||||
tempShowCards(sourceList);
|
||||
final List<CardView> choices = SGuiChoose.many(getGui(), title, "Chosen Cards", min, max, getCardViews(sourceList), getCardView(sa.getHostCard()));
|
||||
final List<CardView> choices = SGuiChoose.many(title, "Chosen Cards", min, max, getCardViews(sourceList), getCardView(sa.getHostCard()));
|
||||
endTempShowCards();
|
||||
|
||||
return getCards(choices);
|
||||
@@ -431,8 +427,8 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
return Iterables.getFirst(input.getSelected(), null);
|
||||
}
|
||||
|
||||
final GameEntityView result = getGui().chooseSingleEntityForEffect(title, optionList, delayedReveal, isOptional, this);
|
||||
endTempShowCards(); //assume tempShow called by getGui().chooseSingleEntityForEffect
|
||||
final GameEntityView result = GuiBase.getInterface().chooseSingleEntityForEffect(title, optionList, delayedReveal, isOptional, this);
|
||||
endTempShowCards(); //assume tempShow called by GuiBase.getInterface().chooseSingleEntityForEffect
|
||||
return (T) gameView.getGameEntity(result);
|
||||
}
|
||||
|
||||
@@ -442,12 +438,12 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
for (int i = 0; i <= max - min; i++) {
|
||||
choices[i] = Integer.valueOf(i + min);
|
||||
}
|
||||
return SGuiChoose.one(getGui(), title, choices).intValue();
|
||||
return SGuiChoose.one(title, choices).intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int chooseNumber(SpellAbility sa, String title, List<Integer> choices, Player relatedPlayer) {
|
||||
return SGuiChoose.one(getGui(), title, choices).intValue();
|
||||
return SGuiChoose.one(title, choices).intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -457,7 +453,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
|
||||
// Human is supposed to read the message and understand from it what to choose
|
||||
final SpellAbilityView choice = SGuiChoose.one(getGui(), title, gameView.getSpellAbilityViews(spells));
|
||||
final SpellAbilityView choice = SGuiChoose.one(title, gameView.getSpellAbilityViews(spells));
|
||||
return gameView.getSpellAbility(choice);
|
||||
}
|
||||
|
||||
@@ -466,18 +462,18 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
*/
|
||||
@Override
|
||||
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
return SGuiDialog.confirm(getGui(), getCardView(sa.getHostCard()), message);
|
||||
return SGuiDialog.confirm(getCardView(sa.getHostCard()), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode bidlife,
|
||||
String string, int bid, Player winner) {
|
||||
return SGuiDialog.confirm(getGui(), getCardView(sa.getHostCard()), string + " Highest Bidder " + winner);
|
||||
return SGuiDialog.confirm(getCardView(sa.getHostCard()), string + " Highest Bidder " + winner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message) {
|
||||
return SGuiDialog.confirm(getGui(), getCardView(hostCard), message);
|
||||
return SGuiDialog.confirm(getCardView(hostCard), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -537,7 +533,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public List<Card> orderBlockers(final Card attacker, final List<Card> blockers) {
|
||||
final CardView vAttacker = getCardView(attacker);
|
||||
MatchUtil.getController().setPanelSelection(vAttacker);
|
||||
final List<CardView> choices = SGuiChoose.order(getGui(), "Choose Damage Order for " + vAttacker, "Damaged First", getCardViews(blockers), vAttacker);
|
||||
final List<CardView> choices = SGuiChoose.order("Choose Damage Order for " + vAttacker, "Damaged First", getCardViews(blockers), vAttacker);
|
||||
return gameView.getCards(choices);
|
||||
}
|
||||
|
||||
@@ -545,7 +541,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public List<Card> orderBlocker(final Card attacker, final Card blocker, final List<Card> oldBlockers) {
|
||||
final CardView vAttacker = getCardView(attacker);
|
||||
MatchUtil.getController().setPanelSelection(vAttacker);
|
||||
final List<CardView> choices = SGuiChoose.insertInList(getGui(), "Choose blocker after which to place " + vAttacker + " in damage order; cancel to place it first", getCardView(blocker), getCardViews(oldBlockers));
|
||||
final List<CardView> choices = SGuiChoose.insertInList("Choose blocker after which to place " + vAttacker + " in damage order; cancel to place it first", getCardView(blocker), getCardViews(oldBlockers));
|
||||
return gameView.getCards(choices);
|
||||
}
|
||||
|
||||
@@ -553,7 +549,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public List<Card> orderAttackers(final Card blocker, final List<Card> attackers) {
|
||||
final CardView vBlocker = getCardView(blocker);
|
||||
MatchUtil.getController().setPanelSelection(vBlocker);
|
||||
final List<CardView> choices = SGuiChoose.order(getGui(), "Choose Damage Order for " + vBlocker, "Damaged First", getCardViews(attackers), vBlocker);
|
||||
final List<CardView> choices = SGuiChoose.order("Choose Damage Order for " + vBlocker, "Damaged First", getCardViews(attackers), vBlocker);
|
||||
return gameView.getCards(choices);
|
||||
}
|
||||
|
||||
@@ -571,11 +567,11 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
String fm = MessageUtil.formatMessage(message, player, owner);
|
||||
if (!cards.isEmpty()) {
|
||||
tempShowCards(cards);
|
||||
SGuiChoose.reveal(getGui(), fm, getCardViews(cards));
|
||||
SGuiChoose.reveal(fm, getCardViews(cards));
|
||||
endTempShowCards();
|
||||
}
|
||||
else {
|
||||
SGuiDialog.message(getGui(), MessageUtil.formatMessage("There are no cards in {player's} " +
|
||||
SGuiDialog.message(MessageUtil.formatMessage("There are no cards in {player's} " +
|
||||
zone.name().toLowerCase(), player, owner), fm);
|
||||
}
|
||||
}
|
||||
@@ -595,7 +591,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
}
|
||||
else {
|
||||
final List<CardView> toBottomViews = SGuiChoose.many(getGui(), "Select cards to be put on the bottom of your library", "Cards to put on the bottom", -1, getCardViews(topN), null);
|
||||
final List<CardView> toBottomViews = SGuiChoose.many("Select cards to be put on the bottom of your library", "Cards to put on the bottom", -1, getCardViews(topN), null);
|
||||
toBottom = gameView.getCards(toBottomViews);
|
||||
topN.removeAll(toBottom);
|
||||
if (topN.isEmpty()) {
|
||||
@@ -605,7 +601,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
toTop = topN;
|
||||
}
|
||||
else {
|
||||
final List<CardView> toTopViews = SGuiChoose.order(getGui(), "Arrange cards to be put on top of your library", "Cards arranged", getCardViews(topN), null);
|
||||
final List<CardView> toTopViews = SGuiChoose.order("Arrange cards to be put on top of your library", "Cards arranged", getCardViews(topN), null);
|
||||
toTop = gameView.getCards(toTopViews);
|
||||
}
|
||||
}
|
||||
@@ -618,7 +614,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
final PaperCard pc = FModel.getMagicDb().getCommonCards().getCard(c.getName());
|
||||
final Card c1 = (pc != null ? Card.fromPaperCard(pc, null) : c);
|
||||
final CardView view = getCardView(c1);
|
||||
return SGuiDialog.confirm(getGui(), view, "Put " + view + " on the top or bottom of your library?", new String[]{"Top", "Bottom"});
|
||||
return SGuiDialog.confirm(view, "Put " + view + " on the top or bottom of your library?", new String[]{"Top", "Bottom"});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -627,22 +623,22 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
tempShowCards(cards);
|
||||
switch (destinationZone) {
|
||||
case Library:
|
||||
choices = SGuiChoose.order(getGui(), "Choose order of cards to put into the library", "Closest to top", getCardViews(cards), null);
|
||||
choices = SGuiChoose.order("Choose order of cards to put into the library", "Closest to top", getCardViews(cards), null);
|
||||
break;
|
||||
case Battlefield:
|
||||
choices = SGuiChoose.order(getGui(), "Choose order of cards to put onto the battlefield", "Put first", getCardViews(cards), null);
|
||||
choices = SGuiChoose.order("Choose order of cards to put onto the battlefield", "Put first", getCardViews(cards), null);
|
||||
break;
|
||||
case Graveyard:
|
||||
choices = SGuiChoose.order(getGui(), "Choose order of cards to put into the graveyard", "Closest to bottom", getCardViews(cards), null);
|
||||
choices = SGuiChoose.order("Choose order of cards to put into the graveyard", "Closest to bottom", getCardViews(cards), null);
|
||||
break;
|
||||
case PlanarDeck:
|
||||
choices = SGuiChoose.order(getGui(), "Choose order of cards to put into the planar deck", "Closest to top", getCardViews(cards), null);
|
||||
choices = SGuiChoose.order("Choose order of cards to put into the planar deck", "Closest to top", getCardViews(cards), null);
|
||||
break;
|
||||
case SchemeDeck:
|
||||
choices = SGuiChoose.order(getGui(), "Choose order of cards to put into the scheme deck", "Closest to top", getCardViews(cards), null);
|
||||
choices = SGuiChoose.order("Choose order of cards to put into the scheme deck", "Closest to top", getCardViews(cards), null);
|
||||
break;
|
||||
case Stack:
|
||||
choices = SGuiChoose.order(getGui(), "Choose order of copies to cast", "Put first", getCardViews(cards), null);
|
||||
choices = SGuiChoose.order("Choose order of copies to cast", "Put first", getCardViews(cards), null);
|
||||
break;
|
||||
default:
|
||||
System.out.println("ZoneType " + destinationZone + " - Not Ordered");
|
||||
@@ -657,7 +653,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public List<Card> chooseCardsToDiscardFrom(Player p, SpellAbility sa, List<Card> valid, int min, int max) {
|
||||
if (p != player) {
|
||||
tempShowCards(valid);
|
||||
final List<CardView> choices = SGuiChoose.many(getGui(), "Choose " + min + " card" + (min != 1 ? "s" : "") + " to discard",
|
||||
final List<CardView> choices = SGuiChoose.many("Choose " + min + " card" + (min != 1 ? "s" : "") + " to discard",
|
||||
"Discarded", min, min, getCardViews(valid), null);
|
||||
endTempShowCards();
|
||||
return getCards(choices);
|
||||
@@ -672,7 +668,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
public void playMiracle(final SpellAbility miracle, final Card card) {
|
||||
final CardView view = getCardView(card);
|
||||
if (SGuiDialog.confirm(getGui(), view, view + " - Drawn. Play for Miracle Cost?")) {
|
||||
if (SGuiDialog.confirm(view, view + " - Drawn. Play for Miracle Cost?")) {
|
||||
HumanPlay.playSpellAbility(this, player, miracle);
|
||||
}
|
||||
}
|
||||
@@ -686,11 +682,11 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
cntChoice[i] = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
final Integer chosenAmount = SGuiChoose.one(getGui(), "Exile how many cards?", cntChoice);
|
||||
final Integer chosenAmount = SGuiChoose.one("Exile how many cards?", cntChoice);
|
||||
System.out.println("Delve for " + chosenAmount);
|
||||
|
||||
for (int i = 0; i < chosenAmount; i++) {
|
||||
final CardView nowChosen = SGuiChoose.oneOrNone(getGui(), "Exile which card?", getCardViews(grave));
|
||||
final CardView nowChosen = SGuiChoose.oneOrNone("Exile which card?", getCardViews(grave));
|
||||
|
||||
if (nowChosen == null) {
|
||||
// User canceled,abort delving.
|
||||
@@ -758,7 +754,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
Mana m = manaChoices.get(i);
|
||||
options.add(String.format("%d. %s mana from %s", 1+i, MagicColor.toLongString(m.getColor()), m.getSourceCard()));
|
||||
}
|
||||
String chosen = SGuiChoose.one(getGui(), "Pay Mana from Mana Pool", options);
|
||||
String chosen = SGuiChoose.one("Pay Mana from Mana Pool", options);
|
||||
String idx = TextUtil.split(chosen, '.')[0];
|
||||
return manaChoices.get(Integer.parseInt(idx)-1);
|
||||
}
|
||||
@@ -773,14 +769,14 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
Iterables.removeAll(types, invalidTypes);
|
||||
}
|
||||
if (isOptional) {
|
||||
return SGuiChoose.oneOrNone(getGui(), "Choose a " + kindOfType.toLowerCase() + " type", types);
|
||||
return SGuiChoose.oneOrNone("Choose a " + kindOfType.toLowerCase() + " type", types);
|
||||
}
|
||||
return SGuiChoose.one(getGui(), "Choose a " + kindOfType.toLowerCase() + " type", types);
|
||||
return SGuiChoose.one("Choose a " + kindOfType.toLowerCase() + " type", types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object vote(SpellAbility sa, String prompt, List<Object> options, ArrayListMultimap<Object, Player> votes) {
|
||||
return SGuiChoose.one(getGui(), prompt, options);
|
||||
return SGuiChoose.one(prompt, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -788,7 +784,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
*/
|
||||
@Override
|
||||
public boolean confirmReplacementEffect(ReplacementEffect replacementEffect, SpellAbility effectSA, String question) {
|
||||
return SGuiDialog.confirm(getGui(), getCardView(replacementEffect.getHostCard()), question);
|
||||
return SGuiDialog.confirm(getCardView(replacementEffect.getHostCard()), question);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -971,7 +967,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
if (srcCards.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
final List<CardView> chosen = SGuiChoose.many(getGui(), "Choose cards to activate from opening hand and their order", "Activate first", -1, getCardViews(srcCards), null);
|
||||
final List<CardView> chosen = SGuiChoose.many("Choose cards to activate from opening hand and their order", "Activate first", -1, getCardViews(srcCards), null);
|
||||
for (final CardView view : chosen) {
|
||||
final Card c = getCard(view);
|
||||
for (SpellAbility sa : usableFromOpeningHand) {
|
||||
@@ -1001,7 +997,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
case PlayOrDraw: labels = new String[]{"Play", "Draw"}; break;
|
||||
default: labels = kindOfChoice.toString().split("Or");
|
||||
}
|
||||
return SGuiDialog.confirm(getGui(), getCardView(sa.getHostCard()), question, defaultVal == null || defaultVal.booleanValue(), labels);
|
||||
return SGuiDialog.confirm(getCardView(sa.getHostCard()), question, defaultVal == null || defaultVal.booleanValue(), labels);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1011,13 +1007,13 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
strResults[i] = labelsSrc[results[i] ? 0 : 1];
|
||||
}
|
||||
return SGuiChoose.one(getGui(), sa.getHostCard().getName() + " - Choose a result", strResults) == labelsSrc[0];
|
||||
return SGuiChoose.one(sa.getHostCard().getName() + " - Choose a result", strResults) == labelsSrc[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card chooseProtectionShield(GameEntity entityBeingDamaged, List<String> options, Map<String, Card> choiceMap) {
|
||||
String title = entityBeingDamaged + " - select which prevention shield to use";
|
||||
return choiceMap.get(SGuiChoose.one(getGui(), title, options));
|
||||
return choiceMap.get(SGuiChoose.one(title, options));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1028,12 +1024,12 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
|
||||
String counterChoiceTitle = "Choose a counter type on " + cardWithCounter;
|
||||
final CounterType chosen = SGuiChoose.one(getGui(), counterChoiceTitle, cardWithCounter.getCounters().keySet());
|
||||
final CounterType chosen = SGuiChoose.one(counterChoiceTitle, cardWithCounter.getCounters().keySet());
|
||||
|
||||
String putOrRemoveTitle = "What to do with that '" + chosen.getName() + "' counter ";
|
||||
final String putString = "Put another " + chosen.getName() + " counter on " + cardWithCounter;
|
||||
final String removeString = "Remove a " + chosen.getName() + " counter from " + cardWithCounter;
|
||||
final String addOrRemove = SGuiChoose.one(getGui(), putOrRemoveTitle, new String[]{putString,removeString});
|
||||
final String addOrRemove = SGuiChoose.one(putOrRemoveTitle, new String[]{putString,removeString});
|
||||
|
||||
return new ImmutablePair<CounterType,String>(chosen,addOrRemove);
|
||||
}
|
||||
@@ -1051,7 +1047,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
};
|
||||
|
||||
List<Pair<SpellAbilityStackInstance, GameObject>> chosen = SGuiChoose.getChoices(getGui(), saSpellskite.getHostCard().getName(), 1, 1, allTargets, null, fnToString);
|
||||
List<Pair<SpellAbilityStackInstance, GameObject>> chosen = SGuiChoose.getChoices(saSpellskite.getHostCard().getName(), 1, 1, allTargets, null, fnToString);
|
||||
return Iterables.getFirst(chosen, null);
|
||||
}
|
||||
|
||||
@@ -1062,7 +1058,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
game.getGameLog().add(GameLogEntryType.LAND, message);
|
||||
}
|
||||
else {
|
||||
SGuiDialog.message(getGui(), message, sa.getHostCard() == null ? "" : getCardView(sa.getHostCard()).toString());
|
||||
SGuiDialog.message(message, sa.getHostCard() == null ? "" : getCardView(sa.getHostCard()).toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1079,10 +1075,10 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
for (int i = 0; i < num; i++) {
|
||||
SpellAbilityView a;
|
||||
if (i < min) {
|
||||
a = SGuiChoose.one(getGui(), modeTitle, choices);
|
||||
a = SGuiChoose.one(modeTitle, choices);
|
||||
}
|
||||
else {
|
||||
a = SGuiChoose.oneOrNone(getGui(), modeTitle, choices);
|
||||
a = SGuiChoose.oneOrNone(modeTitle, choices);
|
||||
}
|
||||
if (a == null) {
|
||||
break;
|
||||
@@ -1096,7 +1092,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
@Override
|
||||
public List<String> chooseColors(String message, SpellAbility sa, int min, int max, List<String> options) {
|
||||
return SGuiChoose.getChoices(getGui(), message, min, max, options);
|
||||
return SGuiChoose.getChoices(message, min, max, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1130,9 +1126,9 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
colorNames[i++] = MagicColor.toLongString(b);
|
||||
}
|
||||
if (colorNames.length > 2) {
|
||||
return MagicColor.fromName(SGuiChoose.one(getGui(), message, colorNames));
|
||||
return MagicColor.fromName(SGuiChoose.one(message, colorNames));
|
||||
}
|
||||
int idxChosen = SGuiDialog.confirm(getGui(), getCardView(c), message, colorNames) ? 0 : 1;
|
||||
int idxChosen = SGuiDialog.confirm(getCardView(c), message, colorNames) ? 0 : 1;
|
||||
return MagicColor.fromName(colorNames[idxChosen]);
|
||||
}
|
||||
|
||||
@@ -1141,7 +1137,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
Iterable<PaperCard> cardsFromDb = FModel.getMagicDb().getCommonCards().getUniqueCards();
|
||||
List<PaperCard> cards = Lists.newArrayList(Iterables.filter(cardsFromDb, cpp));
|
||||
Collections.sort(cards);
|
||||
return SGuiChoose.one(getGui(), message, cards);
|
||||
return SGuiChoose.one(message, cards);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1149,7 +1145,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
if (options.size() <= 1) {
|
||||
return Iterables.getFirst(options, null);
|
||||
}
|
||||
return SGuiChoose.one(getGui(), prompt, options);
|
||||
return SGuiChoose.one(prompt, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1164,12 +1160,12 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
if (possibleReplacers.size() == 1) {
|
||||
return possibleReplacers.get(0);
|
||||
}
|
||||
return SGuiChoose.one(getGui(), prompt, possibleReplacers);
|
||||
return SGuiChoose.one(prompt, possibleReplacers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String chooseProtectionType(String string, SpellAbility sa, List<String> choices) {
|
||||
return SGuiChoose.one(getGui(), string, choices);
|
||||
return SGuiChoose.one(string, choices);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1182,7 +1178,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public void orderAndPlaySimultaneousSa(List<SpellAbility> activePlayerSAs) {
|
||||
List<SpellAbility> orderedSAs = activePlayerSAs;
|
||||
if (activePlayerSAs.size() > 1) { // give a dual list form to create instead of needing to do it one at a time
|
||||
final List<SpellAbilityView> orderedSAViews = SGuiChoose.order(getGui(), "Select order for Simultaneous Spell Abilities", "Resolve first", gameView.getSpellAbilityViews(activePlayerSAs), null);
|
||||
final List<SpellAbilityView> orderedSAViews = SGuiChoose.order("Select order for Simultaneous Spell Abilities", "Resolve first", gameView.getSpellAbilityViews(activePlayerSAs), null);
|
||||
orderedSAs = getSpellAbilities(orderedSAViews);
|
||||
}
|
||||
int size = orderedSAs.size();
|
||||
@@ -1231,7 +1227,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
final String p1Str = String.format("Pile 1 (%s cards)", pile1.size());
|
||||
final String p2Str = String.format("Pile 2 (%s cards)", pile2.size());
|
||||
final String[] possibleValues = { p1Str , p2Str };
|
||||
return SGuiDialog.confirm(getGui(), getCardView(sa.getHostCard()), "Choose a Pile", possibleValues);
|
||||
return SGuiDialog.confirm(getCardView(sa.getHostCard()), "Choose a Pile", possibleValues);
|
||||
}
|
||||
|
||||
tempShowCards(pile1);
|
||||
@@ -1251,7 +1247,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
// make sure Pile 1 or Pile 2 is clicked on
|
||||
boolean result;
|
||||
while (true) {
|
||||
final CardView chosen = SGuiChoose.one(getGui(), "Choose a pile", cards);
|
||||
final CardView chosen = SGuiChoose.one("Choose a pile", cards);
|
||||
if (chosen.equals(pileView1)) {
|
||||
result = true;
|
||||
break;
|
||||
@@ -1269,7 +1265,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
@Override
|
||||
public void revealAnte(String message, Multimap<Player, PaperCard> removedAnteCards) {
|
||||
for (Player p : removedAnteCards.keySet()) {
|
||||
SGuiChoose.reveal(getGui(), message + " from " + Lang.getPossessedObject(MessageUtil.mayBeYou(player, p), "deck"), removedAnteCards.get(p));
|
||||
SGuiChoose.reveal(message + " from " + Lang.getPossessedObject(MessageUtil.mayBeYou(player, p), "deck"), removedAnteCards.get(p));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1282,12 +1278,12 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
for (CardShields shield : c.getShields()) {
|
||||
shields.add(shield);
|
||||
}
|
||||
return SGuiChoose.one(getGui(), "Choose a regeneration shield:", shields);
|
||||
return SGuiChoose.one("Choose a regeneration shield:", shields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaperCard> chooseCardsYouWonToAddToDeck(List<PaperCard> losses) {
|
||||
return SGuiChoose.many(getGui(), "Select cards to add to your deck", "Add these to my deck", 0, losses.size(), losses, null);
|
||||
return SGuiChoose.many("Select cards to add to your deck", "Add these to my deck", 0, losses.size(), losses, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1326,8 +1322,8 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
* What follows are the View methods.
|
||||
*/
|
||||
private class GameView extends LocalGameView {
|
||||
public GameView(IGuiBase gui0, Game game0) {
|
||||
super(gui0, game0);
|
||||
public GameView(Game game0) {
|
||||
super(game0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1403,10 +1399,10 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
return true;
|
||||
}
|
||||
|
||||
FThreads.invokeInEdtNowOrLater(getGui(), new Runnable() {
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SOptionPane.showMessageDialog(getGui(), "Cannot pass priority at this time.");
|
||||
SOptionPane.showMessageDialog("Cannot pass priority at this time.");
|
||||
}
|
||||
});
|
||||
return false;
|
||||
@@ -1720,7 +1716,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public void generateMana() {
|
||||
Player pPriority = game.getPhaseHandler().getPriorityPlayer();
|
||||
if (pPriority == null) {
|
||||
SGuiDialog.message(getGui(), "No player has priority at the moment, so mana cannot be added to their pool.");
|
||||
SGuiDialog.message("No player has priority at the moment, so mana cannot be added to their pool.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1749,7 +1745,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
gamesDir.mkdir();
|
||||
}
|
||||
|
||||
String filename = getGui().showFileDialog("Select Game State File", ForgeConstants.USER_GAMES_DIR);
|
||||
String filename = GuiBase.getInterface().showFileDialog("Select Game State File", ForgeConstants.USER_GAMES_DIR);
|
||||
if (filename == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1792,10 +1788,10 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
in.close();
|
||||
}
|
||||
catch (final FileNotFoundException fnfe) {
|
||||
SOptionPane.showErrorDialog(getGui(), "File not found: " + filename);
|
||||
SOptionPane.showErrorDialog("File not found: " + filename);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
SOptionPane.showErrorDialog(getGui(), "Error loading battle setup file!");
|
||||
SOptionPane.showErrorDialog("Error loading battle setup file!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1807,7 +1803,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
Player pPriority = game.getPhaseHandler().getPriorityPlayer();
|
||||
if (pPriority == null) {
|
||||
SGuiDialog.message(getGui(), "No player has priority at the moment, so game state cannot be setup.");
|
||||
SGuiDialog.message("No player has priority at the moment, so game state cannot be setup.");
|
||||
return;
|
||||
}
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@@ -1909,7 +1905,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public void tutorForCard() {
|
||||
Player pPriority = game.getPhaseHandler().getPriorityPlayer();
|
||||
if (pPriority == null) {
|
||||
SGuiDialog.message(getGui(), "No player has priority at the moment, so their deck can't be tutored from.");
|
||||
SGuiDialog.message("No player has priority at the moment, so their deck can't be tutored from.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1937,14 +1933,14 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
*/
|
||||
public void addCountersToPermanent() {
|
||||
final List<Card> cards = game.getCardsIn(ZoneType.Battlefield);
|
||||
final CardView cardView = SGuiChoose.oneOrNone(getGui(), "Add counters to which card?", getCardViews(cards));
|
||||
final CardView cardView = SGuiChoose.oneOrNone("Add counters to which card?", getCardViews(cards));
|
||||
final Card card = getCard(cardView);
|
||||
if (card == null) { return; }
|
||||
|
||||
final CounterType counter = SGuiChoose.oneOrNone(getGui(), "Which type of counter?", CounterType.values());
|
||||
final CounterType counter = SGuiChoose.oneOrNone("Which type of counter?", CounterType.values());
|
||||
if (counter == null) { return; }
|
||||
|
||||
final Integer count = SGuiChoose.getInteger(getGui(), "How many counters?", 1, Integer.MAX_VALUE, 10);
|
||||
final Integer count = SGuiChoose.getInteger("How many counters?", 1, Integer.MAX_VALUE, 10);
|
||||
if (count == null) { return; }
|
||||
|
||||
card.addCounter(counter, count, false);
|
||||
@@ -1986,11 +1982,11 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
public void setPlayerLife() {
|
||||
final List<Player> players = game.getPlayers();
|
||||
final PlayerView playerView = SGuiChoose.oneOrNone(getGui(), "Set life for which player?", getPlayerViews(players));
|
||||
final PlayerView playerView = SGuiChoose.oneOrNone("Set life for which player?", getPlayerViews(players));
|
||||
final Player player = getPlayer(playerView);
|
||||
if (player == null) { return; }
|
||||
|
||||
final Integer life = SGuiChoose.getInteger(getGui(), "Set life to what?", 0);
|
||||
final Integer life = SGuiChoose.getInteger("Set life to what?", 0);
|
||||
if (life == null) { return; }
|
||||
|
||||
player.setLife(life, null);
|
||||
@@ -1999,7 +1995,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public void winGame() {
|
||||
Input input = gameView.getInputQueue().getInput();
|
||||
if (!(input instanceof InputPassPriority)) {
|
||||
SOptionPane.showMessageDialog(getGui(), "You must have priority to use this feature.", "Win Game", SOptionPane.INFORMATION_ICON);
|
||||
SOptionPane.showMessageDialog("You must have priority to use this feature.", "Win Game", SOptionPane.INFORMATION_ICON);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2018,7 +2014,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
public void addCardToHand() {
|
||||
final List<Player> players = game.getPlayers();
|
||||
final PlayerView pView = SGuiChoose.oneOrNone(getGui(), "Put card in hand for which player?", getPlayerViews(players));
|
||||
final PlayerView pView = SGuiChoose.oneOrNone("Put card in hand for which player?", getPlayerViews(players));
|
||||
final Player p = getPlayer(pView);
|
||||
if (null == p) {
|
||||
return;
|
||||
@@ -2028,7 +2024,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
Collections.sort(cards);
|
||||
|
||||
// use standard forge's list selection dialog
|
||||
final IPaperCard c = SGuiChoose.oneOrNone(getGui(), "Name the card", cards);
|
||||
final IPaperCard c = SGuiChoose.oneOrNone("Name the card", cards);
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
@@ -2040,7 +2036,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
public void addCardToBattlefield() {
|
||||
final List<Player> players = game.getPlayers();
|
||||
final PlayerView pView = SGuiChoose.oneOrNone(getGui(), "Put card in play for which player?", getPlayerViews(players));
|
||||
final PlayerView pView = SGuiChoose.oneOrNone("Put card in play for which player?", getPlayerViews(players));
|
||||
final Player p = getPlayer(pView);
|
||||
if (null == p) {
|
||||
return;
|
||||
@@ -2050,7 +2046,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
Collections.sort(cards);
|
||||
|
||||
// use standard forge's list selection dialog
|
||||
final IPaperCard c = SGuiChoose.oneOrNone(getGui(), "Name the card", cards);
|
||||
final IPaperCard c = SGuiChoose.oneOrNone("Name the card", cards);
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
@@ -2071,7 +2067,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
if (choices.size() == 1) {
|
||||
sa = choices.iterator().next();
|
||||
} else {
|
||||
final SpellAbilityView saView = SGuiChoose.oneOrNone(getGui(), "Choose", getSpellAbilityViews(choices));
|
||||
final SpellAbilityView saView = SGuiChoose.oneOrNone("Choose", getSpellAbilityViews(choices));
|
||||
sa = getSpellAbility(saView);
|
||||
}
|
||||
|
||||
@@ -2091,11 +2087,11 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
public void riggedPlanarRoll() {
|
||||
final List<Player> players = game.getPlayers();
|
||||
final PlayerView playerView = SGuiChoose.oneOrNone(getGui(), "Which player should roll?", getPlayerViews(players));
|
||||
final PlayerView playerView = SGuiChoose.oneOrNone("Which player should roll?", getPlayerViews(players));
|
||||
final Player player = getPlayer(playerView);
|
||||
if (player == null) { return; }
|
||||
|
||||
final PlanarDice res = SGuiChoose.oneOrNone(getGui(), "Choose result", PlanarDice.values());
|
||||
final PlanarDice res = SGuiChoose.oneOrNone("Choose result", PlanarDice.values());
|
||||
if (res == null) { return; }
|
||||
|
||||
System.out.println("Rigging planar dice roll: " + res.toString());
|
||||
@@ -2121,7 +2117,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
Collections.sort(allPlanars);
|
||||
|
||||
// use standard forge's list selection dialog
|
||||
final IPaperCard c = SGuiChoose.oneOrNone(getGui(), "Name the card", allPlanars);
|
||||
final IPaperCard c = SGuiChoose.oneOrNone("Name the card", allPlanars);
|
||||
if (c == null) { return; }
|
||||
final Card forgeCard = Card.fromPaperCard(c, p);
|
||||
|
||||
|
||||
@@ -283,9 +283,9 @@ public class TargetSelection {
|
||||
|
||||
Object chosen = null;
|
||||
if (!choices.isEmpty() && mandatory) {
|
||||
chosen = SGuiChoose.one(controller.getGui(), getTgt().getVTSelection(), choicesFiltered);
|
||||
chosen = SGuiChoose.one(getTgt().getVTSelection(), choicesFiltered);
|
||||
} else {
|
||||
chosen = SGuiChoose.oneOrNone(controller.getGui(), getTgt().getVTSelection(), choicesFiltered);
|
||||
chosen = SGuiChoose.oneOrNone(getTgt().getVTSelection(), choicesFiltered);
|
||||
}
|
||||
if (chosen == null) {
|
||||
return false;
|
||||
@@ -341,7 +341,7 @@ public class TargetSelection {
|
||||
// Not enough targets, cancel targeting
|
||||
return false;
|
||||
} else {
|
||||
final Object madeChoice = SGuiChoose.oneOrNone(controller.getGui(), message, selectOptions);
|
||||
final Object madeChoice = SGuiChoose.oneOrNone(message, selectOptions);
|
||||
if (madeChoice == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import forge.deck.DeckGroup;
|
||||
import forge.game.GameFormat;
|
||||
import forge.game.event.GameEvent;
|
||||
import forge.game.event.GameEventMulligan;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.PreconDeck;
|
||||
import forge.model.FModel;
|
||||
@@ -58,8 +57,6 @@ import forge.util.storage.StorageBase;
|
||||
*
|
||||
*/
|
||||
public class QuestController {
|
||||
|
||||
private final IGuiBase gui;
|
||||
private QuestData model;
|
||||
// gadgets
|
||||
|
||||
@@ -103,12 +100,7 @@ public class QuestController {
|
||||
/** */
|
||||
public static final int MAX_PET_SLOTS = 2;
|
||||
|
||||
public QuestController(final IGuiBase gui) {
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
public final IGuiBase getGui() {
|
||||
return this.gui;
|
||||
public QuestController() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,6 @@ import forge.game.GameRules;
|
||||
import forge.game.GameType;
|
||||
import forge.game.Match;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
@@ -25,7 +24,7 @@ public class QuestDraftUtils {
|
||||
public static boolean aiMatchInProgress = false;
|
||||
private static boolean waitForUserInput = false;
|
||||
|
||||
public static void continueMatch(final Game lastGame, final IGuiBase gui) {
|
||||
public static void continueMatch(final Game lastGame) {
|
||||
if (lastGame.getMatch().isMatchOver()) {
|
||||
matchInProgress = false;
|
||||
}
|
||||
@@ -65,7 +64,7 @@ public class QuestDraftUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void startNextMatch(final IGuiBase gui) {
|
||||
public static void startNextMatch() {
|
||||
|
||||
if (matchups.size() > 0) {
|
||||
return;
|
||||
@@ -88,38 +87,38 @@ public class QuestDraftUtils {
|
||||
switch (currentSet) {
|
||||
|
||||
case 7:
|
||||
addMatchup(0, 1, draft, gui);
|
||||
addMatchup(2, 3, draft, gui);
|
||||
addMatchup(4, 5, draft, gui);
|
||||
addMatchup(6, 7, draft, gui);
|
||||
addMatchup(0, 1, draft);
|
||||
addMatchup(2, 3, draft);
|
||||
addMatchup(4, 5, draft);
|
||||
addMatchup(6, 7, draft);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
addMatchup(2, 3, draft, gui);
|
||||
addMatchup(4, 5, draft, gui);
|
||||
addMatchup(6, 7, draft, gui);
|
||||
addMatchup(2, 3, draft);
|
||||
addMatchup(4, 5, draft);
|
||||
addMatchup(6, 7, draft);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
addMatchup(4, 5, draft, gui);
|
||||
addMatchup(6, 7, draft, gui);
|
||||
addMatchup(4, 5, draft);
|
||||
addMatchup(6, 7, draft);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
addMatchup(6, 7, draft, gui);
|
||||
addMatchup(6, 7, draft);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
addMatchup(8, 9, draft, gui);
|
||||
addMatchup(10, 11, draft, gui);
|
||||
addMatchup(8, 9, draft);
|
||||
addMatchup(10, 11, draft);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
addMatchup(10, 11, draft, gui);
|
||||
addMatchup(10, 11, draft);
|
||||
break;
|
||||
|
||||
case 13:
|
||||
addMatchup(12, 13, draft, gui);
|
||||
addMatchup(12, 13, draft);
|
||||
break;
|
||||
|
||||
case 14:
|
||||
@@ -128,11 +127,11 @@ public class QuestDraftUtils {
|
||||
|
||||
}
|
||||
|
||||
update(gui);
|
||||
update();
|
||||
|
||||
}
|
||||
|
||||
private static void addMatchup(final int player1, final int player2, final QuestEventDraft draft, final IGuiBase gui) {
|
||||
private static void addMatchup(final int player1, final int player2, final QuestEventDraft draft) {
|
||||
|
||||
DraftMatchup matchup = new DraftMatchup();
|
||||
DeckGroup decks = FModel.getQuest().getAssets().getDraftDeckStorage().get(QuestEventDraft.DECK_NAME);
|
||||
@@ -174,7 +173,7 @@ public class QuestDraftUtils {
|
||||
matchups.add(matchup);
|
||||
}
|
||||
|
||||
public static void update(final IGuiBase gui) {
|
||||
public static void update() {
|
||||
if (matchups.isEmpty()) {
|
||||
if (!matchInProgress) {
|
||||
aiMatchInProgress = false;
|
||||
@@ -215,16 +214,14 @@ public class QuestDraftUtils {
|
||||
|
||||
MatchUtil.getController().startNewMatch(new Match(rules, nextMatch.matchStarter));
|
||||
}
|
||||
|
||||
public static void continueMatches(final IGuiBase gui) {
|
||||
|
||||
public static void continueMatches() {
|
||||
waitForUserInput = false;
|
||||
update(gui);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
private static class DraftMatchup {
|
||||
|
||||
private List<RegisteredPlayer> matchStarter = new ArrayList<RegisteredPlayer>();
|
||||
private boolean hasHumanPlayer = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package forge.quest;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardEdition.CardInSet;
|
||||
import forge.card.CardRarity;
|
||||
@@ -24,7 +25,6 @@ import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.BoosterPack;
|
||||
import forge.item.PaperCard;
|
||||
import forge.limited.BoosterDraft;
|
||||
@@ -666,10 +666,10 @@ public class QuestEventDraft {
|
||||
return creditsAvailable < getEntryFee();
|
||||
}
|
||||
|
||||
public BoosterDraft enter(final IGuiBase gui) {
|
||||
public BoosterDraft enter() {
|
||||
FModel.getQuest().getAchievements().setCurrentDraft(this);
|
||||
FModel.getQuest().getAssets().subtractCredits(getEntryFee());
|
||||
return BoosterDraft.createDraft(gui, LimitedPoolType.Block, FModel.getBlocks().get(getBlock()), getBoosterConfiguration());
|
||||
return BoosterDraft.createDraft(LimitedPoolType.Block, FModel.getBlocks().get(getBlock()), getBoosterConfiguration());
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
@@ -806,7 +806,7 @@ public class QuestEventDraft {
|
||||
usedNames.add(event.aiNames[i]);
|
||||
}
|
||||
|
||||
int numberOfIcons = quest.getGui().getAvatarCount();
|
||||
int numberOfIcons = GuiBase.getInterface().getAvatarCount();
|
||||
List<Integer> usedIcons = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
|
||||
@@ -10,10 +10,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.BoosterBox;
|
||||
import forge.item.BoosterPack;
|
||||
import forge.item.BoxedProduct;
|
||||
@@ -151,7 +151,7 @@ public class QuestSpellShop {
|
||||
}
|
||||
};
|
||||
|
||||
public static void buy(IGuiBase gui, Iterable<Entry<InventoryItem, Integer>> items, IItemManager<InventoryItem> shopManager, IItemManager<InventoryItem> inventoryManager, boolean confirmPurchase) {
|
||||
public static void buy(Iterable<Entry<InventoryItem, Integer>> items, IItemManager<InventoryItem> shopManager, IItemManager<InventoryItem> inventoryManager, boolean confirmPurchase) {
|
||||
long totalCost = 0;
|
||||
ItemPool<InventoryItem> itemsToBuy = new ItemPool<InventoryItem>(InventoryItem.class);
|
||||
for (Entry<InventoryItem, Integer> itemEntry : items) {
|
||||
@@ -171,11 +171,11 @@ public class QuestSpellShop {
|
||||
|
||||
long creditsShort = totalCost - FModel.getQuest().getAssets().getCredits();
|
||||
if (creditsShort > 0) {
|
||||
SOptionPane.showMessageDialog(gui, "You need " + creditsShort + " more credits to purchase the following " + suffix.toLowerCase() + ".\n" + displayList, title);
|
||||
SOptionPane.showMessageDialog("You need " + creditsShort + " more credits to purchase the following " + suffix.toLowerCase() + ".\n" + displayList, title);
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirmPurchase && !SOptionPane.showConfirmDialog(gui, "Pay " + totalCost + " credits to purchase the following " +
|
||||
if (confirmPurchase && !SOptionPane.showConfirmDialog("Pay " + totalCost + " credits to purchase the following " +
|
||||
suffix.toLowerCase() + "?\n" + displayList, title, "Buy", "Cancel")) {
|
||||
return;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ public class QuestSpellShop {
|
||||
final List<PaperCard> remainingCards = new ArrayList<>();
|
||||
|
||||
while (((BoxedProduct) booster).boosterPacksRemaining() > 0 && !skipTheRest) {
|
||||
skipTheRest = gui.showBoxedProduct(booster.getName(), "You have found the following cards inside (Booster Pack " + (totalPacks - ((BoxedProduct) booster).boosterPacksRemaining() + 1) + " of " + totalPacks + "):", ((BoxedProduct) booster).getNextBoosterPack());
|
||||
skipTheRest = GuiBase.getInterface().showBoxedProduct(booster.getName(), "You have found the following cards inside (Booster Pack " + (totalPacks - ((BoxedProduct) booster).boosterPacksRemaining() + 1) + " of " + totalPacks + "):", ((BoxedProduct) booster).getNextBoosterPack());
|
||||
}
|
||||
|
||||
if (skipTheRest) {
|
||||
@@ -231,12 +231,12 @@ public class QuestSpellShop {
|
||||
remainingCards.addAll(((BoxedProduct) booster).getExtraCards());
|
||||
|
||||
if (remainingCards.size() > 0) {
|
||||
gui.showCardList(booster.getName(), "You have found the following cards inside:", remainingCards);
|
||||
GuiBase.getInterface().showCardList(booster.getName(), "You have found the following cards inside:", remainingCards);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
gui.showCardList(booster.getName(), "You have found the following cards inside:", newCards);
|
||||
GuiBase.getInterface().showCardList(booster.getName(), "You have found the following cards inside:", newCards);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ public class QuestSpellShop {
|
||||
}
|
||||
|
||||
boolean one = (qty == 1);
|
||||
SOptionPane.showMessageDialog(gui, String.format(
|
||||
SOptionPane.showMessageDialog(String.format(
|
||||
"%s '%s' %s added to your decklist.%n%n%s cards were also added to your pool.",
|
||||
one ? "Deck" : String.format("%d copies of deck", qty),
|
||||
deck.getName(), one ? "was" : "were", one ? "Its" : "Their"),
|
||||
@@ -261,7 +261,7 @@ public class QuestSpellShop {
|
||||
inventoryManager.addItems(itemsToAdd);
|
||||
}
|
||||
|
||||
public static void sell(final IGuiBase gui, Iterable<Entry<InventoryItem, Integer>> items, IItemManager<InventoryItem> shopManager, IItemManager<InventoryItem> inventoryManager, boolean confirmSale) {
|
||||
public static void sell(Iterable<Entry<InventoryItem, Integer>> items, IItemManager<InventoryItem> shopManager, IItemManager<InventoryItem> inventoryManager, boolean confirmSale) {
|
||||
long totalReceived = 0;
|
||||
ItemPool<InventoryItem> itemsToSell = new ItemPool<InventoryItem>(InventoryItem.class);
|
||||
for (Entry<InventoryItem, Integer> itemEntry : items) {
|
||||
@@ -280,7 +280,7 @@ public class QuestSpellShop {
|
||||
String displayList = SItemManagerUtil.buildDisplayList(itemsToSell);
|
||||
String title = "Sell " + suffix;
|
||||
|
||||
if (!SOptionPane.showConfirmDialog(gui, "Sell the following " + suffix.toLowerCase() + " for " + totalReceived +
|
||||
if (!SOptionPane.showConfirmDialog("Sell the following " + suffix.toLowerCase() + " for " + totalReceived +
|
||||
" credit" + (totalReceived != 1 ? "s" : "") + "?\n" + displayList, title, "Sell", "Cancel")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.card.CardDb.SetPreference;
|
||||
@@ -35,7 +36,6 @@ import forge.game.Match;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.interfaces.IButton;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperToken;
|
||||
import forge.match.MatchUtil;
|
||||
@@ -193,8 +193,8 @@ public class QuestUtil {
|
||||
return FModel.getMagicDb().getCommonCards().getCardFromEdition(name, SetPreference.Latest);
|
||||
}
|
||||
|
||||
public static void travelWorld(final IGuiBase gui) {
|
||||
if (!checkActiveQuest(gui, "Travel between worlds.")) {
|
||||
public static void travelWorld() {
|
||||
if (!checkActiveQuest("Travel between worlds.")) {
|
||||
return;
|
||||
}
|
||||
List<QuestWorld> worlds = new ArrayList<QuestWorld>();
|
||||
@@ -207,12 +207,12 @@ public class QuestUtil {
|
||||
}
|
||||
|
||||
if (worlds.size() < 1) {
|
||||
SOptionPane.showErrorDialog(gui, "There are currently no worlds you can travel to\nin this version of Forge.", "No Worlds");
|
||||
SOptionPane.showErrorDialog("There are currently no worlds you can travel to\nin this version of Forge.", "No Worlds");
|
||||
return;
|
||||
}
|
||||
|
||||
final String setPrompt = "Where do you wish to travel?";
|
||||
final QuestWorld newWorld = SGuiChoose.oneOrNone(gui, setPrompt, worlds);
|
||||
final QuestWorld newWorld = SGuiChoose.oneOrNone(setPrompt, worlds);
|
||||
|
||||
if (worlds.indexOf(newWorld) < 0) {
|
||||
return;
|
||||
@@ -223,7 +223,7 @@ public class QuestUtil {
|
||||
if (nextChallengeInWins() < 1 && qCtrl.getAchievements().getCurrentChallenges().size() > 0) {
|
||||
needRemove = true;
|
||||
|
||||
if (!SOptionPane.showConfirmDialog(gui,
|
||||
if (!SOptionPane.showConfirmDialog(
|
||||
"You have uncompleted challenges in your current world. If you travel now, they will be LOST!"
|
||||
+ "\nAre you sure you wish to travel anyway?\n"
|
||||
+ "(Click \"No\" to go back and complete your current challenges first.)",
|
||||
@@ -468,11 +468,11 @@ public class QuestUtil {
|
||||
return draftEvent;
|
||||
}
|
||||
|
||||
public static boolean checkActiveQuest(final IGuiBase gui, final String location) {
|
||||
public static boolean checkActiveQuest(final String location) {
|
||||
QuestController qc = FModel.getQuest();
|
||||
if (qc == null || qc.getAssets() == null) {
|
||||
String msg = "Please create a Quest before attempting to " + location;
|
||||
SOptionPane.showErrorDialog(gui, msg, "No Quest");
|
||||
SOptionPane.showErrorDialog(msg, "No Quest");
|
||||
System.out.println(msg);
|
||||
return false;
|
||||
}
|
||||
@@ -480,24 +480,24 @@ public class QuestUtil {
|
||||
}
|
||||
|
||||
/** */
|
||||
public static void showSpellShop(final IGuiBase gui) {
|
||||
if (!checkActiveQuest(gui, "Visit the Spell Shop.")) {
|
||||
public static void showSpellShop() {
|
||||
if (!checkActiveQuest("Visit the Spell Shop.")) {
|
||||
return;
|
||||
}
|
||||
gui.showSpellShop();
|
||||
GuiBase.getInterface().showSpellShop();
|
||||
}
|
||||
|
||||
/** */
|
||||
public static void showBazaar(final IGuiBase gui) {
|
||||
if (!checkActiveQuest(gui, "Visit the Bazaar.")) {
|
||||
public static void showBazaar() {
|
||||
if (!checkActiveQuest("Visit the Bazaar.")) {
|
||||
return;
|
||||
}
|
||||
gui.showBazaar();
|
||||
GuiBase.getInterface().showBazaar();
|
||||
}
|
||||
|
||||
/** */
|
||||
public static void chooseAndUnlockEdition(final IGuiBase gui) {
|
||||
if (!checkActiveQuest(gui, "Unlock Editions.")) {
|
||||
public static void chooseAndUnlockEdition() {
|
||||
if (!checkActiveQuest("Unlock Editions.")) {
|
||||
return;
|
||||
}
|
||||
final QuestController qData = FModel.getQuest();
|
||||
@@ -508,19 +508,19 @@ public class QuestUtil {
|
||||
|
||||
CardEdition unlocked = toUnlock.left;
|
||||
qData.getAssets().subtractCredits(toUnlock.right);
|
||||
SOptionPane.showMessageDialog(gui, "You have successfully unlocked " + unlocked.getName() + "!",
|
||||
SOptionPane.showMessageDialog("You have successfully unlocked " + unlocked.getName() + "!",
|
||||
unlocked.getName() + " unlocked!", null);
|
||||
|
||||
QuestUtilUnlockSets.doUnlock(gui, qData, unlocked);
|
||||
QuestUtilUnlockSets.doUnlock(qData, unlocked);
|
||||
}
|
||||
|
||||
public static void startGame(final IGuiBase gui) {
|
||||
if (canStartGame(gui)) {
|
||||
finishStartingGame(gui);
|
||||
public static void startGame() {
|
||||
if (canStartGame()) {
|
||||
finishStartingGame();
|
||||
}
|
||||
}
|
||||
|
||||
public static void finishStartingGame(final IGuiBase gui) {
|
||||
public static void finishStartingGame() {
|
||||
final QuestController qData = FModel.getQuest();
|
||||
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@@ -569,7 +569,7 @@ public class QuestUtil {
|
||||
starter.add(humanStart.setPlayer(GamePlayerUtil.getQuestPlayer()));
|
||||
|
||||
LobbyPlayer aiPlayer = GamePlayerUtil.createAiPlayer(event.getOpponent() == null ? event.getTitle() : event.getOpponent());
|
||||
gui.setPlayerAvatar(aiPlayer, event);
|
||||
GuiBase.getInterface().setPlayerAvatar(aiPlayer, event);
|
||||
starter.add(aiStart.setPlayer(aiPlayer));
|
||||
|
||||
boolean useRandomFoil = FModel.getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL);
|
||||
@@ -587,7 +587,7 @@ public class QuestUtil {
|
||||
rules.setManaBurn(FModel.getPreferences().getPrefBoolean(FPref.UI_MANABURN));
|
||||
rules.canCloneUseTargetsImage = FModel.getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE);
|
||||
final Match mc = new Match(rules, starter);
|
||||
FThreads.invokeInEdtNowOrLater(gui, new Runnable(){
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.startGame(mc);
|
||||
@@ -612,15 +612,15 @@ public class QuestUtil {
|
||||
* Checks to see if a game can be started and displays relevant dialogues.
|
||||
* @return
|
||||
*/
|
||||
public static boolean canStartGame(final IGuiBase gui) {
|
||||
if (!checkActiveQuest(gui, "Start a duel.") || null == event) {
|
||||
public static boolean canStartGame() {
|
||||
if (!checkActiveQuest("Start a duel.") || null == event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Deck deck = getDeckForNewGame();
|
||||
if (deck == null) {
|
||||
String msg = "Please select a Quest Deck.";
|
||||
SOptionPane.showErrorDialog(gui, msg, "No Deck");
|
||||
SOptionPane.showErrorDialog(msg, "No Deck");
|
||||
System.out.println(msg);
|
||||
return false;
|
||||
}
|
||||
@@ -628,7 +628,7 @@ public class QuestUtil {
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) {
|
||||
String errorMessage = GameType.Quest.getDeckFormat().getDeckConformanceProblem(deck);
|
||||
if (null != errorMessage) {
|
||||
SOptionPane.showErrorDialog(gui, "Your deck " + errorMessage + " Please edit or choose a different deck.", "Invalid Deck");
|
||||
SOptionPane.showErrorDialog("Your deck " + errorMessage + " Please edit or choose a different deck.", "Invalid Deck");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.UnOpenedProduct;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.SealedProduct;
|
||||
import forge.model.FModel;
|
||||
@@ -82,7 +82,7 @@ public class QuestUtilUnlockSets {
|
||||
options.add(String.format("%s [PRICE: %d credits]", ee.left.getName(), ee.right));
|
||||
}
|
||||
|
||||
int index = options.indexOf(SGuiChoose.oneOrNone(qData.getGui(), setPrompt, options));
|
||||
int index = options.indexOf(SGuiChoose.oneOrNone(setPrompt, options));
|
||||
if (index < 0 || index >= options.size()) {
|
||||
return null;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class QuestUtilUnlockSets {
|
||||
CardEdition choosenEdition = toBuy.left;
|
||||
|
||||
if (qData.getAssets().getCredits() < price) {
|
||||
SOptionPane.showMessageDialog(qData.getGui(),
|
||||
SOptionPane.showMessageDialog(
|
||||
"Unfortunately, you cannot afford that set yet.\n"
|
||||
+ "To unlock " + choosenEdition.getName() + ", you need " + price + " credits.\n"
|
||||
+ "You have only " + qData.getAssets().getCredits() + " credits.",
|
||||
@@ -102,7 +102,7 @@ public class QuestUtilUnlockSets {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!SOptionPane.showConfirmDialog(qData.getGui(),
|
||||
if (!SOptionPane.showConfirmDialog(
|
||||
"Unlocking " + choosenEdition.getName() + " will cost you " + price + " credits.\n"
|
||||
+ "You have " + qData.getAssets().getCredits() + " credits.\n\n"
|
||||
+ "Are you sure you want to unlock " + choosenEdition.getName() + "?",
|
||||
@@ -179,7 +179,7 @@ public class QuestUtilUnlockSets {
|
||||
* @param qData the quest controller
|
||||
* @param unlockedSet the edition to unlock
|
||||
*/
|
||||
public static void doUnlock(final IGuiBase gui, final QuestController qData, final CardEdition unlockedSet) {
|
||||
public static void doUnlock(final QuestController qData, final CardEdition unlockedSet) {
|
||||
IStorage<SealedProduct.Template> starters = FModel.getMagicDb().getTournamentPacks();
|
||||
IStorage<SealedProduct.Template> boosters = FModel.getMagicDb().getBoosters();
|
||||
qData.getFormat().unlockSet(unlockedSet.getCode());
|
||||
@@ -198,7 +198,7 @@ public class QuestUtilUnlockSets {
|
||||
}
|
||||
|
||||
qData.getCards().addAllCards(cardsWon);
|
||||
gui.showCardList(unlockedSet.getName(), "You get the following bonus cards:", cardsWon);
|
||||
GuiBase.getInterface().showCardList(unlockedSet.getName(), "You get the following bonus cards:", cardsWon);
|
||||
qData.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import forge.game.player.GameLossReason;
|
||||
import forge.game.player.PlayerOutcome;
|
||||
import forge.game.player.PlayerStatistics;
|
||||
import forge.interfaces.IButton;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.interfaces.IWinLoseView;
|
||||
import forge.item.*;
|
||||
import forge.model.FModel;
|
||||
@@ -37,15 +36,13 @@ import java.util.Map.Entry;
|
||||
|
||||
public abstract class QuestWinLoseController {
|
||||
private final IGameView lastGame;
|
||||
protected final IGuiBase gui;
|
||||
private final transient boolean wonMatch;
|
||||
private final transient boolean isAnte;
|
||||
private final transient QuestController qData;
|
||||
private final transient QuestEvent qEvent;
|
||||
|
||||
public QuestWinLoseController(final IGameView game0, final IGuiBase gui) {
|
||||
public QuestWinLoseController(final IGameView game0) {
|
||||
lastGame = game0;
|
||||
this.gui = gui;
|
||||
qData = FModel.getQuest();
|
||||
qEvent = qData.getCurrentEvent();
|
||||
wonMatch = lastGame.isMatchWonBy(GamePlayerUtil.getQuestPlayer());
|
||||
@@ -507,7 +504,7 @@ public abstract class QuestWinLoseController {
|
||||
|
||||
Collections.sort(formats);
|
||||
|
||||
final GameFormat selected = SGuiChoose.getChoices(gui, "Choose bonus booster format", 1, 1, formats, pref, null).get(0);
|
||||
final GameFormat selected = SGuiChoose.getChoices("Choose bonus booster format", 1, 1, formats, pref, null).get(0);
|
||||
FModel.getQuestPreferences().setPref(QPref.BOOSTER_FORMAT, selected.toString());
|
||||
|
||||
cardsWon = qData.getCards().generateQuestBooster(selected.getFilterPrinted());
|
||||
@@ -544,7 +541,7 @@ public abstract class QuestWinLoseController {
|
||||
maxChoices--;
|
||||
}
|
||||
|
||||
final CardEdition chooseEd = SGuiChoose.one(gui, "Choose bonus booster set", options);
|
||||
final CardEdition chooseEd = SGuiChoose.one("Choose bonus booster set", options);
|
||||
|
||||
IUnOpenedProduct product = new UnOpenedProduct(FModel.getMagicDb().getBoosters().get(chooseEd.getCode()));
|
||||
cardsWon = product.get();
|
||||
@@ -635,7 +632,7 @@ public abstract class QuestWinLoseController {
|
||||
}
|
||||
else if (ii instanceof IQuestRewardCard) {
|
||||
final List<PaperCard> cardChoices = ((IQuestRewardCard) ii).getChoices();
|
||||
final PaperCard chosenCard = (null == cardChoices ? null : SGuiChoose.one(gui, "Choose " + ((IQuestRewardCard) ii).getName(), cardChoices));
|
||||
final PaperCard chosenCard = (null == cardChoices ? null : SGuiChoose.one("Choose " + ((IQuestRewardCard) ii).getName(), cardChoices));
|
||||
if (null != chosenCard) {
|
||||
cardsWon.add(chosenCard);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.google.common.eventbus.Subscribe;
|
||||
import forge.GuiBase;
|
||||
import forge.events.UiEvent;
|
||||
import forge.game.event.GameEvent;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.properties.ForgeConstants;
|
||||
@@ -20,7 +19,7 @@ import forge.properties.ForgePreferences.FPref;
|
||||
*
|
||||
*/
|
||||
public class SoundSystem {
|
||||
public static final SoundSystem instance = new SoundSystem(GuiBase.getInterface());
|
||||
public static final SoundSystem instance = new SoundSystem();
|
||||
|
||||
public static final int DELAY = 30;
|
||||
|
||||
@@ -28,11 +27,9 @@ public class SoundSystem {
|
||||
private static final Map<SoundEffectType, IAudioClip> loadedClips = new EnumMap<SoundEffectType, IAudioClip>(SoundEffectType.class);
|
||||
private static final Map<String, IAudioClip> loadedScriptClips = new HashMap<String, IAudioClip>();
|
||||
|
||||
private final IGuiBase gui;
|
||||
private final EventVisualizer visualizer;
|
||||
|
||||
private SoundSystem(final IGuiBase gui) {
|
||||
this.gui = gui;
|
||||
private SoundSystem() {
|
||||
this.visualizer = new EventVisualizer(GamePlayerUtil.getGuiPlayer());
|
||||
}
|
||||
private boolean isUsingAltSystem() {
|
||||
@@ -54,7 +51,7 @@ public class SoundSystem {
|
||||
IAudioClip clip = loadedClips.get(type);
|
||||
if (clip == null) { // cache miss
|
||||
String resource = type.getResourceFileName();
|
||||
clip = gui.createAudioClip(resource);
|
||||
clip = GuiBase.getInterface().createAudioClip(resource);
|
||||
if (clip == null) {
|
||||
clip = emptySound;
|
||||
}
|
||||
@@ -76,7 +73,7 @@ public class SoundSystem {
|
||||
|
||||
IAudioClip clip = loadedScriptClips.get(fileName);
|
||||
if (null == clip) { // cache miss
|
||||
clip = gui.createAudioClip(fileName);
|
||||
clip = GuiBase.getInterface().createAudioClip(fileName);
|
||||
if (clip == null) {
|
||||
clip = emptySound;
|
||||
}
|
||||
@@ -91,7 +88,7 @@ public class SoundSystem {
|
||||
*/
|
||||
public void play(String resourceFileName, boolean isSynchronized) {
|
||||
if (isUsingAltSystem()) {
|
||||
gui.startAltSoundSystem(ForgeConstants.SOUND_DIR + resourceFileName, isSynchronized);
|
||||
GuiBase.getInterface().startAltSoundSystem(ForgeConstants.SOUND_DIR + resourceFileName, isSynchronized);
|
||||
}
|
||||
else {
|
||||
IAudioClip snd = fetchResource(resourceFileName);
|
||||
@@ -106,7 +103,7 @@ public class SoundSystem {
|
||||
*/
|
||||
public void play(SoundEffectType type, boolean isSynchronized) {
|
||||
if (isUsingAltSystem()) {
|
||||
gui.startAltSoundSystem(ForgeConstants.SOUND_DIR + type.getResourceFileName(), isSynchronized);
|
||||
GuiBase.getInterface().startAltSoundSystem(ForgeConstants.SOUND_DIR + type.getResourceFileName(), isSynchronized);
|
||||
}
|
||||
else {
|
||||
IAudioClip snd = fetchResource(type);
|
||||
@@ -192,7 +189,7 @@ public class SoundSystem {
|
||||
if (filename == null) { return; }
|
||||
|
||||
try {
|
||||
currentTrack = gui.createAudioMusic(filename);
|
||||
currentTrack = GuiBase.getInterface().createAudioMusic(filename);
|
||||
currentTrack.play(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.GuiBase;
|
||||
import forge.view.CardView;
|
||||
|
||||
public class SGuiChoose {
|
||||
@@ -31,19 +31,19 @@ public class SGuiChoose {
|
||||
* getChoices.
|
||||
* @see #getChoices(String, int, int, Object...)
|
||||
*/
|
||||
public static <T> T oneOrNone(final IGuiBase gui, final String message, final T[] choices) {
|
||||
public static <T> T oneOrNone(final String message, final T[] choices) {
|
||||
if ((choices == null) || (choices.length == 0)) {
|
||||
return null;
|
||||
}
|
||||
final List<T> choice = SGuiChoose.getChoices(gui, message, 0, 1, choices);
|
||||
final List<T> choice = SGuiChoose.getChoices(message, 0, 1, choices);
|
||||
return choice.isEmpty() ? null : choice.get(0);
|
||||
}
|
||||
|
||||
public static <T> T oneOrNone(final IGuiBase gui, final String message, final Collection<T> choices) {
|
||||
public static <T> T oneOrNone(final String message, final Collection<T> choices) {
|
||||
if ((choices == null) || choices.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final List<T> choice = SGuiChoose.getChoices(gui, message, 0, 1, choices);
|
||||
final List<T> choice = SGuiChoose.getChoices(message, 0, 1, choices);
|
||||
return choice.isEmpty() ? null : choice.get(0);
|
||||
}
|
||||
|
||||
@@ -61,13 +61,13 @@ public class SGuiChoose {
|
||||
* a T object.
|
||||
* @return a T object.
|
||||
*/
|
||||
public static <T> T one(final IGuiBase gui, final String message, final T[] choices) {
|
||||
final List<T> choice = SGuiChoose.getChoices(gui, message, 1, 1, choices);
|
||||
public static <T> T one(final String message, final T[] choices) {
|
||||
final List<T> choice = SGuiChoose.getChoices(message, 1, 1, choices);
|
||||
assert choice.size() == 1;
|
||||
return choice.get(0);
|
||||
}
|
||||
|
||||
public static <T> T one(final IGuiBase gui, final String message, final Collection<T> choices) {
|
||||
public static <T> T one(final String message, final Collection<T> choices) {
|
||||
if (choices == null || choices.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -75,48 +75,48 @@ public class SGuiChoose {
|
||||
return Iterables.getFirst(choices, null);
|
||||
}
|
||||
|
||||
final List<T> choice = SGuiChoose.getChoices(gui, message, 1, 1, choices);
|
||||
final List<T> choice = SGuiChoose.getChoices(message, 1, 1, choices);
|
||||
assert choice.size() == 1;
|
||||
return choice.get(0);
|
||||
}
|
||||
|
||||
public static <T> List<T> noneOrMany(final IGuiBase gui, final String message, final Collection<T> choices) {
|
||||
return SGuiChoose.getChoices(gui, message, 0, choices.size(), choices, null, null);
|
||||
public static <T> List<T> noneOrMany(final String message, final Collection<T> choices) {
|
||||
return SGuiChoose.getChoices(message, 0, choices.size(), choices, null, null);
|
||||
}
|
||||
|
||||
// Nothing to choose here. Code uses this to just reveal one or more items
|
||||
public static <T> void reveal(final IGuiBase gui, final String message, final T item) {
|
||||
public static <T> void reveal(final String message, final T item) {
|
||||
List<T> items = new ArrayList<T>();
|
||||
items.add(item);
|
||||
reveal(gui, message, items);
|
||||
reveal(message, items);
|
||||
}
|
||||
public static <T> void reveal(final IGuiBase gui, final String message, final T[] items) {
|
||||
SGuiChoose.getChoices(gui, message, -1, -1, items);
|
||||
public static <T> void reveal(final String message, final T[] items) {
|
||||
SGuiChoose.getChoices(message, -1, -1, items);
|
||||
}
|
||||
public static <T> void reveal(final IGuiBase gui, final String message, final Collection<T> items) {
|
||||
SGuiChoose.getChoices(gui, message, -1, -1, items);
|
||||
public static <T> void reveal(final String message, final Collection<T> items) {
|
||||
SGuiChoose.getChoices(message, -1, -1, items);
|
||||
}
|
||||
|
||||
// Get Integer in range
|
||||
public static Integer getInteger(final IGuiBase gui, final String message) {
|
||||
return getInteger(gui, message, 0, Integer.MAX_VALUE, false);
|
||||
public static Integer getInteger(final String message) {
|
||||
return getInteger(message, 0, Integer.MAX_VALUE, false);
|
||||
}
|
||||
public static Integer getInteger(final IGuiBase gui, final String message, int min) {
|
||||
return getInteger(gui, message, min, Integer.MAX_VALUE, false);
|
||||
public static Integer getInteger(final String message, int min) {
|
||||
return getInteger(message, min, Integer.MAX_VALUE, false);
|
||||
}
|
||||
public static Integer getInteger(final IGuiBase gui, final String message, int min, int max) {
|
||||
return getInteger(gui, message, min, max, false);
|
||||
public static Integer getInteger(final String message, int min, int max) {
|
||||
return getInteger(message, min, max, false);
|
||||
}
|
||||
public static Integer getInteger(final IGuiBase gui, final String message, int min, int max, boolean sortDesc) {
|
||||
public static Integer getInteger(final String message, int min, int max, boolean sortDesc) {
|
||||
if (max <= min) { return min; } //just return min if max <= min
|
||||
|
||||
//force cutting off after 100 numbers at most
|
||||
if (max == Integer.MAX_VALUE) {
|
||||
return getInteger(gui, message, min, max, min + 99);
|
||||
return getInteger(message, min, max, min + 99);
|
||||
}
|
||||
int count = max - min + 1;
|
||||
if (count > 100) {
|
||||
return getInteger(gui, message, min, max, min + 99);
|
||||
return getInteger(message, min, max, min + 99);
|
||||
}
|
||||
|
||||
final Integer[] choices = new Integer[count];
|
||||
@@ -130,13 +130,13 @@ public class SGuiChoose {
|
||||
choices[i] = Integer.valueOf(i + min);
|
||||
}
|
||||
}
|
||||
return SGuiChoose.oneOrNone(gui, message, choices);
|
||||
return SGuiChoose.oneOrNone(message, choices);
|
||||
}
|
||||
public static Integer getInteger(final IGuiBase gui, final String message, int min, int max, int cutoff) {
|
||||
public static Integer getInteger(final String message, int min, int max, int cutoff) {
|
||||
if (max <= min || cutoff < min) { return min; } //just return min if max <= min or cutoff < min
|
||||
|
||||
if (cutoff >= max) { //fallback to regular integer prompt if cutoff at or after max
|
||||
return getInteger(gui, message, min, max);
|
||||
return getInteger(message, min, max);
|
||||
}
|
||||
|
||||
List<Object> choices = new ArrayList<Object>();
|
||||
@@ -145,7 +145,7 @@ public class SGuiChoose {
|
||||
}
|
||||
choices.add("Other...");
|
||||
|
||||
Object choice = SGuiChoose.oneOrNone(gui, message, choices);
|
||||
Object choice = SGuiChoose.oneOrNone(message, choices);
|
||||
if (choice instanceof Integer || choice == null) {
|
||||
return (Integer)choice;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class SGuiChoose {
|
||||
prompt += ":";
|
||||
|
||||
while (true) {
|
||||
String str = SOptionPane.showInputDialog(gui, prompt, message);
|
||||
String str = SOptionPane.showInputDialog(prompt, message);
|
||||
if (str == null) { return null; } // that is 'cancel'
|
||||
|
||||
if (StringUtils.isNumeric(str)) {
|
||||
@@ -179,30 +179,30 @@ public class SGuiChoose {
|
||||
}
|
||||
|
||||
// returned Object will never be null
|
||||
public static <T> List<T> getChoices(final IGuiBase gui, final String message, final int min, final int max, final T[] choices) {
|
||||
return getChoices(gui, message, min, max, Arrays.asList(choices), null, null);
|
||||
public static <T> List<T> getChoices(final String message, final int min, final int max, final T[] choices) {
|
||||
return getChoices(message, min, max, Arrays.asList(choices), null, null);
|
||||
}
|
||||
|
||||
public static <T> List<T> getChoices(final IGuiBase gui, final String message, final int min, final int max, final Collection<T> choices) {
|
||||
return getChoices(gui, message, min, max, choices, null, null);
|
||||
public static <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices) {
|
||||
return getChoices(message, min, max, choices, null, null);
|
||||
}
|
||||
|
||||
public static <T> List<T> getChoices(final IGuiBase gui, final String message, final int min, final int max, final Collection<T> choices, final T selected, final Function<T, String> display) {
|
||||
return gui.getChoices(message, min, max, choices, selected, display);
|
||||
public static <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) {
|
||||
return GuiBase.getInterface().getChoices(message, min, max, choices, selected, display);
|
||||
}
|
||||
|
||||
public static <T> List<T> many(final IGuiBase gui, final String title, final String topCaption, int cnt, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
return many(gui, title, topCaption, cnt, cnt, sourceChoices, referenceCard);
|
||||
public static <T> List<T> many(final String title, final String topCaption, int cnt, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
return many(title, topCaption, cnt, cnt, sourceChoices, referenceCard);
|
||||
}
|
||||
|
||||
public static <T> List<T> many(final IGuiBase gui, final String title, final String topCaption, int min, int max, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
public static <T> List<T> many(final String title, final String topCaption, int min, int max, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
int m2 = min >= 0 ? sourceChoices.size() - min : -1;
|
||||
int m1 = max >= 0 ? sourceChoices.size() - max : -1;
|
||||
return order(gui, title, topCaption, m1, m2, sourceChoices, null, referenceCard, false);
|
||||
return order(title, topCaption, m1, m2, sourceChoices, null, referenceCard, false);
|
||||
}
|
||||
|
||||
public static <T> List<T> order(final IGuiBase gui, final String title, final String top, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
return order(gui, title, top, 0, 0, sourceChoices, null, referenceCard, false);
|
||||
public static <T> List<T> order(final String title, final String top, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
return order(title, top, 0, 0, sourceChoices, null, referenceCard, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,8 +215,8 @@ public class SGuiChoose {
|
||||
* @param oldItems the list of objects.
|
||||
* @return A shallow copy of the list of objects, with newItem inserted.
|
||||
*/
|
||||
public static <T> List<T> insertInList(final IGuiBase gui, final String title, final T newItem, final List<T> oldItems) {
|
||||
final T placeAfter = oneOrNone(gui, title, oldItems);
|
||||
public static <T> List<T> insertInList(final String title, final T newItem, final List<T> oldItems) {
|
||||
final T placeAfter = oneOrNone(title, oldItems);
|
||||
final int indexAfter = (placeAfter == null ? 0 : oldItems.indexOf(placeAfter) + 1);
|
||||
final List<T> result = Lists.newArrayListWithCapacity(oldItems.size() + 1);
|
||||
result.addAll(oldItems);
|
||||
@@ -224,62 +224,62 @@ public class SGuiChoose {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static <T> List<T> order(final IGuiBase gui, final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
private static <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) {
|
||||
return gui.order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, referenceCard, sideboardingMode);
|
||||
return GuiBase.getInterface().order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, referenceCard, sideboardingMode);
|
||||
}
|
||||
|
||||
// If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine
|
||||
public static <T> T sortedOneOrNone(final IGuiBase gui, final String message, final T[] choices, Comparator<T> comparer) {
|
||||
public static <T> T sortedOneOrNone(final String message, final T[] choices, Comparator<T> comparer) {
|
||||
if ((choices == null) || (choices.length == 0)) {
|
||||
return null;
|
||||
}
|
||||
final List<T> choice = SGuiChoose.sortedGetChoices(gui, message, 0, 1, choices, comparer);
|
||||
final List<T> choice = SGuiChoose.sortedGetChoices(message, 0, 1, choices, comparer);
|
||||
return choice.isEmpty() ? null : choice.get(0);
|
||||
}
|
||||
|
||||
// If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine
|
||||
public static <T> T sortedOneOrNone(final IGuiBase gui, final String message, final List<T> choices, Comparator<T> comparer) {
|
||||
public static <T> T sortedOneOrNone(final String message, final List<T> choices, Comparator<T> comparer) {
|
||||
if ((choices == null) || choices.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final List<T> choice = SGuiChoose.sortedGetChoices(gui, message, 0, 1, choices, comparer);
|
||||
final List<T> choice = SGuiChoose.sortedGetChoices(message, 0, 1, choices, comparer);
|
||||
return choice.isEmpty() ? null : choice.get(0);
|
||||
}
|
||||
|
||||
// If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine
|
||||
public static <T> T sortedOne(final IGuiBase gui, final String message, final T[] choices, Comparator<T> comparer) {
|
||||
final List<T> choice = SGuiChoose.sortedGetChoices(gui, message, 1, 1, choices, comparer);
|
||||
public static <T> T sortedOne(final String message, final T[] choices, Comparator<T> comparer) {
|
||||
final List<T> choice = SGuiChoose.sortedGetChoices(message, 1, 1, choices, comparer);
|
||||
assert choice.size() == 1;
|
||||
return choice.get(0);
|
||||
}
|
||||
|
||||
// If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine
|
||||
public static <T> T sortedOne(final IGuiBase gui, final String message, final List<T> choices, Comparator<T> comparer) {
|
||||
public static <T> T sortedOne(final String message, final List<T> choices, Comparator<T> comparer) {
|
||||
if ((choices == null) || (choices.size() == 0)) {
|
||||
return null;
|
||||
}
|
||||
final List<T> choice = SGuiChoose.sortedGetChoices(gui, message, 1, 1, choices, comparer);
|
||||
final List<T> choice = SGuiChoose.sortedGetChoices(message, 1, 1, choices, comparer);
|
||||
assert choice.size() == 1;
|
||||
return choice.get(0);
|
||||
}
|
||||
|
||||
// If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine
|
||||
public static <T> List<T> sortedNoneOrMany(final IGuiBase gui, final String message, final List<T> choices, Comparator<T> comparer) {
|
||||
return SGuiChoose.sortedGetChoices(gui, message, 0, choices.size(), choices, comparer);
|
||||
public static <T> List<T> sortedNoneOrMany(final String message, final List<T> choices, Comparator<T> comparer) {
|
||||
return SGuiChoose.sortedGetChoices(message, 0, choices.size(), choices, comparer);
|
||||
}
|
||||
|
||||
// If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine
|
||||
public static <T> List<T> sortedGetChoices(final IGuiBase gui, final String message, final int min, final int max, final T[] choices, Comparator<T> comparer) {
|
||||
public static <T> List<T> sortedGetChoices(final String message, final int min, final int max, final T[] choices, Comparator<T> comparer) {
|
||||
// You may create a copy of source array if callers expect the collection to be unchanged
|
||||
Arrays.sort(choices, comparer);
|
||||
return getChoices(gui, message, min, max, choices);
|
||||
return getChoices(message, min, max, choices);
|
||||
}
|
||||
|
||||
// If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine
|
||||
public static <T> List<T> sortedGetChoices(final IGuiBase gui, final String message, final int min, final int max, final List<T> choices, Comparator<T> comparer) {
|
||||
public static <T> List<T> sortedGetChoices(final String message, final int min, final int max, final List<T> choices, Comparator<T> comparer) {
|
||||
// You may create a copy of source list if callers expect the collection to be unchanged
|
||||
Collections.sort(choices, comparer);
|
||||
return getChoices(gui, message, min, max, choices);
|
||||
return getChoices(message, min, max, choices);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.util.gui;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.view.CardView;
|
||||
|
||||
/**
|
||||
@@ -12,21 +11,21 @@ import forge.view.CardView;
|
||||
public class SGuiDialog {
|
||||
private static final String[] defaultConfirmOptions = { "Yes", "No" };
|
||||
|
||||
public static boolean confirm(final IGuiBase gui, final CardView c, final String question) {
|
||||
return SGuiDialog.confirm(gui, c, question, true, null);
|
||||
public static boolean confirm(final CardView c, final String question) {
|
||||
return SGuiDialog.confirm(c, question, true, null);
|
||||
}
|
||||
public static boolean confirm(final IGuiBase gui, final CardView c, final String question, final boolean defaultChoice) {
|
||||
return SGuiDialog.confirm(gui, c, question, defaultChoice, null);
|
||||
public static boolean confirm(final CardView c, final String question, final boolean defaultChoice) {
|
||||
return SGuiDialog.confirm(c, question, defaultChoice, null);
|
||||
}
|
||||
public static boolean confirm(final IGuiBase gui, final CardView c, final String question, String[] options) {
|
||||
return SGuiDialog.confirm(gui, c, question, true, options);
|
||||
public static boolean confirm(final CardView c, final String question, String[] options) {
|
||||
return SGuiDialog.confirm(c, question, true, options);
|
||||
}
|
||||
|
||||
public static boolean confirm(final IGuiBase gui, final CardView c, final String question, final boolean defaultIsYes, final String[] options) {
|
||||
public static boolean confirm(final CardView c, final String question, final boolean defaultIsYes, final String[] options) {
|
||||
final String title = c == null ? "Question" : c + " - Ability";
|
||||
String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question;
|
||||
String[] opts = options == null ? defaultConfirmOptions : options;
|
||||
int answer = SOptionPane.showCardOptionDialog(gui, c, questionToUse, title, SOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1);
|
||||
int answer = SOptionPane.showCardOptionDialog(c, questionToUse, title, SOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1);
|
||||
return answer == 0;
|
||||
}
|
||||
|
||||
@@ -38,11 +37,11 @@ public class SGuiDialog {
|
||||
* @param message
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public static void message(final IGuiBase gui, final String message) {
|
||||
message(gui, message, "Forge");
|
||||
public static void message(final String message) {
|
||||
message(message, "Forge");
|
||||
}
|
||||
|
||||
public static void message(final IGuiBase gui, final String message, final String title) {
|
||||
SOptionPane.showMessageDialog(gui, message, title, null);
|
||||
public static void message(final String message, final String title) {
|
||||
SOptionPane.showMessageDialog(message, title, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package forge.util.gui;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.view.CardView;
|
||||
|
||||
public class SOptionPane {
|
||||
@@ -10,74 +10,74 @@ public class SOptionPane {
|
||||
public static final FSkinProp WARNING_ICON = FSkinProp.ICO_WARNING;
|
||||
public static final FSkinProp ERROR_ICON = FSkinProp.ICO_ERROR;
|
||||
|
||||
public static void showMessageDialog(IGuiBase gui, String message) {
|
||||
showMessageDialog(gui, message, "Forge", INFORMATION_ICON);
|
||||
public static void showMessageDialog(String message) {
|
||||
showMessageDialog(message, "Forge", INFORMATION_ICON);
|
||||
}
|
||||
|
||||
public static void showMessageDialog(IGuiBase gui, String message, String title) {
|
||||
showMessageDialog(gui, message, title, INFORMATION_ICON);
|
||||
public static void showMessageDialog(String message, String title) {
|
||||
showMessageDialog(message, title, INFORMATION_ICON);
|
||||
}
|
||||
|
||||
public static void showErrorDialog(IGuiBase gui, String message) {
|
||||
showMessageDialog(gui, message, "Forge", ERROR_ICON);
|
||||
public static void showErrorDialog(String message) {
|
||||
showMessageDialog(message, "Forge", ERROR_ICON);
|
||||
}
|
||||
|
||||
public static void showErrorDialog(IGuiBase gui, String message, String title) {
|
||||
showMessageDialog(gui, message, title, ERROR_ICON);
|
||||
public static void showErrorDialog(String message, String title) {
|
||||
showMessageDialog(message, title, ERROR_ICON);
|
||||
}
|
||||
|
||||
public static void showMessageDialog(IGuiBase gui, String message, String title, FSkinProp icon) {
|
||||
showOptionDialog(gui, message, title, icon, new String[] {"OK"}, 0);
|
||||
public static void showMessageDialog(String message, String title, FSkinProp icon) {
|
||||
showOptionDialog(message, title, icon, new String[] {"OK"}, 0);
|
||||
}
|
||||
|
||||
public static boolean showConfirmDialog(IGuiBase gui, String message) {
|
||||
return showConfirmDialog(gui, message, "Forge");
|
||||
public static boolean showConfirmDialog(String message) {
|
||||
return showConfirmDialog(message, "Forge");
|
||||
}
|
||||
|
||||
public static boolean showConfirmDialog(IGuiBase gui, String message, String title) {
|
||||
return showConfirmDialog(gui, message, title, "Yes", "No", true);
|
||||
public static boolean showConfirmDialog(String message, String title) {
|
||||
return showConfirmDialog(message, title, "Yes", "No", true);
|
||||
}
|
||||
|
||||
public static boolean showConfirmDialog(IGuiBase gui, String message, String title, boolean defaultYes) {
|
||||
return showConfirmDialog(gui, message, title, "Yes", "No", defaultYes);
|
||||
public static boolean showConfirmDialog(String message, String title, boolean defaultYes) {
|
||||
return showConfirmDialog(message, title, "Yes", "No", defaultYes);
|
||||
}
|
||||
|
||||
public static boolean showConfirmDialog(IGuiBase gui, String message, String title, String yesButtonText, String noButtonText) {
|
||||
return showConfirmDialog(gui, message, title, yesButtonText, noButtonText, true);
|
||||
public static boolean showConfirmDialog(String message, String title, String yesButtonText, String noButtonText) {
|
||||
return showConfirmDialog(message, title, yesButtonText, noButtonText, true);
|
||||
}
|
||||
|
||||
public static boolean showConfirmDialog(IGuiBase gui, String message, String title, String yesButtonText, String noButtonText, boolean defaultYes) {
|
||||
public static boolean showConfirmDialog(String message, String title, String yesButtonText, String noButtonText, boolean defaultYes) {
|
||||
String[] options = {yesButtonText, noButtonText};
|
||||
int reply = SOptionPane.showOptionDialog(gui, message, title, QUESTION_ICON, options, defaultYes ? 0 : 1);
|
||||
int reply = SOptionPane.showOptionDialog(message, title, QUESTION_ICON, options, defaultYes ? 0 : 1);
|
||||
return (reply == 0);
|
||||
}
|
||||
|
||||
public static int showOptionDialog(IGuiBase gui, String message, String title, FSkinProp icon, String[] options) {
|
||||
return showOptionDialog(gui, message, title, icon, options, 0);
|
||||
public static int showOptionDialog(String message, String title, FSkinProp icon, String[] options) {
|
||||
return showOptionDialog(message, title, icon, options, 0);
|
||||
}
|
||||
|
||||
public static int showOptionDialog(IGuiBase gui, String message, String title, FSkinProp icon, String[] options, int defaultOption) {
|
||||
return gui.showOptionDialog(message, title, icon, options, defaultOption);
|
||||
public static int showOptionDialog(String message, String title, FSkinProp icon, String[] options, int defaultOption) {
|
||||
return GuiBase.getInterface().showOptionDialog(message, title, icon, options, defaultOption);
|
||||
}
|
||||
|
||||
public static int showCardOptionDialog(IGuiBase gui, CardView card, String message, String title, FSkinProp icon, String[] options, int defaultOption) {
|
||||
return gui.showCardOptionDialog(card, message, title, icon, options, defaultOption);
|
||||
public static int showCardOptionDialog(CardView card, String message, String title, FSkinProp icon, String[] options, int defaultOption) {
|
||||
return GuiBase.getInterface().showCardOptionDialog(card, message, title, icon, options, defaultOption);
|
||||
}
|
||||
|
||||
public static String showInputDialog(IGuiBase gui, String message, String title) {
|
||||
return showInputDialog(gui, message, title, null, "", null);
|
||||
public static String showInputDialog(String message, String title) {
|
||||
return showInputDialog(message, title, null, "", null);
|
||||
}
|
||||
|
||||
public static String showInputDialog(IGuiBase gui, String message, String title, FSkinProp icon) {
|
||||
return showInputDialog(gui, message, title, icon, "", null);
|
||||
public static String showInputDialog(String message, String title, FSkinProp icon) {
|
||||
return showInputDialog(message, title, icon, "", null);
|
||||
}
|
||||
|
||||
public static String showInputDialog(IGuiBase gui, String message, String title, FSkinProp icon, String initialInput) {
|
||||
return showInputDialog(gui, message, title, icon, initialInput, null);
|
||||
public static String showInputDialog(String message, String title, FSkinProp icon, String initialInput) {
|
||||
return showInputDialog(message, title, icon, initialInput, null);
|
||||
}
|
||||
|
||||
public static String showInputDialog(IGuiBase gui, String message, String title, FSkinProp icon, String initialInput, String[] inputOptions) {
|
||||
return gui.showInputDialog(message, title, icon, initialInput, inputOptions);
|
||||
public static String showInputDialog(String message, String title, FSkinProp icon, String initialInput, String[] inputOptions) {
|
||||
return GuiBase.getInterface().showInputDialog(message, title, icon, initialInput, inputOptions);
|
||||
}
|
||||
|
||||
private SOptionPane() {
|
||||
|
||||
@@ -28,21 +28,18 @@ import forge.game.player.RegisteredPlayer;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.input.InputProxy;
|
||||
import forge.match.input.InputQueue;
|
||||
|
||||
public abstract class LocalGameView implements IGameView {
|
||||
protected final Game game;
|
||||
protected final IGuiBase gui;
|
||||
protected final InputQueue inputQueue;
|
||||
protected final InputProxy inputProxy;
|
||||
private PlayerView localPlayerView;
|
||||
|
||||
public LocalGameView(IGuiBase gui0, Game game0) {
|
||||
public LocalGameView(Game game0) {
|
||||
game = game0;
|
||||
gui = gui0;
|
||||
inputProxy = new InputProxy(this);
|
||||
inputQueue = new InputQueue(game, inputProxy);
|
||||
}
|
||||
@@ -51,10 +48,6 @@ public abstract class LocalGameView implements IGameView {
|
||||
return game;
|
||||
}
|
||||
|
||||
public final IGuiBase getGui() {
|
||||
return gui;
|
||||
}
|
||||
|
||||
public final InputQueue getInputQueue() {
|
||||
return inputQueue;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ package forge.view;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.input.Input;
|
||||
import forge.match.input.InputPlaybackControl;
|
||||
import forge.match.input.InputQueue;
|
||||
@@ -24,8 +23,8 @@ public class WatchLocalGame extends LocalGameView {
|
||||
* the {@link InputQueue} of the game to enable playback
|
||||
* controls, or {@code null} to disallow them.
|
||||
*/
|
||||
public WatchLocalGame(IGuiBase gui0, Game game0) {
|
||||
super(gui0, game0);
|
||||
public WatchLocalGame(Game game0) {
|
||||
super(game0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user