* UI: improved skip buttons and preferences:

* added new setting for STACK skip button: stops on full empty stack (default) or on new objects added;
 * added new dynamic hints for skip buttons to see current settings and modes;
 * fixed that some skip buttons not de-activated after goal was achieved;
 * fixed wrong default render mode for cards, MTGO must be default (#4409);
This commit is contained in:
Oleg Agafonov 2019-03-17 04:38:31 +04:00
parent c4eeec1bb2
commit bf2861c309
6 changed files with 1030 additions and 840 deletions

View file

@ -4071,7 +4071,7 @@
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="phases_stopSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="170" max="32767" attributes="0"/>
<EmptySpace pref="185" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -4079,7 +4079,7 @@
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabelHeadLine">
<Properties>
<Property name="text" type="java.lang.String" value="Choose phases your game will stop on if not skipped by a skip action (e.g. F6):"/>
<Property name="text" type="java.lang.String" value="Default stop steps if not skip buttons activated (e.g. F6):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabelYourTurn">
@ -4112,7 +4112,7 @@
</Component>
<Component class="javax.swing.JLabel" name="jLabelMain1">
<Properties>
<Property name="text" type="java.lang.String" value="Main:"/>
<Property name="text" type="java.lang.String" value="Main 1:"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkBoxMainYou">
@ -4159,7 +4159,7 @@
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Stop settings">
<TitledBorder title="SKIP settings">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
@ -4170,14 +4170,14 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/>
<Property name="rows" type="int" value="7"/>
<Property name="rows" type="int" value="8"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="cbStopAttack">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Stop on declare attackers step if you skip steps (F4/F5/F7) and attackers are available"/>
<Property name="toolTipText" type="java.lang.String" value="If you use F4, F5 or F7 to skip steps, you stop on declare attackers step if attackers are available. If this option is not activated, you also skip the declare attackers step with this actions. F9 does always skip the declare attackers step."/>
<Property name="text" type="java.lang.String" value="STOP skips on declare attackers if attackers are available"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/>
</Properties>
<Events>
@ -4186,18 +4186,31 @@
</Component>
<Component class="javax.swing.JCheckBox" name="cbStopBlock">
<Properties>
<Property name="text" type="java.lang.String" value="Stop on your declare blockers step also if no blockers available"/>
<Property name="toolTipText" type="java.lang.String" value="Also if you have no blockers to declare, the game stops at the declare blockers step."/>
<Property name="text" type="java.lang.String" value="STOP skips on declare blockers if blockers are available"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbStopBlockActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbStopOnNewStackObjects">
<Properties>
<Property name="text" type="java.lang.String" value="Skip to STACK resolved (F10): stop on new objects added (on) or stop until empty (off)"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 25]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbStopOnNewStackObjectsActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbStopOnAllMain">
<Properties>
<Property name="text" type="java.lang.String" value="Skip with F7 to next main phase (if not activated skip always to your next main phase)"/>
<Property name="toolTipText" type="java.lang.String" value="If activated F7 skips to next main phases (regardless of the active players)."/>
<Property name="text" type="java.lang.String" value="Skip to MAIN step (F7): stop on any main steps (on) or stop on your main step (off)"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/>
</Properties>
<Events>
@ -4206,8 +4219,8 @@
</Component>
<Component class="javax.swing.JCheckBox" name="cbStopOnAllEnd">
<Properties>
<Property name="text" type="java.lang.String" value="Skip with F5 to next end step (if not activated only to end steps of opponents)"/>
<Property name="toolTipText" type="java.lang.String" value="If activated - F5 skips to the next end step (regardless of the current player)"/>
<Property name="text" type="java.lang.String" value="Skip to END step (F5): stop on any end steps (on) or stop on opponents end step (off)"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 25]"/>
@ -4302,7 +4315,7 @@
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Card images:">
<TitledBorder title="Card images">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
@ -4469,7 +4482,7 @@
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Background images setting:">
<TitledBorder title="Background images">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
@ -4610,7 +4623,7 @@
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Card rendering:">
<TitledBorder title="Card styles (restart xmage to apply new settings)">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
@ -4648,7 +4661,7 @@
<SubComponents>
<Component class="javax.swing.JCheckBox" name="cbCardRenderImageFallback">
<Properties>
<Property name="text" type="java.lang.String" value="Fall back to plain image based rendering"/>
<Property name="text" type="java.lang.String" value="Render mode: MTGO style (off) or IMAGE style (on)"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbCardRenderImageFallbackActionPerformed"/>
@ -6043,7 +6056,7 @@
<Component id="keyToggleRecordMacro" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="controlsDescriptionLabel" pref="478" max="32767" attributes="0"/>
<Component id="controlsDescriptionLabel" pref="468" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
@ -6249,7 +6262,7 @@
</Component>
<Component class="javax.swing.JLabel" name="labelToggleRecordMacro">
<Properties>
<Property name="text" type="java.lang.String" value="Toggle Record Macro"/>
<Property name="text" type="java.lang.String" value="Record Macro (unsupported)"/>
</Properties>
</Component>
<Component class="mage.client.components.KeyBindButton" name="keyToggleRecordMacro">

