forked from External/mage
This commit is contained in:
parent
818a9442a9
commit
ee75192f0a
5 changed files with 83 additions and 12 deletions
|
|
@ -131,6 +131,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
private final Map<String, MageSplitter> splitters = new LinkedHashMap<>(); // settings key, splitter
|
||||
// do not save splitters in intermediate state, e.g. connection to new server with active game
|
||||
private boolean isSplittersFullyRestored = false;
|
||||
|
||||
private boolean vertical = false;
|
||||
|
||||
public static class MageSplitter {
|
||||
JSplitPane splitPane;
|
||||
|
|
@ -228,6 +230,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public GamePanel() {
|
||||
this.vertical = PreferencesDialog.getCachedValue(KEY_GUI_VERTICAL_LAYOUT, "false").equals("true");
|
||||
initComponents = true;
|
||||
initComponents();
|
||||
|
||||
|
|
@ -259,9 +262,16 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
pnlCommandsSkipAndStack.add(pnlShortCuts, BorderLayout.NORTH);
|
||||
pnlCommandsSkipAndStack.add(stackObjects, BorderLayout.CENTER);
|
||||
// ... split: feedback + hand <|> skip + stack
|
||||
splitHandAndStack.setLeftComponent(pnlCommandsFeedbackAndHand);
|
||||
splitHandAndStack.setRightComponent(pnlCommandsSkipAndStack);
|
||||
splitHandAndStack.setResizeWeight(DIVIDER_KEEP_RIGHT_COMPONENT);
|
||||
if (vertical) {
|
||||
splitHandAndStack.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
splitHandAndStack.setBottomComponent(pnlCommandsFeedbackAndHand);
|
||||
splitHandAndStack.setTopComponent(pnlCommandsSkipAndStack);
|
||||
splitHandAndStack.setResizeWeight(DIVIDER_KEEP_RIGHT_COMPONENT);
|
||||
} else {
|
||||
splitHandAndStack.setLeftComponent(pnlCommandsFeedbackAndHand);
|
||||
splitHandAndStack.setRightComponent(pnlCommandsSkipAndStack);
|
||||
splitHandAndStack.setResizeWeight(DIVIDER_KEEP_RIGHT_COMPONENT);
|
||||
}
|
||||
pnlCommandsFeedbackAndHand.setMinimumSize(new Dimension(0, 0)); // allow any sizes for hand
|
||||
pnlCommandsSkipAndStack.setMinimumSize(new Dimension(0, 0)); // allow any sizes for stack
|
||||
// ... all
|
||||
|
|
@ -302,7 +312,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
final JLayeredPane jLayeredBackgroundPane = new JLayeredPane();
|
||||
jLayeredBackgroundPane.setSize(1024, 768);
|
||||
this.add(jLayeredBackgroundPane);
|
||||
jLayeredBackgroundPane.add(splitGameAndBigCard, JLayeredPane.DEFAULT_LAYER);
|
||||
var basePane = this.vertical ? splitBattlefieldAndChats : splitGameAndBigCard;
|
||||
jLayeredBackgroundPane.add(basePane, JLayeredPane.DEFAULT_LAYER);
|
||||
|
||||
|
||||
Map<String, JComponent> myUi = getUIComponents(jLayeredBackgroundPane);
|
||||
Plugins.instance.updateGamePanel(myUi);
|
||||
|
|
@ -314,7 +326,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
int width = ((JComponent) e.getSource()).getWidth();
|
||||
int height = ((JComponent) e.getSource()).getHeight();
|
||||
jLayeredBackgroundPane.setSize(width, height);
|
||||
splitGameAndBigCard.setSize(width, height);
|
||||
basePane.setSize(width, height);
|
||||
|
||||
if (height < storedHeight) {
|
||||
// TODO: wtf, is it needs? Research and delete that code with storedHeight
|
||||
|
|
@ -552,7 +564,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
float guiScale = GUISizeHelper.dialogGuiScale;
|
||||
int hGap = GUISizeHelper.guiSizeScale(SKIP_BUTTONS_SPACE_H, guiScale);
|
||||
int vGap = GUISizeHelper.guiSizeScale(SKIP_BUTTONS_SPACE_V, guiScale);
|
||||
pnlShortCuts.setLayout(new FlowLayout(FlowLayout.RIGHT, hGap, vGap));
|
||||
if (vertical) {
|
||||
pnlShortCuts.setLayout(new FlowLayout(FlowLayout.CENTER, 1, vGap));
|
||||
} else {
|
||||
pnlShortCuts.setLayout(new FlowLayout(FlowLayout.RIGHT, hGap, vGap));
|
||||
}
|
||||
// skip buttons - sizes
|
||||
Dimension strictSize = new Dimension(2 * GUISizeHelper.gameCommandButtonHeight, GUISizeHelper.gameCommandButtonHeight);
|
||||
setSkipButtonSize(btnCancelSkip, guiScale, strictSize);
|
||||
|
|
@ -2274,7 +2290,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initComponents() {
|
||||
private boolean initComponents() {
|
||||
abilityPicker = new mage.client.components.ability.AbilityPicker(GUISizeHelper.dialogGuiScale);
|
||||
pnlHelperHandButtonsStackArea = new javax.swing.JPanel();
|
||||
pnlShortCuts = new javax.swing.JPanel();
|
||||
|
|
@ -2358,7 +2374,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
// split: chat <|> game logs
|
||||
splitChatAndLogs = new javax.swing.JSplitPane();
|
||||
splitChatAndLogs.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
if (vertical) {
|
||||
splitChatAndLogs.setOrientation(javax.swing.JSplitPane.HORIZONTAL_SPLIT);
|
||||
} else {
|
||||
splitChatAndLogs.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
}
|
||||
splitChatAndLogs.setResizeWeight(DIVIDER_KEEP_LEFT_COMPONENT);
|
||||
splitChatAndLogs.setTopComponent(userChatPanel);
|
||||
splitChatAndLogs.setBottomComponent(gameChatPanel);
|
||||
|
|
@ -2368,8 +2388,15 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
splitBattlefieldAndChats.setBorder(null);
|
||||
splitBattlefieldAndChats.setResizeWeight(DIVIDER_KEEP_RIGHT_COMPONENT);
|
||||
splitBattlefieldAndChats.setOneTouchExpandable(true);
|
||||
splitBattlefieldAndChats.setLeftComponent(pnlHelperHandButtonsStackArea);
|
||||
splitBattlefieldAndChats.setRightComponent(splitChatAndLogs);
|
||||
|
||||
if (vertical) {
|
||||
splitBattlefieldAndChats.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
splitBattlefieldAndChats.setBottomComponent(pnlHelperHandButtonsStackArea);
|
||||
splitBattlefieldAndChats.setTopComponent(splitChatAndLogs);
|
||||
} else {
|
||||
splitBattlefieldAndChats.setLeftComponent(pnlHelperHandButtonsStackArea);
|
||||
splitBattlefieldAndChats.setRightComponent(splitChatAndLogs);
|
||||
}
|
||||
|
||||
// warning, it's important to store/restore splitters in same order as real life GUI
|
||||
// from outer to inner (otherwise panels will be hidden or weird)
|
||||
|
|
@ -2752,7 +2779,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
// split: game <|> chat/log
|
||||
splitGameAndBigCard.setLeftComponent(splitBattlefieldAndChats);
|
||||
splitGameAndBigCard.setRightComponent(bigCardPanel);
|
||||
if (!vertical) {
|
||||
splitGameAndBigCard.setRightComponent(bigCardPanel);
|
||||
}
|
||||
return vertical;
|
||||
}
|
||||
|
||||
private void removeListener() {
|
||||
|
|
@ -2820,7 +2850,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.btnSkipForward.removeActionListener(al);
|
||||
}
|
||||
|
||||
final BasicSplitPaneUI myUi = (BasicSplitPaneUI) splitGameAndBigCard.getUI();
|
||||
final BasicSplitPaneUI myUi = vertical ? (BasicSplitPaneUI) splitBattlefieldAndChats.getUI() : (BasicSplitPaneUI) splitGameAndBigCard.getUI();
|
||||
final BasicSplitPaneDivider divider = myUi.getDivider();
|
||||
final JButton upArrowButton = (JButton) divider.getComponent(0);
|
||||
for (ActionListener al : upArrowButton.getActionListeners()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue