From 62d5d45a45acbe2df86a25765b67e1f0cb85b761 Mon Sep 17 00:00:00 2001 From: draxdyn Date: Fri, 24 Jun 2016 18:53:34 +0200 Subject: [PATCH] Add support for F6 Skips everything until next turn, except for declare attackers and blockers. F11 and F9 are a better design, but F6 is provided for compatibility with established conventions. There is currently no GUI button for it. --- .../src/main/java/mage/client/MageFrame.java | 15 ++++++++++ .../main/java/mage/client/game/GamePanel.java | 15 ++++++++++ .../java/mage/client/game/PlayAreaPanel.java | 16 +++++++++-- .../client/remote/CallbackClientImpl.java | 1 + .../src/mage/player/human/HumanPlayer.java | 7 +++-- .../java/mage/constants/PlayerAction.java | 1 + .../main/java/mage/players/PlayerImpl.java | 28 +++++++++++++++++-- 7 files changed, 75 insertions(+), 8 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index c36056dace..7965c5e51c 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -43,6 +43,7 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; @@ -61,6 +62,7 @@ import javax.imageio.ImageIO; import javax.swing.AbstractButton; import javax.swing.Box; import javax.swing.ImageIcon; +import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; @@ -75,6 +77,7 @@ import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JToggleButton; import javax.swing.JToolBar.Separator; +import javax.swing.KeyStroke; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -242,6 +245,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { try { UIManager.put("desktop", new Color(0, 0, 0, 0)); UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); + // stop JSplitPane from eating F6 and F8 or any other function keys + { + Object value = UIManager.get("SplitPane.ancestorInputMap"); + + if(value instanceof InputMap) { + InputMap map = (InputMap)value; + for(int vk = KeyEvent.VK_F2; vk <= KeyEvent.VK_F12; ++vk) { + map.remove(KeyStroke.getKeyStroke(vk, 0)); + } + } + } + GUISizeHelper.calculateGUISizes(); // UIManager.put("Table.rowHeight", GUISizeHelper.tableRowHeight); } catch (Exception ex) { diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index f214e0f120..fcefe2720e 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -1431,6 +1431,15 @@ public final class GamePanel extends javax.swing.JPanel { } }); + ks = KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0); + this.getInputMap(c).put(ks, "F6_PRESS"); + this.getActionMap().put("F6_PRESS", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + btnEndTurnSkipStackActionPerformed(actionEvent); + } + }); + btnSkipToNextMain.setContentAreaFilled(false); btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE)); btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipMainButtonImage())); @@ -2023,6 +2032,12 @@ public final class GamePanel extends javax.swing.JPanel { updateSkipButtons(false, true, false, false, false, false); } + private void btnEndTurnSkipStackActionPerformed(java.awt.event.ActionEvent evt) { + session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null); + AudioManager.playOnSkipButton(); + updateSkipButtons(true, false, false, false, true, false); + } + private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null); AudioManager.playOnSkipButton(); diff --git a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java index 8d6627eaf2..e7ad6fff29 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java @@ -178,6 +178,10 @@ public class PlayAreaPanel extends javax.swing.JPanel { gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null); break; } + case "F6": { + gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null); + break; + } case "F7": { gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null); break; @@ -211,6 +215,7 @@ public class PlayAreaPanel extends javax.swing.JPanel { popupMenu.add(skipMenu); String tooltipText = "This skip actions stops if something goes to
stack and if attackers or blocker have to be declared."; + String everythingTooltipText = "This skip actions stops if attackers or blocker have to be declared, but not if something goes to the stack."; menuItem = new JMenuItem("F4 - Phases until next turn"); menuItem.setActionCommand("F4"); menuItem.setToolTipText(tooltipText); @@ -225,6 +230,13 @@ public class PlayAreaPanel extends javax.swing.JPanel { skipMenu.add(menuItem); menuItem.addActionListener(skipListener); + menuItem = new JMenuItem("F6 - Everything until the next turn"); + menuItem.setActionCommand("F6"); + menuItem.setToolTipText(everythingTooltipText); + menuItem.setMnemonic(KeyEvent.VK_U); + skipMenu.add(menuItem); + menuItem.addActionListener(skipListener); + menuItem = new JMenuItem("F7 - Phases until begin of next main phase"); menuItem.setToolTipText(tooltipText); menuItem.setActionCommand("F7"); @@ -234,14 +246,14 @@ public class PlayAreaPanel extends javax.swing.JPanel { menuItem = new JMenuItem("F9 - Everything until your own next turn"); menuItem.setActionCommand("F9"); - menuItem.setToolTipText(tooltipText); + menuItem.setToolTipText(everythingTooltipText); menuItem.setMnemonic(KeyEvent.VK_V); skipMenu.add(menuItem); menuItem.addActionListener(skipListener); menuItem = new JMenuItem("F11 - Everything until end step prior to your own next turn"); menuItem.setActionCommand("F11"); - menuItem.setToolTipText(tooltipText); + menuItem.setToolTipText(everythingTooltipText); menuItem.setMnemonic(KeyEvent.VK_P); skipMenu.add(menuItem); menuItem.addActionListener(skipListener); diff --git a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java index 45ad11d10b..326d3a3d59 100644 --- a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java +++ b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java @@ -391,6 +391,7 @@ public class CallbackClientImpl implements CallbackClient { .append("
F2 - Confirm \"Ok\", \"Yes\" or \"Done\" button") .append("
F4 - Skip current turn but stop on declare attackers/blockers and something on the stack") .append("
F5 - Skip to next end step but stop on declare attackers/blockers and something on the stack") + .append("
F6 - Skip current turn but stop on declare attackers/blockers") .append("
F7 - Skip to next main phase but stop on declare attackers/blockers and something on the stack") .append("
F9 - Skip everything until your next turn") .append("
F11 - Skip everything until the end step just prior to your turn") 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 d06202227c..a2a48fb1d6 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 @@ -577,7 +577,8 @@ public class HumanPlayer extends PlayerImpl { return false; } } - if (passedAllTurns) { + + if (passedAllTurns || passedTurnSkipStack) { if (passWithManaPoolCheck(game)) { return false; } @@ -600,7 +601,7 @@ public class HumanPlayer extends PlayerImpl { if (game.getStack().isEmpty()) { passedUntilStackResolved = false; boolean dontCheckPassStep = false; - if (passedTurn) { + if (passedTurn || passedTurnSkipStack) { if (passWithManaPoolCheck(game)) { return false; } @@ -887,7 +888,7 @@ public class HumanPlayer extends PlayerImpl { filter.add(new ControllerIdPredicate(attackingPlayerId)); while (!abort) { if (passedAllTurns || passedUntilEndStepBeforeMyTurn - || (!getUserData().getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction() && (passedTurn || passedUntilEndOfTurn || passedUntilNextMain))) { + || (!getUserData().getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction() && (passedTurn || passedTurnSkipStack || passedUntilEndOfTurn || passedUntilNextMain))) { return; } Map options = new HashMap<>(); diff --git a/Mage/src/main/java/mage/constants/PlayerAction.java b/Mage/src/main/java/mage/constants/PlayerAction.java index cf79e59620..c21bf05d45 100644 --- a/Mage/src/main/java/mage/constants/PlayerAction.java +++ b/Mage/src/main/java/mage/constants/PlayerAction.java @@ -38,6 +38,7 @@ public enum PlayerAction { PASS_PRIORITY_UNTIL_TURN_END_STEP, PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, PASS_PRIORITY_UNTIL_NEXT_TURN, + PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, PASS_PRIORITY_UNTIL_STACK_RESOLVED, PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, PASS_PRIORITY_CANCEL_ALL_ACTIONS, diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index d477f5f93e..eaee1467ca 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -169,11 +169,12 @@ public abstract class PlayerImpl implements Player, Serializable { // priority control protected boolean passed; // player passed priority protected boolean passedTurn; // F4 + protected boolean passedTurnSkipStack; // F6 protected boolean passedUntilEndOfTurn; // F5 - protected boolean passedUntilNextMain; // F6 - protected boolean passedUntilStackResolved; // F8 + protected boolean passedUntilNextMain; // F7 + protected boolean passedUntilStackResolved; // F10 protected boolean passedUntilEndStepBeforeMyTurn; // F11 - protected Date dateLastAddedToStack; // F8 + protected Date dateLastAddedToStack; // F10 protected boolean skippedAtLeastOnce; // used to track if passed started in specific phase /** * This indicates that player passed all turns until his own turn starts @@ -319,6 +320,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.passed = player.passed; this.passedTurn = player.passedTurn; + this.passedTurnSkipStack = player.passedTurnSkipStack; this.passedUntilEndOfTurn = player.passedUntilEndOfTurn; this.passedUntilNextMain = player.passedUntilNextMain; this.skippedAtLeastOnce = player.skippedAtLeastOnce; @@ -447,6 +449,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.playersUnderYourControl.clear(); this.passed = false; this.passedTurn = false; + this.passedTurnSkipStack = false; this.passedUntilEndOfTurn = false; this.passedUntilNextMain = false; this.skippedAtLeastOnce = false; @@ -611,6 +614,7 @@ public abstract class PlayerImpl implements Player, Serializable { @Override public void endOfTurn(Game game) { this.passedTurn = false; + this.passedTurnSkipStack = false; } @Override @@ -1957,6 +1961,7 @@ public abstract class PlayerImpl implements Player, Serializable { public void resetPlayerPassedActions() { this.passed = false; this.passedTurn = false; + this.passedTurnSkipStack = false; this.passedUntilEndOfTurn = false; this.passedUntilNextMain = false; this.passedUntilStackResolved = false; @@ -2005,6 +2010,7 @@ public abstract class PlayerImpl implements Player, Serializable { passedUntilNextMain = false; passedUntilEndOfTurn = false; passedTurn = false; + passedTurnSkipStack = false; passedAllTurns = true; passedUntilStackResolved = false; passedUntilEndStepBeforeMyTurn = false; @@ -2013,6 +2019,7 @@ public abstract class PlayerImpl implements Player, Serializable { case PASS_PRIORITY_UNTIL_TURN_END_STEP: // F5 passedUntilNextMain = false; passedTurn = false; + passedTurnSkipStack = false; passedAllTurns = false; passedUntilEndOfTurn = true; passedUntilStackResolved = false; @@ -2027,11 +2034,23 @@ public abstract class PlayerImpl implements Player, Serializable { passedUntilStackResolved = false; passedUntilEndStepBeforeMyTurn = false; passedTurn = true; + passedTurnSkipStack = false; + this.skip(); + break; + case PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK: // F6 + passedUntilNextMain = false; + passedAllTurns = false; + passedUntilEndOfTurn = false; + passedUntilStackResolved = false; + passedUntilEndStepBeforeMyTurn = false; + passedTurn = false; + passedTurnSkipStack = true; this.skip(); break; case PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE: //F7 passedAllTurns = false; passedTurn = false; + passedTurnSkipStack = false; passedUntilEndOfTurn = false; passedUntilNextMain = true; passedUntilStackResolved = false; @@ -2042,6 +2061,7 @@ public abstract class PlayerImpl implements Player, Serializable { case PASS_PRIORITY_UNTIL_STACK_RESOLVED: //F8 passedAllTurns = false; passedTurn = false; + passedTurnSkipStack = false; passedUntilEndOfTurn = false; passedUntilNextMain = false; passedUntilStackResolved = true; @@ -2052,6 +2072,7 @@ public abstract class PlayerImpl implements Player, Serializable { case PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN: //F11 passedAllTurns = false; passedTurn = false; + passedTurnSkipStack = false; passedUntilEndOfTurn = false; passedUntilNextMain = false; passedUntilStackResolved = false; @@ -2061,6 +2082,7 @@ public abstract class PlayerImpl implements Player, Serializable { case PASS_PRIORITY_CANCEL_ALL_ACTIONS: passedAllTurns = false; passedTurn = false; + passedTurnSkipStack = false; passedUntilEndOfTurn = false; passedUntilNextMain = false; passedUntilStackResolved = false;