mirror of
https://github.com/correl/mage.git
synced 2025-04-10 01:01:05 -09:00
* GUI: fixed that deck editor doesn't restore settings after games (cards list hides after draft/sideboarding, see #4350);
This commit is contained in:
parent
5585e1d878
commit
e07dd273f2
3 changed files with 713 additions and 697 deletions
Mage.Client/src/main/java/mage/client
|
@ -31,7 +31,6 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
private BigCard lastBigCard = null;
|
||||
private int dividerLocationNormal = 0;
|
||||
private int dividerLocationLimited = 0;
|
||||
private static final boolean isLimitedBuildingOrientation = false;
|
||||
|
||||
public DeckCardLayout getCardLayout() {
|
||||
return deckList.getCardLayout();
|
||||
|
@ -163,7 +162,7 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
});
|
||||
}
|
||||
|
||||
public Settings saveSettings() {
|
||||
public Settings saveSettings(boolean isLimitedBuildingOrientation) {
|
||||
Settings settings = new Settings();
|
||||
settings.maindeckSettings = deckList.saveSettings();
|
||||
settings.sideboardSetings = sideboardList.saveSettings();
|
||||
|
@ -177,7 +176,7 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
return settings;
|
||||
}
|
||||
|
||||
public void loadSettings(Settings s) {
|
||||
public void loadSettings(Settings s, boolean isLimitedBuildingOrientation) {
|
||||
if (s != null) {
|
||||
deckList.loadSettings(s.maindeckSettings);
|
||||
sideboardList.loadSettings(s.sideboardSetings);
|
||||
|
@ -208,8 +207,8 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
private void setGUISize() {
|
||||
}
|
||||
|
||||
public void setOrientation(boolean limitedBuildingOrientation) {
|
||||
if (limitedBuildingOrientation) {
|
||||
public void setOrientation(boolean isLimitedBuildingOrientation) {
|
||||
if (isLimitedBuildingOrientation) {
|
||||
deckAreaSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
||||
if (dividerLocationLimited != 0) {
|
||||
deckAreaSplitPane.setDividerLocation(dividerLocationLimited);
|
||||
|
|
|
@ -78,7 +78,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
deckArea.setOpaque(false);
|
||||
panelLeft.setOpaque(false);
|
||||
panelRight.setOpaque(false);
|
||||
restoreDividerLocationsAndDeckAreaSettings();
|
||||
countdown = new javax.swing.Timer(1000,
|
||||
e -> {
|
||||
if (--timeout > 0) {
|
||||
|
@ -93,13 +92,18 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
// Set up tracking to save the deck editor settings when the deck editor is hidden.
|
||||
// save editor settings dynamicly on hides (e.g. app close)
|
||||
addHierarchyListener((HierarchyEvent e) -> {
|
||||
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
|
||||
if (!isShowing()) {
|
||||
// It's bugged and called on sideboarding creates too (before load). So:
|
||||
// * for free mode - save here
|
||||
// * for draft/sideboarding - save on cleanup call
|
||||
if (mode == DeckEditorMode.FREE_BUILDING) {
|
||||
saveDividerLocationsAndDeckAreaSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -127,21 +131,32 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
private void saveDividerLocationsAndDeckAreaSettings() {
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION, Integer.toString(panelRight.getDividerLocation()));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_DECKAREA_SETTINGS, this.deckArea.saveSettings().toString());
|
||||
boolean isLimitedBuildingOrientation = (mode != DeckEditorMode.FREE_BUILDING);
|
||||
if (isLimitedBuildingOrientation) {
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_LIMITED, Integer.toString(panelRight.getDividerLocation()));
|
||||
} else {
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_NORMAL, Integer.toString(panelRight.getDividerLocation()));
|
||||
}
|
||||
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_DECKAREA_SETTINGS, this.deckArea.saveSettings(isLimitedBuildingOrientation).toString());
|
||||
}
|
||||
|
||||
private void restoreDividerLocationsAndDeckAreaSettings() {
|
||||
// Load horizontal split position setting
|
||||
String dividerLocation = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION, "");
|
||||
String dividerLocation = "";
|
||||
boolean isLimitedBuildingOrientation = (mode != DeckEditorMode.FREE_BUILDING);
|
||||
if (isLimitedBuildingOrientation) {
|
||||
dividerLocation = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_LIMITED, "");
|
||||
} else {
|
||||
dividerLocation = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_NORMAL, "");
|
||||
}
|
||||
if (!dividerLocation.isEmpty()) {
|
||||
panelRight.setDividerLocation(Integer.parseInt(dividerLocation));
|
||||
}
|
||||
|
||||
// Load deck area settings
|
||||
this.deckArea.loadSettings(
|
||||
DeckArea.Settings.parse(
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_DECKAREA_SETTINGS, "")));
|
||||
DeckArea.Settings.parse(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_DECKAREA_SETTINGS, "")),
|
||||
isLimitedBuildingOrientation);
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
|
@ -157,11 +172,12 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
this.mode = mode;
|
||||
this.btnAddLand.setVisible(false);
|
||||
|
||||
restoreDividerLocationsAndDeckAreaSettings();
|
||||
switch (mode) {
|
||||
case LIMITED_BUILDING:
|
||||
this.btnAddLand.setVisible(true);
|
||||
this.txtTimeRemaining.setVisible(true);
|
||||
// Fall through to sideboarding
|
||||
// Fall through to sideboarding (no break)
|
||||
case SIDEBOARDING:
|
||||
this.btnSubmit.setVisible(true);
|
||||
this.btnSubmitTimer.setVisible(true);
|
||||
|
|
|
@ -3,6 +3,7 @@ package mage.client.dialog;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.SessionHandler;
|
||||
import mage.client.components.KeyBindButton;
|
||||
import mage.client.themes.ThemeType;
|
||||
import mage.client.util.CardLanguage;
|
||||
import mage.client.util.ClientDefaultSettings;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
|
@ -15,7 +16,6 @@ import mage.remote.Connection;
|
|||
import mage.remote.Connection.ProxyType;
|
||||
import mage.view.UserRequestMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
import mage.client.themes.ThemeType;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
|
@ -160,7 +160,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
public static final String KEY_TABLES_DIVIDER_LOCATION_4 = "tablePanelDividerLocation4";
|
||||
|
||||
// Positions of deck editor divider bars
|
||||
public static final String KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION = "editorHorizontalDividerLocation";
|
||||
public static final String KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_NORMAL = "editorHorizontalDividerLocationNormal";
|
||||
public static final String KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_LIMITED = "editorHorizontalDividerLocationLimited";
|
||||
public static final String KEY_EDITOR_DECKAREA_SETTINGS = "editorDeckAreaSettings";
|
||||
|
||||
// user list
|
||||
|
@ -807,7 +808,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
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) {
|
||||
|
@ -870,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);
|
||||
|
@ -1070,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);
|
||||
|
@ -1554,7 +1555,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("Default images language:");
|
||||
labelPreferedImageLanguage.setFocusable(false);
|
||||
|
@ -1562,7 +1563,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"}));
|
||||
|
||||
labelHint1.setText("(change it to 1-3 if image source bans your IP for too many connections)");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue