* 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

@ -1,55 +1,13 @@
/*
* PreferencesDialog.java
*
* Created on 26.06.2011, 16:35:40
*/
package mage.client.dialog;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.border.Border;
import javax.swing.filechooser.FileFilter;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.components.KeyBindButton;
import static mage.client.constants.Constants.BATTLEFIELD_FEEDBACK_COLORIZING_MODE_ENABLE_BY_MULTICOLOR;
import mage.client.util.CardLanguage;
import mage.client.util.Config;
import mage.client.util.GUISizeHelper;
import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
import static mage.constants.Constants.DEFAULT_AVATAR_ID;
import static mage.constants.Constants.MAX_AVATAR_ID;
import static mage.constants.Constants.MIN_AVATAR_ID;
import mage.players.net.UserData;
import mage.players.net.UserGroup;
import mage.players.net.UserSkipPrioritySteps;
@ -59,6 +17,23 @@ import mage.remote.Session;
import mage.view.UserRequestMessage;
import org.apache.log4j.Logger;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.List;
import java.util.*;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import static mage.client.constants.Constants.BATTLEFIELD_FEEDBACK_COLORIZING_MODE_ENABLE_BY_MULTICOLOR;
import static mage.constants.Constants.*;
/**
* Preferences dialog.
*
@ -149,6 +124,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_STOP_BLOCK = "stopDeclareBlockersStep";
public static final String KEY_STOP_ALL_MAIN_PHASES = "stopOnAllMainPhases";
public static final String KEY_STOP_ALL_END_PHASES = "stopOnAllEndPhases";
public static final String KEY_STOP_NEW_STACK_OBJECTS = "stopOnNewStackObjects";
public static final String KEY_PASS_PRIORITY_CAST = "passPriorityCast";
public static final String KEY_PASS_PRIORITY_ACTIVATION = "passPriorityActivation";
public static final String KEY_AUTO_ORDER_TRIGGER = "autoOrderTrigger";
@ -353,10 +329,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
return true;
}
if (filename != null) {
if (filename.endsWith(".jpg") || filename.endsWith(".jpeg")
|| filename.endsWith(".png") || filename.endsWith(".bmp")) {
return true;
}
return filename.endsWith(".jpg") || filename.endsWith(".jpeg")
|| filename.endsWith(".png") || filename.endsWith(".bmp");
}
return false;
}
@ -474,6 +448,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
phases_stopSettings = new javax.swing.JPanel();
cbStopAttack = new javax.swing.JCheckBox();
cbStopBlock = new javax.swing.JCheckBox();
cbStopOnNewStackObjects = new javax.swing.JCheckBox();
cbStopOnAllMain = new javax.swing.JCheckBox();
cbStopOnAllEnd = new javax.swing.JCheckBox();
cbPassPriorityCast = new javax.swing.JCheckBox();
@ -673,7 +648,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
showFullImagePath.setSelected(true);
showFullImagePath.setToolTipText("Show the path Xmage is expecting for this card's image (only displays if missing)");
showFullImagePath.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
showFullImagePath.setLabel("Display image path for missing images");
showFullImagePath.setText("Display image path for missing images");
showFullImagePath.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
showFullImagePathActionPerformed(evt);
@ -829,11 +804,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(cbAskMoveToGraveOrder))
);
nonLandPermanentsInOnePile.getAccessibleContext().setAccessibleName(KEY_PERMANENTS_IN_ONE_PILE);
nonLandPermanentsInOnePile.getAccessibleContext().setAccessibleName("nonLandPermanentsInOnePile");
main_battlefield.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Battlefield"));
cbBattlefieldFeedbackColorizingMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Disable colorizing", "Enable one color for all phases", "Enable multicolor for different phases" }));
cbBattlefieldFeedbackColorizingMode.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Disable colorizing", "Enable one color for all phases", "Enable multicolor for different phases"}));
cbBattlefieldFeedbackColorizingMode.setToolTipText("Battlefield feedback panel colorizing on your turn (e.g. use green color if you must select card or answer to request)");
cbBattlefieldFeedbackColorizingMode.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -896,18 +871,18 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabGuiSize.setMaximumSize(new java.awt.Dimension(527, 423));
tabGuiSize.setMinimumSize(new java.awt.Dimension(527, 423));
java.awt.GridBagLayout tabGuiSizeLayout = new java.awt.GridBagLayout();
tabGuiSizeLayout.columnWidths = new int[] {0};
tabGuiSizeLayout.rowHeights = new int[] {0, 20, 0};
tabGuiSizeLayout.columnWeights = new double[] {1.0};
tabGuiSizeLayout.rowWeights = new double[] {1.0, 0.0, 1.0};
tabGuiSizeLayout.columnWidths = new int[]{0};
tabGuiSizeLayout.rowHeights = new int[]{0, 20, 0};
tabGuiSizeLayout.columnWeights = new double[]{1.0};
tabGuiSizeLayout.rowWeights = new double[]{1.0, 0.0, 1.0};
tabGuiSize.setLayout(tabGuiSizeLayout);
guiSizeBasic.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Size basic elements"));
guiSizeBasic.setMinimumSize(new java.awt.Dimension(600, 180));
guiSizeBasic.setPreferredSize(new java.awt.Dimension(600, 180));
java.awt.GridBagLayout guiSizeBasicLayout = new java.awt.GridBagLayout();
guiSizeBasicLayout.columnWeights = new double[] {1.0, 1.0, 1.0};
guiSizeBasicLayout.rowWeights = new double[] {1.0, 0.2, 1.0, 0.2};
guiSizeBasicLayout.columnWeights = new double[]{1.0, 1.0, 1.0};
guiSizeBasicLayout.rowWeights = new double[]{1.0, 0.2, 1.0, 0.2};
guiSizeBasic.setLayout(guiSizeBasicLayout);
sliderFontSize.setMajorTickSpacing(5);
@ -1096,8 +1071,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
guiSizeGame.setMinimumSize(new java.awt.Dimension(600, 180));
guiSizeGame.setPreferredSize(new java.awt.Dimension(600, 180));
java.awt.GridBagLayout guiSizeGameLayout = new java.awt.GridBagLayout();
guiSizeGameLayout.columnWeights = new double[] {1.0, 1.0, 1.0, 1.0};
guiSizeGameLayout.rowWeights = new double[] {1.0, 0.2, 1.0, 0.2};
guiSizeGameLayout.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0};
guiSizeGameLayout.rowWeights = new double[]{1.0, 0.2, 1.0, 0.2};
guiSizeGame.setLayout(guiSizeGameLayout);
sliderCardSizeHand.setMajorTickSpacing(5);
@ -1318,7 +1293,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabsPanel.addTab("GUI Size", tabGuiSize);
jLabelHeadLine.setText("Choose phases your game will stop on if not skipped by a skip action (e.g. F6):");
jLabelHeadLine.setText("Default stop steps if not skip buttons activated (e.g. F6):");
jLabelYourTurn.setText("Your turn");
@ -1328,7 +1303,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
jLabelDraw.setText("Draw:");
jLabelMain1.setText("Main:");
jLabelMain1.setText("Main 1:");
jLabelBeforeCombat.setText("Before combat:");
@ -1338,12 +1313,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
jLabelEndOfTurn.setText("End of turn:");
phases_stopSettings.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Stop settings"));
phases_stopSettings.setLayout(new java.awt.GridLayout(7, 1));
phases_stopSettings.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "SKIP settings"));
phases_stopSettings.setLayout(new java.awt.GridLayout(8, 1));
cbStopAttack.setSelected(true);
cbStopAttack.setText("Stop on declare attackers step if you skip steps (F4/F5/F7) and attackers are available");
cbStopAttack.setToolTipText("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.");
cbStopAttack.setText("STOP skips on declare attackers if attackers are available");
cbStopAttack.setToolTipText("");
cbStopAttack.setActionCommand("");
cbStopAttack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -1352,8 +1327,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
});
phases_stopSettings.add(cbStopAttack);
cbStopBlock.setText("Stop on your declare blockers step also if no blockers available");
cbStopBlock.setToolTipText("Also if you have no blockers to declare, the game stops at the declare blockers step.");
cbStopBlock.setText("STOP skips on declare blockers if blockers are available");
cbStopBlock.setToolTipText("");
cbStopBlock.setActionCommand("");
cbStopBlock.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -1362,8 +1337,19 @@ public class PreferencesDialog extends javax.swing.JDialog {
});
phases_stopSettings.add(cbStopBlock);
cbStopOnAllMain.setText("Skip with F7 to next main phase (if not activated skip always to your next main phase)");
cbStopOnAllMain.setToolTipText("If activated F7 skips to next main phases (regardless of the active players).");
cbStopOnNewStackObjects.setText("Skip to STACK resolved (F10): stop on new objects added (on) or stop until empty (off)");
cbStopOnNewStackObjects.setToolTipText("");
cbStopOnNewStackObjects.setActionCommand("");
cbStopOnNewStackObjects.setPreferredSize(new java.awt.Dimension(300, 25));
cbStopOnNewStackObjects.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbStopOnNewStackObjectsActionPerformed(evt);
}
});
phases_stopSettings.add(cbStopOnNewStackObjects);
cbStopOnAllMain.setText("Skip to MAIN step (F7): stop on any main steps (on) or stop on your main step (off)");
cbStopOnAllMain.setToolTipText("");
cbStopOnAllMain.setActionCommand("");
cbStopOnAllMain.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -1372,8 +1358,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
});
phases_stopSettings.add(cbStopOnAllMain);
cbStopOnAllEnd.setText("Skip with F5 to next end step (if not activated only to end steps of opponents)");
cbStopOnAllEnd.setToolTipText("If activated - F5 skips to the next end step (regardless of the current player)");
cbStopOnAllEnd.setText("Skip to END step (F5): stop on any end steps (on) or stop on opponents end step (off)");
cbStopOnAllEnd.setToolTipText("");
cbStopOnAllEnd.setActionCommand("");
cbStopOnAllEnd.setPreferredSize(new java.awt.Dimension(300, 25));
cbStopOnAllEnd.addActionListener(new java.awt.event.ActionListener() {
@ -1527,12 +1513,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(checkBoxEndTurnOthers))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(phases_stopSettings, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(170, Short.MAX_VALUE))
.addContainerGap(185, Short.MAX_VALUE))
);
tabsPanel.addTab("Phases & Priority", tabPhases);
panelCardImages.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card images:"));
panelCardImages.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card images"));
cbUseDefaultImageFolder.setText("Use default location to save images");
cbUseDefaultImageFolder.addActionListener(new java.awt.event.ActionListener() {
@ -1565,7 +1551,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
});
cbPreferedImageLanguage.setMaximumRowCount(20);
cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
labelPreferedImageLanguage.setText("Prefered image language:");
labelPreferedImageLanguage.setFocusable(false);
@ -1573,7 +1559,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
labelNumberOfDownloadThreads.setText("Number of download threads:");
cbNumberOfDownloadThreads.setMaximumRowCount(20);
cbNumberOfDownloadThreads.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbNumberOfDownloadThreads.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
org.jdesktop.layout.GroupLayout panelCardImagesLayout = new org.jdesktop.layout.GroupLayout(panelCardImages);
panelCardImages.setLayout(panelCardImagesLayout);
@ -1632,7 +1618,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(labelPreferedImageLanguage)))
);
panelBackgroundImages.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Background images setting:"));
panelBackgroundImages.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Background images"));
cbUseDefaultBackground.setText("Use default image");
cbUseDefaultBackground.addActionListener(new java.awt.event.ActionListener() {
@ -1736,9 +1722,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(jLabel15)))
);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card rendering:"));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card styles (restart xmage to apply new settings)"));
cbCardRenderImageFallback.setText("Fall back to plain image based rendering");
cbCardRenderImageFallback.setText("Render mode: MTGO style (off) or IMAGE style (on)");
cbCardRenderImageFallback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbCardRenderImageFallbackActionPerformed(evt);
@ -2612,7 +2598,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
});
labelToggleRecordMacro.setText("Toggle Record Macro");
labelToggleRecordMacro.setText("Record Macro (unsupported)");
keyToggleRecordMacro.setText("keyBindButton1");
@ -2651,7 +2637,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(keyEndStep, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(keyToggleRecordMacro, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(controlsDescriptionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)))
.add(controlsDescriptionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)))
.addContainerGap())
);
tabControlsLayout.setVerticalGroup(
@ -2707,7 +2693,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabsPanel.addTab("Controls", tabControls);
saveButton.setLabel("Save");
saveButton.setText("Save");
saveButton.setMaximumSize(new java.awt.Dimension(100, 30));
saveButton.setMinimumSize(new java.awt.Dimension(100, 30));
saveButton.setPreferredSize(new java.awt.Dimension(100, 30));
@ -2718,7 +2704,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
});
exitButton.setLabel("Exit");
exitButton.setText("Exit");
exitButton.setMaximumSize(new java.awt.Dimension(100, 30));
exitButton.setMinimumSize(new java.awt.Dimension(100, 30));
exitButton.setPreferredSize(new java.awt.Dimension(100, 30));
@ -2867,6 +2853,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.cbStopBlock, KEY_STOP_BLOCK, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbStopOnAllMain, KEY_STOP_ALL_MAIN_PHASES, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbStopOnAllEnd, KEY_STOP_ALL_END_PHASES, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbStopOnNewStackObjects, KEY_STOP_NEW_STACK_OBJECTS, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbPassPriorityCast, KEY_PASS_PRIORITY_CAST, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbPassPriorityActivation, KEY_PASS_PRIORITY_ACTIVATION, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbAutoOrderTrigger, KEY_AUTO_ORDER_TRIGGER, "true", "false", UPDATE_CACHE_POLICY);
@ -2929,7 +2916,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
try {
SessionHandler.updatePreferencesForServer(getUserData());
prefs.flush();
} catch (BackingStoreException ex) {
logger.error("Error: couldn't save preferences", ex);
@ -3235,6 +3221,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
// TODO add your handling code here:
}//GEN-LAST:event_displayLifeOnAvatarActionPerformed
private void cbStopOnNewStackObjectsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbStopOnNewStackObjectsActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbStopOnNewStackObjectsActionPerformed
private void showProxySettings() {
Connection.ProxyType proxyType = (Connection.ProxyType) cbProxyType.getSelectedItem();
switch (proxyType) {
@ -3285,7 +3275,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
public static void main(String[] args) {
int param = 0;
if (args.length > 0) {
String param1 = args[0];
@ -3382,6 +3372,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.cbStopBlock, KEY_STOP_BLOCK, "true", "true");
load(prefs, dialog.cbStopOnAllMain, KEY_STOP_ALL_MAIN_PHASES, "true", "false");
load(prefs, dialog.cbStopOnAllEnd, KEY_STOP_ALL_END_PHASES, "true", "false");
load(prefs, dialog.cbStopOnNewStackObjects, KEY_STOP_NEW_STACK_OBJECTS, "true", "false");
load(prefs, dialog.cbPassPriorityCast, KEY_PASS_PRIORITY_CAST, "true", "false");
load(prefs, dialog.cbPassPriorityActivation, KEY_PASS_PRIORITY_ACTIVATION, "true", "false");
load(prefs, dialog.cbAutoOrderTrigger, KEY_AUTO_ORDER_TRIGGER, "true", "true");
@ -3422,7 +3413,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
dialog.cbPreferedImageLanguage.setSelectedItem(MageFrame.getPreferences().get(KEY_CARD_IMAGES_PREF_LANGUAGE, CardLanguage.ENGLISH.getCode()));
// rendering settings
load(prefs, dialog.cbCardRenderImageFallback, KEY_CARD_RENDERING_FALLBACK, "true");
load(prefs, dialog.cbCardRenderImageFallback, KEY_CARD_RENDERING_FALLBACK, "true", "false");
load(prefs, dialog.cbCardRenderHideSetSymbol, KEY_CARD_RENDERING_SET_SYMBOL, "true");
load(prefs, dialog.cbCardRenderShowReminderText, KEY_CARD_RENDERING_REMINDER_TEXT, "true");
@ -3549,6 +3540,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
userSkipPrioritySteps.setStopOnDeclareBlockerIfNoneAvailable(dialog.cbStopBlock.isSelected());
userSkipPrioritySteps.setStopOnAllEndPhases(dialog.cbStopOnAllEnd.isSelected());
userSkipPrioritySteps.setStopOnAllMainPhases(dialog.cbStopOnAllMain.isSelected());
userSkipPrioritySteps.setStopOnStackNewObjects(dialog.cbStopOnNewStackObjects.isSelected());
return userSkipPrioritySteps;
}
@ -3804,7 +3796,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
private void addAvatar(JPanel jPanel, final int id, boolean selected, boolean locked) {
String path = "/avatars/" + String.valueOf(id) + ".jpg";
String path = "/avatars/" + id + ".jpg";
PANELS.put(id, jPanel);
Image image = ImageHelper.getImageFromResources(path);
@ -3918,6 +3910,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JCheckBox cbStopBlock;
private javax.swing.JCheckBox cbStopOnAllEnd;
private javax.swing.JCheckBox cbStopOnAllMain;
private javax.swing.JCheckBox cbStopOnNewStackObjects;
private javax.swing.JCheckBox cbUseDefaultBackground;
private javax.swing.JCheckBox cbUseDefaultBattleImage;
private javax.swing.JCheckBox cbUseDefaultImageFolder;

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())) {
} 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;
}
}