mirror of
https://github.com/correl/mage.git
synced 2025-03-16 17:00:13 -09:00
add restoring tournament table chat divider location
refactor getting current bounds into utility function
This commit is contained in:
parent
5822a7d94d
commit
ebc36c503e
4 changed files with 22 additions and 7 deletions
|
@ -203,6 +203,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
public static final String KEY_TABLES_DIVIDER_LOCATION_1 = "tablePanelDividerLocation1";
|
public static final String KEY_TABLES_DIVIDER_LOCATION_1 = "tablePanelDividerLocation1";
|
||||||
public static final String KEY_TABLES_DIVIDER_LOCATION_2 = "tablePanelDividerLocation2";
|
public static final String KEY_TABLES_DIVIDER_LOCATION_2 = "tablePanelDividerLocation2";
|
||||||
public static final String KEY_TABLES_DIVIDER_LOCATION_3 = "tablePanelDividerLocation3";
|
public static final String KEY_TABLES_DIVIDER_LOCATION_3 = "tablePanelDividerLocation3";
|
||||||
|
public static final String KEY_TABLES_DIVIDER_LOCATION_4 = "tablePanelDividerLocation4";
|
||||||
|
|
||||||
// Positions of deck editor divider bars
|
// 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 = "editorHorizontalDividerLocation";
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -54,6 +55,7 @@ import mage.client.util.GUISizeHelper;
|
||||||
import mage.client.util.audio.AudioManager;
|
import mage.client.util.audio.AudioManager;
|
||||||
import mage.client.util.gui.TableUtil;
|
import mage.client.util.gui.TableUtil;
|
||||||
import mage.client.util.gui.countryBox.CountryCellRenderer;
|
import mage.client.util.gui.countryBox.CountryCellRenderer;
|
||||||
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.players.PlayerType;
|
import mage.players.PlayerType;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.view.SeatView;
|
import mage.view.SeatView;
|
||||||
|
@ -61,6 +63,7 @@ import mage.view.TableView;
|
||||||
|
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER;
|
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER;
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
|
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
|
||||||
|
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -154,6 +157,9 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
this.tableId = tableId;
|
this.tableId = tableId;
|
||||||
this.isTournament = isTournament;
|
this.isTournament = isTournament;
|
||||||
|
|
||||||
|
Rectangle currentBounds = MageFrame.getDesktop().getBounds();
|
||||||
|
|
||||||
updateTask = new UpdateSeatsTask(SessionHandler.getSession(), roomId, tableId, this);
|
updateTask = new UpdateSeatsTask(SessionHandler.getSession(), roomId, tableId, this);
|
||||||
if (SessionHandler.isTableOwner(roomId, tableId)) {
|
if (SessionHandler.isTableOwner(roomId, tableId)) {
|
||||||
this.btnStart.setVisible(true);
|
this.btnStart.setVisible(true);
|
||||||
|
@ -171,6 +177,8 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
this.setModal(false);
|
this.setModal(false);
|
||||||
this.setLocation(100, 100);
|
this.setLocation(100, 100);
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
|
String tournamentChatDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_4, null);
|
||||||
|
GuiDisplayUtil.restoreDividerLocations(currentBounds, tournamentChatDivider, jSplitPane1);
|
||||||
} else {
|
} else {
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
|
@ -185,6 +193,8 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
MageFrame.getUI().removeButton(MageComponents.TABLE_WAITING_START_BUTTON);
|
MageFrame.getUI().removeButton(MageComponents.TABLE_WAITING_START_BUTTON);
|
||||||
this.removeDialog();
|
this.removeDialog();
|
||||||
TableUtil.saveColumnWidthAndOrderToPrefs(jTableSeats, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER);
|
TableUtil.saveColumnWidthAndOrderToPrefs(jTableSeats, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER);
|
||||||
|
GuiDisplayUtil.saveCurrentBoundsToPrefs();
|
||||||
|
GuiDisplayUtil.setDividerLocation(KEY_TABLES_DIVIDER_LOCATION_4, this.jSplitPane1.getDividerLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -410,10 +410,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveDividerLocations() {
|
private void saveDividerLocations() {
|
||||||
// save desktop bounds and divider locations
|
// save divider locations and divider saveDividerLocations
|
||||||
Rectangle rec = MageFrame.getDesktop().getBounds();
|
GuiDisplayUtil.saveCurrentBoundsToPrefs();
|
||||||
String currentBounds = Double.toString(rec.getWidth()) + 'x' + Double.toString(rec.getHeight());
|
|
||||||
PreferencesDialog.saveValue(KEY_MAGE_PANEL_LAST_SIZE, currentBounds);
|
|
||||||
GuiDisplayUtil.setDividerLocation(KEY_TABLES_DIVIDER_LOCATION_1, this.jSplitPane1.getDividerLocation());
|
GuiDisplayUtil.setDividerLocation(KEY_TABLES_DIVIDER_LOCATION_1, this.jSplitPane1.getDividerLocation());
|
||||||
GuiDisplayUtil.setDividerLocation(KEY_TABLES_DIVIDER_LOCATION_2, this.jSplitPaneTables.getDividerLocation());
|
GuiDisplayUtil.setDividerLocation(KEY_TABLES_DIVIDER_LOCATION_2, this.jSplitPaneTables.getDividerLocation());
|
||||||
GuiDisplayUtil.setDividerLocation(KEY_TABLES_DIVIDER_LOCATION_3, chatPanelMain.getSplitDividerLocation());
|
GuiDisplayUtil.setDividerLocation(KEY_TABLES_DIVIDER_LOCATION_3, chatPanelMain.getSplitDividerLocation());
|
||||||
|
@ -432,9 +430,9 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
private void restoreDividers() {
|
private void restoreDividers() {
|
||||||
Rectangle currentBounds = MageFrame.getDesktop().getBounds();
|
Rectangle currentBounds = MageFrame.getDesktop().getBounds();
|
||||||
if (currentBounds != null) {
|
if (currentBounds != null) {
|
||||||
String firstDivider = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_1, null);
|
String firstDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_1, null);
|
||||||
String tableDivider = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_2, null);
|
String tableDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_2, null);
|
||||||
String chatDivider = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_3, null);
|
String chatDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_3, null);
|
||||||
GuiDisplayUtil.restoreDividerLocations(currentBounds, firstDivider, jSplitPane1);
|
GuiDisplayUtil.restoreDividerLocations(currentBounds, firstDivider, jSplitPane1);
|
||||||
GuiDisplayUtil.restoreDividerLocations(currentBounds, tableDivider, jSplitPaneTables);
|
GuiDisplayUtil.restoreDividerLocations(currentBounds, tableDivider, jSplitPaneTables);
|
||||||
GuiDisplayUtil.restoreDividerLocations(currentBounds, chatDivider, chatPanelMain);
|
GuiDisplayUtil.restoreDividerLocations(currentBounds, chatDivider, chatPanelMain);
|
||||||
|
|
|
@ -48,6 +48,12 @@ public final class GuiDisplayUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void saveCurrentBoundsToPrefs() {
|
||||||
|
Rectangle rec = MageFrame.getDesktop().getBounds();
|
||||||
|
String currentBounds = Double.toString(rec.getWidth()) + 'x' + Double.toString(rec.getHeight());
|
||||||
|
PreferencesDialog.saveValue(KEY_MAGE_PANEL_LAST_SIZE, currentBounds);
|
||||||
|
}
|
||||||
|
|
||||||
public static void setDividerLocation(String dividerPrefKey, int position) {
|
public static void setDividerLocation(String dividerPrefKey, int position) {
|
||||||
PreferencesDialog.saveValue(dividerPrefKey, Integer.toString(position));
|
PreferencesDialog.saveValue(dividerPrefKey, Integer.toString(position));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue