Avoid storing and passing IGuiBase instances everywhere since only one IGuiBase instance will ever exist on a single session

This commit is contained in:
drdev
2014-10-06 04:49:03 +00:00
parent afcad4e672
commit 6242c33c6a
134 changed files with 657 additions and 856 deletions

View File

@@ -148,7 +148,7 @@ public class GuiDesktop implements IGuiBase {
@Override
public int showCardOptionDialog(final CardView card, String message, String title, FSkinProp skinIcon, String[] options, int defaultOption) {
if (card != null) {
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtAndWait(new Runnable() {
@Override
public void run() {
GuiBase.getInterface().setCard(card);
@@ -196,9 +196,9 @@ public class GuiDesktop implements IGuiBase {
controller.tempShow(optionList);
List<GameEntityView> gameEntityViews = controller.getGameView().getGameEntityViews(optionList, false);
if (isOptional) {
return SGuiChoose.oneOrNone(this, title, gameEntityViews);
return SGuiChoose.oneOrNone(title, gameEntityViews);
}
return SGuiChoose.one(this, title, gameEntityViews);
return SGuiChoose.one(title, gameEntityViews);
}
@Override

View File

@@ -194,7 +194,7 @@ public class ImageCache {
* Returns the Image corresponding to the key.
*/
private static BufferedImage getImage(final String key) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
try {
return ImageCache._CACHE.get(key);
} catch (final ExecutionException ex) {

View File

@@ -92,7 +92,7 @@ final class ImageLoader extends CacheLoader<String, BufferedImage> {
return ImageIO.read(file);
}
catch (IOException ex) {
BugReporter.reportException(ex, GuiBase.getInterface(), "Could not read image file " + file.getAbsolutePath() + " ");
BugReporter.reportException(ex, "Could not read image file " + file.getAbsolutePath() + " ");
break;
}
}

View File

@@ -37,7 +37,7 @@ public final class Singletons {
public static FControl getControl() { return control; }
public static void initializeOnce(boolean withUi) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false);
FThreads.assertExecutedByEdt(false);
synchronized (Singletons.class) {
if (initialized) {
@@ -50,7 +50,7 @@ public final class Singletons {
view = FView.SINGLETON_INSTANCE;
}
FModel.initialize(GuiBase.getInterface(), view == null ? null : view.getSplash().getProgressBar());
FModel.initialize(view == null ? null : view.getSplash().getProgressBar());
if (withUi) {
control = FControl.instance;

View File

@@ -1,7 +1,6 @@
package forge.deckchooser;
import forge.FThreads;
import forge.GuiBase;
import forge.UiCommand;
import forge.deck.ColorDeckGenerator;
import forge.deck.Deck;
@@ -51,7 +50,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
//Show dialog to select a deck
public static Deck promptForDeck(String title, DeckType defaultDeckType, boolean forAi) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
final FDeckChooser chooser = new FDeckChooser(forAi);
chooser.initialize(defaultDeckType);
chooser.populate();
@@ -131,7 +130,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
"White", "Blue", "Black", "Red", "Green" };
ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>();
for (int i = 0; i < colors.length; i++) {
decks.add(new ColorDeckGenerator(GuiBase.getInterface(), colors[i], i, lstDecks, isAi));
decks.add(new ColorDeckGenerator(colors[i], i, lstDecks, isAi));
}
lstDecks.setPool(decks);

View File

@@ -19,7 +19,6 @@ package forge.download;
import java.net.Proxy;
import forge.GuiBase;
import forge.UiCommand;
import forge.assets.FSkinProp;
import forge.gui.SOverlayUtils;
@@ -96,7 +95,7 @@ public class GuiDownloader extends DefaultBoundedRangeModel {
pnl.add(pnlDialog, "w 400px!, h 350px!, ax center, ay center");
SOverlayUtils.showOverlay();
service.initialize(GuiBase.getInterface(), txtAddress, txtPort, progressBar, btnStart, cmdClose, null, new Runnable() {
service.initialize(txtAddress, txtPort, progressBar, btnStart, cmdClose, null, new Runnable() {
@Override
public void run() {
fireStateChanged();

View File

@@ -17,7 +17,6 @@
*/
package forge.error;
import forge.GuiBase;
import forge.gui.WrapLayout;
import forge.toolbox.FHyperlink;
import forge.toolbox.FLabel;
@@ -93,7 +92,7 @@ public class BugReportDialog {
@Override
public void actionPerformed(final ActionEvent e) {
BugReporter.copyAndGoToForums(GuiBase.getInterface(), text.getText());
BugReporter.copyAndGoToForums(text.getText());
}
}
@@ -109,7 +108,7 @@ public class BugReportDialog {
@Override
public void actionPerformed(final ActionEvent e) {
BugReporter.saveToFile(GuiBase.getInterface(), area.getText());
BugReporter.saveToFile(area.getText());
}
}

View File

@@ -20,7 +20,6 @@ import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import forge.FThreads;
import forge.GuiBase;
import forge.item.InventoryItem;
import forge.screens.match.CMatchUI;
import forge.toolbox.FOptionPane;
@@ -241,7 +240,7 @@ public class GuiChoose {
};
FutureTask<List<T>> future = new FutureTask<List<T>>(showChoice);
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), future);
FThreads.invokeInEdtAndWait(future);
try {
return future.get();
} catch (Exception e) { // should be no exception here
@@ -300,7 +299,7 @@ public class GuiChoose {
};
FutureTask<List<T>> ft = new FutureTask<List<T>>(callable);
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), ft);
FThreads.invokeInEdtAndWait(ft);
try {
return ft.get();
} catch (Exception e) { // we have waited enough

View File

@@ -8,7 +8,6 @@ import javax.swing.UIManager;
import org.apache.commons.lang3.StringUtils;
import forge.FThreads;
import forge.GuiBase;
import forge.screens.match.CMatchUI;
import forge.toolbox.FOptionPane;
import forge.view.CardView;
@@ -46,7 +45,7 @@ public class GuiDialog {
}};
FutureTask<Boolean> future = new FutureTask<Boolean>(confirmTask);
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), future);
FThreads.invokeInEdtAndWait(future);
try {
return future.get().booleanValue();
}
@@ -69,7 +68,7 @@ public class GuiDialog {
}
public static void message(final String message, final String title) {
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtAndWait(new Runnable() {
@Override
public void run() {
FOptionPane.showMessageDialog(message, title, null);

View File

@@ -17,7 +17,6 @@
*/
package forge.gui;
import forge.GuiBase;
import forge.UiCommand;
import forge.assets.FSkinProp;
import forge.error.BugReporter;
@@ -514,7 +513,7 @@ public class ImportDialog {
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
_progressBar.setString("Error");
BugReporter.reportException(e, GuiBase.getInterface());
BugReporter.reportException(e);
}
});
} finally {
@@ -778,7 +777,7 @@ public class ImportDialog {
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
// we never interrupt the thread, so this is not expected to happen
BugReporter.reportException(e, GuiBase.getInterface());
BugReporter.reportException(e);
}
});
}
@@ -937,7 +936,7 @@ public class ImportDialog {
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
_progressBar.setString("Error");
BugReporter.reportException(e, GuiBase.getInterface());
BugReporter.reportException(e);
}
});
}

View File

@@ -22,7 +22,6 @@ import com.google.common.base.Function;
import com.google.common.collect.Lists;
import forge.FThreads;
import forge.GuiBase;
import forge.toolbox.FList;
import forge.toolbox.FMouseAdapter;
import forge.toolbox.FOptionPane;
@@ -76,7 +75,7 @@ public class ListChooser<T> {
private FOptionPane optionPane;
public ListChooser(final String title, final int minChoices, final int maxChoices, final Collection<T> list, final Function<T, String> display) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
this.minChoices = minChoices;
this.maxChoices = maxChoices;
this.list = list.getClass().isInstance(List.class) ? (List<T>)list : Lists.newArrayList(list);

View File

@@ -1,7 +1,6 @@
package forge.gui.framework;
import forge.FThreads;
import forge.GuiBase;
import forge.view.FFrame;
import javax.swing.*;
@@ -24,7 +23,7 @@ public class SDisplayUtil {
/** Flashes animation on input panel if play is currently waiting on input.
*
* @param tab0 &emsp; {@link java.gui.framework.IVDoc}
* @param tab0 &emsp; {@link java.GuiBase.getInterface().framework.IVDoc}
*/
public static void remind(final IVDoc<? extends ICDoc> tab0) {
showTab(tab0);
@@ -85,7 +84,7 @@ public class SDisplayUtil {
timer1.scheduleAtFixedRate(tt, 0, delay);
}
/** @param tab0 &emsp; {@link java.gui.framework.IVDoc} */
/** @param tab0 &emsp; {@link java.GuiBase.getInterface().framework.IVDoc} */
public static void showTab(final IVDoc<? extends ICDoc> tab0) {
Runnable showTabRoutine = new Runnable() {
@@ -102,7 +101,7 @@ public class SDisplayUtil {
}
}
};
FThreads.invokeInEdtLater(GuiBase.getInterface(), showTabRoutine);
FThreads.invokeInEdtLater(showTabRoutine);
}
public static GraphicsDevice getGraphicsDevice(Point point) {

View File

@@ -82,7 +82,7 @@ public class CEditorDraftingProcess extends ACEditorBase<PaperCard, DeckGroup> {
}
/**
* Show gui.
* Show GuiBase.getInterface().
*
* @param inBoosterDraft
* the in_booster draft

View File

@@ -17,7 +17,6 @@
*/
package forge.screens.deckeditor.controllers;
import forge.GuiBase;
import forge.UiCommand;
import forge.assets.FSkinProp;
import forge.deck.DeckBase;
@@ -149,7 +148,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
return;
}
QuestSpellShop.buy(GuiBase.getInterface(), items, this.getCatalogManager(), this.getDeckManager(), true);
QuestSpellShop.buy(items, this.getCatalogManager(), this.getDeckManager(), true);
updateCreditsLabel();
}
@@ -160,7 +159,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
protected void onRemoveItems(Iterable<Entry<InventoryItem, Integer>> items, boolean toAlternate) {
if (showingFullCatalog || toAlternate) { return; }
QuestSpellShop.sell(GuiBase.getInterface(), items, this.getCatalogManager(), this.getDeckManager(), true);
QuestSpellShop.sell(items, this.getCatalogManager(), this.getDeckManager(), true);
updateCreditsLabel();
}

View File

@@ -94,7 +94,7 @@ public class CEditorQuestDraftingProcess extends ACEditorBase<PaperCard, DeckGro
}
/**
* Show gui.
* Show GuiBase.getInterface().
*
* @param inBoosterDraft
* the in_booster draft

View File

@@ -92,7 +92,7 @@ public class CEditorWinstonProcess extends ACEditorBase<PaperCard, DeckGroup> {
}
/**
* Show gui.
* Show GuiBase.getInterface().
*
* @param inBoosterDraft
* the in_booster draft

View File

@@ -1,6 +1,5 @@
package forge.screens.home.quest;
import forge.GuiBase;
import forge.UiCommand;
import forge.Singletons;
import forge.gui.framework.EDocID;
@@ -43,29 +42,29 @@ public enum CSubmenuChallenges implements ICDoc {
view.getBtnSpellShop().setCommand(
new UiCommand() { @Override
public void run() { QuestUtil.showSpellShop(GuiBase.getInterface()); } });
public void run() { QuestUtil.showSpellShop(); } });
view.getBtnBazaar().setCommand(
new UiCommand() { @Override
public void run() { QuestUtil.showBazaar(GuiBase.getInterface()); } });
public void run() { QuestUtil.showBazaar(); } });
view.getBtnUnlock().setCommand(
new UiCommand() { @Override
public void run() { QuestUtil.chooseAndUnlockEdition(GuiBase.getInterface()); CSubmenuChallenges.this.update(); } });
public void run() { QuestUtil.chooseAndUnlockEdition(); CSubmenuChallenges.this.update(); } });
view.getBtnTravel().setCommand(
new UiCommand() { @Override
public void run() { QuestUtil.travelWorld(GuiBase.getInterface()); CSubmenuChallenges.this.update(); } });
public void run() { QuestUtil.travelWorld(); CSubmenuChallenges.this.update(); } });
view.getBtnStart().addActionListener(
new ActionListener() { @Override
public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(GuiBase.getInterface()); } });
public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(); } });
((FLabel) view.getLblZep()).setCommand(
new UiCommand() {
@Override
public void run() {
if (!QuestUtil.checkActiveQuest(GuiBase.getInterface(), "Launch a Zeppelin.")) {
if (!QuestUtil.checkActiveQuest("Launch a Zeppelin.")) {
return;
}
FModel.getQuest().getAchievements().setCurrentChallenges(null);

View File

@@ -1,6 +1,5 @@
package forge.screens.home.quest;
import forge.GuiBase;
import forge.UiCommand;
import forge.gui.framework.EDocID;
import forge.gui.framework.ICDoc;
@@ -37,23 +36,23 @@ public enum CSubmenuDuels implements ICDoc {
view.getBtnSpellShop().setCommand(
new UiCommand() { @Override
public void run() { QuestUtil.showSpellShop(GuiBase.getInterface()); } });
public void run() { QuestUtil.showSpellShop(); } });
view.getBtnBazaar().setCommand(
new UiCommand() { @Override
public void run() { QuestUtil.showBazaar(GuiBase.getInterface()); } });
public void run() { QuestUtil.showBazaar(); } });
view.getBtnTravel().setCommand(
new UiCommand() { @Override
public void run() { QuestUtil.travelWorld(GuiBase.getInterface()); CSubmenuDuels.this.update(); } });
public void run() { QuestUtil.travelWorld(); CSubmenuDuels.this.update(); } });
view.getBtnUnlock().setCommand(
new UiCommand() { @Override
public void run() { QuestUtil.chooseAndUnlockEdition(GuiBase.getInterface()); CSubmenuDuels.this.update(); } });
public void run() { QuestUtil.chooseAndUnlockEdition(); CSubmenuDuels.this.update(); } });
view.getBtnStart().addActionListener(
new ActionListener() { @Override
public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(GuiBase.getInterface()); } });
public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(); } });
final QuestController quest = FModel.getQuest();
view.getCbPlant().addActionListener(new ActionListener() {
@@ -87,11 +86,11 @@ public enum CSubmenuDuels implements ICDoc {
view.getBtnRandomOpponent().setCommand(new UiCommand() {
@Override
public void run() {
if (QuestUtil.canStartGame(GuiBase.getInterface())) {
if (QuestUtil.canStartGame()) {
FModel.getQuest().getDuelsManager().randomizeOpponents();
final List<QuestEventDuel> duels = FModel.getQuest().getDuelsManager().generateDuels();
QuestUtil.setEvent(duels.get((int) (Math.random() * duels.size())));
QuestUtil.startGame(GuiBase.getInterface());
QuestUtil.startGame();
}
}
});

View File

@@ -1,6 +1,5 @@
package forge.screens.home.quest;
import forge.GuiBase;
import forge.UiCommand;
import forge.Singletons;
import forge.deck.DeckProxy;
@@ -57,7 +56,7 @@ public enum CSubmenuQuestDecks implements ICDoc {
VSubmenuQuestDecks.SINGLETON_INSTANCE.getBtnNewDeck().setCommand(new UiCommand() {
@Override
public void run() {
if (!QuestUtil.checkActiveQuest(GuiBase.getInterface(), "Create a Deck.")) {
if (!QuestUtil.checkActiveQuest("Create a Deck.")) {
return;
}
Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_QUEST);

View File

@@ -329,7 +329,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
view.setMode(Mode.TOURNAMENT_ACTIVE);
}
QuestDraftUtils.update(GuiBase.getInterface());
QuestDraftUtils.update();
switch (view.getMode()) {
@@ -513,7 +513,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
drafting = true;
BoosterDraft draft = draftEvent.enter(GuiBase.getInterface());
BoosterDraft draft = draftEvent.enter();
final CEditorQuestDraftingProcess draftController = new CEditorQuestDraftingProcess();
draftController.showGui(draft);
@@ -553,7 +553,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
return;
}
QuestDraftUtils.startNextMatch(GuiBase.getInterface());
QuestDraftUtils.startNextMatch();
}

View File

@@ -1,6 +1,5 @@
package forge.screens.home.sanctioned;
import forge.GuiBase;
import forge.UiCommand;
import forge.Singletons;
import forge.deck.Deck;
@@ -154,7 +153,7 @@ public enum CSubmenuDraft implements ICDoc {
final LimitedPoolType poolType = GuiChoose.oneOrNone("Choose Draft Format", LimitedPoolType.values());
if (poolType == null) { return; }
BoosterDraft draft = BoosterDraft.createDraft(GuiBase.getInterface(), poolType);
BoosterDraft draft = BoosterDraft.createDraft(poolType);
if (draft == null) { return; }
final CEditorDraftingProcess draftController = new CEditorDraftingProcess();

View File

@@ -1,6 +1,5 @@
package forge.screens.home.sanctioned;
import forge.GuiBase;
import forge.UiCommand;
import forge.Singletons;
import forge.deck.*;
@@ -115,7 +114,7 @@ public enum CSubmenuSealed implements ICDoc {
@SuppressWarnings("unchecked")
private <T extends DeckBase> void setupSealed() {
final DeckGroup sealed = SealedCardPoolGenerator.generateSealedDeck(GuiBase.getInterface(), true);
final DeckGroup sealed = SealedCardPoolGenerator.generateSealedDeck(true);
if (sealed == null) { return; }
final ACEditorBase<? extends InventoryItem, T> editor = (ACEditorBase<? extends InventoryItem, T>) new CEditorLimited(

View File

@@ -1,6 +1,5 @@
package forge.screens.home.sanctioned;
import forge.GuiBase;
import forge.UiCommand;
import forge.Singletons;
import forge.deck.Deck;
@@ -142,7 +141,7 @@ public enum CSubmenuWinston implements ICDoc {
final LimitedPoolType poolType = GuiChoose.oneOrNone("Choose Draft Format", LimitedPoolType.values());
if (poolType == null) { return; }
WinstonDraft draft = WinstonDraft.createDraft(GuiBase.getInterface(), poolType);
WinstonDraft draft = WinstonDraft.createDraft(poolType);
if (draft == null) { return; }
final CEditorWinstonProcess draftController = new CEditorWinstonProcess();

View File

@@ -1,6 +1,5 @@
package forge.screens.home.settings;
import forge.GuiBase;
import forge.UiCommand;
import forge.download.GuiDownloadPicturesLQ;
import forge.download.GuiDownloadPrices;
@@ -38,7 +37,7 @@ public enum CSubmenuDownloaders implements ICDoc {
private final UiCommand cmdImportPictures = new UiCommand() { @Override
public void run() { new ImportDialog(null, null); } };
private final UiCommand cmdReportBug = new UiCommand() { @Override
public void run() { BugReporter.reportBug(GuiBase.getInterface(), null); }
public void run() { BugReporter.reportBug(null); }
};
/* (non-Javadoc)

View File

@@ -1,6 +1,5 @@
package forge.screens.home.settings;
import forge.GuiBase;
import forge.UiCommand;
import forge.Singletons;
import forge.ai.AiProfileUtil;
@@ -340,7 +339,7 @@ public enum CSubmenuPreferences implements ICDoc {
return new UiCommand() {
@Override
public void run() {
GamePlayerUtil.setPlayerName(GuiBase.getInterface());
GamePlayerUtil.setPlayerName();
setPlayerNameButtonText();
}
};

View File

@@ -35,7 +35,6 @@ import javax.swing.SwingUtilities;
import org.apache.commons.lang3.tuple.Pair;
import forge.FThreads;
import forge.GuiBase;
import forge.ImageCache;
import forge.LobbyPlayer;
import forge.Singletons;
@@ -234,7 +233,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
}
public void setCard(final CardView c, final boolean isInAltState) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
CDetail.SINGLETON_INSTANCE.showCard(c, isInAltState);
CPicture.SINGLETON_INSTANCE.showCard(c, isInAltState);
}
@@ -412,7 +411,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
public void focusButton(final IButton button) {
// ensure we don't steal focus from an overlay
if (!SOverlayUtils.overlayHasFocus()) {
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
((FButton)button).requestFocusInWindow();
@@ -586,7 +585,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
final List<CardView> blockers, final int damage,
final GameEntityView defender, final boolean overrideOrder) {
final Object[] result = { null }; // how else can I extract a value from EDT thread?
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtAndWait(new Runnable() {
@Override
public void run() {
VAssignDamage v = new VAssignDamage(attacker, blockers, damage, defender, overrideOrder);
@@ -604,7 +603,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
public void startNewMatch(final Match match) {
SOverlayUtils.startGameOverlay();
SOverlayUtils.showOverlay();
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
MatchUtil.startGame(match);

View File

@@ -27,7 +27,6 @@ import javax.swing.SwingConstants;
import net.miginfocom.swing.MigLayout;
import forge.assets.FSkinProp;
import forge.gauntlet.GauntletWinLoseController;
import forge.interfaces.IGuiBase;
import forge.toolbox.FLabel;
import forge.toolbox.FSkin;
import forge.toolbox.FSkin.SkinnedPanel;
@@ -46,7 +45,7 @@ public class GauntletWinLose extends ControlWinLose {
* @param view0 ViewWinLose object
* @param match
*/
public GauntletWinLose(final ViewWinLose view0, final IGameView game0, final IGuiBase gui) {
public GauntletWinLose(final ViewWinLose view0, final IGameView game0) {
super(view0, game0);
controller = new GauntletWinLoseController(view0, game0) {
@Override

View File

@@ -21,7 +21,6 @@ import java.awt.Dimension;
import javax.swing.SwingConstants;
import forge.GuiBase;
import forge.limited.LimitedWinLoseController;
import forge.toolbox.FSkin;
import forge.toolbox.FSkin.Colors;
@@ -49,7 +48,7 @@ public class LimitedWinLose extends ControlWinLose {
*/
public LimitedWinLose(final ViewWinLose view0, final IGameView game0) {
super(view0, game0);
controller = new LimitedWinLoseController(view0, game0, GuiBase.getInterface()) {
controller = new LimitedWinLoseController(view0, game0) {
@Override
protected void showOutcome(Runnable runnable) {
runnable.run(); //just run on GUI thread

View File

@@ -20,7 +20,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import forge.GuiBase;
import forge.LobbyPlayer;
import forge.Singletons;
import forge.assets.FSkinProp;
@@ -103,10 +102,10 @@ public class QuestDraftWinLose extends ControlWinLose {
if (lastGame.isMatchOver()) {
this.actionOnQuitMatch();
QuestDraftUtils.matchInProgress = false;
QuestDraftUtils.update(GuiBase.getInterface());
QuestDraftUtils.update();
} else {
this.actionOnContinue();
QuestDraftUtils.update(GuiBase.getInterface());
QuestDraftUtils.update();
}
return false;
@@ -127,7 +126,7 @@ public class QuestDraftWinLose extends ControlWinLose {
public void actionPerformed(final ActionEvent e) {
MatchUtil.endCurrentGame();
QuestDraftUtils.matchInProgress = false;
QuestDraftUtils.continueMatches(GuiBase.getInterface());
QuestDraftUtils.continueMatches();
}
});
} else {
@@ -142,7 +141,7 @@ public class QuestDraftWinLose extends ControlWinLose {
if (FOptionPane.showOptionDialog("Quitting the match now will forfeit the tournament!\n\nReally quit?", "Really Quit Tournament?", FSkin.getImage(FSkinProp.ICO_WARNING).scale(2), new String[] { "Yes", "No" }, 1) == 0) {
MatchUtil.endCurrentGame();
QuestDraftUtils.matchInProgress = false;
QuestDraftUtils.continueMatches(GuiBase.getInterface());
QuestDraftUtils.continueMatches();
}
}
});

View File

@@ -21,7 +21,6 @@ import java.util.List;
import javax.swing.SwingConstants;
import forge.GuiBase;
import forge.assets.FSkinProp;
import forge.item.PaperCard;
import forge.model.FModel;
@@ -65,7 +64,7 @@ public class QuestWinLose extends ControlWinLose {
public QuestWinLose(final ViewWinLose view0, final IGameView game0) {
super(view0, game0);
view = view0;
controller = new QuestWinLoseController(game0, GuiBase.getInterface()) {
controller = new QuestWinLoseController(game0) {
@Override
protected void showRewards(Runnable runnable) {
runnable.run(); //just run on GUI thread

View File

@@ -14,7 +14,6 @@ import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils;
import forge.GuiBase;
import forge.LobbyPlayer;
import forge.UiCommand;
import forge.game.GameLogEntry;
@@ -76,7 +75,7 @@ public class ViewWinLose implements IWinLoseView<FButton> {
control = new LimitedWinLose(this, game0);
break;
case Gauntlet:
control = new GauntletWinLose(this, game0, GuiBase.getInterface());
control = new GauntletWinLose(this, game0);
break;
default: // will catch it after switch
break;

View File

@@ -20,7 +20,6 @@ package forge.screens.match.controllers;
import java.io.File;
import forge.FThreads;
import forge.GuiBase;
import forge.Singletons;
import forge.UiCommand;
import forge.assets.FSkinProp;
@@ -62,7 +61,7 @@ public enum CDock implements ICDoc {
SOverlayUtils.genericOverlay();
FView.SINGLETON_INSTANCE.getPnlContent().removeAll();
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable(){
FThreads.invokeInEdtLater(new Runnable(){
@Override public void run() {
SLayoutIO.loadLayout(null);
SOverlayUtils.hideOverlay();
@@ -92,7 +91,7 @@ public enum CDock implements ICDoc {
FView.SINGLETON_INSTANCE.getPnlContent().removeAll();
// let it redraw everything first
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
if (loadFile != null) {

View File

@@ -31,7 +31,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import forge.FThreads;
import forge.GuiBase;
import forge.Singletons;
import forge.UiCommand;
import forge.gui.framework.ICDoc;
@@ -81,7 +80,7 @@ public class CHand implements ICDoc {
}
public void update(final Observable a, final Object b) {
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), updateRoutine);
FThreads.invokeInEdtNowOrLater(updateRoutine);
}
private final Runnable updateRoutine = new Runnable() {
@@ -89,7 +88,7 @@ public class CHand implements ICDoc {
};
public void updateHand() {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
final HandArea p = view.getHandArea();

View File

@@ -1,6 +1,5 @@
package forge.screens.match.controllers;
import forge.GuiBase;
import forge.UiCommand;
import forge.FThreads;
import forge.gui.framework.ICDoc;
@@ -54,7 +53,7 @@ public enum CLog implements ICDoc, Observer {
*/
@Override
public void update() {
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), r);
FThreads.invokeInEdtNowOrLater(r);
}
}

View File

@@ -27,7 +27,6 @@ import java.awt.event.FocusListener;
import javax.swing.JButton;
import forge.FThreads;
import forge.GuiBase;
import forge.UiCommand;
import forge.gui.framework.ICDoc;
import forge.gui.framework.SDisplayUtil;
@@ -147,7 +146,7 @@ public enum CPrompt implements ICDoc {
}
public void updateText() {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
final IGameView game = MatchUtil.getGameView();
final String text = String.format("T:%d G:%d/%d [%s]", game.getTurnNumber(), game.getNumPlayedGamesInMatch() + 1, game.getNumGamesInMatch(), game.getGameType());
view.getLblGames().setText(text);

View File

@@ -1,7 +1,6 @@
package forge.toolbox;
import forge.FThreads;
import forge.GuiBase;
import forge.interfaces.IProgressBar;
import javax.swing.*;
@@ -37,7 +36,7 @@ public class FProgressBar extends JProgressBar implements IProgressBar {
* @param s0 &emsp; A description to prepend before statistics.
*/
public void setDescription(final String s0) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
desc = s0;
setString(s0);
}
@@ -82,7 +81,7 @@ public class FProgressBar extends JProgressBar implements IProgressBar {
/** Resets the various values required for this class. Must be called from EDT. */
public void reset() {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
setIndeterminate(true);
setValue(0);
tempVal = 0;

View File

@@ -18,7 +18,6 @@
package forge.toolbox;
import forge.FThreads;
import forge.GuiBase;
import forge.Singletons;
import forge.assets.FSkinProp;
import forge.assets.ISkinImage;
@@ -1036,7 +1035,7 @@ public class FSkin {
public static void loadLight(final String skinName, final boolean onInit) {
if (onInit) {
// No need for this method to be loaded while on the EDT.
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false);
FThreads.assertExecutedByEdt(false);
if (allSkins == null) { //initialize
allSkins = new ArrayList<String>();
@@ -1108,7 +1107,7 @@ public class FSkin {
public static void loadFull(final boolean onInit) {
if (onInit) {
// No need for this method to be loaded while on the EDT.
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false);
FThreads.assertExecutedByEdt(false);
// Preferred skin name must be called via loadLight() method,
// which does some cleanup and init work.

View File

@@ -18,7 +18,6 @@
package forge.view;
import forge.FThreads;
import forge.GuiBase;
import forge.gui.SOverlayUtils;
import forge.screens.match.VMatchUI;
@@ -69,7 +68,7 @@ public class ButtonUtil {
// ensure we don't steal focus from an overlay
if (!SOverlayUtils.overlayHasFocus()) {
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() { @Override public void run() { button.requestFocusInWindow(); } });
FThreads.invokeInEdtLater(new Runnable() { @Override public void run() { button.requestFocusInWindow(); } });
}
}

View File

@@ -41,7 +41,7 @@ public final class Main {
GuiBase.setInterface(new GuiDesktop());
//install our error handler
ExceptionHandler.registerErrorHandling(GuiBase.getInterface());
ExceptionHandler.registerErrorHandling();
// Start splash screen first, then data models, then controller.
if (args.length == 0) {

View File

@@ -7,7 +7,6 @@ import java.util.List;
import org.apache.commons.lang3.time.StopWatch;
import forge.GuiBase;
import forge.deck.Deck;
import forge.deck.io.DeckSerializer;
import forge.game.Game;
@@ -22,7 +21,7 @@ import forge.util.Lang;
public class SimulateMatch {
public static void simulate(String[] args) {
FModel.initialize(GuiBase.getInterface(), null);
FModel.initialize(null);
System.out.println("Simulation mode");
if(args.length < 3 ) {

View File

@@ -30,7 +30,6 @@ import java.util.List;
import javax.swing.SwingUtilities;
import forge.FThreads;
import forge.GuiBase;
import forge.screens.match.CMatchUI;
import forge.toolbox.FScrollPane;
import forge.toolbox.FSkin.SkinnedPanel;
@@ -333,7 +332,7 @@ public abstract class CardPanelContainer extends SkinnedPanel {
* a {@link forge.view.arcane.CardPanel} object.
*/
public final void removeCardPanel(final CardPanel fromPanel) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
if (CardPanelContainer.this.getMouseDragPanel() != null) {
CardPanel.getDragAnimationPanel().setVisible(false);
CardPanel.getDragAnimationPanel().repaint();
@@ -385,7 +384,7 @@ public abstract class CardPanelContainer extends SkinnedPanel {
* </p>
*/
public final void clear() {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
for (CardPanel p : CardPanelContainer.this.getCardPanels()) {
p.dispose();
}

View File

@@ -28,7 +28,6 @@ import java.util.List;
import com.google.common.collect.Lists;
import forge.FThreads;
import forge.GuiBase;
import forge.game.zone.ZoneType;
import forge.screens.match.CMatchUI;
import forge.screens.match.controllers.CPrompt;
@@ -595,7 +594,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
* </p>
*/
public void setupPlayZone() {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
recalculateCardPanels(model, zone);
}

View File

@@ -20,7 +20,7 @@ public class BoosterDraft1Test {
*/
@Test(groups = { "UnitTest", "fast" }, timeOut = 1000, enabled = false)
public void boosterDraft1Test1() throws Exception {
final BoosterDraft draft = BoosterDraft.createDraft(GuiBase.getInterface(), LimitedPoolType.Full);
final BoosterDraft draft = BoosterDraft.createDraft(LimitedPoolType.Full);
if (draft == null) { return; }
while (draft.hasNextChoice()) {

View File

@@ -45,7 +45,7 @@ public class PanelTest extends JFrame {
this.jbInit();
}
catch (final Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
ex.printStackTrace();
}
}

View File

@@ -17,7 +17,6 @@ import forge.assets.ImageCache;
import forge.error.BugReporter;
import forge.error.ExceptionHandler;
import forge.interfaces.IDeviceAdapter;
import forge.interfaces.IGuiBase;
import forge.match.MatchUtil;
import forge.model.FModel;
import forge.properties.ForgeConstants;
@@ -57,8 +56,7 @@ public class Forge implements ApplicationListener {
if (GuiBase.getInterface() == null) {
clipboard = clipboard0;
deviceAdapter = deviceAdapter0;
final IGuiBase gui = new GuiMobile(assetDir0);
GuiBase.setInterface(gui);
GuiBase.setInterface(new GuiMobile(assetDir0));
}
return app;
}
@@ -69,7 +67,7 @@ public class Forge implements ApplicationListener {
@Override
public void create() {
//install our error handler
ExceptionHandler.registerErrorHandling(GuiBase.getInterface());
ExceptionHandler.registerErrorHandling();
MatchUtil.setController(MatchController.instance);
@@ -94,7 +92,7 @@ public class Forge implements ApplicationListener {
AssetsDownloader.checkForUpdates(splashScreen);
if (exited) { return; } //don't continue if user chose to exit or couldn't download required assets
FModel.initialize(GuiBase.getInterface(), splashScreen.getProgressBar());
FModel.initialize(splashScreen.getProgressBar());
splashScreen.getProgressBar().setDescription("Loading fonts...");
FSkinFont.preloadAll();
@@ -215,7 +213,7 @@ public class Forge implements ApplicationListener {
}
catch (Exception ex) {
graphics.end();
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
}
}
@@ -259,7 +257,7 @@ public class Forge implements ApplicationListener {
}
catch (Exception ex) {
graphics.end();
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
}
}
@@ -277,7 +275,7 @@ public class Forge implements ApplicationListener {
}
catch (Exception ex) {
graphics.end();
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
}
}
@@ -451,7 +449,7 @@ public class Forge implements ApplicationListener {
return false;
}
catch (Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
return true;
}
}
@@ -467,7 +465,7 @@ public class Forge implements ApplicationListener {
return false;
}
catch (Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
return true;
}
}
@@ -483,7 +481,7 @@ public class Forge implements ApplicationListener {
return false;
}
catch (Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
return true;
}
}
@@ -499,7 +497,7 @@ public class Forge implements ApplicationListener {
return false;
}
catch (Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
return true;
}
}
@@ -515,7 +513,7 @@ public class Forge implements ApplicationListener {
return false;
}
catch (Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
return true;
}
}
@@ -531,7 +529,7 @@ public class Forge implements ApplicationListener {
return false;
}
catch (Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
return true;
}
}
@@ -547,7 +545,7 @@ public class Forge implements ApplicationListener {
return false;
}
catch (Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
return true;
}
}
@@ -563,7 +561,7 @@ public class Forge implements ApplicationListener {
return false;
}
catch (Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
return true;
}
}

View File

@@ -112,7 +112,7 @@ public class GuiMobile implements IGuiBase {
@Override
public ISkinImage getUnskinnedIcon(String path) {
if (FThreads.isGuiThread(this)) {
if (isGuiThread()) {
return new FTextureImage(new Texture(Gdx.files.absolute(path)));
}
@@ -219,9 +219,9 @@ public class GuiMobile implements IGuiBase {
if (delayedReveal == null || Iterables.isEmpty(delayedReveal.getCards())) {
if (isOptional) {
return SGuiChoose.oneOrNone(this, title, choiceList);
return SGuiChoose.oneOrNone(title, choiceList);
}
return SGuiChoose.one(this, title, choiceList);
return SGuiChoose.one(title, choiceList);
}
controller.tempShow(delayedReveal.getCards());

View File

@@ -21,7 +21,6 @@ import com.esotericsoftware.minlog.Log;
import forge.FThreads;
import forge.Forge;
import forge.GuiBase;
import forge.properties.ForgeConstants;
import forge.screens.SplashScreen;
import forge.toolbox.FProgressBar;
@@ -52,7 +51,7 @@ public class AssetsDownloader {
if (!Forge.getDeviceAdapter().isConnectedToWifi()) {
message += " If so, you may want to connect to wifi first. The download is around 6.5MB.";
}
if (SOptionPane.showConfirmDialog(GuiBase.getInterface(), message, "New Version Available", "Update Now", "Update Later")) {
if (SOptionPane.showConfirmDialog(message, "New Version Available", "Update Now", "Update Later")) {
String apkFile = downloadFile("update", "forge-android-" + version + "-signed-aligned.apk",
"http://cardforge.org/android/releases/forge/forge-gui-android/" + version + "/",
Forge.getDeviceAdapter().getDownloadsDir(), splashScreen.getProgressBar());
@@ -61,7 +60,7 @@ public class AssetsDownloader {
Forge.exit(true);
return;
}
SOptionPane.showMessageDialog(GuiBase.getInterface(), "Could not download update. " +
SOptionPane.showMessageDialog("Could not download update. " +
"Press OK to proceed without update.", "Update Failed");
}
}
@@ -99,7 +98,7 @@ public class AssetsDownloader {
else {
message += "You cannot start the app since you haven't previously downloaded these files.";
}
SOptionPane.showMessageDialog(GuiBase.getInterface(), message, "No Internet Connection");
SOptionPane.showMessageDialog(message, "No Internet Connection");
if (!canIgnoreDownload) {
Forge.exit(true); //exit if can't ignore download
}
@@ -125,7 +124,7 @@ public class AssetsDownloader {
message += "This download is mandatory to start the app since you haven't previously downloaded these files.";
options = new String[] { "Download", "Exit" };
}
switch (SOptionPane.showOptionDialog(GuiBase.getInterface(), message, "Download Resource Files?",
switch (SOptionPane.showOptionDialog(message, "Download Resource Files?",
null, options)) {
case 1:
if (!canIgnoreDownload) {
@@ -142,7 +141,7 @@ public class AssetsDownloader {
FSkinFont.deleteCachedFiles(); //delete cached font files in case any skin's .ttf file changed
//reload light version of skin after assets updated
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtAndWait(new Runnable() {
@Override
public void run() {
FSkinFont.updateAll(); //update all fonts used by splash screen

View File

@@ -9,7 +9,6 @@ import com.badlogic.gdx.math.Matrix4;
import forge.FThreads;
import forge.Graphics;
import forge.GuiBase;
//Special graphics object for rendering to a texture
public abstract class FBufferedImage extends FImageComplex {
@@ -77,7 +76,7 @@ public abstract class FBufferedImage extends FImageComplex {
final FrameBuffer fb = frameBuffer;
if (fb != null) {
frameBuffer = null;
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override
public void run() {
fb.dispose(); //must be disposed on EDT thread

View File

@@ -15,7 +15,6 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import forge.FThreads;
import forge.GuiBase;
import forge.assets.FSkinImage.SourceFile;
import forge.card.CardFaceSymbols;
import forge.card.CardImageRenderer;
@@ -52,7 +51,7 @@ public class FSkin {
FThreads.invokeInBackgroundThread(new Runnable() {
@Override
public void run() {
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
loadLight(skinName, null);
@@ -64,7 +63,7 @@ public class FSkin {
FSkinFont.deleteCachedFiles(); //delete cached font files so font can be update for new skin
FSkinFont.updateAll();
CardImageRenderer.forceStaticFieldUpdate();
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
loader.hide();

View File

@@ -22,7 +22,6 @@ import com.badlogic.gdx.graphics.glutils.PixmapTextureData;
import com.badlogic.gdx.utils.Array;
import forge.FThreads;
import forge.GuiBase;
import forge.properties.ForgeConstants;
import forge.util.FileUtil;
import forge.util.Utils;
@@ -164,7 +163,7 @@ public class FSkinFont {
FileHandle fontFile = Gdx.files.absolute(ForgeConstants.FONTS_DIR + fontName + ".fnt");
if (fontFile != null && fontFile.exists()) {
final BitmapFontData data = new BitmapFontData(fontFile, false);
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override
public void run() { //font must be initialized on UI thread
font = new BitmapFont(data, (TextureRegion)null, true);
@@ -203,7 +202,7 @@ public class FSkinFont {
final Array<PixmapPacker.Page> pages = packer.getPages();
//finish generating font on UI thread
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override
public void run() {
TextureRegion[] textureRegions = new TextureRegion[pages.size];

View File

@@ -18,7 +18,6 @@
package forge.card;
import forge.Graphics;
import forge.GuiBase;
import forge.assets.FSkinImage;
import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostShard;
@@ -179,7 +178,7 @@ public class CardFaceSymbols {
String symbol = tok.nextToken();
FSkinImage image = MANA_IMAGES.get(symbol);
if (image == null) {
BugReporter.reportBug(GuiBase.getInterface(), "Symbol not recognized \"" + symbol + "\" in string: " + s);
BugReporter.reportBug("Symbol not recognized \"" + symbol + "\" in string: " + s);
continue;
}
g.drawImage(image, x, y, w, h);

View File

@@ -2,7 +2,6 @@ package forge.deck;
import forge.FThreads;
import forge.Forge;
import forge.GuiBase;
import forge.deck.Deck;
import forge.deck.FDeckEditor.EditorType;
import forge.deck.io.DeckPreferences;
@@ -57,7 +56,7 @@ public class FDeckChooser extends FScreen {
//Show screen to select a deck
private static FDeckChooser deckChooserForPrompt;
public static void promptForDeck(String title, GameType gameType, boolean forAi, final Callback<Deck> callback) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
if (deckChooserForPrompt == null) {
deckChooserForPrompt = new FDeckChooser(gameType, forAi, null);
}
@@ -375,7 +374,7 @@ public class FDeckChooser extends FScreen {
"White", "Blue", "Black", "Red", "Green" };
ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>();
for (int i = 0; i < colors.length; i++) {
decks.add(new ColorDeckGenerator(GuiBase.getInterface(), colors[i], i, lstDecks, isAi));
decks.add(new ColorDeckGenerator(colors[i], i, lstDecks, isAi));
}
lstDecks.setPool(decks);

View File

@@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
import forge.Forge;
import forge.Graphics;
import forge.GuiBase;
import forge.assets.FSkinColor;
import forge.assets.FSkinFont;
import forge.assets.FSkinColor.Colors;
@@ -44,13 +43,13 @@ public class BugReportDialog extends FScreen { //use screen rather than dialog s
btnReport.setCommand(new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
BugReporter.copyAndGoToForums(GuiBase.getInterface(), tvDetails.text);
BugReporter.copyAndGoToForums(tvDetails.text);
}
});
btnSave.setCommand(new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
BugReporter.saveToFile(GuiBase.getInterface(), tvDetails.text);
BugReporter.saveToFile(tvDetails.text);
}
});
btnContinue.setCommand(new FEventHandler() {

View File

@@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.FThreads;
import forge.Graphics;
import forge.GuiBase;
import forge.assets.FSkinColor;
import forge.assets.FSkinColor.Colors;
import forge.assets.FSkinFont;
@@ -27,7 +26,7 @@ public class LoadingOverlay extends FOverlay {
ThreadUtil.invokeInGameThread(new Runnable() {
@Override
public void run() {
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
runnable.run();

View File

@@ -9,7 +9,6 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.FThreads;
import forge.Forge;
import forge.Graphics;
import forge.GuiBase;
import forge.LobbyPlayer;
import forge.assets.FSkin;
import forge.assets.FSkinColor;
@@ -177,7 +176,7 @@ public class ConstructedScreen extends LaunchScreen {
playerPanels.get(6).initialize(FPref.CONSTRUCTED_P7_DECK_STATE, DeckType.COLOR_DECK);
playerPanels.get(7).initialize(FPref.CONSTRUCTED_P8_DECK_STATE, DeckType.COLOR_DECK);*/ //TODO: Support multiplayer and improve performance of loading this screen by using background thread
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
btnStart.setEnabled(true);

View File

@@ -2,7 +2,6 @@ package forge.screens.draft;
import forge.FThreads;
import forge.Forge;
import forge.GuiBase;
import forge.properties.ForgePreferences.FPref;
import forge.screens.LaunchScreen;
import forge.screens.LoadingOverlay;
@@ -49,13 +48,13 @@ public class DraftScreen extends LaunchScreen {
ThreadUtil.invokeInGameThread(new Runnable() { //must run in game thread to prevent blocking UI thread
@Override
public void run() {
final LimitedPoolType poolType = SGuiChoose.oneOrNone(GuiBase.getInterface(), "Choose Draft Format", LimitedPoolType.values());
final LimitedPoolType poolType = SGuiChoose.oneOrNone("Choose Draft Format", LimitedPoolType.values());
if (poolType == null) { return; }
final BoosterDraft draft = BoosterDraft.createDraft(GuiBase.getInterface(), poolType);
final BoosterDraft draft = BoosterDraft.createDraft(poolType);
if (draft == null) { return; }
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
LoadingOverlay.show("Loading new draft...", new Runnable() {
@@ -132,14 +131,14 @@ public class DraftScreen extends LaunchScreen {
}
}
final Integer rounds = SGuiChoose.getInteger(GuiBase.getInterface(), "How many opponents are you willing to face?",
final Integer rounds = SGuiChoose.getInteger("How many opponents are you willing to face?",
1, FModel.getDecks().getDraft().get(humanDeck.getName()).getAiDecks().size());
if (rounds == null) {
creatingMatch = false;
return;
}
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
LoadingOverlay.show("Loading new game...", new Runnable() {

View File

@@ -12,7 +12,6 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.FThreads;
import forge.Graphics;
import forge.GuiBase;
import forge.assets.FSkinColor;
import forge.assets.FSkinColor.Colors;
import forge.assets.FSkinFont;
@@ -285,14 +284,14 @@ public class GauntletScreen extends LaunchScreen {
String gauntletName;
String oldGauntletName = gauntlet.getName();
while (true) {
gauntletName = SOptionPane.showInputDialog(GuiBase.getInterface(), "Enter new name for gauntlet:", "Rename Gauntlet", null, oldGauntletName);
gauntletName = SOptionPane.showInputDialog("Enter new name for gauntlet:", "Rename Gauntlet", null, oldGauntletName);
if (gauntletName == null) { return; }
gauntletName = QuestUtil.cleanString(gauntletName);
if (gauntletName.equals(oldGauntletName)) { return; } //quit if chose same name
if (gauntletName.isEmpty()) {
SOptionPane.showMessageDialog(GuiBase.getInterface(), "Please specify a gauntlet name.");
SOptionPane.showMessageDialog("Please specify a gauntlet name.");
continue;
}
@@ -304,13 +303,13 @@ public class GauntletScreen extends LaunchScreen {
}
}
if (exists) {
SOptionPane.showMessageDialog(GuiBase.getInterface(), "A gauntlet already exists with that name. Please pick another gauntlet name.");
SOptionPane.showMessageDialog("A gauntlet already exists with that name. Please pick another gauntlet name.");
continue;
}
break;
}
final String newGauntletName = gauntletName;
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
gauntlet.rename(newGauntletName);
@@ -328,7 +327,7 @@ public class GauntletScreen extends LaunchScreen {
ThreadUtil.invokeInGameThread(new Runnable() {
@Override
public void run() {
if (!SOptionPane.showConfirmDialog(GuiBase.getInterface(),
if (!SOptionPane.showConfirmDialog(
"Are you sure you want to delete '" + gauntlet.getName() + "'?",
"Delete Gauntlet", "Delete", "Cancel")) {
return;

View File

@@ -13,7 +13,6 @@ import com.badlogic.gdx.Gdx;
import forge.Forge;
import forge.Graphics;
import forge.GuiBase;
import forge.LobbyPlayer;
import forge.assets.FImage;
import forge.assets.FSkin;
@@ -220,7 +219,7 @@ public class MatchController implements IMatchController {
if (abilities.size() == 1) {
return abilities.get(0).getId();
}
final SpellAbilityView choice = SGuiChoose.oneOrNone(GuiBase.getInterface(), "Choose ability to play", abilities);
final SpellAbilityView choice = SGuiChoose.oneOrNone("Choose ability to play", abilities);
return choice == null ? -1 : choice.getId();
}

View File

@@ -9,7 +9,6 @@ import com.badlogic.gdx.math.Vector2;
import forge.FThreads;
import forge.Graphics;
import forge.GuiBase;
import forge.card.CardZoom;
import forge.card.CardRenderer.CardStackPosition;
import forge.match.MatchUtil;
@@ -80,7 +79,7 @@ public abstract class VCardDisplayArea extends VDisplayArea {
}
public final void removeCardPanel(final CardAreaPanel fromPanel) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
/*if (CardPanelContainer.this.getMouseDragPanel() != null) {
CardPanel.getDragAnimationPanel().setVisible(false);
CardPanel.getDragAnimationPanel().repaint();

View File

@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import forge.FThreads;
import forge.GuiBase;
import forge.screens.match.views.VCardDisplayArea.CardAreaPanel;
import forge.toolbox.FContainer;
import forge.view.CardView;
@@ -42,7 +41,7 @@ public class VField extends FContainer {
}
public void update() {
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), updateRoutine);
FThreads.invokeInEdtNowOrLater(updateRoutine);
}
private final Runnable updateRoutine = new Runnable() {

View File

@@ -1,7 +1,6 @@
package forge.screens.match.views;
import forge.FThreads;
import forge.GuiBase;
import forge.view.PlayerView;
public class VFlashbackZone extends VCardDisplayArea {
@@ -13,7 +12,7 @@ public class VFlashbackZone extends VCardDisplayArea {
@Override
public void update() {
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), updateRoutine);
FThreads.invokeInEdtNowOrLater(updateRoutine);
}
private final Runnable updateRoutine = new Runnable() {

View File

@@ -3,7 +3,6 @@ package forge.screens.match.views;
import java.util.ArrayList;
import forge.FThreads;
import forge.GuiBase;
import forge.game.zone.ZoneType;
import forge.toolbox.FCardPanel;
import forge.toolbox.FDisplayObject;
@@ -25,7 +24,7 @@ public class VZoneDisplay extends VCardDisplayArea {
@Override
public void update() {
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), updateRoutine);
FThreads.invokeInEdtNowOrLater(updateRoutine);
}
private final Runnable updateRoutine = new Runnable() {

View File

@@ -18,7 +18,6 @@ package forge.screens.match.winlose;
*/
import forge.FThreads;
import forge.GuiBase;
import forge.assets.FSkinProp;
import forge.gauntlet.GauntletWinLoseController;
import forge.util.gui.SOptionPane;
@@ -67,7 +66,7 @@ public class GauntletWinLose extends ControlWinLose {
sb.deleteCharAt(sb.length() - 1); //remove final new line character
}
SOptionPane.showMessageDialog(GuiBase.getInterface(), sb.toString(), "Gauntlet Progress", icon);
SOptionPane.showMessageDialog(sb.toString(), "Gauntlet Progress", icon);
}
});
}

View File

@@ -17,7 +17,6 @@ package forge.screens.match.winlose;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import forge.GuiBase;
import forge.limited.LimitedWinLoseController;
import forge.view.IGameView;
@@ -36,7 +35,7 @@ public class LimitedWinLose extends ControlWinLose {
*/
public LimitedWinLose(final ViewWinLose view0, IGameView lastGame) {
super(view0, lastGame);
controller = new LimitedWinLoseController(view0, lastGame, GuiBase.getInterface()) {
controller = new LimitedWinLoseController(view0, lastGame) {
@Override
protected void showOutcome(Runnable runnable) {
//invoke reward logic in background thread so dialogs can be shown

View File

@@ -19,7 +19,6 @@ package forge.screens.match.winlose;
import java.util.List;
import forge.FThreads;
import forge.GuiBase;
import forge.assets.FSkinProp;
import forge.item.PaperCard;
import forge.quest.QuestWinLoseController;
@@ -47,7 +46,7 @@ public class QuestWinLose extends ControlWinLose {
*/
public QuestWinLose(final ViewWinLose view0, IGameView lastGame) {
super(view0, lastGame);
controller = new QuestWinLoseController(lastGame, GuiBase.getInterface()) {
controller = new QuestWinLoseController(lastGame) {
@Override
protected void showRewards(Runnable runnable) {
//invoke reward logic in background thread so dialogs can be shown
@@ -56,12 +55,12 @@ public class QuestWinLose extends ControlWinLose {
@Override
protected void showCards(String title, List<PaperCard> cards) {
SGuiChoose.reveal(gui, title, cards);
SGuiChoose.reveal(title, cards);
}
@Override
protected void showMessage(String message, String title, FSkinProp icon) {
SOptionPane.showMessageDialog(gui, message, title, icon);
SOptionPane.showMessageDialog(message, title, icon);
}
};
}

View File

@@ -15,7 +15,6 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.FThreads;
import forge.Forge;
import forge.Graphics;
import forge.GuiBase;
import forge.assets.FSkinColor;
import forge.assets.FSkinColor.Colors;
import forge.assets.FSkinFont;
@@ -180,14 +179,14 @@ public class LoadQuestScreen extends FScreen {
String questName;
String oldQuestName = quest.getName();
while (true) {
questName = SOptionPane.showInputDialog(GuiBase.getInterface(), "Enter new name for quest:", "Rename Quest", null, oldQuestName);
questName = SOptionPane.showInputDialog("Enter new name for quest:", "Rename Quest", null, oldQuestName);
if (questName == null) { return; }
questName = QuestUtil.cleanString(questName);
if (questName.equals(oldQuestName)) { return; } //quit if chose same name
if (questName.isEmpty()) {
SOptionPane.showMessageDialog(GuiBase.getInterface(), "Please specify a quest name.");
SOptionPane.showMessageDialog("Please specify a quest name.");
continue;
}
@@ -199,7 +198,7 @@ public class LoadQuestScreen extends FScreen {
}
}
if (exists) {
SOptionPane.showMessageDialog(GuiBase.getInterface(), "A quest already exists with that name. Please pick another quest name.");
SOptionPane.showMessageDialog("A quest already exists with that name. Please pick another quest name.");
continue;
}
break;
@@ -216,7 +215,7 @@ public class LoadQuestScreen extends FScreen {
ThreadUtil.invokeInGameThread(new Runnable() {
@Override
public void run() {
if (!SOptionPane.showConfirmDialog(GuiBase.getInterface(),
if (!SOptionPane.showConfirmDialog(
"Are you sure you want to delete '" + quest.getName() + "'?",
"Delete Quest", "Delete", "Cancel")) {
return;

View File

@@ -13,7 +13,6 @@ import org.apache.commons.lang3.text.WordUtils;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.FThreads;
import forge.GuiBase;
import forge.assets.FSkinFont;
import forge.assets.FSkinImage;
import forge.card.MagicColor;
@@ -435,7 +434,7 @@ public class NewQuestScreen extends FScreen {
case CustomFormat:
if (customFormatCodes.isEmpty()) {
if (!SOptionPane.showConfirmDialog(GuiBase.getInterface(),
if (!SOptionPane.showConfirmDialog(
"You have defined a custom format that doesn't contain any sets.\nThis will start a game without restriction.\n\nContinue?")) {
return;
}
@@ -448,7 +447,7 @@ public class NewQuestScreen extends FScreen {
case Cube:
dckStartPool = getSelectedDeck();
if (dckStartPool == null) {
SOptionPane.showMessageDialog(GuiBase.getInterface(),
SOptionPane.showMessageDialog(
"You have not selected a deck to start.", "Cannot start a quest", SOptionPane.ERROR_ICON);
return;
}
@@ -495,7 +494,7 @@ public class NewQuestScreen extends FScreen {
break;
case CustomFormat:
if (customPrizeFormatCodes.isEmpty()) {
if (!SOptionPane.showConfirmDialog(GuiBase.getInterface(),
if (!SOptionPane.showConfirmDialog(
"You have defined custom format as containing no sets.\nThis will choose all editions without restriction as prized.\n\nContinue?")) {
return;
}
@@ -512,17 +511,17 @@ public class NewQuestScreen extends FScreen {
String questName;
while (true) {
questName = SOptionPane.showInputDialog(GuiBase.getInterface(), "Poets will remember your quest as:", "Quest Name");
questName = SOptionPane.showInputDialog("Poets will remember your quest as:", "Quest Name");
if (questName == null) { return; }
questName = QuestUtil.cleanString(questName);
if (questName.isEmpty()) {
SOptionPane.showMessageDialog(GuiBase.getInterface(), "Please specify a quest name.");
SOptionPane.showMessageDialog("Please specify a quest name.");
continue;
}
if (FileUtil.doesFileExist(ForgeConstants.QUEST_SAVE_DIR + questName + ".dat")) {
SOptionPane.showMessageDialog(GuiBase.getInterface(), "A quest already exists with that name. Please pick another quest name.");
SOptionPane.showMessageDialog("A quest already exists with that name. Please pick another quest name.");
continue;
}
break;
@@ -532,7 +531,7 @@ public class NewQuestScreen extends FScreen {
}
private void startNewQuest(final String questName, final GameFormat fmtPrizes, final Deck dckStartPool, final GameFormat fmtStartPool) {
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
LoadingOverlay.show("Creating new quest...", new Runnable() {

View File

@@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.FThreads;
import forge.Forge;
import forge.GuiBase;
import forge.assets.FSkinFont;
import forge.deck.DeckProxy;
import forge.deck.DeckgenUtil;
@@ -71,10 +70,10 @@ public class QuestDecksScreen extends FScreen {
ThreadUtil.invokeInGameThread(new Runnable() { //must run in game thread to prevent blocking UI thread
@Override
public void run() {
if (!QuestUtil.checkActiveQuest(GuiBase.getInterface(), "Create a Deck.")) {
if (!QuestUtil.checkActiveQuest("Create a Deck.")) {
return;
}
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
QuestDeckEditor editor = new QuestDeckEditor();

View File

@@ -1,8 +1,6 @@
package forge.screens.quest;
import forge.FThreads;
import forge.GuiBase;
import forge.interfaces.IGuiBase;
import forge.model.FModel;
import forge.quest.QuestUtil;
import forge.screens.LaunchScreen;
@@ -29,15 +27,14 @@ public abstract class QuestLaunchScreen extends LaunchScreen {
FThreads.invokeInBackgroundThread(new Runnable() {
@Override
public void run() {
final IGuiBase gui = GuiBase.getInterface();
if (QuestUtil.canStartGame(gui)) {
FThreads.invokeInEdtLater(gui, new Runnable() {
if (QuestUtil.canStartGame()) {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
LoadingOverlay.show("Loading new game...", new Runnable() {
@Override
public void run() {
QuestUtil.finishStartingGame(gui);
QuestUtil.finishStartingGame();
creatingMatch = false;
}
});

View File

@@ -4,7 +4,6 @@ import java.io.File;
import forge.FThreads;
import forge.Forge;
import forge.GuiBase;
import forge.assets.FSkinImage;
import forge.deck.Deck;
import forge.deck.FDeckEditor.DeckController;
@@ -12,7 +11,6 @@ import forge.deck.FDeckEditor.EditorType;
import forge.interfaces.IButton;
import forge.interfaces.ICheckBox;
import forge.interfaces.IComboBox;
import forge.interfaces.IGuiBase;
import forge.menu.FMenuItem;
import forge.menu.FPopupMenu;
import forge.model.FModel;
@@ -81,14 +79,13 @@ public class QuestMenu extends FPopupMenu implements IVQuestStats {
}
});
private static final FMenuItem unlockSetsItem = new FMenuItem("Unlock Sets", FSkinImage.QUEST_MAP, new FEventHandler() {
final IGuiBase gui = GuiBase.getInterface();
@Override
public void handleEvent(FEvent e) {
ThreadUtil.invokeInGameThread(new Runnable() { //invoke in background thread so prompts can work
@Override
public void run() {
QuestUtil.chooseAndUnlockEdition(gui);
FThreads.invokeInEdtLater(gui, new Runnable() {
QuestUtil.chooseAndUnlockEdition();
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
updateCurrentQuestScreen();
@@ -99,14 +96,13 @@ public class QuestMenu extends FPopupMenu implements IVQuestStats {
}
});
private static final FMenuItem travelItem = new FMenuItem("Travel", FSkinImage.QUEST_MAP, new FEventHandler() {
final IGuiBase gui = GuiBase.getInterface();
@Override
public void handleEvent(FEvent e) {
ThreadUtil.invokeInGameThread(new Runnable() { //invoke in background thread so prompts can work
@Override
public void run() {
QuestUtil.travelWorld(gui);
FThreads.invokeInEdtLater(gui, new Runnable() {
QuestUtil.travelWorld();
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
updateCurrentQuestScreen();

View File

@@ -8,7 +8,6 @@ import java.util.Map;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.FThreads;
import forge.GuiBase;
import forge.assets.FImage;
import forge.assets.FSkinFont;
import forge.assets.FSkinImage;
@@ -133,7 +132,7 @@ public class QuestSpellShopScreen extends TabPageScreen<QuestSpellShopScreen> {
ItemPool<InventoryItem> items = new ItemPool<InventoryItem>(InventoryItem.class);
items.add(item, result);
activateItems(items);
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
parentScreen.updateCreditsLabel();
@@ -181,7 +180,7 @@ public class QuestSpellShopScreen extends TabPageScreen<QuestSpellShopScreen> {
@Override
protected void activateItems(ItemPool<InventoryItem> items) {
QuestSpellShop.buy(GuiBase.getInterface(), items, itemManager, ((InventoryPage)parentScreen.tabPages[1]).itemManager, true);
QuestSpellShop.buy(items, itemManager, ((InventoryPage)parentScreen.tabPages[1]).itemManager, true);
}
@Override
@@ -211,7 +210,7 @@ public class QuestSpellShopScreen extends TabPageScreen<QuestSpellShopScreen> {
@Override
public void run() {
QuestSpellShop.sellExtras(((SpellShopPage)parentScreen.tabPages[0]).itemManager, itemManager);
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
parentScreen.updateCreditsLabel();
@@ -241,7 +240,7 @@ public class QuestSpellShopScreen extends TabPageScreen<QuestSpellShopScreen> {
@Override
protected void activateItems(ItemPool<InventoryItem> items) {
QuestSpellShop.sell(GuiBase.getInterface(), items, ((SpellShopPage)parentScreen.tabPages[0]).itemManager, itemManager, true);
QuestSpellShop.sell(items, ((SpellShopPage)parentScreen.tabPages[0]).itemManager, itemManager, true);
}
@Override

View File

@@ -2,7 +2,6 @@ package forge.screens.quest;
import java.util.List;
import forge.GuiBase;
import forge.assets.FSkinFont;
import forge.assets.FSkinImage;
import forge.interfaces.IButton;
@@ -128,7 +127,7 @@ public class QuestStatsScreen extends FScreen {
lblZep.setCommand(new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
if (!QuestUtil.checkActiveQuest(GuiBase.getInterface(), "Launch a Zeppelin.")) {
if (!QuestUtil.checkActiveQuest("Launch a Zeppelin.")) {
return;
}
FModel.getQuest().getAchievements().setCurrentChallenges(null);

View File

@@ -2,7 +2,6 @@ package forge.screens.sealed;
import forge.FThreads;
import forge.Forge;
import forge.GuiBase;
import forge.assets.FSkinFont;
import forge.deck.DeckGroup;
import forge.deck.DeckProxy;
@@ -47,10 +46,10 @@ public class SealedScreen extends LaunchScreen {
ThreadUtil.invokeInGameThread(new Runnable() { //must run in game thread to prevent blocking UI thread
@Override
public void run() {
final DeckGroup sealed = SealedCardPoolGenerator.generateSealedDeck(GuiBase.getInterface(), false);
final DeckGroup sealed = SealedCardPoolGenerator.generateSealedDeck(false);
if (sealed == null) { return; }
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
DeckPreferences.setSealedDeck(sealed.getName());

View File

@@ -21,7 +21,6 @@ import java.net.Proxy;
import com.badlogic.gdx.Gdx;
import forge.GuiBase;
import forge.UiCommand;
import forge.assets.FSkinFont;
import forge.download.GuiDownloadService;
@@ -83,7 +82,7 @@ public class GuiDownloader extends FDialog {
show();
service.initialize(GuiBase.getInterface(), txtAddress, txtPort, progressBar, btnStart, cmdClose, new Runnable() {
service.initialize(txtAddress, txtPort, progressBar, btnStart, cmdClose, new Runnable() {
@Override
public void run() {
Gdx.graphics.setContinuousRendering(false);

View File

@@ -6,7 +6,6 @@ import java.util.ConcurrentModificationException;
import com.badlogic.gdx.math.Vector2;
import forge.Graphics;
import forge.GuiBase;
import forge.error.BugReporter;
public abstract class FContainer extends FDisplayObject {
@@ -75,7 +74,7 @@ public abstract class FContainer extends FDisplayObject {
//ignore concurrent modification exceptions during render
}
catch (Exception ex) {
BugReporter.reportException(ex, GuiBase.getInterface());
BugReporter.reportException(ex);
}
}

View File

@@ -21,7 +21,6 @@ package forge.toolbox;
import com.google.common.base.Function;
import forge.FThreads;
import forge.GuiBase;
import forge.assets.FSkinFont;
import forge.toolbox.FEvent;
import forge.toolbox.FEvent.FEventHandler;
@@ -71,7 +70,7 @@ public class ListChooser<T> extends FContainer {
private final Callback<List<T>> callback;
public ListChooser(final String title, final int minChoices, final int maxChoices, final Collection<T> list0, final Function<T, String> display0, final Callback<List<T>> callback0) {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
FThreads.assertExecutedByEdt(true);
list = list0;
if (list.size() > 25) { //only show search field if more than 25 items
txtSearch = add(new FTextField());

View File

@@ -1,7 +1,6 @@
package forge.util;
import forge.FThreads;
import forge.GuiBase;
public abstract class WaitCallback<T> extends Callback<T> implements Runnable {
public class Lock {
@@ -20,8 +19,8 @@ public abstract class WaitCallback<T> extends Callback<T> implements Runnable {
}
public final T invokeAndWait() {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false); //not supported if on UI thread
FThreads.invokeInEdtLater(GuiBase.getInterface(), this);
FThreads.assertExecutedByEdt(false); //not supported if on UI thread
FThreads.invokeInEdtLater(this);
try {
synchronized (lock) {
lock.wait();

View File

@@ -3,7 +3,6 @@ package forge.util;
import com.badlogic.gdx.Gdx;
import forge.FThreads;
import forge.GuiBase;
public abstract class WaitRunnable implements Runnable {
public class Lock {
@@ -12,7 +11,7 @@ public abstract class WaitRunnable implements Runnable {
private final Lock lock = new Lock();
public void invokeAndWait() {
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false);
FThreads.assertExecutedByEdt(false);
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {

View File

@@ -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 &emsp; String, part of the custom exception message.
* @param mustBeEDT &emsp; 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);
}
}

View File

@@ -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;
}

View File

@@ -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();
}

View File

@@ -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();
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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();

View File

@@ -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();

View File

@@ -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++) {

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}
});
}

View File

@@ -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() {

Some files were not shown because too many files have changed in this diff Show More