Merge pull request #2033 from draxdyn/f6

Add support for F6
This commit is contained in:
LevelX2 2016-06-28 09:16:09 +02:00 committed by GitHub
commit f7cecdf050
7 changed files with 75 additions and 8 deletions

View file

@ -43,6 +43,7 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -61,6 +62,7 @@ import javax.imageio.ImageIO;
import javax.swing.AbstractButton; import javax.swing.AbstractButton;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem; import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -75,6 +77,7 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.JToggleButton; import javax.swing.JToggleButton;
import javax.swing.JToolBar.Separator; import javax.swing.JToolBar.Separator;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
@ -242,6 +245,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
try { try {
UIManager.put("desktop", new Color(0, 0, 0, 0)); UIManager.put("desktop", new Color(0, 0, 0, 0));
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); 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(); GUISizeHelper.calculateGUISizes();
// UIManager.put("Table.rowHeight", GUISizeHelper.tableRowHeight); // UIManager.put("Table.rowHeight", GUISizeHelper.tableRowHeight);
} catch (Exception ex) { } catch (Exception ex) {

View file

@ -1500,6 +1500,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.setContentAreaFilled(false);
btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE)); btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipMainButtonImage())); btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipMainButtonImage()));
@ -2092,6 +2101,12 @@ public final class GamePanel extends javax.swing.JPanel {
updateSkipButtons(false, true, false, false, false, false); 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) { private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null); session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
AudioManager.playOnSkipButton(); AudioManager.playOnSkipButton();

View file

