Improved card render modes dialog (emblems and planes support);

This commit is contained in:
Oleg Agafonov 2019-05-14 15:14:40 +04:00
parent 06c9d7941c
commit 639c4fab13
7 changed files with 60 additions and 44 deletions

View file

@ -20,6 +20,7 @@ import mage.client.draft.DraftPane;
import mage.client.draft.DraftPanel; import mage.client.draft.DraftPanel;
import mage.client.game.GamePane; import mage.client.game.GamePane;
import mage.client.game.GamePanel; import mage.client.game.GamePanel;
import mage.client.game.PlayAreaPanel;
import mage.client.plugins.adapters.MageActionCallback; import mage.client.plugins.adapters.MageActionCallback;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.preference.MagePreferences; import mage.client.preference.MagePreferences;
@ -1387,6 +1388,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
return GAMES.get(gameId); return GAMES.get(gameId);
} }
public static Map<UUID, PlayAreaPanel> getGamePlayers(UUID gameId) {
GamePanel p = GAMES.get(gameId);
return p != null ? p.getPlayers() : new HashMap<>();
}
public static void removeGame(UUID gameId) { public static void removeGame(UUID gameId) {
GAMES.remove(gameId); GAMES.remove(gameId);
} }

View file

@ -1,10 +1,3 @@
/*
* Card.java
*
* Created on 17-Dec-2009, 9:20:50 PM
*/
package mage.client.cards; package mage.client.cards;
import mage.cards.CardDimensions; import mage.cards.CardDimensions;
@ -37,7 +30,6 @@ import java.util.UUID;
import static mage.client.constants.Constants.*; import static mage.client.constants.Constants.*;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@ -132,7 +124,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight()), 0, 0, this); gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight()), 0, 0, this);
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE)); gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
gImage.drawString(card.getName()+"TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET); gImage.drawString(card.getName() + "TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
if (card.isCreature()) { if (card.isCreature()) {
gImage.drawString(card.getPower() + '/' + card.getToughness(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP); gImage.drawString(card.getPower() + '/' + card.getToughness(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
} else if (card.isPlanesWalker()) { } else if (card.isPlanesWalker()) {
@ -146,7 +138,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.dispose(); gImage.dispose();
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.getNameFontSize())); gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.getNameFontSize()));
gSmall.drawString(card.getName()+"TEST2", Config.dimensions.getContentXOffset(), Config.dimensions.getNameYOffset()); gSmall.drawString(card.getName() + "TEST2", Config.dimensions.getContentXOffset(), Config.dimensions.getNameYOffset());
if (card.isCreature()) { if (card.isCreature()) {
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop()); gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop());
} else if (card.isPlanesWalker()) { } else if (card.isPlanesWalker()) {
@ -309,7 +301,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
@Override @Override
public void paintComponent(Graphics graphics) { public void paintComponent(Graphics graphics) {
drawDetailed((Graphics2D)graphics); drawDetailed((Graphics2D) graphics);
/* /*
Graphics2D g2 = (Graphics2D) graphics; Graphics2D g2 = (Graphics2D) graphics;
g2.drawImage(small, 0, 0, this); g2.drawImage(small, 0, 0, this);
@ -367,13 +359,13 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
List<UUID> targets = card.getTargets(); List<UUID> targets = card.getTargets();
if (targets != null) { if (targets != null) {
for (UUID uuid : targets) { for (UUID uuid : targets) {
PlayAreaPanel playAreaPanel = MageFrame.getGame(gameId).getPlayers().get(uuid); PlayAreaPanel playAreaPanel = MageFrame.getGamePlayers(gameId).get(uuid);
if (playAreaPanel != null) { if (playAreaPanel != null) {
Point target = playAreaPanel.getLocationOnScreen(); Point target = playAreaPanel.getLocationOnScreen();
Point me = this.getLocationOnScreen(); Point me = this.getLocationOnScreen();
ArrowBuilder.getBuilder().addArrow(gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET); ArrowBuilder.getBuilder().addArrow(gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
} else { } else {
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) { for (PlayAreaPanel pa : MageFrame.getGamePlayers(gameId).values()) {
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid); MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
if (permanent != null) { if (permanent != null) {
Point target = permanent.getLocationOnScreen(); Point target = permanent.getLocationOnScreen();

View file

@ -3,8 +3,8 @@ package mage.client.combat;
import mage.cards.MagePermanent; import mage.cards.MagePermanent;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.game.PlayAreaPanel; import mage.client.game.PlayAreaPanel;
import mage.client.util.audio.AudioManager;
import mage.client.util.SettingsManager; import mage.client.util.SettingsManager;
import mage.client.util.audio.AudioManager;
import mage.client.util.gui.ArrowBuilder; import mage.client.util.gui.ArrowBuilder;
import mage.view.CardView; import mage.view.CardView;
import mage.view.CombatGroupView; import mage.view.CombatGroupView;
@ -67,7 +67,7 @@ public enum CombatManager {
} }
private void drawAttacker(CombatGroupView group, CardView attacker, UUID gameId) { private void drawAttacker(CombatGroupView group, CardView attacker, UUID gameId) {
for (PlayAreaPanel pa2 : MageFrame.getGame(gameId).getPlayers().values()) { for (PlayAreaPanel pa2 : MageFrame.getGamePlayers(gameId).values()) {
MagePermanent attackerCard = pa2.getBattlefieldPanel().getPermanents().get(attacker.getId()); MagePermanent attackerCard = pa2.getBattlefieldPanel().getPermanents().get(attacker.getId());
if (attackerCard != null) { if (attackerCard != null) {
drawDefender(group, attackerCard, gameId); drawDefender(group, attackerCard, gameId);
@ -80,7 +80,7 @@ public enum CombatManager {
UUID defenderId = group.getDefenderId(); UUID defenderId = group.getDefenderId();
if (defenderId != null) { if (defenderId != null) {
parentPoint = getParentPoint(attackerCard); parentPoint = getParentPoint(attackerCard);
PlayAreaPanel p = MageFrame.getGame(gameId).getPlayers().get(defenderId); PlayAreaPanel p = MageFrame.getGamePlayers(gameId).get(defenderId);
if (p != null) { if (p != null) {
Point target = p.getLocationOnScreen(); Point target = p.getLocationOnScreen();
target.translate(-parentPoint.x, -parentPoint.y); target.translate(-parentPoint.x, -parentPoint.y);
@ -88,7 +88,7 @@ public enum CombatManager {
attackerPoint.translate(-parentPoint.x, -parentPoint.y); attackerPoint.translate(-parentPoint.x, -parentPoint.y);
ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() - 20, Color.red, ArrowBuilder.Type.COMBAT); ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() - 20, Color.red, ArrowBuilder.Type.COMBAT);
} else { } else {
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) { for (PlayAreaPanel pa : MageFrame.getGamePlayers(gameId).values()) {
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(defenderId); MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(defenderId);
if (permanent != null) { if (permanent != null) {
Point target = permanent.getLocationOnScreen(); Point target = permanent.getLocationOnScreen();
@ -104,7 +104,7 @@ public enum CombatManager {
private void drawBlockers(CombatGroupView group, MagePermanent attackerCard, UUID gameId) { private void drawBlockers(CombatGroupView group, MagePermanent attackerCard, UUID gameId) {
for (CardView blocker : group.getBlockers().values()) { for (CardView blocker : group.getBlockers().values()) {
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) { for (PlayAreaPanel pa : MageFrame.getGamePlayers(gameId).values()) {
MagePermanent blockerCard = pa.getBattlefieldPanel().getPermanents().get(blocker.getId()); MagePermanent blockerCard = pa.getBattlefieldPanel().getPermanents().get(blocker.getId());
if (blockerCard != null) { if (blockerCard != null) {
parentPoint = getParentPoint(blockerCard); parentPoint = getParentPoint(blockerCard);

View file

@ -16,14 +16,17 @@ import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence; import mage.constants.RangeOfInfluence;
import mage.game.Game; import mage.game.Game;
import mage.game.GameImpl; import mage.game.GameImpl;
import mage.game.command.Emblem;
import mage.game.command.Plane;
import mage.game.command.emblems.AjaniAdversaryOfTyrantsEmblem;
import mage.game.command.planes.AkoumPlane;
import mage.game.match.MatchType; import mage.game.match.MatchType;
import mage.game.mulligan.Mulligan; import mage.game.mulligan.Mulligan;
import mage.game.mulligan.VancouverMulligan; import mage.game.mulligan.VancouverMulligan;
import mage.game.permanent.PermanentCard; import mage.game.permanent.PermanentCard;
import mage.players.Player; import mage.players.Player;
import mage.players.StubPlayer; import mage.players.StubPlayer;
import mage.view.CardsView; import mage.view.*;
import mage.view.PermanentView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.swing.*; import javax.swing.*;
@ -94,6 +97,18 @@ public class TestCardRenderDialog extends MageDialog {
return cardView; return cardView;
} }
private AbilityView createEmblem(Emblem emblem) {
AbilityView emblemView = new AbilityView(emblem.getAbilities().get(0), emblem.getName(), new CardView(new EmblemView(emblem)));
emblemView.setName(emblem.getName());
return emblemView;
}
private AbilityView createPlane(Plane plane) {
AbilityView planeView = new AbilityView(plane.getAbilities().get(0), plane.getName(), new CardView(new PlaneView(plane)));
planeView.setName(plane.getName());
return planeView;
}
private void reloadCards() { private void reloadCards() {
cardsPanel.cleanUp(); cardsPanel.cleanUp();
cardsPanel.setCustomRenderMode(comboRenderMode.getSelectedIndex()); cardsPanel.setCustomRenderMode(comboRenderMode.getSelectedIndex());
@ -105,7 +120,7 @@ public class TestCardRenderDialog extends MageDialog {
BigCard big = new BigCard(); BigCard big = new BigCard();
CardsView view = new CardsView(); CardsView view = new CardsView();
PermanentView card; CardView card;
card = createCard(game, player.getId(), "RNA", "263", 0, 0, 0); // mountain card = createCard(game, player.getId(), "RNA", "263", 0, 0, 0); // mountain
view.put(card.getId(), card); view.put(card.getId(), card);
card = createCard(game, player.getId(), "RNA", "185", 0, 0, 0); // Judith, the Scourge Diva card = createCard(game, player.getId(), "RNA", "185", 0, 0, 0); // Judith, the Scourge Diva
@ -120,11 +135,15 @@ public class TestCardRenderDialog extends MageDialog {
view.put(card.getId(), card); view.put(card.getId(), card);
card = createCard(game, player.getId(), "XLN", "234", 0, 0, 0); // Conqueror's Galleon card = createCard(game, player.getId(), "XLN", "234", 0, 0, 0); // Conqueror's Galleon
view.put(card.getId(), card); view.put(card.getId(), card);
card = createEmblem(new AjaniAdversaryOfTyrantsEmblem()); // Emblem Ajani
view.put(card.getId(), card);
card = createPlane(new AkoumPlane()); // Plane - Akoum
view.put(card.getId(), card);
cardsPanel.setCustomCardSize(new Dimension(getCardWidth(), getCardHeight())); cardsPanel.setCustomCardSize(new Dimension(getCardWidth(), getCardHeight()));
cardsPanel.changeGUISize(); cardsPanel.changeGUISize();
cardsPanel.loadCards(view, big, null); cardsPanel.loadCards(view, big, game.getId());
} }
private int getCardWidth() { private int getCardWidth() {

View file

@ -363,8 +363,6 @@ public class MageActionCallback implements ActionCallback {
if (!((GamePane) topPane).getGameId().equals(data.getGameId())) { if (!((GamePane) topPane).getGameId().equals(data.getGameId())) {
return; return;
} }
} else if (data.getGameId() != null) {
return;
} }
hideTooltipPopup(); hideTooltipPopup();

View file

@ -16,14 +16,15 @@ import java.util.UUID;
*/ */
public final class ArrowUtil { public final class ArrowUtil {
private ArrowUtil() {} private ArrowUtil() {
}
public static void drawArrowsForPairedCards(TransferData data, Point parentPoint) { public static void drawArrowsForPairedCards(TransferData data, Point parentPoint) {
if (data.getCard().getPairedCard() != null) { if (data.getCard().getPairedCard() != null) {
Point me = new Point(data.getLocationOnScreen()); Point me = new Point(data.getLocationOnScreen());
me.translate(-parentPoint.x, -parentPoint.y); me.translate(-parentPoint.x, -parentPoint.y);
UUID uuid = data.getCard().getPairedCard(); UUID uuid = data.getCard().getPairedCard();
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) { for (PlayAreaPanel pa : MageFrame.getGamePlayers(data.getGameId()).values()) {
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid); MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
if (permanent != null) { if (permanent != null) {
Point target = permanent.getLocationOnScreen(); Point target = permanent.getLocationOnScreen();
@ -38,7 +39,7 @@ public final class ArrowUtil {
if (data.getCard().getBandedCards() != null && !data.getCard().getBandedCards().isEmpty()) { if (data.getCard().getBandedCards() != null && !data.getCard().getBandedCards().isEmpty()) {
Point me = new Point(data.getLocationOnScreen()); Point me = new Point(data.getLocationOnScreen());
me.translate(-parentPoint.x, -parentPoint.y); me.translate(-parentPoint.x, -parentPoint.y);
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) { for (PlayAreaPanel pa : MageFrame.getGamePlayers(data.getGameId()).values()) {
for (UUID uuid : data.getCard().getBandedCards()) { for (UUID uuid : data.getCard().getBandedCards()) {
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid); MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
if (permanent != null) { if (permanent != null) {
@ -53,7 +54,7 @@ public final class ArrowUtil {
public static void drawArrowsForEnchantPlayers(TransferData data, Point parentPoint) { public static void drawArrowsForEnchantPlayers(TransferData data, Point parentPoint) {
if (data.getGameId() != null && MageFrame.getGame(data.getGameId()) != null) { if (data.getGameId() != null && MageFrame.getGame(data.getGameId()) != null) {
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) { for (PlayAreaPanel pa : MageFrame.getGamePlayers(data.getGameId()).values()) {
PlayerPanelExt playAreaPanel = pa.getPlayerPanel(); PlayerPanelExt playAreaPanel = pa.getPlayerPanel();
if (playAreaPanel != null && playAreaPanel.getPlayer() != null && playAreaPanel.getPlayer().hasAttachments()) { if (playAreaPanel != null && playAreaPanel.getPlayer() != null && playAreaPanel.getPlayer().hasAttachments()) {
Point me = new Point(data.getLocationOnScreen()); Point me = new Point(data.getLocationOnScreen());
@ -62,7 +63,7 @@ public final class ArrowUtil {
if (attachmentId.equals(data.getCard().getId())) { if (attachmentId.equals(data.getCard().getId())) {
Point player = pa.getLocationOnScreen(); Point player = pa.getLocationOnScreen();
player.translate(-parentPoint.x, -parentPoint.y); player.translate(-parentPoint.x, -parentPoint.y);
ArrowBuilder.getBuilder().addArrow(data.getGameId(),(int) me.getX() + 35, (int) me.getY(), (int) player.getX() + 40, (int) player.getY() - 40, Color.magenta, ArrowBuilder.Type.ENCHANT_PLAYERS); ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) player.getX() + 40, (int) player.getY() - 40, Color.magenta, ArrowBuilder.Type.ENCHANT_PLAYERS);
} }
} }
} }
@ -75,7 +76,7 @@ public final class ArrowUtil {
Point me = new Point(data.getLocationOnScreen()); Point me = new Point(data.getLocationOnScreen());
me.translate(-parentPoint.x, -parentPoint.y); me.translate(-parentPoint.x, -parentPoint.y);
UUID uuid = data.getCard().getParentId(); UUID uuid = data.getCard().getParentId();
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) { for (PlayAreaPanel pa : MageFrame.getGamePlayers(data.getGameId()).values()) {
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid); MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
if (permanent != null) { if (permanent != null) {
Point source = permanent.getLocationOnScreen(); Point source = permanent.getLocationOnScreen();
@ -96,7 +97,7 @@ public final class ArrowUtil {
me.translate(-parentPoint.x, -parentPoint.y); me.translate(-parentPoint.x, -parentPoint.y);
for (UUID uuid : targets) { for (UUID uuid : targets) {
PlayAreaPanel p = MageFrame.getGame(data.getGameId()).getPlayers().get(uuid); PlayAreaPanel p = MageFrame.getGamePlayers(data.getGameId()).get(uuid);
if (p != null) { if (p != null) {
Point target = p.getLocationOnScreen(); Point target = p.getLocationOnScreen();
target.translate(-parentPoint.x, -parentPoint.y); target.translate(-parentPoint.x, -parentPoint.y);
@ -104,7 +105,7 @@ public final class ArrowUtil {
continue; continue;
} }
for (PlayAreaPanel panel : MageFrame.getGame(data.getGameId()).getPlayers().values()) { for (PlayAreaPanel panel : MageFrame.getGamePlayers(data.getGameId()).values()) {
MagePermanent permanent = panel.getBattlefieldPanel().getPermanents().get(uuid); MagePermanent permanent = panel.getBattlefieldPanel().getPermanents().get(uuid);
if (permanent != null) { if (permanent != null) {
Point target = permanent.getLocationOnScreen(); Point target = permanent.getLocationOnScreen();
@ -117,7 +118,7 @@ public final class ArrowUtil {
if (view != null) { if (view != null) {
CardsView graveyard = view.getGraveyard(); CardsView graveyard = view.getGraveyard();
if (graveyard.containsKey(uuid)) { if (graveyard.containsKey(uuid)) {
p = MageFrame.getGame(data.getGameId()).getPlayers().get(view.getPlayerId()); p = MageFrame.getGamePlayers(data.getGameId()).get(view.getPlayerId());
if (p != null) { if (p != null) {
Point target = p.getLocationOnScreen(); Point target = p.getLocationOnScreen();
target.translate(-parentPoint.x, -parentPoint.y); target.translate(-parentPoint.x, -parentPoint.y);

View file

@ -52,7 +52,7 @@ public final class CardImageUtils {
return filePath; return filePath;
} }
log.warn("Token image file not found. Set: " + card.getSet() + " Token Set Code: " + card.getTokenSetCode() + " Name: " + card.getName() + " File path: " + getTokenImagePath(card)); //log.warn("Token image file not found. Set: " + card.getSet() + " Token Set Code: " + card.getTokenSetCode() + " Name: " + card.getName() + " File path: " + getTokenImagePath(card));
} else { } else {
log.warn("Trying to get token path for non token card. Set: " + card.getSet() + " Set Code: " + card.getTokenSetCode() + " Name: " + card.getName()); log.warn("Trying to get token path for non token card. Set: " + card.getSet() + " Set Code: " + card.getTokenSetCode() + " Name: " + card.getName());
} }