mirror of
https://github.com/correl/mage.git
synced 2025-04-09 17:00:09 -09:00
Showing already chosen cards in choice dialog
This commit is contained in:
parent
638a6368d2
commit
b5032226f4
9 changed files with 55 additions and 16 deletions
Mage.Client/src/main/java
mage/client
org/mage/card/arcane
Mage.Common/src/mage/cards
Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human
Mage.Server/plugins
|
@ -503,4 +503,8 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
||||||
@Override
|
@Override
|
||||||
public void showCardTitle() {
|
public void showCardTitle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSelected(boolean selected) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ import mage.view.SimpleCardsView;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.util.UUID;
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CardArea extends JPanel {
|
public class CardArea extends JPanel {
|
||||||
|
|
||||||
|
@ -148,6 +149,17 @@ public class CardArea extends JPanel {
|
||||||
|
|
||||||
public void clearReloaded() {
|
public void clearReloaded() {
|
||||||
this.reloaded = false;
|
this.reloaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void selectCards(List<UUID> selected) {
|
||||||
|
for (Component component : cardArea.getComponents()) {
|
||||||
|
if (component instanceof MageCard) {
|
||||||
|
MageCard mageCard = (MageCard)component;
|
||||||
|
if (selected.contains(mageCard.getOriginal().getId())) {
|
||||||
|
mageCard.setSelected(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,9 +72,20 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadCards(String name, CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
public void loadCards(String name, CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
||||||
|
loadCards(name, showCards, bigCard, dimension, gameId, modal, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadCards(String name, CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal, Map<String, Serializable> options) {
|
||||||
this.reloaded = true;
|
this.reloaded = true;
|
||||||
this.title = name;
|
this.title = name;
|
||||||
cardArea.loadCards(showCards, bigCard, dimension, gameId, this);
|
cardArea.loadCards(showCards, bigCard, dimension, gameId, this);
|
||||||
|
if (options != null) {
|
||||||
|
if (options.containsKey("chosen")) {
|
||||||
|
java.util.List<UUID> chosenCards = (java.util.List<UUID>)options.get("chosen");
|
||||||
|
cardArea.selectCards(chosenCards);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.DEFAULT_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.DEFAULT_LAYER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -530,7 +530,7 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
Map<String, Serializable> options0 = options == null ? new HashMap<String, Serializable>() : options;
|
Map<String, Serializable> options0 = options == null ? new HashMap<String, Serializable>() : options;
|
||||||
if (cardView != null && cardView.size() > 0) {
|
if (cardView != null && cardView.size() > 0) {
|
||||||
ShowCardsDialog dialog = showCards(message, cardView, required);
|
ShowCardsDialog dialog = showCards(message, cardView, required, options0);
|
||||||
options0.put("dialog", dialog);
|
options0.put("dialog", dialog);
|
||||||
}
|
}
|
||||||
this.feedbackPanel.getFeedback(required?FeedbackMode.INFORM:FeedbackMode.CANCEL, message, gameView.getSpecial(), options0);
|
this.feedbackPanel.getFeedback(required?FeedbackMode.INFORM:FeedbackMode.CANCEL, message, gameView.getSpecial(), options0);
|
||||||
|
@ -589,9 +589,9 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition());
|
this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShowCardsDialog showCards(String title, CardsView cards, boolean required) {
|
private ShowCardsDialog showCards(String title, CardsView cards, boolean required, Map<String, Serializable> options) {
|
||||||
ShowCardsDialog showCards = new ShowCardsDialog();
|
ShowCardsDialog showCards = new ShowCardsDialog();
|
||||||
showCards.loadCards(title, cards, bigCard, Config.dimensionsEnlarged, gameId, required);
|
showCards.loadCards(title, cards, bigCard, Config.dimensionsEnlarged, gameId, required, options);
|
||||||
return showCards;
|
return showCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,8 +316,10 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
||||||
this.isAnimationPanel = isAnimationPanel;
|
this.isAnimationPanel = isAnimationPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setSelected(boolean isSelected) {
|
public void setSelected(boolean isSelected) {
|
||||||
this.isSelected = isSelected;
|
this.isSelected = isSelected;
|
||||||
|
this.titleText.setGlowColor(Color.green);
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +378,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
||||||
g2d.fillRoundRect(cardXOffset, cardYOffset, cardWidth, cardHeight, cornerSize, cornerSize);
|
g2d.fillRoundRect(cardXOffset, cardYOffset, cardWidth, cardHeight, cornerSize, cornerSize);
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
//g2d.setColor(new Color(0,250,0,200));
|
//g2d.setColor(new Color(0,250,0,200));
|
||||||
g2d.setColor(new Color(200, 120, 40, 200));
|
//g2d.setColor(new Color(200, 120, 40, 200));
|
||||||
|
g2d.setColor(Color.green);
|
||||||
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
|
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package org.mage.card.arcane;
|
package org.mage.card.arcane;
|
||||||
|
|
||||||
import java.awt.AlphaComposite;
|
import javax.swing.*;
|
||||||
import java.awt.Color;
|
import java.awt.*;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.font.FontRenderContext;
|
import java.awt.font.FontRenderContext;
|
||||||
import java.awt.font.LineBreakMeasurer;
|
import java.awt.font.LineBreakMeasurer;
|
||||||
import java.awt.font.TextAttribute;
|
import java.awt.font.TextAttribute;
|
||||||
|
@ -15,8 +11,6 @@ import java.text.AttributedString;
|
||||||
import java.text.BreakIterator;
|
import java.text.BreakIterator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
public class GlowText extends JLabel {
|
public class GlowText extends JLabel {
|
||||||
private static final long serialVersionUID = 1827677946939348001L;
|
private static final long serialVersionUID = 1827677946939348001L;
|
||||||
private int glowSize;
|
private int glowSize;
|
||||||
|
@ -99,4 +93,8 @@ public class GlowText extends JLabel {
|
||||||
public int getLineCount() {
|
public int getLineCount() {
|
||||||
return this.lineCount;
|
return this.lineCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGlowColor(Color glowColor) {
|
||||||
|
this.glowColor = glowColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,5 @@ public abstract class MageCard extends JPanel {
|
||||||
abstract public void toggleTransformed();
|
abstract public void toggleTransformed();
|
||||||
abstract public boolean isTransformed();
|
abstract public boolean isTransformed();
|
||||||
abstract public void showCardTitle();
|
abstract public void showCardTitle();
|
||||||
|
abstract public void setSelected(boolean selected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map getOptions(Target target) {
|
private Map<String, Serializable> getOptions(Target target) {
|
||||||
return target.getNumberOfTargets() != target.getMaxNumberOfTargets() ? staticOptions : null;
|
return target.getNumberOfTargets() != target.getMaxNumberOfTargets() ? staticOptions : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +284,15 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
int count = cards.count(target.getFilter(), game);
|
int count = cards.count(target.getFilter(), game);
|
||||||
if (count == 0) required = false;
|
if (count == 0) required = false;
|
||||||
}
|
}
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, getOptions(target));
|
Map<String, Serializable> options = getOptions(target);
|
||||||
|
if (target.getTargets().size() > 0) {
|
||||||
|
if (options == null) {
|
||||||
|
options = new HashMap<String, Serializable>(1);
|
||||||
|
}
|
||||||
|
List<UUID> chosen = (List<UUID>)target.getTargets();
|
||||||
|
options.put("chosen", (Serializable)chosen);
|
||||||
|
}
|
||||||
|
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, options);
|
||||||
waitForResponse();
|
waitForResponse();
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (target.canTarget(response.getUUID(), cards, game)) {
|
if (target.canTarget(response.getUUID(), cards, game)) {
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Reference in a new issue