View file

@ -86,6 +86,7 @@ public final class GamePanel extends javax.swing.JPanel {
private String chosenHandKey = "You";
private boolean smallMode = false;
private boolean initialized = false;
private skipButtonsList skipButtons = new skipButtonsList();
private boolean menuNameSet = false;
private boolean handCardsOfOpponentAvailable = false;
@ -102,7 +103,6 @@ public final class GamePanel extends javax.swing.JPanel {
private Timer resizeTimer;
private enum PopUpMenuType {
TRIGGER_ORDER
}
@ -707,8 +707,7 @@ public final class GamePanel extends javax.swing.JPanel {
}
players.get(player.getPlayerId()).update(player);
if (player.getPlayerId().equals(playerId)) {
updateSkipButtons(player.isPassedTurn(), player.isPassedUntilEndOfTurn(), player.isPassedUntilNextMain(), player.isPassedAllTurns(), player.isPassedUntilStackResolved(),
player.isPassedUntilEndStepBeforeMyTurn());
skipButtons.updateFromPlayer(player);
}
// update open or remove closed graveyard windows
graveyards.put(player.getName(), player.getGraveyard());
@ -737,6 +736,8 @@ public final class GamePanel extends javax.swing.JPanel {
// can happen at the game start before player list is initiated
}
}
updateSkipButtons();
if (!menuNameSet) {
StringBuilder sb = new StringBuilder();
if (playerId == null) {
@ -820,41 +821,169 @@ public final class GamePanel extends javax.swing.JPanel {
this.repaint();
}
// skip buttons border
private static final int BORDER_SIZE = 2;
private static final Border BORDER_ACTIVE = new LineBorder(Color.orange, BORDER_SIZE);
private static final Border BORDER_NON_ACTIVE = new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE);
private void updateSkipButtons(boolean turn, boolean endOfTurn, boolean nextMain, boolean allTurns, boolean stack, boolean endStepBeforeYourStep) {
if (turn) { //F4
btnSkipToNextTurn.setBorder(new LineBorder(Color.orange, BORDER_SIZE));
} else {
btnSkipToNextTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
}
if (endOfTurn) { // F5
btnSkipToEndTurn.setBorder(new LineBorder(Color.orange, BORDER_SIZE));
} else {
btnSkipToEndTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
}
if (nextMain) { // F7
btnSkipToNextMain.setBorder(new LineBorder(Color.orange, BORDER_SIZE));
} else {
btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
}
if (stack) { // F8
btnSkipStack.setBorder(new LineBorder(Color.orange, BORDER_SIZE));
} else {
btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
}
if (allTurns) { // F9
btnSkipToYourTurn.setBorder(new LineBorder(Color.orange, BORDER_SIZE));
} else {
btnSkipToYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
// skip buttons info
private class skipButton {
private final String text;
private final String extraFalse;
private final String extraTrue;
private final String hotkeyName;
private boolean extraMode = false; // extra option enabled from preferences
private boolean pressState = false; // activated by user or not
skipButton(String text, String extraFalse, String extraTrue, String hotkeyName) {
this.text = text;
this.extraFalse = extraFalse;
this.extraTrue = extraTrue;
this.hotkeyName = hotkeyName;
}
if (endStepBeforeYourStep) { // F11
btnSkipToEndStepBeforeYourTurn.setBorder(new LineBorder(Color.orange, BORDER_SIZE));
} else {
btnSkipToEndStepBeforeYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
public void setExtraMode(boolean enable) {
this.extraMode = enable;
}
public void setPressState(boolean enable) {
this.pressState = enable;
}
public String getTooltip() {
// show hotkey and selects current button mode
// text
String res = "<html>"
+ "<b>" + getCachedKeyText(this.hotkeyName) + "</b>"
+ " - " + text;
// mode
String mesTrue = this.extraTrue;
String mesFalse = this.extraFalse;
if (!this.extraTrue.isEmpty() || !this.extraFalse.isEmpty()) {
if (this.extraMode) {
mesTrue = "<b>" + mesTrue + "</b>";
} else {
mesFalse = "<b>" + mesFalse + "</b>";
}
res = res.replace("EXTRA_FALSE", mesFalse);
res = res.replace("EXTRA_TRUE", mesTrue);
res = res + " - adjust using preferences";
}
return res;
}
public Border getBorder() {
return this.pressState ? BORDER_ACTIVE : BORDER_NON_ACTIVE;
}
}
private class skipButtonsList {
private final skipButton turn;
private final skipButton untilEndOfTurn;
private final skipButton untilNextMain;
private final skipButton allTurns;
private final skipButton untilStackResolved;
private final skipButton untilUntilEndStepBeforeMyTurn;
skipButtonsList() {
this.turn = new skipButton("Skip to next turn", "", "", KEY_CONTROL_NEXT_TURN);
this.untilEndOfTurn = new skipButton("Skip to [EXTRA_TRUE / EXTRA_FALSE] END OF TURN step", "opponent", "next", KEY_CONTROL_END_STEP);
this.untilNextMain = new skipButton("Skip to [EXTRA_TRUE / EXTRA_FALSE] MAIN step", "opponent", "next", KEY_CONTROL_MAIN_STEP);
this.allTurns = new skipButton("Skip to YOUR turn", "", "", KEY_CONTROL_YOUR_TURN);
this.untilStackResolved = new skipButton("Skip until stack is resolved [EXTRA_TRUE]", "", "or stop on new objects added", KEY_CONTROL_SKIP_STACK);
this.untilUntilEndStepBeforeMyTurn = new skipButton("Skip to END OF TURN before YOUR", "", "", KEY_CONTROL_PRIOR_END);
}
private void updateExtraMode(PlayerView player) {
this.turn.setExtraMode(false); // not used
this.untilEndOfTurn.setExtraMode(player.getUserData().getUserSkipPrioritySteps().isStopOnAllEndPhases());
this.untilNextMain.setExtraMode(player.getUserData().getUserSkipPrioritySteps().isStopOnAllMainPhases());
this.allTurns.setExtraMode(false); // not used
this.untilStackResolved.setExtraMode(player.getUserData().getUserSkipPrioritySteps().isStopOnStackNewObjects());
this.untilUntilEndStepBeforeMyTurn.setExtraMode(false); // not used
}
private void updatePressState(PlayerView player) {
this.turn.setPressState(player.isPassedTurn());
this.untilEndOfTurn.setPressState(player.isPassedUntilEndOfTurn());
this.untilNextMain.setPressState(player.isPassedUntilNextMain());
this.allTurns.setPressState(player.isPassedAllTurns());
this.untilStackResolved.setPressState(player.isPassedUntilStackResolved());
this.untilUntilEndStepBeforeMyTurn.setPressState(player.isPassedUntilEndStepBeforeMyTurn());
}
public void updateFromPlayer(PlayerView player) {
updateExtraMode(player);
updatePressState(player);
}
private skipButton findButton(String hotkey) {
switch (hotkey) {
case KEY_CONTROL_NEXT_TURN:
return this.turn;
case KEY_CONTROL_END_STEP:
return this.untilEndOfTurn;
case KEY_CONTROL_MAIN_STEP:
return this.untilNextMain;
case KEY_CONTROL_YOUR_TURN:
return this.allTurns;
case KEY_CONTROL_SKIP_STACK:
return this.untilStackResolved;
case KEY_CONTROL_PRIOR_END:
return this.untilUntilEndStepBeforeMyTurn;
default:
logger.error("Unknown hotkey name " + hotkey);
return null;
}
}
public String getTooltip(String hotkey) {
skipButton butt = findButton(hotkey);
return butt != null ? butt.getTooltip() : "";
}
public Border getBorder(String hotkey) {
skipButton butt = findButton(hotkey);
return butt != null ? butt.getBorder() : BORDER_NON_ACTIVE;
}
public void activateSkipButton(String hotkey) {
// enable ONE button and disable all other (no needs to wait server feedback)
this.turn.setPressState(false);
this.untilEndOfTurn.setPressState(false);
this.untilNextMain.setPressState(false);
this.allTurns.setPressState(false);
this.untilStackResolved.setPressState(false);
this.untilUntilEndStepBeforeMyTurn.setPressState(false);
if (!hotkey.isEmpty()) {
skipButton butt = findButton(hotkey);
if (butt != null) butt.setPressState(true);
}
}
}
private void updateSkipButtons() {
// hints
btnSkipToNextTurn.setToolTipText(skipButtons.turn.getTooltip());
btnSkipToEndTurn.setToolTipText(skipButtons.untilEndOfTurn.getTooltip());
btnSkipToNextMain.setToolTipText(skipButtons.untilNextMain.getTooltip());
btnSkipStack.setToolTipText(skipButtons.untilStackResolved.getTooltip());
btnSkipToYourTurn.setToolTipText(skipButtons.allTurns.getTooltip());
btnSkipToEndStepBeforeYourTurn.setToolTipText(skipButtons.untilUntilEndStepBeforeMyTurn.getTooltip());
// border
btnSkipToNextTurn.setBorder(skipButtons.turn.getBorder());
btnSkipToEndTurn.setBorder(skipButtons.untilEndOfTurn.getBorder());
btnSkipToNextMain.setBorder(skipButtons.untilNextMain.getBorder());
btnSkipStack.setBorder(skipButtons.untilStackResolved.getBorder());
btnSkipToYourTurn.setBorder(skipButtons.allTurns.getBorder());
btnSkipToEndStepBeforeYourTurn.setBorder(skipButtons.untilUntilEndStepBeforeMyTurn.getBorder());
}
/**
@ -1485,11 +1614,12 @@ public final class GamePanel extends javax.swing.JPanel {
}
});
// SKIP BUTTONS (button's hint/state is dynamic)
btnCancelSkip.setContentAreaFilled(false);
btnCancelSkip.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnCancelSkip.setIcon(new ImageIcon(ImageManagerImpl.instance.getCancelSkipButtonImage()));
btnCancelSkip.setToolTipText("Cancel all skip actions ("
+ getCachedKeyText(KEY_CONTROL_CANCEL_SKIP) + ").");
btnCancelSkip.setToolTipText("CANCEL all skips");
btnCancelSkip.setFocusable(false);
btnCancelSkip.addMouseListener(new FirstButtonMousePressedAction(e ->
restorePriorityActionPerformed(null)));
@ -1497,8 +1627,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToNextTurn.setContentAreaFilled(false);
btnSkipToNextTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToNextTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipNextTurnButtonImage()));
btnSkipToNextTurn.setToolTipText("Skip to next turn ("
+ getCachedKeyText(KEY_CONTROL_NEXT_TURN) + ").");
btnSkipToNextTurn.setToolTipText("dynamic");
btnSkipToNextTurn.setFocusable(false);
btnSkipToNextTurn.addMouseListener(new FirstButtonMousePressedAction(e ->
btnEndTurnActionPerformed(null)));
@ -1515,8 +1644,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToEndTurn.setContentAreaFilled(false);
btnSkipToEndTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToEndTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipEndTurnButtonImage()));
btnSkipToEndTurn.setToolTipText("Skip to (opponents/next) end of turn step ("
+ getCachedKeyText(KEY_CONTROL_END_STEP) + ") - adjust using preferences.");
btnSkipToEndTurn.setToolTipText("dynamic");
btnSkipToEndTurn.setFocusable(false);
btnSkipToEndTurn.addMouseListener(new FirstButtonMousePressedAction(e ->
btnUntilEndOfTurnActionPerformed(null)));
@ -1542,8 +1670,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToNextMain.setContentAreaFilled(false);
btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipMainButtonImage()));
btnSkipToNextMain.setToolTipText("Skip to (your) next main phase ("
+ getCachedKeyText(KEY_CONTROL_MAIN_STEP) + ") - adjust using preferences.");
btnSkipToNextMain.setToolTipText("dynamic");
btnSkipToNextMain.setFocusable(false);
btnSkipToNextMain.addMouseListener(new FirstButtonMousePressedAction(e ->
btnUntilNextMainPhaseActionPerformed(null)));
@ -1560,8 +1687,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToYourTurn.setContentAreaFilled(false);
btnSkipToYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToYourTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipYourNextTurnButtonImage()));
btnSkipToYourTurn.setToolTipText("Skip to your next turn ("
+ getCachedKeyText(KEY_CONTROL_YOUR_TURN) + ").");
btnSkipToYourTurn.setToolTipText("dynamic");
btnSkipToYourTurn.setFocusable(false);
btnSkipToYourTurn.addMouseListener(new FirstButtonMousePressedAction(e ->
btnPassPriorityUntilNextYourTurnActionPerformed(null)));
@ -1578,8 +1704,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToEndStepBeforeYourTurn.setContentAreaFilled(false);
btnSkipToEndStepBeforeYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToEndStepBeforeYourTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipEndStepBeforeYourTurnButtonImage()));
btnSkipToEndStepBeforeYourTurn.setToolTipText("Skip to the end step before your turn ("
+ getCachedKeyText(KEY_CONTROL_PRIOR_END) + ") - adjust using preferences.");
btnSkipToEndStepBeforeYourTurn.setToolTipText("dynamic");
btnSkipToEndStepBeforeYourTurn.setFocusable(false);
btnSkipToEndStepBeforeYourTurn.addMouseListener(new FirstButtonMousePressedAction(e ->
btnSkipToEndStepBeforeYourTurnActionPerformed(null)));
@ -1596,8 +1721,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipStack.setContentAreaFilled(false);
btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipStack.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipStackButtonImage()));
btnSkipStack.setToolTipText("Skip until stack is resolved ("
+ getCachedKeyText(KEY_CONTROL_SKIP_STACK) + ").");
btnSkipStack.setToolTipText("dynamic");
btnSkipStack.setFocusable(false);
btnSkipStack.addMouseListener(new FirstButtonMousePressedAction(e ->
btnPassPriorityUntilStackResolvedActionPerformed(null)));
@ -1614,11 +1738,16 @@ public final class GamePanel extends javax.swing.JPanel {
btnConcede.setContentAreaFilled(false);
btnConcede.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnConcede.setIcon(new ImageIcon(ImageManagerImpl.instance.getConcedeButtonImage()));
btnConcede.setToolTipText("Concede the current game.");
btnConcede.setToolTipText("CONCEDE current game");
btnConcede.setFocusable(false);
btnConcede.addMouseListener(new FirstButtonMousePressedAction(e ->
btnConcedeActionPerformed(null)));
// update button hint/states to default values
updateSkipButtons();
// HOTKEYS
KeyStroke ks2 = getCachedKeystroke(KEY_CONTROL_CONFIRM);
this.getInputMap(c).put(ks2, "F2_PRESS");
this.getActionMap().put("F2_PRESS", new AbstractAction() {
@ -2057,66 +2186,85 @@ public final class GamePanel extends javax.swing.JPanel {
private void btnToggleMacroActionPerformed(java.awt.event.ActionEvent evt) {
SessionHandler.sendPlayerAction(PlayerAction.TOGGLE_RECORD_MACRO, gameId, null);
skipButtons.activateSkipButton("");
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, false, false, false, false);
if (btnToggleMacro.getBorder() instanceof EmptyBorder) {
btnToggleMacro.setBorder(new LineBorder(Color.orange, BORDER_SIZE));
if (btnToggleMacro.getBorder().equals(BORDER_ACTIVE)) {
btnToggleMacro.setBorder(BORDER_NON_ACTIVE);
} else {
btnToggleMacro.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnToggleMacro.setBorder(BORDER_ACTIVE);
}
}
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_NEXT_TURN);
AudioManager.playOnSkipButton();
updateSkipButtons(true, false, false, false, false, false);
updateSkipButtons();
}
private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_END_STEP);
AudioManager.playOnSkipButton();
updateSkipButtons(false, true, false, false, false, false);
updateSkipButtons();
}
private void btnEndTurnSkipStackActionPerformed(java.awt.event.ActionEvent evt) {
logger.error("Skip action don't used", new Throwable());
/*
SessionHandler.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) {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_MAIN_STEP);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, true, false, false, false);
updateSkipButtons();
}
private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_YOUR_TURN);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, false, true, false, false);
updateSkipButtons();
}
private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_SKIP_STACK);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, false, false, true, false);
updateSkipButtons();
}
private void btnSkipToEndStepBeforeYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_PRIOR_END);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, false, false, false, true);
updateSkipButtons();
}
private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
skipButtons.activateSkipButton("");
AudioManager.playOnSkipButtonCancel();
updateSkipButtons(false, false, false, false, false, false);
updateSkipButtons();
}
private void mouseClickPhaseBar(MouseEvent evt) {
if (evt.getButton() == MouseEvent.BUTTON1) { // Left button
PreferencesDialog.main(new String[]{PreferencesDialog.OPEN_PHASES_TAB});
// TODO: add event handler on preferences closed and refresh game data from server
}
}

View file

@ -728,6 +728,7 @@ public class HumanPlayer extends PlayerImpl {
controllingPlayer = (HumanPlayer) player;
}
}
if (getJustActivatedType() != null && !holdingPriority) {
if (controllingPlayer.getUserData().isPassPriorityCast()
&& getJustActivatedType() == AbilityType.SPELL) {
@ -742,43 +743,55 @@ public class HumanPlayer extends PlayerImpl {
return false;
}
}
if (isGameUnderControl()) { // Use the skip actions only if the player itself controls its turn
if (passedAllTurns
|| passedTurnSkipStack) {
// SKIP buttons - use the skip actions only if the player itself controls its turn
if (isGameUnderControl()) {
if (passedAllTurns || passedTurnSkipStack) {
if (passWithManaPoolCheck(game)) {
return false;
}
}
if (passedUntilEndStepBeforeMyTurn) {
if (passedUntilEndStepBeforeMyTurn) {
if (game.getTurn().getStepType() != PhaseStep.END_TURN) {
// other step
if (passWithManaPoolCheck(game)) {
return false;
}
} else {
// end step - search yourself
PlayerList playerList = game.getState().getPlayerList(playerId);
if (!playerList.getPrevious().equals(game.getActivePlayerId())) {
if (passWithManaPoolCheck(game)) {
return false;
}
} else {
// stop
passedUntilEndStepBeforeMyTurn = false;
}
}
}
if (game.getStack().isEmpty()) {
// empty stack
boolean dontCheckPassStep = false;
if (passedUntilStackResolved) { // Don't skip to next step with this action. It always only resolves a stack. If stack is empty it does nothing.
passedUntilStackResolved = false;
dontCheckPassStep = true;
}
if (passedTurn
|| passedTurnSkipStack) {
if (passWithManaPoolCheck(game)) {
return false;
}
}
if (passedUntilNextMain) {
if (game.getTurn().getStepType() == PhaseStep.POSTCOMBAT_MAIN
|| game.getTurn().getStepType() == PhaseStep.PRECOMBAT_MAIN) {
// it's a main phase
// it's main step
if (!skippedAtLeastOnce
|| (!playerId.equals(game.getActivePlayerId())
&& !controllingPlayer.getUserData().getUserSkipPrioritySteps().isStopOnAllMainPhases())) {
@ -797,9 +810,10 @@ public class HumanPlayer extends PlayerImpl {
}
}
}
if (passedUntilEndOfTurn) {
if (game.getTurn().getStepType() == PhaseStep.END_TURN) {
// It's end of turn phase
// it's end of turn step
if (!skippedAtLeastOnce
|| (playerId.equals(game.getActivePlayerId())
&& !controllingPlayer
@ -812,7 +826,7 @@ public class HumanPlayer extends PlayerImpl {
}
} else {
dontCheckPassStep = true;
passedUntilEndOfTurn = false;
passedUntilEndOfTurn = false; // reset skip action
}
} else {
skippedAtLeastOnce = true;
@ -821,23 +835,39 @@ public class HumanPlayer extends PlayerImpl {
}
}
}
if (!dontCheckPassStep
&& checkPassStep(game, controllingPlayer)) {
if (passWithManaPoolCheck(game)) {
return false;
}
}
} else if (passedUntilStackResolved) {
if (Objects.equals(dateLastAddedToStack, game.getStack().getDateLastAdded())) {
dateLastAddedToStack = game.getStack().getDateLastAdded();
} else {
// non empty stack
boolean haveNewObjectsOnStack = Objects.equals(dateLastAddedToStack, game.getStack().getDateLastAdded());
dateLastAddedToStack = game.getStack().getDateLastAdded();
if (passedUntilStackResolved) {
if (haveNewObjectsOnStack
&& (playerId.equals(game.getActivePlayerId())
&& controllingPlayer
.getUserData()
.getUserSkipPrioritySteps()
.isStopOnStackNewObjects())) {
// new objects on stack -- disable "pass until stack resolved"
passedUntilStackResolved = false;
} else {
// no new objects on stack -- go to next priority
}
}
if (passedUntilStackResolved) {
if (passWithManaPoolCheck(game)) {
return false;
}
} else {
passedUntilStackResolved = false;
}
}
}
while (canRespond()) {
updateGameStatePriority("priority", game);
holdingPriority = false;

View file

@ -104,7 +104,7 @@ 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 passedTurnSkipStack; // F6 // TODO: research
protected boolean passedUntilEndOfTurn; // F5
protected boolean passedUntilNextMain; // F7
protected boolean passedUntilStackResolved; // F10

View file

@ -1,10 +1,8 @@
package mage.players.net;
import java.io.Serializable;
/**
*
* @author LevelX2
*/
public class UserSkipPrioritySteps implements Serializable {
@ -16,6 +14,7 @@ public class UserSkipPrioritySteps implements Serializable {
boolean stopOnDeclareBlockerIfNoneAvailable = true;
boolean stopOnAllMainPhases = true;
boolean stopOnAllEndPhases = true;
boolean stopOnStackNewObjects = true;
public UserSkipPrioritySteps() {
yourTurn = new SkipPrioritySteps();
@ -62,4 +61,11 @@ public class UserSkipPrioritySteps implements Serializable {
this.stopOnAllEndPhases = stopOnAllEndPhases;
}
public boolean isStopOnStackNewObjects() {
return stopOnStackNewObjects;
}
public void setStopOnStackNewObjects(boolean stopOnStackNewObjects) {
this.stopOnStackNewObjects = stopOnStackNewObjects;
}
}