mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
[UI] Showing choosable cards in dialog - Issue#456
This commit is contained in:
parent
118196c8c3
commit
60d04e2614
7 changed files with 74 additions and 44 deletions
|
@ -530,4 +530,8 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
@Override
|
||||
public void setCardAreaRef(JPanel cardArea) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChoosable(boolean isChoosable) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,16 +28,6 @@
|
|||
|
||||
package mage.client.cards;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
|
@ -49,6 +39,12 @@ import mage.view.CardsView;
|
|||
import mage.view.SimpleCardsView;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CardArea extends JPanel {
|
||||
|
||||
private boolean reloaded = false;
|
||||
|
@ -179,4 +175,15 @@ public class CardArea extends JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public void markCards(List<UUID> marked) {
|
||||
for (Component component : cardArea.getComponents()) {
|
||||
if (component instanceof MageCard) {
|
||||
MageCard mageCard = (MageCard)component;
|
||||
if (marked.contains(mageCard.getOriginal().getId())) {
|
||||
mageCard.setChoosable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,15 +34,6 @@
|
|||
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
|
@ -54,6 +45,14 @@ import mage.view.CardsView;
|
|||
import mage.view.SimpleCardsView;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
@ -98,6 +97,10 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
java.util.List<UUID> chosenCards = (java.util.List<UUID>)options.get("chosen");
|
||||
cardArea.selectCards(chosenCards);
|
||||
}
|
||||
if (options.containsKey("choosable")) {
|
||||
java.util.List<UUID> choosableCards = (java.util.List<UUID>)options.get("choosable");
|
||||
cardArea.markCards(choosableCards);
|
||||
}
|
||||
}
|
||||
|
||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
||||
|
|
|
@ -81,6 +81,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
|
||||
private boolean isSelected;
|
||||
private boolean isPlayable;
|
||||
private boolean isChoosable;
|
||||
private boolean showCastingCost;
|
||||
private boolean hasImage = false;
|
||||
private float alpha = 1.0f;
|
||||
|
@ -353,8 +354,16 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
@Override
|
||||
public void setSelected(boolean isSelected) {
|
||||
this.isSelected = isSelected;
|
||||
this.titleText.setGlowColor(Color.green);
|
||||
repaint();
|
||||
if (isSelected) {
|
||||
this.titleText.setGlowColor(Color.green);
|
||||
}
|
||||
// noxx: bad idea is to call repaint in setter method
|
||||
////repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChoosable(boolean isChoosable) {
|
||||
this.isChoosable = isChoosable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -411,9 +420,13 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
|
||||
int cornerSize = Math.max(4, Math.round(cardWidth * ROUNDED_CORNER_SIZE));
|
||||
g2d.fillRoundRect(cardXOffset, cardYOffset, cardWidth, cardHeight, cornerSize, cornerSize);
|
||||
|
||||
if (isSelected) {
|
||||
g2d.setColor(Color.green);
|
||||
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
|
||||
} else if (isChoosable) {
|
||||
g2d.setColor(new Color(250, 250, 0, 230));
|
||||
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
|
||||
}
|
||||
|
||||
if (isPlayable) {
|
||||
|
@ -421,7 +434,6 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
|
||||
}
|
||||
|
||||
//g2d.setColor(new Color(200, 120, 40, 200));
|
||||
|
||||
//TODO:uncomment
|
||||
/*
|
||||
|
@ -689,6 +701,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
setText(card);
|
||||
|
||||
this.isPlayable = card.isPlayable();
|
||||
this.isChoosable = card.isChoosable();
|
||||
|
||||
boolean updateImage = !gameCard.getName().equals(card.getName()) || gameCard.isFaceDown() != card.isFaceDown(); // update after e.g. turning a night/day card
|
||||
this.gameCard = card;
|
||||
|
|
|
@ -29,4 +29,5 @@ public abstract class MageCard extends JPanel {
|
|||
public abstract void showCardTitle();
|
||||
public abstract void setSelected(boolean selected);
|
||||
public abstract void setCardAreaRef(JPanel cardArea);
|
||||
public abstract void setChoosable(boolean isChoosable);
|
||||
}
|
||||
|
|
|
@ -109,9 +109,10 @@ public class CardView extends SimpleCardView {
|
|||
protected boolean controlledByOwner = true;
|
||||
|
||||
protected boolean rotate;
|
||||
protected boolean hideInfo; // controlls if the tooltip window is shown (eg. controlled face down morph card)
|
||||
protected boolean hideInfo; // controls if the tooltip window is shown (eg. controlled face down morph card)
|
||||
|
||||
protected boolean isPlayable;
|
||||
protected boolean isChoosable;
|
||||
|
||||
public CardView(Card card) {
|
||||
this(card, null, false);
|
||||
|
@ -680,4 +681,8 @@ public class CardView extends SimpleCardView {
|
|||
public void setPlayable(boolean isPlayable) {
|
||||
this.isPlayable = isPlayable;
|
||||
}
|
||||
|
||||
public boolean isChoosable() {
|
||||
return isChoosable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,23 +28,8 @@
|
|||
|
||||
package mage.player.human;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.PlayLandAbility;
|
||||
import mage.abilities.SpecialAction;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
|
@ -60,8 +45,6 @@ import mage.choices.ChoiceImpl;
|
|||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import static mage.constants.SpellAbilityType.SPLIT;
|
||||
import static mage.constants.SpellAbilityType.SPLIT_FUSED;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterAttackingCreature;
|
||||
import mage.filter.common.FilterBlockingCreature;
|
||||
|
@ -86,6 +69,9 @@ import mage.target.common.TargetDefender;
|
|||
import mage.util.ManaUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -348,13 +334,24 @@ public class HumanPlayer extends PlayerImpl {
|
|||
required = false;
|
||||
}
|
||||
Map<String, Serializable> options = getOptions(target);
|
||||
if (options == null) {
|
||||
options = new HashMap<>(1);
|
||||
}
|
||||
|
||||
if (target.getTargets().size() > 0) {
|
||||
if (options == null) {
|
||||
options = new HashMap<>(1);
|
||||
}
|
||||
List<UUID> chosen = (List<UUID>)target.getTargets();
|
||||
options.put("chosen", (Serializable)chosen);
|
||||
}
|
||||
|
||||
List<UUID> choosable = new ArrayList<>();
|
||||
for (UUID cardId : cards) {
|
||||
if (target.canTarget(cardId, cards, game)) {
|
||||
choosable.add(cardId);
|
||||
}
|
||||
}
|
||||
if (!choosable.isEmpty()) {
|
||||
options.put("choosable", (Serializable) choosable);
|
||||
}
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, options);
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
|
|
Loading…
Reference in a new issue