mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Fix the refactored GUI code so that games can now be played.
This commit is contained in:
@@ -21,7 +21,8 @@ public class MagicColor {
|
||||
public static final byte ALL_COLORS = BLACK | BLUE | WHITE | RED | GREEN;
|
||||
public static final int NUMBER_OR_COLORS = 5;
|
||||
|
||||
public static final byte[] WUBRG = new byte[] { WHITE, BLUE, BLACK, RED, GREEN };
|
||||
public static final byte[] WUBRG = new byte[] { WHITE, BLUE, BLACK, RED, GREEN };
|
||||
public static final byte[] WUBRGC = new byte[] { WHITE, BLUE, BLACK, RED, GREEN, COLORLESS };
|
||||
|
||||
public static byte fromName(String s) {
|
||||
if( s == null ) return 0;
|
||||
|
||||
@@ -92,7 +92,7 @@ final class ImageLoader extends CacheLoader<String, BufferedImage> {
|
||||
return ImageIO.read(file);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
BugReporter.reportException(ex, "Could not read image file " + file.getAbsolutePath() + " ");
|
||||
BugReporter.reportException(ex, GuiBase.getInterface(), "Could not read image file " + file.getAbsolutePath() + " ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package forge;
|
||||
|
||||
import forge.control.FControl;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.properties.ForgeProfileProperties;
|
||||
import forge.view.FView;
|
||||
|
||||
@@ -48,7 +47,6 @@ public final class Singletons {
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
ForgeConstants.init(GuiBase.getInterface());
|
||||
ForgeProfileProperties.init(GuiBase.getInterface());
|
||||
|
||||
if (withUi) {
|
||||
|
||||
@@ -124,7 +124,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
EXIT_FORGE
|
||||
}
|
||||
|
||||
private final SoundSystem soundSystem = new SoundSystem(GuiBase.getInterface());
|
||||
private SoundSystem soundSystem;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -219,6 +219,8 @@ public enum FControl implements KeyEventDispatcher {
|
||||
// Preloads skin components (using progress bar).
|
||||
FSkin.loadFull(true);
|
||||
|
||||
this.soundSystem = new SoundSystem(GuiBase.getInterface());
|
||||
|
||||
this.shortcuts = KeyboardShortcuts.attachKeyboardShortcuts();
|
||||
this.display = FView.SINGLETON_INSTANCE.getLpnDocument();
|
||||
|
||||
@@ -423,7 +425,9 @@ public enum FControl implements KeyEventDispatcher {
|
||||
inputQueue.onGameOver(false); //release any waiting input, effectively passing priority
|
||||
}
|
||||
|
||||
playbackControl.onGameStopRequested();
|
||||
if (playbackControl != null) {
|
||||
playbackControl.onGameStopRequested();
|
||||
}
|
||||
}
|
||||
|
||||
private InputQueue inputQueue;
|
||||
@@ -447,7 +451,9 @@ public enum FControl implements KeyEventDispatcher {
|
||||
return; //TODO: See if it's possible to run multiple games at once without crashing
|
||||
}
|
||||
setPlayerName(match.getPlayers());
|
||||
final Game game = match.createGame();
|
||||
this.game = match.createGame();
|
||||
inputQueue = new InputQueue(game);
|
||||
|
||||
final LobbyPlayer me = getGuiPlayer();
|
||||
for (final Player p : game.getPlayers()) {
|
||||
if (p.getLobbyPlayer().equals(me)) {
|
||||
@@ -457,7 +463,6 @@ public enum FControl implements KeyEventDispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
inputQueue = new InputQueue(GuiBase.getInterface(), game);
|
||||
attachToGame(this.gameView);
|
||||
|
||||
// It's important to run match in a different thread to allow GUI inputs to be invoked from inside game.
|
||||
@@ -526,7 +531,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
game0.subscribeToEvents(fcVisitor);
|
||||
|
||||
// Add playback controls to match if needed
|
||||
if (localPlayer != null) {
|
||||
if (localPlayer == null) {
|
||||
// Create dummy controller
|
||||
final PlayerControllerHuman controller =
|
||||
new PlayerControllerLocal(game, null, humanLobbyPlayer, GuiBase.getInterface());
|
||||
|
||||
@@ -30,6 +30,7 @@ import forge.toolbox.FButton;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FDeckViewer extends FDialog {
|
||||
@@ -61,7 +62,7 @@ public class FDeckViewer extends FDialog {
|
||||
return new ImageView<PaperCard>(this, model0) {
|
||||
@Override
|
||||
protected void showHoveredItem(PaperCard item) {
|
||||
final CardView card = CardView.getCardForUi(item);
|
||||
final CardView card = ViewUtil.getCardForUi(item);
|
||||
if (card == null) { return; }
|
||||
|
||||
cardDetail.setCard(card);
|
||||
@@ -77,7 +78,7 @@ public class FDeckViewer extends FDialog {
|
||||
final IPaperCard paperCard = cardManager.getSelectedItem();
|
||||
if (paperCard == null) { return; }
|
||||
|
||||
final CardView card = CardView.getCardForUi(paperCard);
|
||||
final CardView card = ViewUtil.getCardForUi(paperCard);
|
||||
if (card == null) { return; }
|
||||
|
||||
cardDetail.setCard(card);
|
||||
|
||||
@@ -37,8 +37,8 @@ import forge.properties.ForgePreferences.FPref;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple class that shows a list of cards in a dialog with preview in its
|
||||
@@ -189,7 +189,7 @@ public class BoxedProductCardListViewer extends FDialog {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < BoxedProductCardListViewer.this.list.size())) {
|
||||
final PaperCard cp = BoxedProductCardListViewer.this.list.get(row);
|
||||
BoxedProductCardListViewer.this.detail.setCard(CardView.getCardForUi(cp));
|
||||
BoxedProductCardListViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
BoxedProductCardListViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* The class CardDetailPanel. Shows the details of a card.
|
||||
@@ -131,7 +132,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
powerToughnessLabel.setVisible(false);
|
||||
idLabel.setText("");
|
||||
cdArea.setText(CardDetailUtil.getItemDescription(item));
|
||||
this.updateBorder(item instanceof IPaperCard ? CardView.getCardForUi((IPaperCard)item).getState() : null, false);
|
||||
this.updateBorder(item instanceof IPaperCard ? ViewUtil.getCardForUi((IPaperCard)item).getState() : null, false);
|
||||
|
||||
String set = item.getEdition();
|
||||
setInfoLabel.setText(set);
|
||||
|
||||
@@ -37,8 +37,8 @@ import forge.properties.ForgePreferences.FPref;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple class that shows a list of cards in a dialog with preview in its
|
||||
@@ -172,7 +172,7 @@ public class CardListViewer extends FDialog {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < CardListViewer.this.list.size())) {
|
||||
final PaperCard cp = CardListViewer.this.list.get(row);
|
||||
CardListViewer.this.detail.setCard(CardView.getCardForUi(cp));
|
||||
CardListViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
CardListViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import forge.toolbox.FScrollPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.SpellAbilityView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
// An input box for handling the order of choices.
|
||||
// Left box has the original choices
|
||||
@@ -330,7 +331,7 @@ public class DualListBox<T> extends FDialog {
|
||||
} else if (obj instanceof SpellAbilityView) {
|
||||
card = ((SpellAbilityView) obj).getHostCard();
|
||||
} else if (obj instanceof PaperCard) {
|
||||
card = CardView.getCardForUi((IPaperCard) obj);
|
||||
card = ViewUtil.getCardForUi((IPaperCard) obj);
|
||||
}
|
||||
|
||||
GuiUtils.clearPanelSelections();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package forge.gui;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.error.BugReporter;
|
||||
@@ -513,7 +514,7 @@ public class ImportDialog {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
_progressBar.setString("Error");
|
||||
BugReporter.reportException(e);
|
||||
BugReporter.reportException(e, GuiBase.getInterface());
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
@@ -777,7 +778,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);
|
||||
BugReporter.reportException(e, GuiBase.getInterface());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -936,7 +937,7 @@ public class ImportDialog {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
_progressBar.setString("Error");
|
||||
BugReporter.reportException(e);
|
||||
BugReporter.reportException(e, GuiBase.getInterface());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import forge.toolbox.FSkin.SkinFont;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -232,7 +233,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
ItemInfo item = getItemAtPoint(e.getPoint());
|
||||
if (item != null && item.item instanceof IPaperCard) {
|
||||
setLockHoveredItem(true); //lock hoveredItem while zoomer open
|
||||
final CardView card = CardView.getCardForUi((IPaperCard) item.item);
|
||||
final CardView card = ViewUtil.getCardForUi((IPaperCard) item.item);
|
||||
CardZoomer.SINGLETON_INSTANCE.doMouseButtonZoom(card);
|
||||
}
|
||||
}
|
||||
@@ -1099,7 +1100,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
if (item instanceof IPaperCard) {
|
||||
IPaperCard paperCard = (IPaperCard)item;
|
||||
if (paperCard.isFoil()) {
|
||||
final CardView card = CardView.getCardForUi(paperCard);
|
||||
final CardView card = ViewUtil.getCardForUi(paperCard);
|
||||
if (card.getFoilIndex() == 0) { //if foil finish not yet established, assign a random one
|
||||
card.setRandomFoil();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import forge.deck.DeckBase;
|
||||
import forge.deck.io.DeckHtmlSerializer;
|
||||
import forge.deck.io.DeckSerializer;
|
||||
import forge.deck.io.DeckStorage;
|
||||
import forge.error.BugReporter;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.properties.ForgeConstants;
|
||||
@@ -156,7 +155,7 @@ public enum CCurrentDeck implements ICDoc {
|
||||
}
|
||||
});
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
//BugReporter.reportException(ex);
|
||||
throw new RuntimeException("Error creating new deck. " + ex);
|
||||
}
|
||||
}
|
||||
@@ -175,7 +174,7 @@ public enum CCurrentDeck implements ICDoc {
|
||||
.setModel(DeckSerializer.fromFile(file));
|
||||
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
//BugReporter.reportException(ex);
|
||||
throw new RuntimeException("Error importing deck." + ex);
|
||||
}
|
||||
}
|
||||
@@ -219,7 +218,7 @@ public enum CCurrentDeck implements ICDoc {
|
||||
DeckSerializer.writeDeck(deck, filename);
|
||||
controller.setModel(DeckSerializer.fromFile(filename)); //reload deck from file so everything is in sync
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
//BugReporter.reportException(ex);
|
||||
throw new RuntimeException("Error exporting deck." + ex);
|
||||
}
|
||||
}
|
||||
@@ -237,7 +236,7 @@ public enum CCurrentDeck implements ICDoc {
|
||||
((DeckController<Deck>) CDeckEditorUI.SINGLETON_INSTANCE
|
||||
.getCurrentEditorController().getDeckController()).getModel(), filename);
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
//BugReporter.reportException(ex);
|
||||
throw new RuntimeException("Error exporting deck." + ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ import forge.toolbox.FTextField;
|
||||
import forge.util.Lang;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.NameGenerator;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of constructed submenu singleton.
|
||||
@@ -1228,7 +1228,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
|
||||
if (obj instanceof PaperCard) {
|
||||
pp.setVanguardButtonText(((PaperCard) obj).getName());
|
||||
cdp.setCard(CardView.getCardForUi((PaperCard) obj));
|
||||
cdp.setCard(ViewUtil.getCardForUi((PaperCard) obj));
|
||||
cdp.setVisible(true);
|
||||
refreshPanels(false, true);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import forge.toolbox.FList;
|
||||
import forge.toolbox.FPanel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple JPanel that shows three columns: card list, pic, and description..
|
||||
@@ -112,7 +112,7 @@ public class QuestWinLoseCardViewer extends FPanel {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < QuestWinLoseCardViewer.this.list.size())) {
|
||||
final PaperCard cp = QuestWinLoseCardViewer.this.list.get(row);
|
||||
QuestWinLoseCardViewer.this.detail.setCard(CardView.getCardForUi(cp));
|
||||
QuestWinLoseCardViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
QuestWinLoseCardViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.Map;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.testng.collections.Lists;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.gui.framework.FScreen;
|
||||
@@ -245,6 +245,7 @@ public enum TargetingOverlay {
|
||||
}
|
||||
for (final CardView attackingCard : combat.getAttackers()) {
|
||||
final Iterable<CardView> cards = combat.getBlockers(attackingCard);
|
||||
if (cards == null) continue;
|
||||
for (final CardView blockingCard : cards) {
|
||||
if (!attackingCard.equals(c) && !blockingCard.equals(c)) { continue; }
|
||||
arcsCombat.add(new Point[] {
|
||||
|
||||
@@ -198,13 +198,13 @@ public class VAssignDamage {
|
||||
if (defender instanceof CardView)
|
||||
fakeCard = (CardView)defender;
|
||||
else if (defender instanceof PlayerView) {
|
||||
fakeCard = new CardView(null, -1, true);
|
||||
fakeCard = new CardView(-1, true);
|
||||
fakeCard.getState().setName(this.defender.toString());
|
||||
final PlayerView p = (PlayerView)defender;
|
||||
fakeCard.setOwner(p);
|
||||
fakeCard.getState().setImageKey(CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getLobbyPlayer()));
|
||||
} else {
|
||||
fakeCard = new CardView(null, -2, true);
|
||||
fakeCard = new CardView(-2, true);
|
||||
fakeCard.getState().setName(this.defender.toString());
|
||||
}
|
||||
addPanelForDefender(pnlDefenders, fakeCard);
|
||||
|
||||
@@ -3,8 +3,8 @@ package forge.screens.match;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.List;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.gui.GuiChoose;
|
||||
|
||||
@@ -121,8 +121,12 @@ public enum CCombat implements ICDoc {
|
||||
}
|
||||
}
|
||||
|
||||
for (final CardView blocker : blockers) {
|
||||
display.append(" < ").append(combatantToString(blocker)).append("\n");
|
||||
if (blockers != null) {
|
||||
for (final CardView blocker : blockers) {
|
||||
display.append(" < ")
|
||||
.append(combatantToString(blocker))
|
||||
.append("\n");
|
||||
}
|
||||
}
|
||||
previousBand = isBand;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import forge.item.InventoryItemFromSet;
|
||||
import forge.screens.match.views.VDetail;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* Controls the card detail area in the match UI.
|
||||
@@ -58,7 +59,7 @@ public enum CDetail implements ICDoc {
|
||||
|
||||
public void showCard(final InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
showCard(CardView.getCardForUi((IPaperCard)item));
|
||||
showCard(ViewUtil.getCardForUi((IPaperCard)item));
|
||||
} else if (item instanceof InventoryItemFromSet) {
|
||||
view.getLblFlipcard().setVisible(false);
|
||||
view.getPnlDetail().setItem((InventoryItemFromSet)item);
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.util.Observable;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.Singletons;
|
||||
@@ -105,7 +107,11 @@ public class CHand implements ICDoc {
|
||||
}
|
||||
|
||||
//update card panels in hand area
|
||||
final List<CardView> cards = player.getHandCards();
|
||||
|
||||
final List<CardView> cards;
|
||||
synchronized (player) {
|
||||
cards = ImmutableList.copyOf(player.getHandCards());
|
||||
}
|
||||
final List<CardPanel> placeholders = new ArrayList<CardPanel>();
|
||||
final List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import forge.screens.match.views.VPicture;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* Singleton controller for VPicture.
|
||||
@@ -81,7 +82,7 @@ public enum CPicture implements ICDoc {
|
||||
public void showImage(final InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
final IPaperCard paperCard = ((IPaperCard)item);
|
||||
final CardView c = CardView.getCardForUi(paperCard);
|
||||
final CardView c = ViewUtil.getCardForUi(paperCard);
|
||||
if (paperCard.isFoil() && c.getFoilIndex() == 0) {
|
||||
c.setRandomFoil();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class VCommand implements IVDoc<CCommand> {
|
||||
|
||||
// TODO player is hard-coded into tabletop...should be dynamic
|
||||
// (haven't looked into it too deeply). Doublestrike 12-04-12
|
||||
tabletop = new PlayArea(scroller, id0 == EDocID.COMMAND_0, player.getCommandCards());
|
||||
tabletop = new PlayArea(scroller, id0 == EDocID.COMMAND_0, player);
|
||||
|
||||
control = new CCommand(player, this);
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class VField implements IVDoc<CField> {
|
||||
|
||||
// TODO player is hard-coded into tabletop...should be dynamic
|
||||
// (haven't looked into it too deeply). Doublestrike 12-04-12
|
||||
tabletop = new PlayArea(scroller, id0 == EDocID.FIELD_1, player.getBfCards());
|
||||
tabletop = new PlayArea(scroller, id0 == EDocID.FIELD_1, player);
|
||||
|
||||
control = new CField(player, this, playerViewer);
|
||||
|
||||
|
||||
@@ -24,10 +24,9 @@ import java.util.Map.Entry;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.testng.collections.Maps;
|
||||
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
|
||||
@@ -30,7 +30,7 @@ import forge.gui.CardDetailPanel;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.item.PaperCard;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple JPanel that shows three columns: card list, pic, and description..
|
||||
@@ -93,7 +93,7 @@ public class CardViewer extends JPanel {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < CardViewer.this.list.size())) {
|
||||
final PaperCard cp = CardViewer.this.list.get(row);
|
||||
CardViewer.this.detail.setCard(CardView.getCardForUi(cp));
|
||||
CardViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
CardViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class Main {
|
||||
GuiBase.setInterface(new GuiDesktop());
|
||||
|
||||
//install our error handler
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
ExceptionHandler.registerErrorHandling(GuiBase.getInterface());
|
||||
|
||||
// Start splash screen first, then data models, then controller.
|
||||
if (args.length == 0) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.util.Animation;
|
||||
import forge.view.arcane.util.CardPanelMouseListener;
|
||||
|
||||
@@ -76,7 +77,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
private int extraCardSpacingX, cardSpacingX, cardSpacingY;
|
||||
private int stackSpacingX, stackSpacingY;
|
||||
|
||||
private final List<CardView> model;
|
||||
private final PlayerView model;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -85,13 +86,13 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
*
|
||||
* @param scrollPane
|
||||
* @param mirror
|
||||
* @param list
|
||||
* @param player
|
||||
*/
|
||||
public PlayArea(final FScrollPane scrollPane, final boolean mirror, final List<CardView> list) {
|
||||
public PlayArea(final FScrollPane scrollPane, final boolean mirror, final PlayerView player) {
|
||||
super(scrollPane);
|
||||
this.setBackground(Color.white);
|
||||
this.mirror = mirror;
|
||||
this.model = list;
|
||||
this.model = player;
|
||||
}
|
||||
|
||||
private final CardStackRow collectAllLands() {
|
||||
@@ -577,7 +578,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
super.mouseLeftClicked(panel, evt);
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void mouseRightClicked(final CardPanel panel, final MouseEvent evt) {
|
||||
@@ -595,7 +596,12 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
recalculateCardPanels(model);
|
||||
}
|
||||
|
||||
private void recalculateCardPanels(final List<CardView> model) {
|
||||
private void recalculateCardPanels(final PlayerView model) {
|
||||
final List<CardView> modelCopy;
|
||||
synchronized (model) {
|
||||
modelCopy = Lists.newArrayList(model.getBfCards());
|
||||
}
|
||||
|
||||
final List<CardView> oldCards = Lists.newArrayList();
|
||||
for (final CardPanel cpa : getCardPanels()) {
|
||||
oldCards.add(cpa.getCard());
|
||||
@@ -604,7 +610,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
final List<CardView> toReplace = Lists.newArrayList();
|
||||
|
||||
// delete all cards that differ in timestamp (they have been blinked)
|
||||
for (final CardView c : model) {
|
||||
for (final CardView c : modelCopy) {
|
||||
for (int i = 0; i < toDelete.size(); i++) {
|
||||
final CardView c2 = toDelete.get(i);
|
||||
if (c.getId() == c2.getId()) {
|
||||
@@ -623,8 +629,8 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
removeCardPanel(getCardPanel(card.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
final List<CardView> toAdd = new ArrayList<CardView>(model);
|
||||
|
||||
final List<CardView> toAdd = new ArrayList<CardView>(modelCopy);
|
||||
toAdd.removeAll(oldCards);
|
||||
toAdd.addAll(toReplace);
|
||||
|
||||
@@ -648,7 +654,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
}
|
||||
|
||||
for (final CardView card : model) {
|
||||
for (final CardView card : modelCopy) {
|
||||
updateCard(card, true);
|
||||
}
|
||||
invalidate();
|
||||
|
||||
@@ -45,7 +45,7 @@ public class PanelTest extends JFrame {
|
||||
this.jbInit();
|
||||
}
|
||||
catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, GuiBase.getInterface());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,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,
|
||||
BugReporter.reportException(ex, gui,
|
||||
"Proxy connection could not be established!\nProxy address: %s\nProxy port: %s",
|
||||
txtAddress.getText(), txtPort.getText());
|
||||
return;
|
||||
|
||||
@@ -114,15 +114,15 @@ public class BugReporter {
|
||||
/**
|
||||
* Alias for reportException(ex, null).
|
||||
*/
|
||||
public static void reportException(final Throwable ex) {
|
||||
reportException(ex, null);
|
||||
public static void reportException(final Throwable ex, final IGuiBase gui) {
|
||||
reportException(ex, gui, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for reportException(ex, String.format(format, args)).
|
||||
*/
|
||||
public static void reportException(final Throwable ex, final String format, final Object... args) {
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.lang.Thread.UncaughtExceptionHandler;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.MultiplexOutputStream;
|
||||
|
||||
@@ -46,6 +47,7 @@ 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;
|
||||
@@ -54,10 +56,12 @@ 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() {
|
||||
public static void registerErrorHandling(final IGuiBase gui) {
|
||||
//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");
|
||||
@@ -101,7 +105,7 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void uncaughtException(final Thread t, final Throwable ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, gui);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,6 +116,6 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
|
||||
* a {@link java.lang.Throwable} object.
|
||||
*/
|
||||
public final void handle(final Throwable ex) {
|
||||
BugReporter.reportException(ex);
|
||||
BugReporter.reportException(ex, gui);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
package forge.gauntlet;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
@@ -8,19 +21,11 @@ import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
|
||||
import forge.deck.CardPool;
|
||||
import forge.error.BugReporter;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.IgnoringXStream;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class GauntletIO {
|
||||
/** Prompt in text field for new (unsaved) built gauntlets. */
|
||||
public static final String TXF_PROMPT = "[New Gauntlet]";
|
||||
@@ -85,7 +90,6 @@ public class GauntletIO {
|
||||
|
||||
return data;
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex, "Error loading Gauntlet Data");
|
||||
throw new RuntimeException(ex);
|
||||
} finally {
|
||||
if (null != zin) {
|
||||
@@ -100,7 +104,6 @@ public class GauntletIO {
|
||||
final XStream xStream = GauntletIO.getSerializer(false);
|
||||
GauntletIO.savePacked(xStream, gd0);
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex, "Error saving Gauntlet Data.");
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,10 @@ public abstract class InputBase implements java.io.Serializable, Input {
|
||||
public InputBase(final PlayerControllerHuman controller) {
|
||||
this.controller = controller;
|
||||
}
|
||||
protected final PlayerControllerHuman getController() {
|
||||
public final PlayerControllerHuman getController() {
|
||||
return this.controller;
|
||||
}
|
||||
protected IGuiBase getGui() {
|
||||
public IGuiBase getGui() {
|
||||
return getController().getGui();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,9 @@ import forge.util.ThreadUtil;
|
||||
public class InputLockUI implements Input {
|
||||
private final AtomicInteger iCall = new AtomicInteger();
|
||||
|
||||
private final IGuiBase gui;
|
||||
private IGuiBase gui;
|
||||
private final Game game;
|
||||
public InputLockUI(final IGuiBase gui, final Game game, final InputQueue inputQueue) {
|
||||
this.gui = gui;
|
||||
public InputLockUI(final Game game, final InputQueue inputQueue) {
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
@@ -25,6 +24,10 @@ public class InputLockUI implements Input {
|
||||
return gui;
|
||||
}
|
||||
|
||||
public void setGui(final IGuiBase gui) {
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
public void showMessageInitial() {
|
||||
int ixCall = 1 + iCall.getAndIncrement();
|
||||
ThreadUtil.delay(500, new InputUpdater(ixCall));
|
||||
|
||||
@@ -22,7 +22,7 @@ public class InputPlaybackControl extends InputSyncronizedBase implements InputS
|
||||
control = fControlGamePlayback;
|
||||
}
|
||||
@Override
|
||||
protected IGuiBase getGui() {
|
||||
public IGuiBase getGui() {
|
||||
return gui;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@ import java.util.Observer;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.Game;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.util.gui.SOptionPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.SpellAbilityView;
|
||||
|
||||
@@ -43,22 +43,18 @@ public class InputProxy implements Observer {
|
||||
|
||||
/** The input. */
|
||||
private AtomicReference<Input> input = new AtomicReference<Input>();
|
||||
private IGameView game = null;
|
||||
private final Game game;
|
||||
|
||||
// private static final boolean DEBUG_INPUT = true; // false;
|
||||
|
||||
private final PlayerControllerHuman controller;
|
||||
public InputProxy(final PlayerControllerHuman controller) {
|
||||
public InputProxy(final PlayerControllerHuman controller, final Game game) {
|
||||
this.controller = controller;
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
private IGuiBase getGui() {
|
||||
return controller.getGui();
|
||||
}
|
||||
|
||||
public void setGame(IGameView game0) {
|
||||
game = game0;
|
||||
getGui().getInputQueue().addObserver(this);
|
||||
return this.controller.getGui();
|
||||
}
|
||||
|
||||
public boolean passPriority() {
|
||||
@@ -80,7 +76,6 @@ public class InputProxy implements Observer {
|
||||
@Override
|
||||
public final void update(final Observable observable, final Object obj) {
|
||||
final Input nextInput = getGui().getInputQueue().getActualInput(game);
|
||||
|
||||
/* if(DEBUG_INPUT)
|
||||
System.out.printf("%s ... \t%s on %s, \tstack = %s%n",
|
||||
FThreads.debugGetStackTraceItem(6, true), nextInput == null ? "null" : nextInput.getClass().getSimpleName(),
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.concurrent.BlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.view.IGameView;
|
||||
import forge.game.player.Player;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -37,8 +37,13 @@ public class InputQueue extends Observable {
|
||||
private final BlockingDeque<InputSynchronized> inputStack = new LinkedBlockingDeque<InputSynchronized>();
|
||||
private final InputLockUI inputLock;
|
||||
|
||||
public InputQueue(final IGuiBase gui, final Game game) {
|
||||
inputLock = new InputLockUI(gui, game, this);
|
||||
public InputQueue(final Game game) {
|
||||
inputLock = new InputLockUI(game, this);
|
||||
for (final Player p : game.getPlayers()) {
|
||||
if (p.getController() instanceof PlayerControllerHuman) {
|
||||
this.addObserver(((PlayerControllerHuman) p.getController()).getInputProxy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void updateObservers() {
|
||||
@@ -66,7 +71,7 @@ public class InputQueue extends Observable {
|
||||
*
|
||||
* @return a {@link forge.gui.input.InputBase} object.
|
||||
*/
|
||||
public final Input getActualInput(IGameView game) {
|
||||
public final Input getActualInput(final Game game) {
|
||||
Input topMost = inputStack.peek(); // incoming input to Control
|
||||
if (topMost != null && !game.isGameOver()) {
|
||||
return topMost;
|
||||
@@ -79,8 +84,9 @@ public class InputQueue extends Observable {
|
||||
return inputStack.toString();
|
||||
}
|
||||
|
||||
public void setInput(InputSynchronized input) {
|
||||
public void setInput(final InputSynchronized input) {
|
||||
this.inputStack.push(input);
|
||||
inputLock.setGui(input.getGui());
|
||||
syncPoint();
|
||||
this.updateObservers();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package forge.match.input;
|
||||
|
||||
import forge.interfaces.IGuiBase;
|
||||
|
||||
public interface InputSynchronized extends Input {
|
||||
void awaitLatchRelease();
|
||||
void relaseLatchWhenGameIsOver();
|
||||
IGuiBase getGui();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public abstract class InputSyncronizedBase extends InputBase implements InputSyn
|
||||
cdlDone.await();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
BugReporter.reportException(e);
|
||||
BugReporter.reportException(e, getGui());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import forge.game.player.PlayerController;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.match.input.InputProxy;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
@@ -26,16 +27,22 @@ import forge.view.StackItemView;
|
||||
public abstract class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
private final IGuiBase gui;
|
||||
private final InputProxy inputProxy;
|
||||
|
||||
public PlayerControllerHuman(final Game game0, final Player p, final LobbyPlayer lp, final IGuiBase gui) {
|
||||
super(game0, p, lp);
|
||||
this.gui = gui;
|
||||
this.inputProxy = new InputProxy(this, game0);
|
||||
}
|
||||
|
||||
public final IGuiBase getGui() {
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
public final InputProxy getInputProxy() {
|
||||
return this.inputProxy;
|
||||
}
|
||||
|
||||
public abstract boolean canUndoLastAction();
|
||||
public abstract boolean tryUndoLastAction();
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ import forge.match.input.InputConfirm;
|
||||
import forge.match.input.InputConfirmMulligan;
|
||||
import forge.match.input.InputPassPriority;
|
||||
import forge.match.input.InputProliferate;
|
||||
import forge.match.input.InputProxy;
|
||||
import forge.match.input.InputSelectCardsForConvoke;
|
||||
import forge.match.input.InputSelectCardsFromList;
|
||||
import forge.match.input.InputSelectEntitiesFromList;
|
||||
@@ -106,18 +105,12 @@ import forge.view.ViewUtil;
|
||||
* Handles phase skips for now.
|
||||
*/
|
||||
public class PlayerControllerLocal extends PlayerControllerHuman implements IGameView {
|
||||
private final InputProxy inputProxy;
|
||||
public PlayerControllerLocal(final Game game0, final Player p, final LobbyPlayer lp, final IGuiBase gui) {
|
||||
super(game0, p, lp, gui);
|
||||
this.inputProxy = new InputProxy(this);
|
||||
// aggressively cache a view for each player
|
||||
// aggressively cache a view for each player (also caches cards)
|
||||
for (final Player player : game.getRegisteredPlayers()) {
|
||||
getPlayerView(player);
|
||||
}
|
||||
// aggressively cache a view for each card
|
||||
for (final Card c : game.getCardsInGame()) {
|
||||
getCardView(c);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUiSetToSkipPhase(final Player turn, final PhaseType phase) {
|
||||
@@ -126,7 +119,7 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
|
||||
/**
|
||||
* Uses GUI to learn which spell the player (human in our case) would like to play
|
||||
*/
|
||||
*/
|
||||
public SpellAbility getAbilityToPlay(final List<SpellAbility> abilities, final ITriggerEvent triggerEvent) {
|
||||
final SpellAbilityView choice = getGui().getAbilityToPlay(getSpellAbilityViews(abilities), triggerEvent);
|
||||
return getSpellAbility(choice);
|
||||
@@ -1354,6 +1347,9 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
*/
|
||||
@Override
|
||||
public CombatView getCombat(final Combat c) {
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
updateCombatView(c);
|
||||
return combatView;
|
||||
}
|
||||
@@ -1361,9 +1357,10 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
private final void updateCombatView(final Combat combat) {
|
||||
combatView.reset();
|
||||
for (final AttackingBand b : combat.getAttackingBands()) {
|
||||
if (b == null) continue;
|
||||
final GameEntity defender = combat.getDefenderByAttacker(b);
|
||||
final List<Card> blockers = b.isBlocked() ? combat.getBlockers(b) : null;
|
||||
combatView.addAttackingBand(getCardViews(b.getAttackers()), getGameEntityView(defender), getCardViews(blockers));
|
||||
final List<Card> blockers = b.isBlocked() == null ? null : combat.getBlockers(b);
|
||||
combatView.addAttackingBand(getCardViews(b.getAttackers()), getGameEntityView(defender), blockers == null ? null : getCardViews(blockers));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1411,32 +1408,32 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
|
||||
@Override
|
||||
public void selectButtonOk() {
|
||||
inputProxy.selectButtonOK();
|
||||
getInputProxy().selectButtonOK();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
inputProxy.selectButtonCancel();
|
||||
getInputProxy().selectButtonCancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passPriority() {
|
||||
return inputProxy.passPriority();
|
||||
return getInputProxy().passPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPlayer(final PlayerView player, final ITriggerEvent triggerEvent) {
|
||||
inputProxy.selectPlayer(player, triggerEvent);
|
||||
getInputProxy().selectPlayer(player, triggerEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final CardView card, final ITriggerEvent triggerEvent) {
|
||||
inputProxy.selectCard(card, triggerEvent);
|
||||
getInputProxy().selectCard(card, triggerEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAbility(final SpellAbilityView sa) {
|
||||
inputProxy.selectAbility(sa);
|
||||
getInputProxy().selectAbility(sa);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -1538,12 +1535,16 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
getPlayerView(p, view);
|
||||
} else {
|
||||
view = new PlayerView(p.getLobbyPlayer(), p.getController());
|
||||
getPlayerView(p, view);
|
||||
players.put(p, view);
|
||||
getPlayerView(p, view);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
private PlayerView getPlayerViewFast(final Player p) {
|
||||
return players.get(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer(final PlayerView p) {
|
||||
return players.inverse().get(p);
|
||||
@@ -1565,6 +1566,10 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
view.setGraveCards(getCardViews(p.getCardsIn(ZoneType.Graveyard)));
|
||||
view.setHandCards(getCardViews(p.getCardsIn(ZoneType.Hand)));
|
||||
view.setLibraryCards(getCardViews(p.getCardsIn(ZoneType.Library)));
|
||||
|
||||
for (final byte b : MagicColor.WUBRGC) {
|
||||
view.setMana(b, p.getManaPool().getAmountOfColor(b));
|
||||
}
|
||||
}
|
||||
|
||||
public CardView getCardView(final Card c) {
|
||||
@@ -1578,13 +1583,28 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
view = cards.get(cUi);
|
||||
writeCardToView(cUi, view);
|
||||
} else {
|
||||
view = new CardView(cUi, cUi.getUniqueNumber(), cUi == c);
|
||||
writeCardToView(cUi, view);
|
||||
view = new CardView(cUi.getUniqueNumber(), cUi == c);
|
||||
cards.put(cUi, view);
|
||||
writeCardToView(cUi, view);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
private CardView getCardViewFast(final Card c) {
|
||||
return cards.get(c);
|
||||
}
|
||||
|
||||
private final Function<Card, CardView> FN_GET_CARDVIEW_FAST = new Function<Card, CardView>() {
|
||||
@Override
|
||||
public CardView apply(Card input) {
|
||||
return getCardViewFast(input);
|
||||
}
|
||||
};
|
||||
|
||||
private Iterable<CardView> getCardViewsFast(final Iterable<Card> cards) {
|
||||
return Iterables.transform(cards, FN_GET_CARDVIEW_FAST);
|
||||
}
|
||||
|
||||
public Card getCard(final CardView c) {
|
||||
return cards.inverse().get(c);
|
||||
}
|
||||
@@ -1599,29 +1619,30 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
// First, write the values independent of other views.
|
||||
ViewUtil.writeNonDependentCardViewProperties(c, view);
|
||||
// Next, write the values that depend on other views.
|
||||
view.setOwner(getPlayerView(c.getOwner()));
|
||||
view.setController(getPlayerView(c.getController()));
|
||||
view.setOwner(getPlayerViewFast(c.getOwner()));
|
||||
view.setController(getPlayerViewFast(c.getController()));
|
||||
view.setAttacking(game.getCombat() != null && game.getCombat().isAttacking(c));
|
||||
view.setBlocking(game.getCombat() != null && game.getCombat().isBlocking(c));
|
||||
view.setChosenPlayer(getPlayerView(c.getChosenPlayer()));
|
||||
view.setEquipping(getCardView(Iterables.getFirst(c.getEquipping(), null)));
|
||||
view.setEquippedBy(getCardViews(c.getEquippedBy()));
|
||||
view.setEnchantingCard(getCardView(c.getEnchantingCard()));
|
||||
view.setEnchantingPlayer(getPlayerView(c.getEnchantingPlayer()));
|
||||
view.setEnchantedBy(getCardViews(c.getEnchantedBy()));
|
||||
view.setFortifiedBy(getCardViews(c.getFortifiedBy()));
|
||||
view.setGainControlTargets(getCardViews(c.getGainControlTargets()));
|
||||
view.setCloneOrigin(getCardView(c.getCloneOrigin()));
|
||||
view.setImprinted(getCardViews(c.getImprinted()));
|
||||
view.setHauntedBy(getCardViews(c.getHauntedBy()));
|
||||
view.setHaunting(getCardView(c.getHaunting()));
|
||||
view.setMustBlock(c.getMustBlockCards() == null ? Collections.<CardView>emptySet() : getCardViews(c.getMustBlockCards()));
|
||||
view.setPairedWith(getCardView(c.getPairedWith()));
|
||||
view.setChosenPlayer(getPlayerViewFast(c.getChosenPlayer()));
|
||||
view.setEquipping(getCardViewFast(Iterables.getFirst(c.getEquipping(), null)));
|
||||
view.setEquippedBy(getCardViewsFast(c.getEquippedBy()));
|
||||
view.setEnchantingCard(getCardViewFast(c.getEnchantingCard()));
|
||||
view.setEnchantingPlayer(getPlayerViewFast(c.getEnchantingPlayer()));
|
||||
view.setEnchantedBy(getCardViewsFast(c.getEnchantedBy()));
|
||||
view.setFortifiedBy(getCardViewsFast(c.getFortifiedBy()));
|
||||
view.setGainControlTargets(getCardViewsFast(c.getGainControlTargets()));
|
||||
view.setCloneOrigin(getCardViewFast(c.getCloneOrigin()));
|
||||
view.setImprinted(getCardViewsFast(c.getImprinted()));
|
||||
view.setHauntedBy(getCardViewsFast(c.getHauntedBy()));
|
||||
view.setHaunting(getCardViewFast(c.getHaunting()));
|
||||
view.setMustBlock(c.getMustBlockCards() == null ? Collections.<CardView>emptySet() : getCardViewsFast(c.getMustBlockCards()));
|
||||
view.setPairedWith(getCardViewFast(c.getPairedWith()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayShowCard(final CardView c) {
|
||||
return cards.inverse().get(c).canBeShownTo(player);
|
||||
final Card card = cards.inverse().get(c);
|
||||
return card == null || card.canBeShownTo(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1649,6 +1670,7 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
|
||||
private void writeSpellAbilityToView(final SpellAbility sa, final SpellAbilityView view) {
|
||||
view.setHostCard(getCardView(sa.getHostCard()));
|
||||
view.setDescription(sa.getDescription());
|
||||
view.setCanPlay(sa.canPlay());
|
||||
view.setPromptIfOnlyPossibleAbility(sa.promptIfOnlyPossibleAbility());
|
||||
}
|
||||
|
||||
@@ -20,19 +20,18 @@ package forge.properties;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.interfaces.IGuiBase;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.util.BuildInfo;
|
||||
|
||||
public final class ForgeConstants {
|
||||
public static void init(final IGuiBase gui) {
|
||||
ASSETS_DIR = gui.getAssetsDir();
|
||||
}
|
||||
|
||||
private static String ASSETS_DIR;
|
||||
public static String ASSETS_DIR() { return ASSETS_DIR; }
|
||||
public static final String PROFILE_FILE = ASSETS_DIR() + "forge.profile.properties";
|
||||
public static final String ASSETS_DIR = StringUtils.containsIgnoreCase(BuildInfo.getVersionString(), "svn") ?
|
||||
"../forge-gui/" : "";
|
||||
public static final String PROFILE_FILE = ASSETS_DIR + "forge.profile.properties";
|
||||
public static final String PROFILE_TEMPLATE_FILE = PROFILE_FILE + ".example";
|
||||
|
||||
public static final String RES_DIR = ASSETS_DIR() + "res/";
|
||||
public static final String RES_DIR = ASSETS_DIR + "res/";
|
||||
public static final String LISTS_DIR = RES_DIR + "lists/";
|
||||
public static final String KEYWORD_LIST_FILE = LISTS_DIR + "NonStackingKWList.txt";
|
||||
public static final String TYPE_LIST_FILE = LISTS_DIR + "TypeLists.txt";
|
||||
@@ -46,9 +45,9 @@ public final class ForgeConstants {
|
||||
public static final String IMAGE_LIST_QUEST_PRECONS_FILE = LISTS_DIR + "precon-images.txt";
|
||||
public static final String IMAGE_LIST_QUEST_TOURNAMENTPACKS_FILE = LISTS_DIR + "tournamentpack-images.txt";
|
||||
|
||||
public static final String CHANGES_FILE = ASSETS_DIR() + "CHANGES.txt";
|
||||
public static final String LICENSE_FILE = ASSETS_DIR() + "LICENSE.txt";
|
||||
public static final String README_FILE = ASSETS_DIR() + "README.txt";
|
||||
public static final String CHANGES_FILE = ASSETS_DIR + "CHANGES.txt";
|
||||
public static final String LICENSE_FILE = ASSETS_DIR + "LICENSE.txt";
|
||||
public static final String README_FILE = ASSETS_DIR + "README.txt";
|
||||
public static final String HOWTO_FILE = RES_DIR + "howto.txt";
|
||||
|
||||
public static final String DRAFT_DIR = RES_DIR + "draft/";
|
||||
|
||||
@@ -150,7 +150,7 @@ public class ForgeProfileProperties {
|
||||
// returns a pair <userDir, cacheDir>
|
||||
private static Pair<String, String> getDefaultDirs() {
|
||||
if (isRunningOnDesktop) { //special case for mobile devices
|
||||
String assetsDir = ForgeConstants.ASSETS_DIR();
|
||||
String assetsDir = ForgeConstants.ASSETS_DIR;
|
||||
return Pair.of(assetsDir + "data" + File.separator, assetsDir + "cache" + File.separator);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,35 @@
|
||||
*/
|
||||
package forge.quest.io;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
@@ -29,39 +58,30 @@ import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.error.BugReporter;
|
||||
import forge.item.*;
|
||||
import forge.item.BoosterBox;
|
||||
import forge.item.BoosterPack;
|
||||
import forge.item.FatPack;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.PreconDeck;
|
||||
import forge.item.TournamentPack;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.QuestEventDraft;
|
||||
import forge.quest.QuestMode;
|
||||
import forge.quest.bazaar.QuestItemType;
|
||||
import forge.quest.data.*;
|
||||
import forge.quest.data.GameFormatQuest;
|
||||
import forge.quest.data.QuestAchievements;
|
||||
import forge.quest.data.QuestAssets;
|
||||
import forge.quest.data.QuestData;
|
||||
import forge.quest.data.QuestEventDraftContainer;
|
||||
import forge.quest.data.QuestItemCondition;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.IgnoringXStream;
|
||||
import forge.util.ItemPool;
|
||||
import forge.util.XmlUtil;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* QuestDataIO class.
|
||||
@@ -130,14 +150,15 @@ public class QuestDataIO {
|
||||
QuestDataIO.updateSaveFile(data, bigXML, xmlSaveFile.getName().replace(".dat", ""));
|
||||
}
|
||||
catch (final Exception e) {
|
||||
BugReporter.reportException(e);
|
||||
//BugReporter.reportException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
catch (final Exception ex) {
|
||||
BugReporter.reportException(ex, "Error loading Quest Data");
|
||||
//BugReporter.reportException(ex, "Error loading Quest Data");
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
@@ -371,7 +392,7 @@ public class QuestDataIO {
|
||||
|
||||
}
|
||||
catch (final Exception ex) {
|
||||
BugReporter.reportException(ex, "Error saving Quest Data.");
|
||||
//BugReporter.reportException(ex, "Error saving Quest Data.");
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,8 @@ import forge.card.CardEdition;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.IPaperCard;
|
||||
|
||||
public class CardView extends GameEntityView {
|
||||
|
||||
@@ -59,11 +57,7 @@ public class CardView extends GameEntityView {
|
||||
private Iterable<CardView> mustBlock;
|
||||
private CardView pairedWith;
|
||||
|
||||
@Deprecated
|
||||
public final Card card;
|
||||
|
||||
public CardView(@Deprecated final Card card, final int id, final boolean isUiDisplayable) {
|
||||
this.card = card;
|
||||
public CardView(final int id, final boolean isUiDisplayable) {
|
||||
this.id = id;
|
||||
this.isUiDisplayable = isUiDisplayable;
|
||||
this.reset();
|
||||
@@ -755,7 +749,7 @@ public class CardView extends GameEntityView {
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.getState().getName() + " (" + this.getId() + ")";
|
||||
return this.getState().toString();
|
||||
}
|
||||
|
||||
public class CardStateView {
|
||||
@@ -791,6 +785,11 @@ public class CardView extends GameEntityView {
|
||||
this.hasTrample = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getName() + " (" + this.getCard().getId() + ")";
|
||||
}
|
||||
|
||||
public CardView getCard() {
|
||||
return CardView.this;
|
||||
}
|
||||
@@ -1022,11 +1021,4 @@ public class CardView extends GameEntityView {
|
||||
return this.type.contains("Planeswalker");
|
||||
}
|
||||
}
|
||||
|
||||
public static CardView getCardForUi(final IPaperCard pc) {
|
||||
final Card c = Card.getCardForUi(pc);
|
||||
final CardView view = new CardView(c, -1, true);
|
||||
ViewUtil.writeNonDependentCardViewProperties(c, view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
@@ -18,7 +19,14 @@ public class PlayerView extends GameEntityView {
|
||||
private int life, poisonCounters, maxHandSize, numDrawnThisTurn, preventNextDamage;
|
||||
private List<String> keywords;
|
||||
private String commanderInfo;
|
||||
private List<CardView> anteCards, bfCards, commandCards, exileCards, flashbackCards, graveCards, handCards, libraryCards;
|
||||
private List<CardView> anteCards = Lists.newArrayList(),
|
||||
bfCards = Lists.newArrayList(),
|
||||
commandCards = Lists.newArrayList(),
|
||||
exileCards = Lists.newArrayList(),
|
||||
flashbackCards = Lists.newArrayList(),
|
||||
graveCards = Lists.newArrayList(),
|
||||
handCards = Lists.newArrayList(),
|
||||
libraryCards = Lists.newArrayList();
|
||||
private boolean hasUnlimitedHandSize;
|
||||
private Map<Byte, Integer> mana = Maps.newHashMapWithExpectedSize(MagicColor.NUMBER_OR_COLORS + 1);
|
||||
|
||||
@@ -160,7 +168,8 @@ public class PlayerView extends GameEntityView {
|
||||
* @param anteCards the anteCards to set
|
||||
*/
|
||||
public void setAnteCards(final List<CardView> anteCards) {
|
||||
this.anteCards = ImmutableList.copyOf(anteCards);
|
||||
this.anteCards.clear();
|
||||
this.anteCards.addAll(anteCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +183,8 @@ public class PlayerView extends GameEntityView {
|
||||
* @param bfCards the bfCards to set
|
||||
*/
|
||||
public void setBfCards(final List<CardView> bfCards) {
|
||||
this.bfCards = ImmutableList.copyOf(bfCards);
|
||||
this.bfCards.clear();
|
||||
this.bfCards.addAll(bfCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +198,8 @@ public class PlayerView extends GameEntityView {
|
||||
* @param commandCards the commandCards to set
|
||||
*/
|
||||
public void setCommandCards(List<CardView> commandCards) {
|
||||
this.commandCards = commandCards;
|
||||
this.commandCards.clear();
|
||||
this.commandCards.addAll(commandCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,7 +213,8 @@ public class PlayerView extends GameEntityView {
|
||||
* @param exileCards the exileCards to set
|
||||
*/
|
||||
public void setExileCards(final List<CardView> exileCards) {
|
||||
this.exileCards = ImmutableList.copyOf(exileCards);
|
||||
this.exileCards.clear();
|
||||
this.exileCards.addAll(exileCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,7 +228,8 @@ public class PlayerView extends GameEntityView {
|
||||
* @param flashbackCards the flashbackCards to set
|
||||
*/
|
||||
public void setFlashbackCards(final List<CardView> flashbackCards) {
|
||||
this.flashbackCards = ImmutableList.copyOf(flashbackCards);
|
||||
this.flashbackCards.clear();
|
||||
this.flashbackCards.addAll(flashbackCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,7 +243,8 @@ public class PlayerView extends GameEntityView {
|
||||
* @param graveCards the graveCards to set
|
||||
*/
|
||||
public void setGraveCards(final List<CardView> graveCards) {
|
||||
this.graveCards = ImmutableList.copyOf(graveCards);
|
||||
this.graveCards.clear();
|
||||
this.graveCards.addAll(graveCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +258,8 @@ public class PlayerView extends GameEntityView {
|
||||
* @param handCards the handCards to set
|
||||
*/
|
||||
public void setHandCards(final List<CardView> handCards) {
|
||||
this.handCards = ImmutableList.copyOf(handCards);
|
||||
this.handCards.clear();
|
||||
this.handCards.addAll(handCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,7 +273,8 @@ public class PlayerView extends GameEntityView {
|
||||
* @param libraryCards the libraryCards to set
|
||||
*/
|
||||
public void setLibraryCards(final List<CardView> libraryCards) {
|
||||
this.libraryCards = ImmutableList.copyOf(libraryCards);
|
||||
this.libraryCards.clear();
|
||||
this.libraryCards.addAll(libraryCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,10 +292,10 @@ public class PlayerView extends GameEntityView {
|
||||
}
|
||||
|
||||
public int getMana(final Byte color) {
|
||||
return this.mana.get(color).intValue();
|
||||
return this.mana.containsKey(color) ? this.mana.get(color).intValue() : 0;
|
||||
}
|
||||
|
||||
private void setMana(final byte color, final int mana) {
|
||||
public void setMana(final byte color, final int mana) {
|
||||
this.mana.put(Byte.valueOf(color), Integer.valueOf(mana));
|
||||
}
|
||||
public void setWhiteMana(final int mana) {
|
||||
|
||||
@@ -3,8 +3,14 @@ package forge.view;
|
||||
public class SpellAbilityView {
|
||||
|
||||
private CardView hostCard;
|
||||
private String description;
|
||||
private boolean canPlay, promptIfOnlyPossibleAbility;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hostCard
|
||||
*/
|
||||
@@ -19,6 +25,20 @@ public class SpellAbilityView {
|
||||
this.hostCard = hostCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the canPlay
|
||||
*/
|
||||
|
||||
@@ -47,4 +47,8 @@ public class StackItemView {
|
||||
return optionalTrigger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getText();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Collections;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCharacteristics;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
public final class ViewUtil {
|
||||
@@ -23,7 +24,7 @@ public final class ViewUtil {
|
||||
*/
|
||||
public static void writeNonDependentCardViewProperties(final Card c, final CardView view) {
|
||||
final boolean hasAltState = c.isDoubleFaced() || c.isFlipCard() || c.isFaceDown();
|
||||
view.setZone(c.getZone().getZoneType());
|
||||
view.setZone(c.getZone() == null ? null : c.getZone().getZoneType());
|
||||
view.setHasAltState(hasAltState);
|
||||
view.setFaceDown(c.isFaceDown());
|
||||
view.setFoilIndex(c.getFoil());
|
||||
@@ -87,4 +88,11 @@ public final class ViewUtil {
|
||||
altView.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public static CardView getCardForUi(final IPaperCard pc) {
|
||||
final Card c = Card.getCardForUi(pc);
|
||||
final CardView view = new CardView(-1, true);
|
||||
writeNonDependentCardViewProperties(c, view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user