mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Fix many more problems with the GUI refactoring (plus some preparations for mobile GUI support).
This commit is contained in:
@@ -223,9 +223,6 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public void updatePhase() {
|
||||
//PhaseHandler pH = Singletons.getControl().getObservedGame().getPhaseHandler();
|
||||
//PhaseType ph = pH.getPhase();
|
||||
|
||||
final PlayerView p = Singletons.getControl().getGameView().getPlayerTurn();
|
||||
final PhaseType ph = Singletons.getControl().getGameView().getPhase();
|
||||
final CMatchUI matchUi = CMatchUI.SINGLETON_INSTANCE;
|
||||
@@ -411,9 +408,9 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openZones(final List<ZoneType> zones, final Map<PlayerView, Object> players) {
|
||||
public boolean openZones(final Collection<ZoneType> zones, final Map<PlayerView, Object> players) {
|
||||
if (zones.size() == 1) {
|
||||
switch (zones.get(0)) {
|
||||
switch (zones.iterator().next()) {
|
||||
case Battlefield:
|
||||
case Hand:
|
||||
return true; //don't actually need to open anything, but indicate that zone can be opened
|
||||
|
||||
@@ -130,7 +130,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
powerToughnessLabel.setVisible(false);
|
||||
idLabel.setText("");
|
||||
cdArea.setText(CardDetailUtil.getItemDescription(item));
|
||||
this.updateBorder(item instanceof IPaperCard ? ViewUtil.getCardForUi((IPaperCard)item).getOriginal() : null, false);
|
||||
this.updateBorder(item instanceof IPaperCard ? ViewUtil.getCardForUi((IPaperCard)item).getOriginal() : null);
|
||||
|
||||
String set = item.getEdition();
|
||||
setInfoLabel.setText(set);
|
||||
@@ -175,25 +175,21 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.setInfoLabel.setBorder(null);
|
||||
this.cdArea.setText("");
|
||||
if (card == null) {
|
||||
this.updateBorder((CardStateView)null, false);
|
||||
this.updateBorder(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final CardStateView state = card.getState(isInAltState);
|
||||
//this.setCard(card.card);
|
||||
|
||||
boolean canShowThis = false;
|
||||
|
||||
//if (Singletons.getControl().mayShowCard(card) || FDialog.isModalOpen()) { //allow showing cards while modal open to account for revealing, picking, and ordering cards
|
||||
canShowThis = true;
|
||||
|
||||
if (state.getManaCost().isNoCost()) {
|
||||
this.nameCostLabel.setText(state.getName());
|
||||
} else {
|
||||
String manaCost = state.getManaCost().toString();
|
||||
//if (state.isSplitCard() && card.getCurState() == CardCharacteristicName.Original) {
|
||||
// manaCost = card.getRules().getMainPart().getManaCost().toString() + " // " + card.getRules().getOtherPart().getManaCost().toString();
|
||||
//}
|
||||
final String manaCost;
|
||||
if (card.isSplitCard() && card.hasAltState()) {
|
||||
manaCost = card.getOriginal().getManaCost() + " // " + card.getAlternate().getManaCost();
|
||||
} else {
|
||||
manaCost = state.getManaCost().toString();
|
||||
}
|
||||
this.nameCostLabel.setText(FSkin.encodeSymbols(state.getName() + " - " + manaCost, true));
|
||||
}
|
||||
this.typeLabel.setText(CardDetailUtil.formatCardType(state));
|
||||
@@ -240,14 +236,14 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(foreColor));
|
||||
}
|
||||
|
||||
this.updateBorder(state, canShowThis);
|
||||
this.updateBorder(state);
|
||||
|
||||
this.powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(state));
|
||||
|
||||
this.idLabel.setText(CardDetailUtil.formatCardId(state));
|
||||
|
||||
// fill the card text
|
||||
this.cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state, canShowThis), true));
|
||||
this.cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state), true));
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
@@ -282,7 +278,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
return this.cdArea;
|
||||
}
|
||||
|
||||
private void updateBorder(final CardStateView card, final boolean canShow) {
|
||||
private void updateBorder(final CardStateView card) {
|
||||
// color info
|
||||
if (card == null) {
|
||||
this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
@@ -290,7 +286,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
Color color = fromDetailColor(CardDetailUtil.getBorderColor(card, canShow));
|
||||
Color color = fromDetailColor(CardDetailUtil.getBorderColor(card));
|
||||
this.setBorder(BorderFactory.createLineBorder(color, 2));
|
||||
scrArea.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, color));
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ import java.util.Set;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.testng.collections.Maps;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
@@ -34,8 +34,7 @@ import javax.swing.border.Border;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.testng.collections.Lists;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.control.FControl;
|
||||
|
||||
@@ -3,14 +3,15 @@ package forge.screens.match;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.match.MatchConstants;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Receives click and programmatic requests for viewing data stacks in the
|
||||
@@ -19,7 +20,8 @@ import forge.view.CardView.CardStateView;
|
||||
*/
|
||||
public class ZoneAction extends ForgeAction {
|
||||
private static final long serialVersionUID = -5822976087772388839L;
|
||||
private final Iterable<CardView> cards;
|
||||
private final PlayerView player;
|
||||
private final ZoneType zone;
|
||||
private final String title;
|
||||
|
||||
/**
|
||||
@@ -32,10 +34,11 @@ public class ZoneAction extends ForgeAction {
|
||||
* @param property
|
||||
*   String obj
|
||||
*/
|
||||
public ZoneAction(final Iterable<CardView> cards, final MatchConstants property) {
|
||||
public ZoneAction(final PlayerView player, final ZoneType zone, final MatchConstants property) {
|
||||
super(property);
|
||||
this.title = property.title;
|
||||
this.cards = Iterables.unmodifiableIterable(cards);
|
||||
this.player = player;
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +66,7 @@ public class ZoneAction extends ForgeAction {
|
||||
}
|
||||
|
||||
protected Iterable<CardView> getCardsAsIterable() {
|
||||
return cards;
|
||||
return player.getCards(zone);
|
||||
}
|
||||
|
||||
protected void doAction(final CardView c) {
|
||||
|
||||
@@ -98,8 +98,8 @@ public enum CCombat implements ICDoc {
|
||||
}
|
||||
|
||||
final Iterable<CardView> blockers = localCombat.getBlockers(band);
|
||||
boolean blocked = (blockers == null);
|
||||
boolean isBand = bandSize > 1;
|
||||
final boolean blocked = (blockers != null);
|
||||
final boolean isBand = bandSize > 1;
|
||||
if (isBand) {
|
||||
// Only print Band data if it's actually a band
|
||||
display.append(" > BAND");
|
||||
|
||||
@@ -26,10 +26,9 @@ import com.google.common.base.Function;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchConstants;
|
||||
import forge.match.input.Input;
|
||||
import forge.match.input.InputPayMana;
|
||||
import forge.screens.match.ZoneAction;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
@@ -57,21 +56,21 @@ public class CField implements ICDoc {
|
||||
/**
|
||||
* Controls Swing components of a player's field instance.
|
||||
*
|
||||
* @param player2   {@link forge.game.player.Player}
|
||||
* @param player0   {@link forge.game.player.Player}
|
||||
* @param v0   {@link forge.screens.match.views.VField}
|
||||
* @param playerViewer
|
||||
*/
|
||||
public CField(final PlayerView player2, final VField v0, LobbyPlayer playerViewer) {
|
||||
this.player = player2;
|
||||
public CField(final PlayerView player0, final VField v0, LobbyPlayer playerViewer) {
|
||||
this.player = player0;
|
||||
this.viewer = playerViewer;
|
||||
this.view = v0;
|
||||
|
||||
final ZoneAction handAction = new ZoneAction(player.getHandCards(), MatchConstants.HUMANHAND);
|
||||
final ZoneAction libraryAction = new ZoneAction(player.getLibraryCards(), MatchConstants.HUMANLIBRARY);
|
||||
final ZoneAction exileAction = new ZoneAction(player.getExileCards(), MatchConstants.HUMANEXILED);
|
||||
final ZoneAction graveAction = new ZoneAction(player.getGraveCards(), MatchConstants.HUMANGRAVEYARD);
|
||||
final ZoneAction handAction = new ZoneAction(player, ZoneType.Hand, MatchConstants.HUMANHAND);
|
||||
final ZoneAction libraryAction = new ZoneAction(player, ZoneType.Library, MatchConstants.HUMANLIBRARY);
|
||||
final ZoneAction exileAction = new ZoneAction(player, ZoneType.Exile, MatchConstants.HUMANEXILED);
|
||||
final ZoneAction graveAction = new ZoneAction(player, ZoneType.Graveyard, MatchConstants.HUMANGRAVEYARD);
|
||||
@SuppressWarnings("serial")
|
||||
final ZoneAction flashBackAction = new ZoneAction(player.getFlashbackCards(), MatchConstants.HUMANFLASHBACK) {
|
||||
final ZoneAction flashBackAction = new ZoneAction(player, null, MatchConstants.HUMANFLASHBACK) {
|
||||
@Override
|
||||
protected void doAction(final CardView c) {
|
||||
// activate cards only via your own flashback button
|
||||
@@ -81,16 +80,16 @@ public class CField implements ICDoc {
|
||||
|
||||
CPrompt.SINGLETON_INSTANCE.selectCard(c, null);
|
||||
}
|
||||
@Override
|
||||
protected Iterable<CardView> getCardsAsIterable() {
|
||||
return player.getFlashbackCards();
|
||||
}
|
||||
};
|
||||
|
||||
Function<Byte, Void> manaAction = new Function<Byte, Void>() {
|
||||
public Void apply(Byte colorCode) {
|
||||
if (CField.this.player.getLobbyPlayer() == CField.this.viewer) {
|
||||
final Input in = Singletons.getControl().getInputQueue().getInput();
|
||||
if (in instanceof InputPayMana) {
|
||||
// Do something
|
||||
((InputPayMana) in).useManaFromPool(colorCode);
|
||||
}
|
||||
Singletons.getControl().getGameView().useMana(colorCode.byteValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,14 +35,12 @@ import javax.swing.border.EmptyBorder;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.ImageCache;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.match.input.InputConfirm;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.controllers.CPrompt;
|
||||
import forge.screens.match.controllers.CStack;
|
||||
@@ -219,7 +217,7 @@ public enum VStack implements IVDoc<CStack> {
|
||||
});
|
||||
}
|
||||
|
||||
DetailColors color = CardDetailUtil.getBorderColor(item.getSource().getOriginal(), !txt.startsWith("Morph "));
|
||||
final DetailColors color = CardDetailUtil.getBorderColor(item.getSource().getOriginal());
|
||||
setBackground(new Color(color.r, color.g, color.b));
|
||||
setForeground(FSkin.getHighContrastColor(getBackground()));
|
||||
}
|
||||
@@ -275,10 +273,9 @@ public enum VStack implements IVDoc<CStack> {
|
||||
}
|
||||
else {
|
||||
game.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (game.peekStack() == item &&
|
||||
Singletons.getControl().getInputQueue().getInput() instanceof InputConfirm) {
|
||||
if (game.peekStack() == item) {
|
||||
//auto-yes if ability is on top of stack
|
||||
CPrompt.SINGLETON_INSTANCE.selectButtonOk();
|
||||
game.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,10 +291,9 @@ public enum VStack implements IVDoc<CStack> {
|
||||
}
|
||||
else {
|
||||
game.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (game.peekStack() == item &&
|
||||
Singletons.getControl().getInputQueue().getInput() instanceof InputConfirm) {
|
||||
if (game.peekStack() == item) {
|
||||
//auto-no if ability is on top of stack
|
||||
CPrompt.SINGLETON_INSTANCE.selectButtonOk();
|
||||
game.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class PlayerDetailsPanel extends JPanel {
|
||||
lblHand.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { handAction.actionPerformed(null); } } );
|
||||
|
||||
lblFlashback.setHoverable(true);
|
||||
lblFlashback.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) {flashBackAction.actionPerformed(null); } } );
|
||||
lblFlashback.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { flashBackAction.actionPerformed(null); } } );
|
||||
|
||||
for(final Pair<FLabel, Byte> labelPair : getManaLabels()) {
|
||||
labelPair.getLeft().setHoverable(true);
|
||||
|
||||
@@ -615,7 +615,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
final CardView c2 = toDelete.get(i);
|
||||
if (c.getId() == c2.getId()) {
|
||||
if (c.getTimestamp() == c2.getTimestamp()) {
|
||||
toDelete.remove(i);
|
||||
toDelete.remove(c2);
|
||||
} else {
|
||||
toReplace.add(c);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user