GUI: added GUI scale support for ability choice dialog (related to #12155, #969)

This commit is contained in:
Oleg Agafonov 2024-07-27 11:58:35 +04:00
parent 2bf6e3e3a2
commit 21ad11dbdc
6 changed files with 106 additions and 101 deletions

View file

@ -290,12 +290,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.players.clear();
this.playersWhoLeft.clear();
if (jLayeredPane != null) {
jLayeredPane.remove(abilityPicker);
jLayeredPane.remove(DialogManager.getManager(gameId));
}
this.abilityPicker.cleanUp();
DialogManager.removeGame(gameId);
uninstallComponents();
if (pickNumber != null) {
pickNumber.removeDialog();
@ -504,6 +499,12 @@ public final class GamePanel extends javax.swing.JPanel {
}
});
}
// as workaround: can change size for closed ability picker only
if (this.abilityPicker != null && !this.abilityPicker.isVisible()) {
this.abilityPicker.fullRefresh(GUISizeHelper.dialogsGuiScale);
this.abilityPicker.init(gameId, bigCard);
}
}
private void saveDividerLocations() {
@ -2904,11 +2905,31 @@ public final class GamePanel extends javax.swing.JPanel {
public void installComponents() {
jLayeredPane.setOpaque(false);
jLayeredPane.add(abilityPicker, JLayeredPane.MODAL_LAYER);
jLayeredPane.add(DialogManager.getManager(gameId), JLayeredPane.MODAL_LAYER, 0);
installAbilityPicker();
}
private void installAbilityPicker() {
jLayeredPane.add(abilityPicker, JLayeredPane.MODAL_LAYER);
abilityPicker.setVisible(false);
}
private void uninstallComponents() {
if (jLayeredPane != null) {
jLayeredPane.remove(DialogManager.getManager(gameId));
}
DialogManager.removeGame(gameId);
uninstallAbilityPicker();
}
private void uninstallAbilityPicker() {
abilityPicker.setVisible(false);
if (jLayeredPane != null) {
jLayeredPane.remove(abilityPicker);
}
this.abilityPicker.cleanUp();
}
private void createPhaseButton(String name, MouseAdapter mouseAdapter) {
Rectangle rect = new Rectangle(36, 36);
HoverButton button = new HoverButton("", ImageManagerImpl.instance.getPhaseImage(name), rect);