diff --git a/Mage.Client/src/main/java/mage/client/components/HoverButton.java b/Mage.Client/src/main/java/mage/client/components/HoverButton.java index d861d2042b1..99948445a72 100644 --- a/Mage.Client/src/main/java/mage/client/components/HoverButton.java +++ b/Mage.Client/src/main/java/mage/client/components/HoverButton.java @@ -1,14 +1,10 @@ package mage.client.components; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Rectangle; -import java.awt.RenderingHints; +import mage.client.util.Command; +import mage.client.util.GUISizeHelper; + +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -18,18 +14,14 @@ import java.awt.font.GlyphVector; import java.util.ArrayList; import java.util.List; -import javax.swing.*; - -import mage.client.util.Command; - /** - * Image button with hover. + * GUI component. Image button with hover support and GUI scale support * - * @author nantuko + * @author nantuko, JayDi85 */ public class HoverButton extends JPanel implements MouseListener { - static final int TOP_TEXT_IMAGE_GAP = 3; + float guiScaleMod = 1.0f; private Image image; private Image hoverImage; @@ -40,10 +32,13 @@ public class HoverButton extends JPanel implements MouseListener { private Rectangle buttonSize; private String text; private boolean textAlwaysVisible = false; + + // real offset setup in constructor due gui scale private int textOffsetY = 0; private int textOffsetButtonY = 2; private int textOffsetX = -1; private int topTextOffsetX = -1; + private Dimension overlayImageSize; private String topText; @@ -61,15 +56,15 @@ public class HoverButton extends JPanel implements MouseListener { private Command onHover = null; private Color textColor = Color.white; private Color topTextColor = null; - private final Rectangle centerTextArea = new Rectangle(5, 18, 75, 40); + private final Rectangle centerTextArea; private Color centerTextColor = new Color(200, 210, 0, 200); private Color origCenterTextColor = new Color(200, 210, 0, 200); private final Color textBGColor = Color.black; - static final Font textFont = new Font("Arial", Font.PLAIN, 12); - static final Font textFontMini = new Font("Arial", Font.PLAIN, 11); - static final Font textSetFontBoldMini = new Font("Arial", Font.BOLD, 12); - static final Font textSetFontBold = new Font("Arial", Font.BOLD, 14); + final Font textFont; + final Font textFontMini; + final Font textSetFontBoldMini; + final Font textSetFontBold; private boolean useMiniFont = false; @@ -90,22 +85,48 @@ public class HoverButton extends JPanel implements MouseListener { } public HoverButton(String text, Image image, Image hover, Image disabled, Rectangle size) { - this(text, image, hover, null, disabled, size); + this(text, image, hover, null, disabled, size, 1.0f); + } + + public HoverButton(String text, Image image, Image hover, Image disabled, Rectangle size, float guiScaleMod) { + this(text, image, hover, null, disabled, size, guiScaleMod); } public HoverButton(String text, Image image, Image hover, Image selected, Image disabled, Rectangle size) { + this(text, image, hover, selected, disabled, size, 1.0f); + } + + public HoverButton(String text, Image image, Image hover, Image selected, Image disabled, Rectangle size, float guiScaleMod) { this.image = image; this.hoverImage = hover; this.selectedImage = selected; this.disabledImage = disabled; - this.imageSize = size; + this.imageSize = size; // already scaled this.text = text; + this.guiScaleMod = guiScaleMod; setOpaque(false); addMouseListener(this); + + // late init due gui scale settings + this.setFont(this.getFont().deriveFont(sizeMod(this.getFont().getSize2D()))); + this.centerTextArea = new Rectangle(sizeMod(5), sizeMod(18), sizeMod(75), sizeMod(40)); + textFont = new Font("Arial", Font.PLAIN, sizeMod(12)); + textFontMini = new Font("Arial", Font.PLAIN, sizeMod(11)); + textSetFontBoldMini = new Font("Arial", Font.BOLD, sizeMod(12)); + textSetFontBold = new Font("Arial", Font.BOLD, sizeMod(14)); + + textOffsetY = 0; + textOffsetButtonY = sizeMod(2); + textOffsetX = -1; // no scale, it's calc on first usage + topTextOffsetX = -1; // no scale, it's calc on first usage } - public HoverButton(HoverButton button) { - this(button.text, button.image, button.hoverImage, button.selectedImage, button.disabledImage, button.imageSize); + private int sizeMod(int value) { + return GUISizeHelper.guiSizeScale(value, this.guiScaleMod); + } + + private float sizeMod(float value) { + return GUISizeHelper.guiSizeScale(value, this.guiScaleMod); } @Override @@ -155,18 +176,18 @@ public class HoverButton extends JPanel implements MouseListener { } topTextOffsetX = calculateOffsetForTop(g2d, topText); g2d.setColor(textBGColor); - g2d.drawString(topText, topTextOffsetX + 1, 14); + g2d.drawString(topText, topTextOffsetX + sizeMod(1), sizeMod(14)); g2d.setColor(topTextColor != null ? topTextColor : textColor); - g2d.drawString(topText, topTextOffsetX, 13); + g2d.drawString(topText, topTextOffsetX, sizeMod(13)); } if (topTextImage != null) { - g.drawImage(topTextImage, 4, 3, this); + g.drawImage(topTextImage, sizeMod(4), sizeMod(3), this); } int offset = 0; for (Image img : topTextImagesRight) { - g.drawImage(img, this.getWidth() - 20, 3 + offset, this); - offset += 20; + g.drawImage(img, this.getWidth() - sizeMod(20), sizeMod(3) + offset, this); + offset += sizeMod(20); } if (centerText != null) { @@ -180,16 +201,16 @@ public class HoverButton extends JPanel implements MouseListener { } else if (val > 99) { fontSize = 34; } - drawCenteredStringWOutline(g2d, centerText, centerTextArea, new Font("Arial", Font.BOLD, fontSize)); + drawCenteredStringWOutline(g2d, centerText, centerTextArea, new Font("Arial", Font.BOLD, sizeMod(fontSize))); } g2d.setColor(textColor); if (overlayImage != null) { - g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, 10, this); + g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, sizeMod(10), this); } else if (set != null) { // draw only if it is not current tab if (!drawSet) { g2d.setFont(textSetFontBoldMini); - g2d.drawString(set, 5, 25); + g2d.drawString(set, sizeMod(5), sizeMod(25)); } } @@ -197,8 +218,8 @@ public class HoverButton extends JPanel implements MouseListener { g2d.setFont(textSetFontBold); int w = (int) (getWidth() / 2.0); int h = (int) (getHeight() / 2.0); - int dy = overlayImage == null ? 15 : 25; - g2d.translate(w + 5, h + dy); + int dy = overlayImage == null ? sizeMod(15) : sizeMod(25); + g2d.translate(w + sizeMod(5), h + dy); g2d.rotate(-Math.PI / 2.0); g2d.drawString(set, 0, 0); } @@ -209,6 +230,7 @@ public class HoverButton extends JPanel implements MouseListener { } private int calculateOffset(Graphics2D g2d) { + // already gui scaled here if (textOffsetX == -1) { // calculate once FontRenderContext frc = g2d.getFontRenderContext(); int textWidth = (int) textFont.getStringBounds(text, frc).getWidth(); @@ -228,6 +250,7 @@ public class HoverButton extends JPanel implements MouseListener { } private int calculateOffsetForTop(Graphics2D g2d, String text) { + // already scaled calc if (topTextOffsetX == -1) { // calculate once FontRenderContext frc = g2d.getFontRenderContext(); int textWidth = (int) textFont.getStringBounds(text, frc).getWidth(); @@ -238,13 +261,10 @@ public class HoverButton extends JPanel implements MouseListener { return topTextOffsetX; } - public void setTextColor(Color textColor) { - this.textColor = textColor; - } - /** * Overrides textColor for the upper text if non-null. * If null, return back to textColor. + * * @param textColor */ public void setTopTextColor(Color textColor) { @@ -253,7 +273,7 @@ public class HoverButton extends JPanel implements MouseListener { public void setOverlayImage(Image image) { this.overlayImage = image; - this.overlayImageSize = new Dimension(image.getWidth(null), image.getHeight(null)); + this.overlayImageSize = new Dimension(image.getWidth(null), image.getHeight(null)); // TODO: need sizeMod? } @Override @@ -387,7 +407,7 @@ public class HoverButton extends JPanel implements MouseListener { /** * Draw a String centered in the middle of a Rectangle. * - * @param g The Graphics instance. + * @param g The Graphics instance. * @param text The String to draw. * @param rect The Rectangle to center the text in. * @param font diff --git a/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java b/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java index 0953c2518e2..07f52f54caa 100644 --- a/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java +++ b/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java @@ -14,7 +14,7 @@ import mage.client.util.ImageCaches; import mage.client.util.SoftValuesLoadingCache; /** - * Mage round pane with transparency. Used for tooltips. + * GUI component. Mage round pane with transparency. Used for tooltips and player panels. * * @author nantuko */ diff --git a/Mage.Client/src/main/java/mage/client/dialog/TestCardRenderDialog.java b/Mage.Client/src/main/java/mage/client/dialog/TestCardRenderDialog.java index 0af62a61e41..92bf460f436 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/TestCardRenderDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/TestCardRenderDialog.java @@ -23,6 +23,10 @@ import mage.client.util.Listener; import mage.constants.MultiplayerAttackOption; import mage.constants.RangeOfInfluence; import mage.constants.Zone; +import mage.counters.Counter; +import mage.counters.CounterType; +import mage.designations.CitysBlessing; +import mage.designations.Monarch; import mage.game.Game; import mage.game.GameException; import mage.game.GameImpl; @@ -62,6 +66,7 @@ public class TestCardRenderDialog extends MageDialog { private static final Logger logger = Logger.getLogger(TestCardRenderDialog.class); float cardSizeMod = 1.0f; + float playerSizeMod = 1.0f; private Match match = null; private Game game = null; private BigCard bigCard = null; @@ -100,7 +105,7 @@ public class TestCardRenderDialog extends MageDialog { // init player panel player = new PlayerPanelExt(); this.playerPanel.setLayout(new BorderLayout(5, 5)); - this.playerPanel.add(player, BorderLayout.NORTH); + this.playerPanel.add(player, BorderLayout.CENTER); // render cards reloadCardsAndPlayer(); @@ -265,6 +270,9 @@ public class TestCardRenderDialog extends MageDialog { this.game = new TestGame(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 20, 7); Deck deck = new Deck(); Player playerYou = new StubPlayer("player1", RangeOfInfluence.ALL); + playerYou.addDesignation(new CitysBlessing()); + game.getState().setMonarchId(playerYou.getId()); + playerYou.addCounters(new Counter(CounterType.POISON.toString(), 10), playerYou.getId(), null, game); this.match.addPlayer(playerYou, deck); this.game.addPlayer(playerYou, deck); Player playerOpponent = new StubPlayer("player2", RangeOfInfluence.ALL); @@ -316,8 +324,14 @@ public class TestCardRenderDialog extends MageDialog { possibleTargets.add(playerYou.getId()); } - this.player.cleanUp(); - this.player.changeGUISize(); + // need re-create panel, because it can't change size in real time + this.playerPanel.removeAll(); + this.playerPanel.setPreferredSize(new java.awt.Dimension(Math.round(100 * this.playerSizeMod), 10)); + this.playerPanel.setLayout(new BorderLayout(5, 5)); + this.player = new PlayerPanelExt(this.playerSizeMod); + this.playerPanel.add(player, BorderLayout.CENTER); + //this.player.cleanUp(); + //this.player.changeGUISize(); GameView gameView = new GameView(this.game.getState(), this.game, controlledId, null); PlayerView currentPlayerView = gameView.getPlayers() .stream() @@ -870,6 +884,7 @@ public class TestCardRenderDialog extends MageDialog { float sliderFrac = ((float) (sliderSize.getValue() - 50)) / 50; // Convert to frac in [0.5, 2.0] exponentially cardSizeMod = (float) Math.pow(2, sliderFrac); + playerSizeMod = (float) Math.pow(2, sliderFrac); reloadCardsAndPlayer(); }//GEN-LAST:event_sliderSizeStateChanged diff --git a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java index 582b847f610..ba349cf4537 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java @@ -45,8 +45,8 @@ public class PlayAreaPanel extends javax.swing.JPanel { private JCheckBoxMenuItem allowViewHandCardsMenuItem; private JCheckBoxMenuItem holdPriorityMenuItem; - public static final int PANEL_HEIGHT = 263; - public static final int PANEL_HEIGHT_SMALL = 210; + public static final int PANEL_HEIGHT = 273; + public static final int PANEL_HEIGHT_SMALL = 220; private static final int PANEL_HEIGHT_EXTRA_FOR_ME = 25; /** diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index 178a8fa09a6..a0d98943e29 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -8,15 +8,16 @@ import mage.client.components.MageRoundPane; import mage.client.components.ext.dlg.DialogManager; import mage.client.dialog.PreferencesDialog; import mage.client.util.CardsViewUtil; +import mage.client.util.GUISizeHelper; import mage.client.util.ImageHelper; import mage.client.util.gui.BufferedImageBuilder; import mage.client.util.gui.countryBox.CountryUtil; import mage.components.ImagePanel; import mage.components.ImagePanelStyle; import mage.constants.CardType; -import static mage.constants.Constants.*; import mage.constants.ManaType; import mage.designations.DesignationType; +import mage.util.DebugUtil; import mage.utils.timer.PriorityTimer; import mage.view.*; import org.mage.card.arcane.ManaSymbols; @@ -30,14 +31,25 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.util.*; +import static mage.constants.Constants.*; + /** * Game GUI: player panel with avatar and icons + *

+ * Lifecycle: + * - create and put to parent panel + * - init by static data like player info + * - update by dynamic data like timer and game view data + *

+ * Warning, it un-support GUI or fonts settings in real time, so must re-create it * * @author nantuko, JayDi85, Susucr */ public class PlayerPanelExt extends javax.swing.JPanel { - // TODO: *.form file was lost, panel must be reworks in designer + // TODO: *.form file was lost, panel must be reworks in designer: + // - new form file useless cause player panel must support gui scale (see sizeMod) - it can be done by dynamic components creating only + // - so it must migrate to new flow/box layout and runtime creating (current code uses "magic" GroupLayout from NetBeans GUI designer) private UUID playerId; private UUID gameId; private PlayerView player; @@ -48,19 +60,20 @@ public class PlayerPanelExt extends javax.swing.JPanel { private static final String DEFAULT_AVATAR_PATH = "/avatars/" + DEFAULT_AVATAR_ID + ".jpg"; private static final int PANEL_WIDTH = 94; - private static final int PANEL_HEIGHT = 290; - private static final int PANEL_HEIGHT_SMALL = 238; - private static final int PANEL_HEIGHT_EXTRA_FOR_ME = 25; - private static final int MANA_LABEL_SIZE_HORIZONTAL = 20; + private static final int PANEL_HEIGHT = 270; // full mode (with avatar image) + private static final int PANEL_HEIGHT_SMALL = 238; // small mode (with avatar button) // TODO: no need in small mode after GUI scale added + private static final int PANEL_HEIGHT_EXTRA_FOR_ME = 25; // hints button - private static final Border GREEN_BORDER = new LineBorder(Color.green, 3); - private static final Border RED_BORDER = new LineBorder(Color.red, 2); - private static final Border YELLOW_BORDER = new LineBorder(Color.yellow, 3); - private static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0); + private final Border GREEN_BORDER; + private final Border RED_BORDER; + private final Border YELLOW_BORDER; + private final Border EMPTY_BORDER; + + float guiScaleMod = 1.0f; private final Color activeValueColor = new Color(244, 9, 47); - private final Font fontValuesZero = this.getFont().deriveFont(Font.PLAIN); - private final Font fontValuesNonZero = this.getFont().deriveFont(Font.BOLD); + private final Font fontValuesZero; + private final Font fontValuesNonZero; private int avatarId = -1; private String flagName; @@ -73,11 +86,33 @@ public class PlayerPanelExt extends javax.swing.JPanel { * Creates new form PlayerPanel */ public PlayerPanelExt() { - setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT)); + this(1.0f); + } + + public PlayerPanelExt(float guiScaleMod) { + // gui scale + this.guiScaleMod = guiScaleMod; + this.setFont(this.getFont().deriveFont(sizeMod(this.getFont().getSize2D()))); + this.fontValuesZero = this.getFont().deriveFont(Font.PLAIN); + this.fontValuesNonZero = this.getFont().deriveFont(Font.BOLD); + this.GREEN_BORDER = new LineBorder(Color.green, sizeMod(3)); + this.RED_BORDER = new LineBorder(Color.red, sizeMod(2)); + this.YELLOW_BORDER = new LineBorder(Color.yellow, sizeMod(3)); + this.EMPTY_BORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0); + + setPreferredSize(new Dimension(sizeMod(PANEL_WIDTH), sizeMod(PANEL_HEIGHT))); initComponents(); setGUISize(); } + private int sizeMod(int value) { + return GUISizeHelper.guiSizeScale(value, this.guiScaleMod); + } + + private float sizeMod(float value) { + return GUISizeHelper.guiSizeScale(value, this.guiScaleMod); + } + public void init(UUID gameId, UUID playerId, boolean controlled, BigCard bigCard, int priorityTime) { this.gameId = gameId; this.playerId = playerId; @@ -226,12 +261,12 @@ public class PlayerPanelExt extends javax.swing.JPanel { if (playerLife > 99) { Font font = lifeLabel.getFont(); - font = font.deriveFont(9f); + font = font.deriveFont(sizeMod(9f)); lifeLabel.setFont(font); changedFontLife = true; } else if (changedFontLife) { Font font = lifeLabel.getFont(); - font = font.deriveFont(12f); + font = font.deriveFont(sizeMod(12f)); lifeLabel.setFont(font); changedFontLife = false; } @@ -244,12 +279,12 @@ public class PlayerPanelExt extends javax.swing.JPanel { int libraryCards = player.getLibraryCount(); if (libraryCards > 99) { Font font = libraryLabel.getFont(); - font = font.deriveFont(9f); + font = font.deriveFont(sizeMod(9f)); libraryLabel.setFont(font); changedFontLibrary = true; } else if (changedFontLibrary) { Font font = libraryLabel.getFont(); - font = font.deriveFont(12f); + font = font.deriveFont(sizeMod(12f)); libraryLabel.setFont(font); changedFontLibrary = false; } @@ -259,13 +294,13 @@ public class PlayerPanelExt extends javax.swing.JPanel { if (graveCards > 99) { if (!changedFontGrave) { Font font = graveLabel.getFont(); - font = font.deriveFont(9f); + font = font.deriveFont(sizeMod(9f)); graveLabel.setFont(font); changedFontGrave = true; } } else if (changedFontGrave) { Font font = lifeLabel.getFont(); - font = font.deriveFont(12f); + font = font.deriveFont(sizeMod(12f)); graveLabel.setFont(font); changedFontGrave = false; } @@ -292,13 +327,13 @@ public class PlayerPanelExt extends javax.swing.JPanel { if (exileCards > 99) { if (!changedFontExile) { Font font = exileLabel.getFont(); - font = font.deriveFont(9f); + font = font.deriveFont(sizeMod(9f)); exileLabel.setFont(font); changedFontExile = true; } } else if (changedFontExile) { Font font = lifeLabel.getFont(); - font = font.deriveFont(12f); + font = font.deriveFont(sizeMod(12f)); exileLabel.setFont(font); changedFontExile = false; } @@ -319,7 +354,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { path = "/avatars/special/" + avatarId + ".gif"; } Image image = ImageHelper.getImageFromResources(path); - Rectangle r = new Rectangle(80, 80); + Rectangle r = new Rectangle(sizeMod(80), sizeMod(80)); BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); this.avatar.update(this.player.getName(), resized, resized, resized, resized, r); } @@ -398,7 +433,8 @@ public class PlayerPanelExt extends javax.swing.JPanel { if (flagName == null) { // do only once avatar.setText(this.player.getName()); flagName = player.getUserData().getFlagName(); - this.avatar.setTopTextImage(CountryUtil.getCountryFlagIconSize(flagName, 11).getImage()); + String flagPath = "/flags/" + flagName + (flagName.endsWith(".png") ? "" : ".png"); + this.avatar.setTopTextImage(ImageHelper.getImageFromResourcesScaledToHeight(flagPath, sizeMod(11))); String countryName = CountryUtil.getCountryName(flagName); basicTooltipText = "Name: " + player.getName() + "
Flag: " + (countryName == null ? "Unknown" : countryName) @@ -414,16 +450,16 @@ public class PlayerPanelExt extends javax.swing.JPanel { for (String name : player.getDesignationNames()) { tooltipText.append("
").append(name); if (DesignationType.CITYS_BLESSING.toString().equals(name)) { - this.avatar.addTopTextImageRight(ImageHelper.getImageFromResources("/info/city_blessing.png")); + this.avatar.addTopTextImageRight(ImageHelper.getImageFromResourcesScaledToHeight("/info/city_blessing.png", sizeMod(11))); } } if (player.isMonarch()) { tooltipText.append("
").append("The Monarch"); - this.avatar.addTopTextImageRight(ImageHelper.getImageFromResources("/info/crown.png")); + this.avatar.addTopTextImageRight(ImageHelper.getImageFromResourcesScaledToHeight("/info/crown.png", sizeMod(11))); } if (player.isInitiative()) { tooltipText.append("
").append("Have the Initiative"); - this.avatar.addTopTextImageRight(ImageHelper.getImageFromResources("/info/initiative.png")); + this.avatar.addTopTextImageRight(ImageHelper.getImageFromResourcesScaledToHeight("/info/initiative.png", sizeMod(11))); } // counters @@ -491,8 +527,8 @@ public class PlayerPanelExt extends javax.swing.JPanel { private void initComponents() { panelBackground = new MageRoundPane(); - panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT)); - Rectangle r = new Rectangle(80, 80); + panelBackground.setPreferredSize(new Dimension(sizeMod(PANEL_WIDTH - 2), sizeMod(PANEL_HEIGHT))); + Rectangle r = new Rectangle(sizeMod(80), sizeMod(80)); // avatarFlag = new JLabel(); // monarchIcon = new JLabel(); timerLabel = new JLabel(); @@ -507,30 +543,35 @@ public class PlayerPanelExt extends javax.swing.JPanel { libraryLabel = new JLabel(); setOpaque(false); - panelBackground.setXOffset(3); - panelBackground.setYOffset(3); + panelBackground.setXOffset(sizeMod(3)); + panelBackground.setYOffset(sizeMod(3)); panelBackground.setVisible(true); + if (DebugUtil.GUI_GAME_DRAW_PLAYER_PANEL_BORDER) { + setBorder(BorderFactory.createLineBorder(Color.green)); + panelBackground.setBorder(BorderFactory.createLineBorder(Color.yellow)); + } + // Avatar Image image = ImageHelper.getImageFromResources(DEFAULT_AVATAR_PATH); BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); - avatar = new HoverButton("", resized, resized, resized, r); + avatar = new HoverButton("", resized, resized, resized, r, this.guiScaleMod); String showPlayerNamePermanently = MageFrame.getPreferences().get(PreferencesDialog.KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true"); if (showPlayerNamePermanently.equals("true")) { avatar.setTextAlwaysVisible(true); } - avatar.setTextOffsetButtonY(10); + avatar.setTextOffsetButtonY(sizeMod(10)); avatar.setObserver(() -> SessionHandler.sendPlayerUUID(gameId, playerId)); // timer area /small layout) timerLabel.setToolTipText("Time left"); - timerLabel.setSize(80, 12); + timerLabel.setSize(sizeMod(80), sizeMod(12)); timerLabel.setHorizontalAlignment(SwingConstants.CENTER); // life area - r = new Rectangle(18, 18); + r = new Rectangle(sizeMod(18), sizeMod(18)); lifeLabel.setToolTipText("Life"); lifeLabel.setHorizontalAlignment(SwingConstants.CENTER); Image imageLife = ImageHelper.getImageFromResources("/info/life.png"); @@ -540,7 +581,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { life.setOpaque(false); // hand area - r = new Rectangle(18, 18); + r = new Rectangle(sizeMod(18), sizeMod(18)); handLabel.setToolTipText("Hand"); handLabel.setHorizontalAlignment(SwingConstants.CENTER); Image imageHand = ImageHelper.getImageFromResources("/info/hand.png"); @@ -550,7 +591,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { hand.setOpaque(false); // Poison count - r = new Rectangle(18, 18); + r = new Rectangle(sizeMod(18), sizeMod(18)); Image imagePoison = ImageHelper.getImageFromResources("/info/poison.png"); BufferedImage resizedPoison = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imagePoison, BufferedImage.TYPE_INT_ARGB), r); poison = new ImagePanel(resizedPoison, ImagePanelStyle.ACTUAL); @@ -559,25 +600,25 @@ public class PlayerPanelExt extends javax.swing.JPanel { poisonLabel.setHorizontalAlignment(SwingConstants.CENTER); // Library - r = new Rectangle(19, 19); + r = new Rectangle(sizeMod(19), sizeMod(19)); libraryLabel.setToolTipText("Library"); libraryLabel.setHorizontalAlignment(SwingConstants.CENTER); Image imageLibrary = ImageHelper.getImageFromResources("/info/library.png"); BufferedImage resizedLibrary = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLibrary, BufferedImage.TYPE_INT_ARGB), r); - library = new HoverButton(null, resizedLibrary, resizedLibrary, resizedLibrary, r); + library = new HoverButton(null, resizedLibrary, resizedLibrary, resizedLibrary, r, this.guiScaleMod); library.setToolTipText("Library"); library.setOpaque(false); library.setObserver(() -> btnLibraryActionPerformed(null)); // Grave count and open graveyard button - r = new Rectangle(21, 21); + r = new Rectangle(sizeMod(21), sizeMod(21)); graveLabel.setToolTipText("Card Types: 0"); graveLabel.setHorizontalAlignment(SwingConstants.CENTER); Image imageGrave = ImageHelper.getImageFromResources("/info/grave.png"); BufferedImage resizedGrave = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageGrave, BufferedImage.TYPE_INT_ARGB), r); - grave = new HoverButton(null, resizedGrave, resizedGrave, resizedGrave, r); + grave = new HoverButton(null, resizedGrave, resizedGrave, resizedGrave, r, this.guiScaleMod); grave.setToolTipText("Graveyard"); grave.setOpaque(false); grave.setObserver(() -> btnGraveActionPerformed(null)); @@ -586,16 +627,16 @@ public class PlayerPanelExt extends javax.swing.JPanel { exileLabel.setToolTipText("Exile"); exileLabel.setHorizontalAlignment(SwingConstants.CENTER); image = ImageHelper.getImageFromResources("/info/exile.png"); - r = new Rectangle(21, 21); + r = new Rectangle(sizeMod(21), sizeMod(21)); resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); - exileZone = new HoverButton(null, resized, resized, resized, r); + exileZone = new HoverButton(null, resized, resized, resized, r, this.guiScaleMod); exileZone.setToolTipText("Exile"); exileZone.setOpaque(false); exileZone.setObserver(() -> btnExileZoneActionPerformed(null)); - exileZone.setBounds(25, 0, 21, 21); + exileZone.setBounds(sizeMod(25), 0, sizeMod(21), sizeMod(21)); // Cheat button - r = new Rectangle(25, 21); + r = new Rectangle(sizeMod(25), sizeMod(21)); image = ImageHelper.getImageFromResources("/info/cheat.png"); resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); cheat = new JButton(); @@ -605,38 +646,39 @@ public class PlayerPanelExt extends javax.swing.JPanel { // tools button like hints toolHintsHelper = new JButton(); + toolHintsHelper.setFont(this.getFont()); toolHintsHelper.setText("hints"); toolHintsHelper.setToolTipText("Open new card hints helper window"); toolHintsHelper.addActionListener(e -> btnToolHintsHelperActionPerformed(e)); zonesPanel = new JPanel(); - zonesPanel.setPreferredSize(new Dimension(100, 60)); - zonesPanel.setSize(100, 60); + zonesPanel.setPreferredSize(new Dimension(sizeMod(100), sizeMod(60))); + zonesPanel.setSize(sizeMod(100), sizeMod(60)); zonesPanel.setLayout(null); zonesPanel.setOpaque(false); image = ImageHelper.getImageFromResources("/info/command_zone.png"); - r = new Rectangle(21, 21); + r = new Rectangle(sizeMod(21), sizeMod(21)); resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); - commandZone = new HoverButton(null, resized, resized, resized, r); + commandZone = new HoverButton(null, resized, resized, resized, r, this.guiScaleMod); commandZone.setToolTipText("Command Zone (Commanders, Emblems and Planes)"); commandZone.setOpaque(false); commandZone.setObserver(() -> btnCommandZoneActionPerformed(null)); - commandZone.setBounds(3, 0, 21, 21); + commandZone.setBounds(sizeMod(3), 0, sizeMod(21), sizeMod(21)); zonesPanel.add(commandZone); commandLabel.setToolTipText("Command zone"); - commandLabel.setBounds(25, 0, 21, 21); + commandLabel.setBounds(sizeMod(25), 0, sizeMod(21), sizeMod(21)); zonesPanel.add(commandLabel); - cheat.setBounds(40, 2, 25, 21); + cheat.setBounds(sizeMod(40), sizeMod(2), sizeMod(25), sizeMod(21)); zonesPanel.add(cheat); - toolHintsHelper.setBounds(3, 2 + 21 + 2, 73, 21); + toolHintsHelper.setBounds(sizeMod(3), sizeMod(2 + 21 + 2), sizeMod(73), sizeMod(21)); zonesPanel.add(toolHintsHelper); // Energy count - r = new Rectangle(18, 18); + r = new Rectangle(sizeMod(18), sizeMod(18)); Image imageEnergy = ImageHelper.getImageFromResources("/info/energy.png"); BufferedImage resizedEnergy = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageEnergy, BufferedImage.TYPE_INT_ARGB), r); energy = new ImagePanel(resizedEnergy, ImagePanelStyle.ACTUAL); @@ -646,7 +688,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { energyLabel.setHorizontalAlignment(SwingConstants.CENTER); // Experience count - r = new Rectangle(18, 18); + r = new Rectangle(sizeMod(18), sizeMod(18)); Image imageExperience = ImageHelper.getImageFromResources("/info/experience.png"); BufferedImage resizedExperience = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageExperience, BufferedImage.TYPE_INT_ARGB), r); experience = new ImagePanel(resizedExperience, ImagePanelStyle.ACTUAL); @@ -656,7 +698,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { experienceLabel.setHorizontalAlignment(SwingConstants.CENTER); // Rad count - r = new Rectangle(16, 16); + r = new Rectangle(sizeMod(16), sizeMod(16)); Image imageRad = ImageHelper.getImageFromResources("/info/rad.png"); BufferedImage resizedRad = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageRad, BufferedImage.TYPE_INT_ARGB), r); rad = new ImagePanel(resizedRad, ImagePanelStyle.ACTUAL); @@ -666,10 +708,11 @@ public class PlayerPanelExt extends javax.swing.JPanel { radLabel.setHorizontalAlignment(SwingConstants.CENTER); btnPlayer = new JButton(); + btnPlayer.setFont(this.getFont()); btnPlayer.setText("Player"); btnPlayer.setVisible(false); btnPlayer.setToolTipText("Player"); - btnPlayer.setPreferredSize(new Dimension(20, 40)); + btnPlayer.setPreferredSize(new Dimension(sizeMod(20), sizeMod(40))); btnPlayer.addActionListener(e -> SessionHandler.sendPlayerUUID(gameId, playerId)); // Add mana symbols @@ -688,7 +731,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { JLabel manaCountLabelW = new JLabel(); manaCountLabelW.setToolTipText("White mana"); setTextForLabel(manaCountLabelW, 0, false); - manaCountLabelW.setIcon(new ImageIcon(ManaSymbols.getSizedManaSymbol("W", 15))); + manaCountLabelW.setIcon(new ImageIcon(ManaSymbols.getSizedManaSymbol("W", sizeMod(15)))); manaCountLabelW.addMouseListener(manaMouseAdapter); manaLabels.put(manaCountLabelW, ManaType.WHITE);l //*/ @@ -696,9 +739,9 @@ public class PlayerPanelExt extends javax.swing.JPanel { JLabel manaCountLabelW = new JLabel(); manaCountLabelW.setHorizontalAlignment(SwingConstants.CENTER); manaLabels.put(manaCountLabelW, ManaType.WHITE); - r = new Rectangle(15, 15); - BufferedImage imageManaW = ManaSymbols.getSizedManaSymbol("W", 15); - HoverButton btnWhiteMana = new HoverButton(null, imageManaW, imageManaW, imageManaW, r); + r = new Rectangle(sizeMod(15), sizeMod(15)); + BufferedImage imageManaW = ManaSymbols.getSizedManaSymbol("W", sizeMod(15)); + HoverButton btnWhiteMana = new HoverButton(null, imageManaW, imageManaW, imageManaW, r, this.guiScaleMod); btnWhiteMana.setOpaque(false); btnWhiteMana.setObserver(() -> btnManaActionPerformed(ManaType.WHITE)); manaButtons.put(manaCountLabelW, btnWhiteMana); @@ -708,9 +751,9 @@ public class PlayerPanelExt extends javax.swing.JPanel { JLabel manaCountLabelU = new JLabel(); manaLabels.put(manaCountLabelU, ManaType.BLUE); manaCountLabelU.setHorizontalAlignment(SwingConstants.CENTER); - r = new Rectangle(15, 15); - BufferedImage imageManaU = ManaSymbols.getSizedManaSymbol("U", 15); - HoverButton btnBlueMana = new HoverButton(null, imageManaU, imageManaU, imageManaU, r); + r = new Rectangle(sizeMod(15), sizeMod(15)); + BufferedImage imageManaU = ManaSymbols.getSizedManaSymbol("U", sizeMod(15)); + HoverButton btnBlueMana = new HoverButton(null, imageManaU, imageManaU, imageManaU, r, this.guiScaleMod); btnBlueMana.setOpaque(false); btnBlueMana.setObserver(() -> btnManaActionPerformed(ManaType.BLUE)); manaButtons.put(manaCountLabelU, btnBlueMana); @@ -719,9 +762,9 @@ public class PlayerPanelExt extends javax.swing.JPanel { JLabel manaCountLabelB = new JLabel(); manaLabels.put(manaCountLabelB, ManaType.BLACK); manaCountLabelB.setHorizontalAlignment(SwingConstants.CENTER); - r = new Rectangle(15, 15); - BufferedImage imageManaB = ManaSymbols.getSizedManaSymbol("B", 15); - HoverButton btnBlackMana = new HoverButton(null, imageManaB, imageManaB, imageManaB, r); + r = new Rectangle(sizeMod(15), sizeMod(15)); + BufferedImage imageManaB = ManaSymbols.getSizedManaSymbol("B", sizeMod(15)); + HoverButton btnBlackMana = new HoverButton(null, imageManaB, imageManaB, imageManaB, r, this.guiScaleMod); btnBlackMana.setOpaque(false); btnBlackMana.setObserver(() -> btnManaActionPerformed(ManaType.BLACK)); manaButtons.put(manaCountLabelB, btnBlackMana); @@ -730,9 +773,9 @@ public class PlayerPanelExt extends javax.swing.JPanel { JLabel manaCountLabelR = new JLabel(); manaLabels.put(manaCountLabelR, ManaType.RED); manaCountLabelR.setHorizontalAlignment(SwingConstants.CENTER); - r = new Rectangle(15, 15); - BufferedImage imageManaR = ManaSymbols.getSizedManaSymbol("R", 15); - HoverButton btnRedMana = new HoverButton(null, imageManaR, imageManaR, imageManaR, r); + r = new Rectangle(sizeMod(15), sizeMod(15)); + BufferedImage imageManaR = ManaSymbols.getSizedManaSymbol("R", sizeMod(15)); + HoverButton btnRedMana = new HoverButton(null, imageManaR, imageManaR, imageManaR, r, this.guiScaleMod); btnRedMana.setOpaque(false); btnRedMana.setObserver(() -> btnManaActionPerformed(ManaType.RED)); manaButtons.put(manaCountLabelR, btnRedMana); @@ -741,9 +784,9 @@ public class PlayerPanelExt extends javax.swing.JPanel { JLabel manaCountLabelG = new JLabel(); manaLabels.put(manaCountLabelG, ManaType.GREEN); manaCountLabelG.setHorizontalAlignment(SwingConstants.CENTER); - r = new Rectangle(15, 15); - BufferedImage imageManaG = ManaSymbols.getSizedManaSymbol("G", 15); - HoverButton btnGreenMana = new HoverButton(null, imageManaG, imageManaG, imageManaG, r); + r = new Rectangle(sizeMod(15), sizeMod(15)); + BufferedImage imageManaG = ManaSymbols.getSizedManaSymbol("G", sizeMod(15)); + HoverButton btnGreenMana = new HoverButton(null, imageManaG, imageManaG, imageManaG, r, this.guiScaleMod); btnGreenMana.setOpaque(false); btnGreenMana.setObserver(() -> btnManaActionPerformed(ManaType.GREEN)); manaButtons.put(manaCountLabelG, btnGreenMana); @@ -752,9 +795,9 @@ public class PlayerPanelExt extends javax.swing.JPanel { JLabel manaCountLabelX = new JLabel(); manaLabels.put(manaCountLabelX, ManaType.COLORLESS); manaCountLabelX.setHorizontalAlignment(SwingConstants.CENTER); - r = new Rectangle(15, 15); - BufferedImage imageManaX = ManaSymbols.getSizedManaSymbol("C", 15); - HoverButton btnColorlessMana = new HoverButton(null, imageManaX, imageManaX, imageManaX, r); + r = new Rectangle(sizeMod(15), sizeMod(15)); + BufferedImage imageManaX = ManaSymbols.getSizedManaSymbol("C", sizeMod(15)); + HoverButton btnColorlessMana = new HoverButton(null, imageManaX, imageManaX, imageManaX, r, this.guiScaleMod); btnColorlessMana.setOpaque(false); btnColorlessMana.setObserver(() -> btnManaActionPerformed(ManaType.COLORLESS)); manaButtons.put(manaCountLabelX, btnColorlessMana); @@ -764,158 +807,158 @@ public class PlayerPanelExt extends javax.swing.JPanel { gl_panelBackground.setHorizontalGroup( gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(7) + .addGap(sizeMod(7)) .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(timerLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)) - .addGap(6)) + .addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, sizeMod(80), Short.MAX_VALUE)) + .addGap(sizeMod(6))) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(9) + .addGap(sizeMod(9)) // The left column of icon+label .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addComponent(life, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE) + .addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(poison, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addComponent(poison, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE) + .addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(energy, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(energyLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addComponent(energy, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE) + .addComponent(energyLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(rad, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(radLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addComponent(rad, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE) + .addComponent(radLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(2) - .addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE) - .addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(2)) + .addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE) + .addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(2) - .addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE) - .addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(2)) + .addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE) + .addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(2) - .addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE) - .addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(2)) + .addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE) + .addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(grave, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))) + .addComponent(grave, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE) + .addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE))) // The right column of icon+label .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addComponent(hand, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE) + .addComponent(handLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(library, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addComponent(library, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE) + .addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(experience, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(experienceLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addComponent(experience, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE) + .addComponent(experienceLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(2) - .addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE) - .addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(2)) + .addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE) + .addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(2) - .addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE) - .addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(2)) + .addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE) + .addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(2) - .addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE) - .addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(2)) + .addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE) + .addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE) - .addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))) - .addGap(4)) + .addComponent(exileZone, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE) + .addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE))) + .addGap(sizeMod(4))) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(6) + .addGap(sizeMod(6)) .addComponent(zonesPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) - .addGap(6))); + .addGap(sizeMod(6)))); gl_panelBackground.setVerticalGroup( gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(6) - .addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE) + .addGap(sizeMod(6)) + .addComponent(avatar, GroupLayout.PREFERRED_SIZE, sizeMod(80), GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(btnPlayer, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE) + .addComponent(btnPlayer, GroupLayout.PREFERRED_SIZE, sizeMod(30), GroupLayout.PREFERRED_SIZE) .addComponent(timerLabel) - .addGap(2) + .addGap(sizeMod(2)) // Life & Hand .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)) - .addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE) + .addGap(sizeMod(1)) + .addComponent(life, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE)) + .addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)) - .addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(1)) + .addComponent(hand, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE)) + .addComponent(handLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) // Poison & Library .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(poison, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)) - .addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE) + .addGap(sizeMod(1)) + .addComponent(poison, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE)) + .addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(library, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)) - .addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(1)) + .addComponent(library, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE)) + .addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) // Energy & Experience .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(energy, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)) - .addComponent(energyLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE) + .addGap(sizeMod(1)) + .addComponent(energy, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE)) + .addComponent(energyLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(experience, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)) - .addComponent(experienceLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(1)) + .addComponent(experience, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE)) + .addComponent(experienceLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) // Rad & .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(rad, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)) - .addComponent(radLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(1)) + .addComponent(rad, GroupLayout.PREFERRED_SIZE, sizeMod(18), GroupLayout.PREFERRED_SIZE)) + .addComponent(radLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) // W & R .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)) - .addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) + .addGap(sizeMod(1)) + .addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE)) + .addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, sizeMod(17), GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)) - .addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(1)) + .addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE)) + .addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, sizeMod(17), GroupLayout.PREFERRED_SIZE)) // U & G .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)) - .addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) + .addGap(sizeMod(1)) + .addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE)) + .addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, sizeMod(17), GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)) - .addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(1)) + .addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE)) + .addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, sizeMod(17), GroupLayout.PREFERRED_SIZE)) // B & X .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)) - .addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) + .addGap(sizeMod(1)) + .addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE)) + .addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, sizeMod(17), GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelBackground.createSequentialGroup() - .addGap(1) - .addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)) - .addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(1)) + .addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, sizeMod(15), GroupLayout.PREFERRED_SIZE)) + .addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, sizeMod(17), GroupLayout.PREFERRED_SIZE)) // grave & exile .addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(grave, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) - .addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE) + .addComponent(grave, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) + .addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelBackground.createSequentialGroup() - .addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) - .addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) - .addGap(2) + .addComponent(exileZone, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) + .addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, sizeMod(20), GroupLayout.PREFERRED_SIZE)) + .addGap(sizeMod(2)) .addComponent(zonesPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))); panelBackground.setLayout(gl_panelBackground); GroupLayout groupLayout = new GroupLayout(this); @@ -939,14 +982,14 @@ public class PlayerPanelExt extends javax.swing.JPanel { avatar.setVisible(false); btnPlayer.setVisible(true); timerLabel.setVisible(true); - panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL + extraForMe)); - panelBackground.setBounds(0, 0, PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL + extraForMe); + panelBackground.setPreferredSize(new Dimension(sizeMod(PANEL_WIDTH - 2), sizeMod(PANEL_HEIGHT_SMALL + extraForMe))); + panelBackground.setBounds(0, 0, sizeMod(PANEL_WIDTH - 2), sizeMod(PANEL_HEIGHT_SMALL + extraForMe)); } else { avatar.setVisible(true); btnPlayer.setVisible(false); timerLabel.setVisible(false); - panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT + extraForMe)); - panelBackground.setBounds(0, 0, PANEL_WIDTH - 2, PANEL_HEIGHT + extraForMe); + panelBackground.setPreferredSize(new Dimension(sizeMod(PANEL_WIDTH - 2), sizeMod(PANEL_HEIGHT + extraForMe))); + panelBackground.setBounds(0, 0, sizeMod(PANEL_WIDTH - 2), sizeMod(PANEL_HEIGHT + extraForMe)); } } diff --git a/Mage.Client/src/main/java/mage/client/util/GUISizeHelper.java b/Mage.Client/src/main/java/mage/client/util/GUISizeHelper.java index 5eb83c37631..3f5d57fedaa 100644 --- a/Mage.Client/src/main/java/mage/client/util/GUISizeHelper.java +++ b/Mage.Client/src/main/java/mage/client/util/GUISizeHelper.java @@ -193,4 +193,25 @@ public final class GUISizeHelper { public static int getCardsScrollbarUnitInc(int cardSize) { return Math.max(8, cardSize / 4); } + + /** + * Scale GUI size values due scale coeff + */ + public static int guiSizeScale(int value, float scaleMod) { + // must keep 1 instead 0 on too small values + if (value == 0) { + return 0; + } else if (value < 0) { + return Math.min(-1, Math.round(value * scaleMod)); + } else { + return Math.max(1, Math.round(value * scaleMod)); + } + } + + /** + * Scale GUI size values due scale coeff + */ + public static float guiSizeScale(float value, float scaleMod) { + return value * scaleMod; + } } diff --git a/Mage.Client/src/main/java/mage/client/util/ImageHelper.java b/Mage.Client/src/main/java/mage/client/util/ImageHelper.java index 6bc2bf3853b..3cf6d42521e 100644 --- a/Mage.Client/src/main/java/mage/client/util/ImageHelper.java +++ b/Mage.Client/src/main/java/mage/client/util/ImageHelper.java @@ -11,6 +11,8 @@ import java.io.InputStream; import java.util.HashMap; import java.util.List; import javax.imageio.ImageIO; +import javax.swing.*; + import static mage.client.constants.Constants.FRAME_MAX_HEIGHT; import static mage.client.constants.Constants.FRAME_MAX_WIDTH; import static mage.client.constants.Constants.SYMBOL_MAX_SPACE; @@ -124,4 +126,14 @@ public final class ImageHelper { } return null; } + + public static Image getImageFromResourcesScaledToHeight(String pathToImage, int height) { + Image res = null; + Image image = ImageHelper.getImageFromResources(pathToImage); + if (image != null) { + int width = Math.round(height * image.getWidth(null) / image.getHeight(null)); + res = ImageHelper.scale((BufferedImage) image, BufferedImage.TYPE_4BYTE_ABGR, width, height); + } + return res; + } } diff --git a/Mage.Client/src/main/java/mage/client/util/gui/countryBox/CountryUtil.java b/Mage.Client/src/main/java/mage/client/util/gui/countryBox/CountryUtil.java index 214f822ffee..1069ec20b6d 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/countryBox/CountryUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/countryBox/CountryUtil.java @@ -1,16 +1,16 @@ package mage.client.util.gui.countryBox; -import java.awt.Image; -import java.awt.image.BufferedImage; -import java.util.HashMap; -import java.util.Map; -import javax.swing.ImageIcon; import mage.client.util.GUISizeHelper; import mage.client.util.ImageHelper; import org.apache.log4j.Logger; +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.HashMap; +import java.util.Map; + /** - * * @author LevelX2 */ public final class CountryUtil { @@ -42,22 +42,6 @@ public final class CountryUtil { return flagIcon; } - public static ImageIcon getCountryFlagIconSize(String countryCode, int height) { - ImageIcon flagIcon = null; - Image flagImage = ImageHelper.getImageFromResources("/flags/" + countryCode + (countryCode.endsWith(".png") ? "" : ".png")); - if (flagImage != null) { - - if (height > 11) { - int width = Math.round(height * flagImage.getWidth(null) / flagImage.getHeight(null)); - BufferedImage resized = ImageHelper.scale((BufferedImage) flagImage, BufferedImage.TYPE_4BYTE_ABGR, width, height); - flagIcon = new ImageIcon(resized); - } else { - flagIcon = new ImageIcon(flagImage); - } - } - return flagIcon; - } - public static void changeGUISize() { FLAG_ICON_CACHE.clear(); } diff --git a/Mage/src/main/java/mage/designations/DesignationType.java b/Mage/src/main/java/mage/designations/DesignationType.java index 17db4717b24..62b77b28c61 100644 --- a/Mage/src/main/java/mage/designations/DesignationType.java +++ b/Mage/src/main/java/mage/designations/DesignationType.java @@ -4,9 +4,9 @@ package mage.designations; * @author LevelX2 */ public enum DesignationType { - THE_MONARCH("The Monarch"), - CITYS_BLESSING("City's Blessing"), - THE_INITIATIVE("The Initiative"); + THE_MONARCH("The Monarch"), // global + CITYS_BLESSING("City's Blessing"), // per player + THE_INITIATIVE("The Initiative"); // global private final String text; diff --git a/Mage/src/main/java/mage/util/DebugUtil.java b/Mage/src/main/java/mage/util/DebugUtil.java index 4f2cbfc888d..86887c420d3 100644 --- a/Mage/src/main/java/mage/util/DebugUtil.java +++ b/Mage/src/main/java/mage/util/DebugUtil.java @@ -34,6 +34,9 @@ public class DebugUtil { // game public static boolean GUI_GAME_DRAW_BATTLEFIELD_BORDER = false; public static boolean GUI_GAME_DRAW_HAND_AND_STACK_BORDER = false; + public static boolean GUI_GAME_DRAW_PLAYER_PANEL_BORDER = true; + + // game dialogs public static boolean GUI_GAME_DIALOGS_DRAW_CARDS_AREA_BORDER = false; public static String getMethodNameWithSource(final int depth) {