@ -178,6 +178,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null); gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
break; break;
} }
case "F6": {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null);
break;
}
case "F7": { case "F7": {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null); gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
break; break;
@ -211,6 +215,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
popupMenu.add(skipMenu); popupMenu.add(skipMenu);
String tooltipText = "<html>This skip actions stops if something goes to <br><b>stack</b> and if <b>attackers</b> or <b>blocker</b> have to be <b>declared</b>."; String tooltipText = "<html>This skip actions stops if something goes to <br><b>stack</b> and if <b>attackers</b> or <b>blocker</b> have to be <b>declared</b>.";
String everythingTooltipText = "<html>This skip actions stops if <b>attackers</b> or <b>blocker</b> have to be <b>declared</b>, but not if something goes to the <b>stack</b>.";
menuItem = new JMenuItem("<html><b>F4</b> - Phases until next turn"); menuItem = new JMenuItem("<html><b>F4</b> - Phases until next turn");
menuItem.setActionCommand("F4"); menuItem.setActionCommand("F4");
menuItem.setToolTipText(tooltipText); menuItem.setToolTipText(tooltipText);
@ -225,6 +230,13 @@ public class PlayAreaPanel extends javax.swing.JPanel {
skipMenu.add(menuItem); skipMenu.add(menuItem);
menuItem.addActionListener(skipListener); menuItem.addActionListener(skipListener);
menuItem = new JMenuItem("<html><b>F6</b> - 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("<html><b>F7</b> - Phases until begin of next main phase"); menuItem = new JMenuItem("<html><b>F7</b> - Phases until begin of next main phase");
menuItem.setToolTipText(tooltipText); menuItem.setToolTipText(tooltipText);
menuItem.setActionCommand("F7"); menuItem.setActionCommand("F7");
@ -234,14 +246,14 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem = new JMenuItem("<html><b>F9</b> - Everything until your own next turn"); menuItem = new JMenuItem("<html><b>F9</b> - Everything until your own next turn");
menuItem.setActionCommand("F9"); menuItem.setActionCommand("F9");
menuItem.setToolTipText(tooltipText); menuItem.setToolTipText(everythingTooltipText);
menuItem.setMnemonic(KeyEvent.VK_V); menuItem.setMnemonic(KeyEvent.VK_V);
skipMenu.add(menuItem); skipMenu.add(menuItem);
menuItem.addActionListener(skipListener); menuItem.addActionListener(skipListener);
menuItem = new JMenuItem("<html><b>F11</b> - Everything until end step prior to your own next turn"); menuItem = new JMenuItem("<html><b>F11</b> - Everything until end step prior to your own next turn");
menuItem.setActionCommand("F11"); menuItem.setActionCommand("F11");
menuItem.setToolTipText(tooltipText); menuItem.setToolTipText(everythingTooltipText);
menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setMnemonic(KeyEvent.VK_P);
skipMenu.add(menuItem); skipMenu.add(menuItem);
menuItem.addActionListener(skipListener); menuItem.addActionListener(skipListener);

View file

@ -391,6 +391,7 @@ public class CallbackClientImpl implements CallbackClient {
.append("<br/><b>F2</b> - Confirm \"Ok\", \"Yes\" or \"Done\" button") .append("<br/><b>F2</b> - Confirm \"Ok\", \"Yes\" or \"Done\" button")
.append("<br/><b>F4</b> - Skip current turn but stop on declare attackers/blockers and something on the stack") .append("<br/><b>F4</b> - Skip current turn but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>F5</b> - Skip to next end step but stop on declare attackers/blockers and something on the stack") .append("<br/><b>F5</b> - Skip to next end step but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>F6</b> - Skip current turn but stop on declare attackers/blockers")
.append("<br/><b>F7</b> - Skip to next main phase but stop on declare attackers/blockers and something on the stack") .append("<br/><b>F7</b> - Skip to next main phase but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>F9</b> - Skip everything until your next turn") .append("<br/><b>F9</b> - Skip everything until your next turn")
.append("<br/><b>F11</b> - Skip everything until the end step just prior to your turn") .append("<br/><b>F11</b> - Skip everything until the end step just prior to your turn")

View file

@ -577,7 +577,8 @@ public class HumanPlayer extends PlayerImpl {
return false; return false;
} }
} }
if (passedAllTurns) {
if (passedAllTurns || passedTurnSkipStack) {
if (passWithManaPoolCheck(game)) { if (passWithManaPoolCheck(game)) {
return false; return false;
} }
@ -600,7 +601,7 @@ public class HumanPlayer extends PlayerImpl {
if (game.getStack().isEmpty()) { if (game.getStack().isEmpty()) {
passedUntilStackResolved = false; passedUntilStackResolved = false;
boolean dontCheckPassStep = false; boolean dontCheckPassStep = false;
if (passedTurn) { if (passedTurn || passedTurnSkipStack) {
if (passWithManaPoolCheck(game)) { if (passWithManaPoolCheck(game)) {
return false; return false;
} }
@ -887,7 +888,7 @@ public class HumanPlayer extends PlayerImpl {
filter.add(new ControllerIdPredicate(attackingPlayerId)); filter.add(new ControllerIdPredicate(attackingPlayerId));
while (!abort) { while (!abort) {
if (passedAllTurns || passedUntilEndStepBeforeMyTurn if (passedAllTurns || passedUntilEndStepBeforeMyTurn
|| (!getUserData().getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction() && (passedTurn || passedUntilEndOfTurn || passedUntilNextMain))) { || (!getUserData().getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction() && (passedTurn || passedTurnSkipStack || passedUntilEndOfTurn || passedUntilNextMain))) {
return; return;
} }
Map<String, Serializable> options = new HashMap<>(); Map<String, Serializable> options = new HashMap<>();

View file

@ -38,6 +38,7 @@ public enum PlayerAction {
PASS_PRIORITY_UNTIL_TURN_END_STEP, PASS_PRIORITY_UNTIL_TURN_END_STEP,
PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE,
PASS_PRIORITY_UNTIL_NEXT_TURN, PASS_PRIORITY_UNTIL_NEXT_TURN,
PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK,
PASS_PRIORITY_UNTIL_STACK_RESOLVED, PASS_PRIORITY_UNTIL_STACK_RESOLVED,
PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN,
PASS_PRIORITY_CANCEL_ALL_ACTIONS, PASS_PRIORITY_CANCEL_ALL_ACTIONS,

View file

@ -169,11 +169,12 @@ public abstract class PlayerImpl implements Player, Serializable {
// priority control // priority control
protected boolean passed; // player passed priority protected boolean passed; // player passed priority
protected boolean passedTurn; // F4 protected boolean passedTurn; // F4
protected boolean passedTurnSkipStack; // F6
protected boolean passedUntilEndOfTurn; // F5 protected boolean passedUntilEndOfTurn; // F5
protected boolean passedUntilNextMain; // F6 protected boolean passedUntilNextMain; // F7
protected boolean passedUntilStackResolved; // F8 protected boolean passedUntilStackResolved; // F10
protected boolean passedUntilEndStepBeforeMyTurn; // F11 protected boolean passedUntilEndStepBeforeMyTurn; // F11
protected Date dateLastAddedToStack; // F8 protected Date dateLastAddedToStack; // F10
protected boolean skippedAtLeastOnce; // used to track if passed started in specific phase protected boolean skippedAtLeastOnce; // used to track if passed started in specific phase
/** /**
* This indicates that player passed all turns until his own turn starts * 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.passed = player.passed;
this.passedTurn = player.passedTurn; this.passedTurn = player.passedTurn;
this.passedTurnSkipStack = player.passedTurnSkipStack;
this.passedUntilEndOfTurn = player.passedUntilEndOfTurn; this.passedUntilEndOfTurn = player.passedUntilEndOfTurn;
this.passedUntilNextMain = player.passedUntilNextMain; this.passedUntilNextMain = player.passedUntilNextMain;
this.skippedAtLeastOnce = player.skippedAtLeastOnce; this.skippedAtLeastOnce = player.skippedAtLeastOnce;
@ -447,6 +449,7 @@ public abstract class PlayerImpl implements Player, Serializable {
this.playersUnderYourControl.clear(); this.playersUnderYourControl.clear();
this.passed = false; this.passed = false;
this.passedTurn = false; this.passedTurn = false;
this.passedTurnSkipStack = false;
this.passedUntilEndOfTurn = false; this.passedUntilEndOfTurn = false;
this.passedUntilNextMain = false; this.passedUntilNextMain = false;
this.skippedAtLeastOnce = false; this.skippedAtLeastOnce = false;
@ -611,6 +614,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public void endOfTurn(Game game) { public void endOfTurn(Game game) {
this.passedTurn = false; this.passedTurn = false;
this.passedTurnSkipStack = false;
} }
@Override @Override
@ -1957,6 +1961,7 @@ public abstract class PlayerImpl implements Player, Serializable {
public void resetPlayerPassedActions() { public void resetPlayerPassedActions() {
this.passed = false; this.passed = false;
this.passedTurn = false; this.passedTurn = false;
this.passedTurnSkipStack = false;
this.passedUntilEndOfTurn = false; this.passedUntilEndOfTurn = false;
this.passedUntilNextMain = false; this.passedUntilNextMain = false;
this.passedUntilStackResolved = false; this.passedUntilStackResolved = false;
@ -2005,6 +2010,7 @@ public abstract class PlayerImpl implements Player, Serializable {
passedUntilNextMain = false; passedUntilNextMain = false;
passedUntilEndOfTurn = false; passedUntilEndOfTurn = false;
passedTurn = false; passedTurn = false;
passedTurnSkipStack = false;
passedAllTurns = true; passedAllTurns = true;
passedUntilStackResolved = false; passedUntilStackResolved = false;
passedUntilEndStepBeforeMyTurn = false; passedUntilEndStepBeforeMyTurn = false;
@ -2013,6 +2019,7 @@ public abstract class PlayerImpl implements Player, Serializable {
case PASS_PRIORITY_UNTIL_TURN_END_STEP: // F5 case PASS_PRIORITY_UNTIL_TURN_END_STEP: // F5
passedUntilNextMain = false; passedUntilNextMain = false;
passedTurn = false; passedTurn = false;
passedTurnSkipStack = false;
passedAllTurns = false; passedAllTurns = false;
passedUntilEndOfTurn = true; passedUntilEndOfTurn = true;
passedUntilStackResolved = false; passedUntilStackResolved = false;
@ -2027,11 +2034,23 @@ public abstract class PlayerImpl implements Player, Serializable {
passedUntilStackResolved = false; passedUntilStackResolved = false;
passedUntilEndStepBeforeMyTurn = false; passedUntilEndStepBeforeMyTurn = false;
passedTurn = true; 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(); this.skip();
break; break;
case PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE: //F7 case PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE: //F7
passedAllTurns = false; passedAllTurns = false;
passedTurn = false; passedTurn = false;
passedTurnSkipStack = false;
passedUntilEndOfTurn = false; passedUntilEndOfTurn = false;
passedUntilNextMain = true; passedUntilNextMain = true;
passedUntilStackResolved = false; passedUntilStackResolved = false;
@ -2042,6 +2061,7 @@ public abstract class PlayerImpl implements Player, Serializable {
case PASS_PRIORITY_UNTIL_STACK_RESOLVED: //F8 case PASS_PRIORITY_UNTIL_STACK_RESOLVED: //F8
passedAllTurns = false; passedAllTurns = false;
passedTurn = false; passedTurn = false;
passedTurnSkipStack = false;
passedUntilEndOfTurn = false; passedUntilEndOfTurn = false;
passedUntilNextMain = false; passedUntilNextMain = false;
passedUntilStackResolved = true; passedUntilStackResolved = true;
@ -2052,6 +2072,7 @@ public abstract class PlayerImpl implements Player, Serializable {
case PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN: //F11 case PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN: //F11
passedAllTurns = false; passedAllTurns = false;
passedTurn = false; passedTurn = false;
passedTurnSkipStack = false;
passedUntilEndOfTurn = false; passedUntilEndOfTurn = false;
passedUntilNextMain = false; passedUntilNextMain = false;
passedUntilStackResolved = false; passedUntilStackResolved = false;
@ -2061,6 +2082,7 @@ public abstract class PlayerImpl implements Player, Serializable {
case PASS_PRIORITY_CANCEL_ALL_ACTIONS: case PASS_PRIORITY_CANCEL_ALL_ACTIONS:
passedAllTurns = false; passedAllTurns = false;
passedTurn = false; passedTurn = false;
passedTurnSkipStack = false;
passedUntilEndOfTurn = false; passedUntilEndOfTurn = false;
passedUntilNextMain = false; passedUntilNextMain = false;
passedUntilStackResolved = false; passedUntilStackResolved = false;