mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
- Fix vanguard avatar selection in lobby
- Fix card (image) viewing with multiple players in same GUI - Fix dev mode toggle buttons with multiple players in same GUI - Fix possible NPE in Quest mode (related to Antes) - Some cleanup
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import forge.ImageKeys;
|
import forge.ImageKeys;
|
||||||
@@ -60,11 +61,11 @@ public class CardView extends GameEntityView {
|
|||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean mayViewAny(Iterable<CardView> cards, PlayerView viewer) {
|
public static boolean mayViewAny(Iterable<CardView> cards, Iterable<PlayerView> viewer) {
|
||||||
if (cards == null) { return false; }
|
if (cards == null) { return false; }
|
||||||
|
|
||||||
for (CardView cv : cards) {
|
for (CardView cv : cards) {
|
||||||
if (cv.canBeShownTo(viewer)) {
|
if (cv.canBeShownToAny(viewer)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,15 +283,13 @@ public class CardView extends GameEntityView {
|
|||||||
if (card.isFaceDown()) {
|
if (card.isFaceDown()) {
|
||||||
sb.append("Face Down");
|
sb.append("Face Down");
|
||||||
// face-down cards don't show unique number to avoid cheating
|
// face-down cards don't show unique number to avoid cheating
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sb.append(card.getName());
|
sb.append(card.getName());
|
||||||
sb.append(" (");
|
sb.append(" (");
|
||||||
sb.append(card.getId());
|
sb.append(card.getId());
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
}
|
}
|
||||||
}
|
} else if (o != null) {
|
||||||
else if (o != null) {
|
|
||||||
sb.append(o.toString());
|
sb.append(o.toString());
|
||||||
}
|
}
|
||||||
sb.append("\r\n");
|
sb.append("\r\n");
|
||||||
@@ -339,7 +338,16 @@ public class CardView extends GameEntityView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public boolean canBeShownTo(final PlayerView viewer) {
|
|
||||||
|
public boolean canBeShownToAny(final Iterable<PlayerView> viewers) {
|
||||||
|
return Iterables.any(viewers, new Predicate<PlayerView>() {
|
||||||
|
public final boolean apply(final PlayerView input) {
|
||||||
|
return canBeShownTo(input);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canBeShownTo(final PlayerView viewer) {
|
||||||
if (viewer == null) { return false; }
|
if (viewer == null) { return false; }
|
||||||
|
|
||||||
ZoneType zone = getZone();
|
ZoneType zone = getZone();
|
||||||
@@ -394,7 +402,16 @@ public class CardView extends GameEntityView {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public boolean canFaceDownBeShownTo(final PlayerView viewer) {
|
|
||||||
|
public boolean canFaceDownBeShownToAny(final Iterable<PlayerView> viewers) {
|
||||||
|
return Iterables.any(viewers, new Predicate<PlayerView>() {
|
||||||
|
@Override public final boolean apply(final PlayerView input) {
|
||||||
|
return canFaceDownBeShownTo(input);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canFaceDownBeShownTo(final PlayerView viewer) {
|
||||||
if (!isFaceDown()) {
|
if (!isFaceDown()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -777,8 +794,11 @@ public class CardView extends GameEntityView {
|
|||||||
set(TrackableProperty.Colors, c.getColor());
|
set(TrackableProperty.Colors, c.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImageKey(PlayerView viewer) {
|
public String getImageKey() {
|
||||||
if (viewer == null || canBeShownTo(viewer)) {
|
return getImageKey(null);
|
||||||
|
}
|
||||||
|
public String getImageKey(Iterable<PlayerView> viewers) {
|
||||||
|
if (viewers == null || canBeShownToAny(viewers)) {
|
||||||
return get(TrackableProperty.ImageKey);
|
return get(TrackableProperty.ImageKey);
|
||||||
}
|
}
|
||||||
return ImageKeys.HIDDEN_CARD;
|
return ImageKeys.HIDDEN_CARD;
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ public class ImageCache {
|
|||||||
* retrieve an image from the cache. returns null if the image is not found in the cache
|
* retrieve an image from the cache. returns null if the image is not found in the cache
|
||||||
* and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension.
|
* and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension.
|
||||||
*/
|
*/
|
||||||
public static BufferedImage getImage(final CardView card, final PlayerView viewer, final int width, final int height) {
|
public static BufferedImage getImage(final CardView card, final Iterable<PlayerView> viewers, final int width, final int height) {
|
||||||
final String key = card.getCurrentState().getImageKey(viewer);
|
final String key = card.getCurrentState().getImageKey(viewers);
|
||||||
return scaleImage(key, width, height, true);
|
return scaleImage(key, width, height, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.Vector;
|
|||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
@@ -299,7 +300,8 @@ public class VLobby implements IUpdateable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void fireDeckSectionChangeListener(final int index, final DeckSection section, final CardPool cards) {
|
private void fireDeckSectionChangeListener(final int index, final DeckSection section, final CardPool cards) {
|
||||||
final Deck copy = new Deck(decks[index]);
|
final Deck deck = decks[index];
|
||||||
|
final Deck copy = deck == null ? new Deck() : new Deck(decks[index]);
|
||||||
copy.putSection(section, cards);
|
copy.putSection(section, cards);
|
||||||
decks[index] = copy;
|
decks[index] = copy;
|
||||||
if (playerChangeListener != null) {
|
if (playerChangeListener != null) {
|
||||||
@@ -342,7 +344,7 @@ public class VLobby implements IUpdateable {
|
|||||||
schemeDeckPanel.setLayout(new MigLayout(sectionConstraints));
|
schemeDeckPanel.setLayout(new MigLayout(sectionConstraints));
|
||||||
schemeDeckPanel.add(new FLabel.Builder().text("Select Scheme deck:").build(), labelConstraints);
|
schemeDeckPanel.add(new FLabel.Builder().text("Select Scheme deck:").build(), labelConstraints);
|
||||||
final FList<Object> schemeDeckList = new FList<Object>();
|
final FList<Object> schemeDeckList = new FList<Object>();
|
||||||
schemeDeckList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
schemeDeckList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
schemeDeckList.addListSelectionListener(new ListSelectionListener() {
|
schemeDeckList.addListSelectionListener(new ListSelectionListener() {
|
||||||
@Override public final void valueChanged(final ListSelectionEvent e) {
|
@Override public final void valueChanged(final ListSelectionEvent e) {
|
||||||
selectSchemeDeck(playerIndex);
|
selectSchemeDeck(playerIndex);
|
||||||
@@ -361,7 +363,7 @@ public class VLobby implements IUpdateable {
|
|||||||
commanderDeckPanel.setLayout(new MigLayout(sectionConstraints));
|
commanderDeckPanel.setLayout(new MigLayout(sectionConstraints));
|
||||||
commanderDeckPanel.add(new FLabel.Builder().text("Select Commander deck:").build(), labelConstraints);
|
commanderDeckPanel.add(new FLabel.Builder().text("Select Commander deck:").build(), labelConstraints);
|
||||||
final FList<Object> commanderDeckList = new FList<Object>();
|
final FList<Object> commanderDeckList = new FList<Object>();
|
||||||
commanderDeckList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
commanderDeckList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
commanderDeckList.addListSelectionListener(new ListSelectionListener() {
|
commanderDeckList.addListSelectionListener(new ListSelectionListener() {
|
||||||
@Override public final void valueChanged(final ListSelectionEvent e) {
|
@Override public final void valueChanged(final ListSelectionEvent e) {
|
||||||
selectCommanderDeck(playerIndex);
|
selectCommanderDeck(playerIndex);
|
||||||
@@ -380,7 +382,7 @@ public class VLobby implements IUpdateable {
|
|||||||
planarDeckPanel.setLayout(new MigLayout(sectionConstraints));
|
planarDeckPanel.setLayout(new MigLayout(sectionConstraints));
|
||||||
planarDeckPanel.add(new FLabel.Builder().text("Select Planar deck:").build(), labelConstraints);
|
planarDeckPanel.add(new FLabel.Builder().text("Select Planar deck:").build(), labelConstraints);
|
||||||
final FList<Object> planarDeckList = new FList<Object>();
|
final FList<Object> planarDeckList = new FList<Object>();
|
||||||
planarDeckList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
planarDeckList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
planarDeckList.addListSelectionListener(new ListSelectionListener() {
|
planarDeckList.addListSelectionListener(new ListSelectionListener() {
|
||||||
@Override public final void valueChanged(final ListSelectionEvent e) {
|
@Override public final void valueChanged(final ListSelectionEvent e) {
|
||||||
selectPlanarDeck(playerIndex);
|
selectPlanarDeck(playerIndex);
|
||||||
@@ -400,11 +402,15 @@ public class VLobby implements IUpdateable {
|
|||||||
final FList<Object> vgdAvatarList = new FList<Object>();
|
final FList<Object> vgdAvatarList = new FList<Object>();
|
||||||
vgdAvatarList.setListData(isPlayerAI(playerIndex) ? aiListData : humanListData);
|
vgdAvatarList.setListData(isPlayerAI(playerIndex) ? aiListData : humanListData);
|
||||||
vgdAvatarList.setSelectedIndex(0);
|
vgdAvatarList.setSelectedIndex(0);
|
||||||
vgdAvatarList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
vgdAvatarList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
vgdAvatarList.addListSelectionListener(vgdLSListener);
|
vgdAvatarList.addListSelectionListener(new ListSelectionListener() {
|
||||||
|
@Override public final void valueChanged(final ListSelectionEvent e) {
|
||||||
|
selectVanguardAvatar(playerIndex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
final FScrollPane scrAvatars = new FScrollPane(vgdAvatarList, true,
|
final FScrollPane scrAvatars = new FScrollPane(vgdAvatarList, true,
|
||||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
|
||||||
final CardDetailPanel vgdDetail = new CardDetailPanel();
|
final CardDetailPanel vgdDetail = new CardDetailPanel();
|
||||||
vgdAvatarDetails.add(vgdDetail);
|
vgdAvatarDetails.add(vgdDetail);
|
||||||
|
|
||||||
@@ -417,10 +423,14 @@ public class VLobby implements IUpdateable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void selectDeck(final int playerIndex) {
|
private void selectDeck(final int playerIndex) {
|
||||||
|
// Full deck selection
|
||||||
selectMainDeck(playerIndex);
|
selectMainDeck(playerIndex);
|
||||||
selectCommanderDeck(playerIndex);
|
selectCommanderDeck(playerIndex);
|
||||||
|
|
||||||
|
// Deck section selection
|
||||||
selectSchemeDeck(playerIndex);
|
selectSchemeDeck(playerIndex);
|
||||||
selectPlanarDeck(playerIndex);
|
selectPlanarDeck(playerIndex);
|
||||||
|
selectVanguardAvatar(playerIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectMainDeck(final int playerIndex) {
|
private void selectMainDeck(final int playerIndex) {
|
||||||
@@ -519,6 +529,50 @@ public class VLobby implements IUpdateable {
|
|||||||
getDeckChooser(playerIndex).saveState();
|
getDeckChooser(playerIndex).saveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void selectVanguardAvatar(final int playerIndex) {
|
||||||
|
if (playerIndex >= activePlayersNum || !hasVariant(GameType.Vanguard)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Object selected = vgdAvatarLists.get(playerIndex).getSelectedValue();
|
||||||
|
final PlayerPanel pp = playerPanels.get(playerIndex);
|
||||||
|
final CardDetailPanel cdp = vgdAvatarDetails.get(playerIndex);
|
||||||
|
|
||||||
|
final PaperCard vanguardAvatar;
|
||||||
|
final Deck deck = decks[playerIndex];
|
||||||
|
if (selected instanceof PaperCard) {
|
||||||
|
pp.setVanguardButtonText(((PaperCard) selected).getName());
|
||||||
|
cdp.setCard(CardView.getCardForUi((PaperCard) selected));
|
||||||
|
cdp.setVisible(true);
|
||||||
|
refreshPanels(false, true);
|
||||||
|
|
||||||
|
vanguardAvatar = (PaperCard)selected;
|
||||||
|
} else {
|
||||||
|
final String sel = (String) selected;
|
||||||
|
pp.setVanguardButtonText(sel);
|
||||||
|
cdp.setVisible(false);
|
||||||
|
|
||||||
|
if (sel == null) {
|
||||||
|
vanguardAvatar = null;
|
||||||
|
} else {
|
||||||
|
if (sel.contains("Use deck's default avatar") && deck != null && deck.has(DeckSection.Avatar)) {
|
||||||
|
vanguardAvatar = deck.get(DeckSection.Avatar).get(0);
|
||||||
|
} else { //Only other string is "Random"
|
||||||
|
if (playerPanels.get(playerIndex).isAi()) { //AI
|
||||||
|
vanguardAvatar = Aggregates.random(getNonRandomAiAvatars());
|
||||||
|
} else { //Human
|
||||||
|
vanguardAvatar = Aggregates.random(getNonRandomHumanAvatars());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final CardPool avatarOnce = new CardPool();
|
||||||
|
avatarOnce.add(vanguardAvatar);
|
||||||
|
fireDeckSectionChangeListener(playerIndex, DeckSection.Avatar, avatarOnce);
|
||||||
|
getDeckChooser(playerIndex).saveState();
|
||||||
|
}
|
||||||
|
|
||||||
protected void onDeckClicked(final int iPlayer, final DeckType type, final Deck deck, final Collection<DeckProxy> selectedDecks) {
|
protected void onDeckClicked(final int iPlayer, final DeckType type, final Deck deck, final Collection<DeckProxy> selectedDecks) {
|
||||||
if (iPlayer < activePlayersNum && lobby.mayEdit(iPlayer)) {
|
if (iPlayer < activePlayersNum && lobby.mayEdit(iPlayer)) {
|
||||||
final String text = type.toString() + ": " + Lang.joinHomogenous(selectedDecks, DeckProxy.FN_GET_NAME);
|
final String text = type.toString() + ": " + Lang.joinHomogenous(selectedDecks, DeckProxy.FN_GET_NAME);
|
||||||
@@ -732,59 +786,6 @@ public class VLobby implements IUpdateable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This listener will look for a vanguard avatar being selected in the lists
|
|
||||||
/ and update the corresponding detail panel. */
|
|
||||||
private ListSelectionListener vgdLSListener = new ListSelectionListener() {
|
|
||||||
@Override public final void valueChanged(final ListSelectionEvent e) {
|
|
||||||
if (!hasVariant(GameType.Vanguard)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int index = vgdAvatarLists.indexOf(e.getSource());
|
|
||||||
if (index >= activePlayersNum) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final Object selected = vgdAvatarLists.get(index).getSelectedValue();
|
|
||||||
final PlayerPanel pp = playerPanels.get(index);
|
|
||||||
final CardDetailPanel cdp = vgdAvatarDetails.get(index);
|
|
||||||
|
|
||||||
final PaperCard vanguardAvatar;
|
|
||||||
final Deck deck = decks[index];
|
|
||||||
if (selected instanceof PaperCard) {
|
|
||||||
pp.setVanguardButtonText(((PaperCard) selected).getName());
|
|
||||||
cdp.setCard(CardView.getCardForUi((PaperCard) selected));
|
|
||||||
cdp.setVisible(true);
|
|
||||||
refreshPanels(false, true);
|
|
||||||
|
|
||||||
vanguardAvatar = (PaperCard)selected;
|
|
||||||
} else {
|
|
||||||
final String sel = (String) selected;
|
|
||||||
pp.setVanguardButtonText(sel);
|
|
||||||
cdp.setVisible(false);
|
|
||||||
|
|
||||||
if (sel == null) {
|
|
||||||
vanguardAvatar = null;
|
|
||||||
} else {
|
|
||||||
if (sel.contains("Use deck's default avatar") && deck != null && deck.has(DeckSection.Avatar)) {
|
|
||||||
vanguardAvatar = deck.get(DeckSection.Avatar).get(0);
|
|
||||||
} else { //Only other string is "Random"
|
|
||||||
if (playerPanels.get(index).isAi()) { //AI
|
|
||||||
vanguardAvatar = Aggregates.random(getNonRandomAiAvatars());
|
|
||||||
} else { //Human
|
|
||||||
vanguardAvatar = Aggregates.random(getNonRandomHumanAvatars());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final CardPool avatarOnce = new CardPool();
|
|
||||||
avatarOnce.add(vanguardAvatar);
|
|
||||||
fireDeckSectionChangeListener(index, DeckSection.Avatar, avatarOnce);
|
|
||||||
getDeckChooser(index).saveState();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
//========== METHODS FOR VARIANTS
|
//========== METHODS FOR VARIANTS
|
||||||
|
|
||||||
|
|||||||
@@ -205,7 +205,8 @@ public final class CMatchUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateCurrentPlayer(final PlayerView player) {
|
protected void updateCurrentPlayer(final PlayerView player) {
|
||||||
// No action necessary
|
// Update toggle buttons in dev mdoe panel
|
||||||
|
getCDev().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CAntes getCAntes() {
|
public CAntes getCAntes() {
|
||||||
@@ -303,10 +304,11 @@ public final class CMatchUI
|
|||||||
|
|
||||||
private void initHandViews() {
|
private void initHandViews() {
|
||||||
final List<VHand> hands = new ArrayList<VHand>();
|
final List<VHand> hands = new ArrayList<VHand>();
|
||||||
|
final Iterable<PlayerView> localPlayers = getLocalPlayers();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final PlayerView p : sortedPlayers) {
|
for (final PlayerView p : sortedPlayers) {
|
||||||
if (allHands || isLocalPlayer(p) || CardView.mayViewAny(p.getHand(), getCurrentPlayer())) {
|
if (allHands || isLocalPlayer(p) || CardView.mayViewAny(p.getHand(), localPlayers)) {
|
||||||
final EDocID doc = EDocID.Hands[i];
|
final EDocID doc = EDocID.Hands[i];
|
||||||
final VHand newHand = new VHand(this, doc, p);
|
final VHand newHand = new VHand(this, doc, p);
|
||||||
newHand.getLayoutControl().initialize();
|
newHand.getLayoutControl().initialize();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package forge.screens.match;
|
package forge.screens.match;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
@@ -103,7 +102,8 @@ public class VMatchUI implements IVTopLevelUI {
|
|||||||
// Default to a cell we know exists
|
// Default to a cell we know exists
|
||||||
cellWithHands = EDocID.REPORT_LOG.getDoc().getParentCell();
|
cellWithHands = EDocID.REPORT_LOG.getDoc().getParentCell();
|
||||||
}
|
}
|
||||||
for (final EDocID handId : EDocID.Hands) {
|
for (int iHandId = 0; iHandId < EDocID.Hands.length; iHandId++) {
|
||||||
|
final EDocID handId = EDocID.Hands[iHandId];
|
||||||
final DragCell parentCell = handId.getDoc().getParentCell();
|
final DragCell parentCell = handId.getDoc().getParentCell();
|
||||||
VHand myVHand = null;
|
VHand myVHand = null;
|
||||||
for (final VHand vHand : lstHands) {
|
for (final VHand vHand : lstHands) {
|
||||||
@@ -122,12 +122,12 @@ public class VMatchUI implements IVTopLevelUI {
|
|||||||
} else {
|
} else {
|
||||||
// Hand present, add it if necessary
|
// Hand present, add it if necessary
|
||||||
if (parentCell == null) {
|
if (parentCell == null) {
|
||||||
final EDocID fieldDoc = EDocID.Fields[Arrays.asList(EDocID.Hands).indexOf(handId)];
|
final EDocID fieldDoc = EDocID.Fields[iHandId];
|
||||||
if (fieldDoc.getDoc().getParentCell() != null) {
|
if (fieldDoc.getDoc().getParentCell() != null) {
|
||||||
fieldDoc.getDoc().getParentCell().addDoc(myVHand);
|
fieldDoc.getDoc().getParentCell().addDoc(myVHand);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final EDocID commandDoc = EDocID.Commands[Arrays.asList(EDocID.Hands).indexOf(handId)];
|
final EDocID commandDoc = EDocID.Commands[iHandId];
|
||||||
if (commandDoc.getDoc().getParentCell() != null) {
|
if (commandDoc.getDoc().getParentCell() != null) {
|
||||||
commandDoc.getDoc().getParentCell().addDoc(myVHand);
|
commandDoc.getDoc().getParentCell().addDoc(myVHand);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -227,9 +227,10 @@ public class CDev implements ICDoc {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if (getController() != null) {
|
final IGameController controller = getController();
|
||||||
view.getLblUnlimitedLands().setToggled(getController().canPlayUnlimitedLands());
|
if (controller != null) {
|
||||||
view.getLblViewAll().setToggled(getController().mayLookAtAllCards());
|
view.getLblUnlimitedLands().setToggled(controller.canPlayUnlimitedLands());
|
||||||
|
view.getLblViewAll().setToggled(controller.mayLookAtAllCards());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ import forge.screens.match.controllers.CPlayers;
|
|||||||
import forge.toolbox.FScrollPanel;
|
import forge.toolbox.FScrollPanel;
|
||||||
import forge.toolbox.FSkin;
|
import forge.toolbox.FSkin;
|
||||||
import forge.toolbox.FSkin.SkinnedLabel;
|
import forge.toolbox.FSkin.SkinnedLabel;
|
||||||
|
import forge.util.FCollectionView;
|
||||||
|
import forge.util.Lang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assembles Swing components of players report.
|
* Assembles Swing components of players report.
|
||||||
@@ -169,16 +171,13 @@ public class VPlayers implements IVDoc<CPlayers> {
|
|||||||
temp[5].setText("");
|
temp[5].setText("");
|
||||||
}
|
}
|
||||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
|
if (FModel.getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
|
||||||
final Iterable<CardView> list = p0.getAnte();
|
final FCollectionView<CardView> list = p0.getAnte();
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Ante'd: ");
|
sb.append("Ante'd: ");
|
||||||
boolean needDelim = false;
|
if (list == null || list.isEmpty()) {
|
||||||
for (CardView cv : list) {
|
sb.append("none");
|
||||||
if (needDelim) {
|
} else {
|
||||||
sb.append(", ");
|
sb.append(Lang.joinHomogenous(list));
|
||||||
}
|
|
||||||
else { needDelim = true; }
|
|
||||||
sb.append(cv);
|
|
||||||
}
|
}
|
||||||
temp[6].setText(sb.toString());
|
temp[6].setText(sb.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ public class VStack implements IVDoc<CStack> {
|
|||||||
final Graphics2D g2d = (Graphics2D) g;
|
final Graphics2D g2d = (Graphics2D) g;
|
||||||
|
|
||||||
//draw image for source card
|
//draw image for source card
|
||||||
final BufferedImage img = ImageCache.getImage(item.getSourceCard(), controller.getMatchUI().getCurrentPlayer(), CARD_WIDTH, CARD_HEIGHT);
|
final BufferedImage img = ImageCache.getImage(item.getSourceCard(), controller.getMatchUI().getLocalPlayers(), CARD_WIDTH, CARD_HEIGHT);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
g2d.drawImage(img, null, PADDING, PADDING);
|
g2d.drawImage(img, null, PADDING, PADDING);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public final class FImageUtil {
|
|||||||
* For flip cards, returns the un-flipped image.
|
* For flip cards, returns the un-flipped image.
|
||||||
*/
|
*/
|
||||||
public static BufferedImage getImage(final CardStateView card) {
|
public static BufferedImage getImage(final CardStateView card) {
|
||||||
BufferedImage image = ImageCache.getOriginalImage(card.getImageKey(null), true);
|
BufferedImage image = ImageCache.getOriginalImage(card.getImageKey(), true);
|
||||||
final int foilIndex = card.getFoilIndex();
|
final int foilIndex = card.getFoilIndex();
|
||||||
if (image != null && foilIndex > 0) {
|
if (image != null && foilIndex > 0) {
|
||||||
image = getImageWithFoilEffect(image, foilIndex);
|
image = getImageWithFoilEffect(image, foilIndex);
|
||||||
@@ -64,7 +64,7 @@ public final class FImageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BufferedImage getImageXlhq(final CardStateView state) {
|
public static BufferedImage getImageXlhq(final CardStateView state) {
|
||||||
final String key = state.getImageKey(null);
|
final String key = state.getImageKey();
|
||||||
if (key.isEmpty() || key.length() < 3) {
|
if (key.isEmpty() || key.length() < 3) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
|||||||
updateImage(false);
|
updateImage(false);
|
||||||
}
|
}
|
||||||
private void updateImage(boolean fromSetCard) {
|
private void updateImage(boolean fromSetCard) {
|
||||||
final BufferedImage image = card == null ? null : ImageCache.getImage(card, matchUI.getCurrentPlayer(), imagePanel.getWidth(), imagePanel.getHeight());
|
final BufferedImage image = card == null ? null : ImageCache.getImage(card, matchUI.getLocalPlayers(), imagePanel.getWidth(), imagePanel.getHeight());
|
||||||
if (fromSetCard) {
|
if (fromSetCard) {
|
||||||
setImage(image);
|
setImage(image);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class ImageCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Texture getImage(final CardView card) {
|
public static Texture getImage(final CardView card) {
|
||||||
final String key = card.getCurrentState().getImageKey(MatchController.instance.getCurrentPlayer());
|
final String key = card.getCurrentState().getImageKey(MatchController.instance.getLocalPlayers());
|
||||||
return getImage(key, true);
|
return getImage(key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ public class CardImageRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void drawZoom(Graphics g, CardView card, GameView gameView, boolean altState, float x, float y, float w, float h) {
|
public static void drawZoom(Graphics g, CardView card, GameView gameView, boolean altState, float x, float y, float w, float h) {
|
||||||
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getCurrentPlayer()), true);
|
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true);
|
||||||
if (image == null) { //draw details if can't draw zoom
|
if (image == null) { //draw details if can't draw zoom
|
||||||
drawDetails(g, card, gameView, altState, x, y, w, h);
|
drawDetails(g, card, gameView, altState, x, y, w, h);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class CardRenderer {
|
|||||||
return getCardArt(ImageKeys.getImageKey(pc, false), pc.getRules().getSplitType() == CardSplitType.Split);
|
return getCardArt(ImageKeys.getImageKey(pc, false), pc.getRules().getSplitType() == CardSplitType.Split);
|
||||||
}
|
}
|
||||||
public static FImageComplex getCardArt(CardView card) {
|
public static FImageComplex getCardArt(CardView card) {
|
||||||
return getCardArt(card.getCurrentState().getImageKey(null), card.isSplitCard());
|
return getCardArt(card.getCurrentState().getImageKey(), card.isSplitCard());
|
||||||
}
|
}
|
||||||
public static FImageComplex getCardArt(String imageKey, boolean isSplitCard) {
|
public static FImageComplex getCardArt(String imageKey, boolean isSplitCard) {
|
||||||
FImageComplex cardArt = cardArtCache.get(imageKey);
|
FImageComplex cardArt = cardArtCache.get(imageKey);
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ public class VStack extends FDropDown {
|
|||||||
final IGuiGame gui = MatchController.instance;
|
final IGuiGame gui = MatchController.instance;
|
||||||
final IGameController controller = MatchController.instance.getGameController();
|
final IGameController controller = MatchController.instance.getGameController();
|
||||||
final PlayerView player = MatchController.instance.getCurrentPlayer();
|
final PlayerView player = MatchController.instance.getCurrentPlayer();
|
||||||
if (MatchController.instance.getCurrentPlayer() != null) { //don't show menu if tapping on art
|
if (player != null) { //don't show menu if tapping on art
|
||||||
if (stackInstance.isAbility()) {
|
if (stackInstance.isAbility()) {
|
||||||
FPopupMenu menu = new FPopupMenu() {
|
FPopupMenu menu = new FPopupMenu() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import java.util.TimerTask;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@@ -93,8 +92,7 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getCardImageKey(final CardStateView csv) {
|
public String getCardImageKey(final CardStateView csv) {
|
||||||
if (getCurrentPlayer() == null) { return csv.getImageKey(null); } //if not in game, card can be shown
|
return csv.getImageKey(getLocalPlayers());
|
||||||
return csv.getImageKey(getCurrentPlayer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -105,9 +103,7 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
|||||||
if (getGameController().mayLookAtAllCards()) {
|
if (getGameController().mayLookAtAllCards()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return Iterables.any(localPlayers, new Predicate<PlayerView>() {
|
return c.canBeShownToAny(getLocalPlayers());
|
||||||
@Override public boolean apply(final PlayerView input) { return c.canBeShownTo(input); };
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -121,7 +117,7 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
|||||||
case Original:
|
case Original:
|
||||||
CardStateView currentState = cv.getCurrentState();
|
CardStateView currentState = cv.getCurrentState();
|
||||||
if (currentState.getState() == CardStateName.FaceDown) {
|
if (currentState.getState() == CardStateName.FaceDown) {
|
||||||
return getCurrentPlayer() == null || cv.canFaceDownBeShownTo(getCurrentPlayer());
|
return getCurrentPlayer() == null || cv.canFaceDownBeShownToAny(getLocalPlayers());
|
||||||
}
|
}
|
||||||
return true; //original can always be shown if not a face down that can't be shown
|
return true; //original can always be shown if not a face down that can't be shown
|
||||||
case Flipped:
|
case Flipped:
|
||||||
|
|||||||
@@ -165,12 +165,8 @@ public class QuestDraftUtils {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waitForUserInput) {
|
if (waitForUserInput || matchInProgress) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matchInProgress) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user