mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* UI: added playable/activatable cards highlight in all zone and windows (mana abilities, commander, graveyard, revealed, etc);
This commit is contained in:
parent
fe52ffd56a
commit
f6123037ec
15 changed files with 302 additions and 192 deletions
|
|
@ -606,10 +606,13 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public synchronized void updateGame(GameView game) {
|
||||
updateGame(game, null);
|
||||
updateGame(game, false, null, null);
|
||||
}
|
||||
|
||||
public synchronized void updateGame(GameView game, Map<String, Serializable> options) {
|
||||
public synchronized void updateGame(GameView game, boolean showPlayable, Map<String, Serializable> options, Set<UUID> targets) {
|
||||
|
||||
prepareSelectableView(game, showPlayable, options, targets);
|
||||
|
||||
if (playerId == null && game.getWatchedHands() == null) {
|
||||
this.handContainer.setVisible(false);
|
||||
} else {
|
||||
|
|
@ -622,14 +625,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
if (playerId != null) {
|
||||
handCards.put(YOUR_HAND, game.getHand());
|
||||
// Mark playable
|
||||
if (game.getCanPlayInHand() != null) {
|
||||
for (CardView card : handCards.get(YOUR_HAND).values()) {
|
||||
if (game.getCanPlayInHand().contains(card.getId())) {
|
||||
card.setPlayable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get opponents hand cards if available (only possible for players)
|
||||
if (game.getOpponentHands() != null) {
|
||||
for (Map.Entry<String, SimpleCardsView> hand : game.getOpponentHands().entrySet()) {
|
||||
|
|
@ -1183,25 +1178,23 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void ask(String question, GameView gameView, int messageId, Map<String, Serializable> options) {
|
||||
updateGame(gameView);
|
||||
updateGame(gameView, false, options, null);
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, false, options, messageId, true, gameView.getPhase());
|
||||
}
|
||||
|
||||
private void prepareSelectableView(GameView gameView, Map<String, Serializable> options, Set<UUID> targets) {
|
||||
// make cards/perm selectable
|
||||
// highlighting chosen
|
||||
// code calls after each selects or updates, no needs in switch off cards
|
||||
private void prepareSelectableView(GameView gameView, boolean showPlayable, Map<String, Serializable> options, Set<UUID> targets) {
|
||||
// make cards/perm selectable/chooseable/playable
|
||||
// playable must be used for ask dialog only (priority and mana pay)
|
||||
|
||||
Zone needZone = Zone.ALL;
|
||||
if (options.containsKey("targetZone")) {
|
||||
if (options != null && options.containsKey("targetZone")) {
|
||||
needZone = (Zone) options.get("targetZone");
|
||||
}
|
||||
|
||||
List<UUID> needChoosen = null;
|
||||
if (options.containsKey("chosen")) {
|
||||
List<UUID> needChoosen;
|
||||
if (options != null && options.containsKey("chosen")) {
|
||||
needChoosen = (List<UUID>) options.get("chosen");
|
||||
}
|
||||
if (needChoosen == null) {
|
||||
} else {
|
||||
needChoosen = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
|
@ -1212,7 +1205,14 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
needSelectable = new HashSet<>();
|
||||
}
|
||||
|
||||
if (needChoosen.size() == 0 && needSelectable.size() == 0) {
|
||||
Set<UUID> needPlayable;
|
||||
if (showPlayable && gameView.getCanPlayObjects() != null) {
|
||||
needPlayable = gameView.getCanPlayObjects();
|
||||
} else {
|
||||
needPlayable = new HashSet<>();
|
||||
}
|
||||
|
||||
if (needChoosen.size() == 0 && needSelectable.size() == 0 && needPlayable.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1225,6 +1225,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
if (needChoosen.contains(card.getId())) {
|
||||
card.setSelected(true);
|
||||
}
|
||||
if (needPlayable.contains(card.getId())) {
|
||||
card.setPlayable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1237,6 +1240,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
if (needChoosen.contains(card.getKey())) {
|
||||
card.getValue().setSelected(true);
|
||||
}
|
||||
// play from stack unsupported
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1250,6 +1254,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
if (needChoosen.contains(perm.getKey())) {
|
||||
perm.getValue().setSelected(true);
|
||||
}
|
||||
if (needPlayable.contains(perm.getKey())) {
|
||||
perm.getValue().setPlayable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1264,6 +1271,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
if (needChoosen.contains(card.getKey())) {
|
||||
card.getValue().setSelected(true);
|
||||
}
|
||||
if (needPlayable.contains(card.getKey())) {
|
||||
card.getValue().setPlayable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1278,6 +1288,26 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
if (needChoosen.contains(card.getKey())) {
|
||||
card.getValue().setSelected(true);
|
||||
}
|
||||
if (needPlayable.contains(card.getKey())) {
|
||||
card.getValue().setPlayable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// command
|
||||
if (needZone == Zone.COMMAND || needZone == Zone.ALL) {
|
||||
for (PlayerView player : gameView.getPlayers()) {
|
||||
for (CommandObjectView com : player.getCommandObjectList()) {
|
||||
if (needSelectable.contains(com.getId())) {
|
||||
com.setChoosable(true);
|
||||
}
|
||||
if (needChoosen.contains(com.getId())) {
|
||||
com.setSelected(true);
|
||||
}
|
||||
if (needPlayable.contains(com.getId())) {
|
||||
com.setPlayable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1291,6 +1321,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
if (needChoosen.contains(card.getKey())) {
|
||||
card.getValue().setSelected(true);
|
||||
}
|
||||
if (needPlayable.contains(card.getKey())) {
|
||||
card.getValue().setPlayable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1315,10 +1348,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
switch (needType) {
|
||||
case PICK_ABILITY:
|
||||
popupMenuType = PopUpMenuType.TRIGGER_ORDER;
|
||||
prepareSelectableView(gameView, options, targets);
|
||||
break;
|
||||
case PICK_TARGET:
|
||||
prepareSelectableView(gameView, options, targets);
|
||||
break;
|
||||
default:
|
||||
logger.warn("Unknown query type in pick target: " + needType + " in " + message);
|
||||
|
|
@ -1327,7 +1358,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
updateGame(gameView);
|
||||
updateGame(gameView, false, options, targets);
|
||||
|
||||
Map<String, Serializable> options0 = options == null ? new HashMap<>() : options;
|
||||
ShowCardsDialog dialog = null;
|
||||
if (cardView != null && !cardView.isEmpty()) {
|
||||
|
|
@ -1359,7 +1391,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
PreferencesDialog.getCachedValue(KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"),
|
||||
false);
|
||||
|
||||
updateGame(gameView, options);
|
||||
updateGame(gameView, true, options, null);
|
||||
|
||||
boolean controllingPlayer = false;
|
||||
for (PlayerView playerView : gameView.getPlayers()) {
|
||||
if (playerView.getPlayerId().equals(playerId)) {
|
||||
|
|
@ -1393,13 +1426,13 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void playMana(String message, GameView gameView, Map<String, Serializable> options, int messageId) {
|
||||
updateGame(gameView);
|
||||
updateGame(gameView, true, options, null);
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, gameView.getSpecial(), options, messageId, true, gameView.getPhase());
|
||||
}
|
||||
|
||||
public void playXMana(String message, GameView gameView, int messageId) {
|
||||
updateGame(gameView);
|
||||
updateGame(gameView, true, null, null);
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, gameView.getSpecial(), null, messageId, true, gameView.getPhase());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
if (panel != null) {
|
||||
appendJsonEvent("GAME_UPDATE", callback.getObjectId(), callback.getData());
|
||||
|
||||
panel.updateGame((GameView) callback.getData());
|
||||
panel.updateGame((GameView) callback.getData(), true, null, null); // update after undo
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
|
||||
package mage.client.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.view.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public final class CardsViewUtil {
|
||||
|
|
@ -55,9 +54,8 @@ public final class CardsViewUtil {
|
|||
CardView cardView = new CardView((EmblemView) commandObject);
|
||||
cards.put(commandObject.getId(), cardView);
|
||||
} else if (commandObject instanceof PlaneView) {
|
||||
CardView cardView = null;
|
||||
cardView = new CardView((PlaneView) commandObject);
|
||||
cards.put(commandObject.getId(), cardView);
|
||||
CardView cardView = new CardView((PlaneView) commandObject);
|
||||
cards.put(commandObject.getId(), cardView);
|
||||
} else if (commandObject instanceof CommanderView) {
|
||||
cards.put(commandObject.getId(), (CommanderView) commandObject);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue