GUI, game: fixed wrong player panels size on reconnect

This commit is contained in:
Oleg Agafonov 2024-08-12 20:58:41 +04:00
parent 7811bcf4c1
commit 4d89fcd72d
4 changed files with 44 additions and 32 deletions

View file

@ -24,6 +24,16 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDebugTestCardRenderModesDialogActionPerformed"/>
</Events>
</MenuItem>
<Component class="javax.swing.JPopupMenu$Separator" name="menuDebugSeparator">
</Component>
<MenuItem class="javax.swing.JMenuItem" name="menuDebugTestCustomCode">
<Properties>
<Property name="text" type="java.lang.String" value="Run custom code"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDebugTestCustomCodeActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Container>
<Container class="javax.swing.JPopupMenu" name="popupDownload">

View file

@ -957,6 +957,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
popupDebug = new javax.swing.JPopupMenu();
menuDebugTestModalDialog = new javax.swing.JMenuItem();
menuDebugTestCardRenderModesDialog = new javax.swing.JMenuItem();
menuDebugSeparator = new javax.swing.JPopupMenu.Separator();
menuDebugTestCustomCode = new javax.swing.JMenuItem();
popupDownload = new javax.swing.JPopupMenu();
menuDownloadSymbols = new javax.swing.JMenuItem();
menuDownloadImages = new javax.swing.JMenuItem();
@ -995,6 +997,15 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
});
popupDebug.add(menuDebugTestCardRenderModesDialog);
popupDebug.add(menuDebugSeparator);
menuDebugTestCustomCode.setText("Run custom code");
menuDebugTestCustomCode.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuDebugTestCustomCodeActionPerformed(evt);
}
});
popupDebug.add(menuDebugTestCustomCode);
menuDownloadSymbols.setText("Download mana symbols");
menuDownloadSymbols.addActionListener(new java.awt.event.ActionListener() {
@ -1233,6 +1244,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
downloadImages();
}//GEN-LAST:event_menuDownloadImagesActionPerformed
private void menuDebugTestCustomCodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDebugTestCustomCodeActionPerformed
LOGGER.info("debug: insert custom code here or set breakpoint");
}//GEN-LAST:event_menuDebugTestCustomCodeActionPerformed
public void downloadImages() {
DownloadPicturesService.startDownload();
}
@ -1591,7 +1606,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private javax.swing.JToolBar.Separator jSeparator7;
private javax.swing.JToolBar.Separator jSeparatorSymbols;
private javax.swing.JToolBar mageToolbar;
private javax.swing.JPopupMenu.Separator menuDebugSeparator;
private javax.swing.JMenuItem menuDebugTestCardRenderModesDialog;
private javax.swing.JMenuItem menuDebugTestCustomCode;
private javax.swing.JMenuItem menuDebugTestModalDialog;
private javax.swing.JMenuItem menuDownloadImages;
private javax.swing.JMenuItem menuDownloadSymbols;
@ -1913,6 +1930,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
menuDownloadImages.setFont(font);
menuDebugTestModalDialog.setFont(font);
menuDebugTestCardRenderModesDialog.setFont(font);
menuDebugTestCustomCode.setFont(font);
mageToolbar.getParent().setBackground(PreferencesDialog.getCurrentTheme().getMageToolbar());

View file

@ -102,7 +102,6 @@ public final class GamePanel extends javax.swing.JPanel {
private final PickMultiNumberDialog pickMultiNumber;
private JLayeredPane jLayeredPane;
private String chosenHandKey = "You";
private boolean smallMode = false; // TODO: no needs in gui scale, delete it
private boolean initialized = false;
private final skipButtonsList skipButtons = new skipButtonsList();
@ -341,7 +340,6 @@ public final class GamePanel extends javax.swing.JPanel {
MageFrame.removeGame(gameId);
saveDividerLocations();
this.gameChatPanel.cleanUp();
;
this.userChatPanel.cleanUp();
this.removeListener();
@ -664,28 +662,13 @@ public final class GamePanel extends javax.swing.JPanel {
// on resize frame
Rectangle rect = this.getBounds();
if (rect.height < 770) {
if (!smallMode) {
smallMode = true;
Dimension bbDimension = new Dimension(128, 184);
bigCard.setMaximumSize(bbDimension);
bigCard.setMinimumSize(bbDimension);
bigCard.setPreferredSize(bbDimension);
pnlShortCuts.revalidate();
for (PlayAreaPanel p : players.values()) {
p.getPlayerPanel().sizePlayerPanel(smallMode);
}
}
} else if (smallMode) {
smallMode = false;
Dimension bbDimension = new Dimension(256, 367);
bigCard.setMaximumSize(bbDimension);
bigCard.setMinimumSize(bbDimension);
bigCard.setPreferredSize(bbDimension);
pnlShortCuts.revalidate();
for (PlayAreaPanel p : players.values()) {
p.getPlayerPanel().sizePlayerPanel(smallMode);
}
p.getPlayerPanel().sizePlayerPanel(false);
}
ArrowBuilder.getBuilder().setSize(rect.width, rect.height);

View file

@ -992,6 +992,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}// </editor-fold>//GEN-END:initComponents
public void sizePlayerPanel(boolean smallMode) {
// TODO: after few releases - delete small mode code, no needs anymore with gui scale, 2024-08-12
int extraForMe = this.isMe ? PANEL_HEIGHT_EXTRA_FOR_ME : 0;
if (smallMode) {
avatar.setVisible(false);