From c04bd6d64ac333c3187c4bb13bb0b943afb0d621 Mon Sep 17 00:00:00 2001 From: Quercitron Date: Sun, 31 Jul 2016 15:57:45 +0300 Subject: [PATCH] Replace Yes/No text with Mulligan/Keep text on mulligan answer buttons to make options more clear. --- .../src/main/java/mage/client/game/FeedbackPanel.java | 10 ++++++++-- .../src/main/java/mage/client/game/HelperPanel.java | 7 +++++++ .../src/mage/player/human/HumanPlayer.java | 8 ++++++-- Mage/src/main/java/mage/game/Game.java | 2 ++ Mage/src/main/java/mage/game/GameImpl.java | 7 ++++++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java b/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java index 39beb587b2..085200b02a 100644 --- a/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java @@ -203,9 +203,15 @@ public class FeedbackPanel extends javax.swing.JPanel { private void handleOptions(Map options) { if (options != null) { + if (options.containsKey("UI.left.btn.text")) { + String text = (String) options.get("UI.left.btn.text"); + this.btnLeft.setText(text); + this.helper.setLeft(text, true); + } if (options.containsKey("UI.right.btn.text")) { - this.btnRight.setText((String) options.get("UI.right.btn.text")); - this.helper.setRight((String) options.get("UI.right.btn.text"), true); + String text = (String) options.get("UI.right.btn.text"); + this.btnRight.setText(text); + this.helper.setRight(text, true); } if (options.containsKey("dialog")) { connectedDialog = (MageDialog) options.get("dialog"); diff --git a/Mage.Client/src/main/java/mage/client/game/HelperPanel.java b/Mage.Client/src/main/java/mage/client/game/HelperPanel.java index b65c05849d..e4873596b3 100644 --- a/Mage.Client/src/main/java/mage/client/game/HelperPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/HelperPanel.java @@ -323,6 +323,13 @@ public class HelperPanel extends JPanel { this.btnUndo.setVisible(enabled); } + public void setLeft(String text, boolean visible) { + this.btnLeft.setVisible(visible); + if (!text.isEmpty()) { + this.btnLeft.setText(text); + } + } + public void setRight(String txtRight, boolean rightVisible) { this.btnRight.setVisible(rightVisible); if (!txtRight.isEmpty()) { diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 203e5d4548..d5c1e37d4e 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -160,9 +160,13 @@ public class HumanPlayer extends PlayerImpl { updateGameStatePriority("chooseMulligan", game); int nextHandSize = game.mulliganDownTo(playerId); do { - game.fireAskPlayerEvent(playerId, new MessageToClient("Mulligan " + String message = "Mulligan " + (getHand().size() > nextHandSize ? "down to " : "for free, draw ") - + nextHandSize + (nextHandSize == 1 ? " card?" : " cards?")), null); + + nextHandSize + (nextHandSize == 1 ? " card?" : " cards?"); + Map options = new HashMap<>(); + options.put("UI.left.btn.text", "Mulligan"); + options.put("UI.right.btn.text", "Keep"); + game.fireAskPlayerEvent(playerId, new MessageToClient(message), null, options); waitForResponse(game); } while (response.getBoolean() == null && !abort); if (!abort) { diff --git a/Mage/src/main/java/mage/game/Game.java b/Mage/src/main/java/mage/game/Game.java index 28df98b888..b73a0dfec3 100644 --- a/Mage/src/main/java/mage/game/Game.java +++ b/Mage/src/main/java/mage/game/Game.java @@ -237,6 +237,8 @@ public interface Game extends MageItem, Serializable { void fireAskPlayerEvent(UUID playerId, MessageToClient message, Ability source); + void fireAskPlayerEvent(UUID playerId, MessageToClient message, Ability source, Map options); + void fireChooseChoiceEvent(UUID playerId, Choice choice); void fireSelectTargetEvent(UUID playerId, MessageToClient message, Set targets, boolean required, Map options); diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 6f0dcd552d..2617e3ff0a 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -2018,10 +2018,15 @@ public abstract class GameImpl implements Game, Serializable { @Override public void fireAskPlayerEvent(UUID playerId, MessageToClient message, Ability source) { + fireAskPlayerEvent(playerId, message, source, null); + } + + @Override + public void fireAskPlayerEvent(UUID playerId, MessageToClient message, Ability source, Map options) { if (simulation) { return; } - playerQueryEventSource.ask(playerId, message.getMessage(), source, addMessageToOptions(message, null)); + playerQueryEventSource.ask(playerId, message.getMessage(), source, addMessageToOptions(message, options)); } @Override