Some more changes to GUI to better support high screen resolutions.

This commit is contained in:
LevelX2 2016-02-14 13:41:43 +01:00
parent a2d4c4738a
commit 1835671f3d
22 changed files with 1366 additions and 859 deletions

View file

@ -32,7 +32,7 @@ public class ManaSymbols {
public static void loadImages() {
String[] symbols = new String[]{"0", "1", "10", "11", "12", "15", "16", "2", "3", "4", "5", "6", "7", "8", "9", "B", "BG",
"BR", "G", "GU", "GW", "R", "RG", "RW", "S", "T", "U", "UB", "UR", "W", "WB", "WU",
"WP", "UP", "BP", "RP", "GP", "X", "C" /*, "Y", "Z", "slash"*/};
"WP", "UP", "BP", "RP", "GP", "X", "C"};
MANA_IMAGES.clear();
SET_IMAGES.clear();
@ -185,7 +185,7 @@ public class ManaSymbols {
continue;
}
g.drawImage(image, x, y, null);
x += symbol.length() > 2 ? 10 : 12; // slash.png is only 10 pixels wide.
x += GUISizeHelper.symbolPaySize;
}
}
@ -202,8 +202,8 @@ public class ManaSymbols {
manaCost = manaCost.replace("\\", "");
StringTokenizer tok = new StringTokenizer(manaCost, " ");
while (tok.hasMoreTokens()) {
String symbol = tok.nextToken().substring(0);
width += symbol.length() > 2 ? 10 : 12; // slash.png is only 10 pixels wide.
tok.nextToken();
width += GUISizeHelper.symbolPaySize;
}
return width;
}

View file

@ -16,12 +16,6 @@ public class Constants {
public static final Rectangle CARD_SIZE_FULL = new Rectangle(101, 149);
public static final Rectangle THUMBNAIL_SIZE_FULL = new Rectangle(102, 146);
public static final int TOOLTIP_WIDTH_MIN = 320;
public static final int TOOLTIP_HEIGHT_MIN = 201;
public static final int TOOLTIP_HEIGHT_MAX = 401;
public static final int TOOLTIP_BORDER_WIDTH = 80;
public interface IO {
String imageBaseDir = "plugins" + File.separator + "images";

View file

@ -1,10 +1,10 @@
package org.mage.plugins.card.info;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JEditorPane;
import javax.swing.SwingUtilities;
import mage.client.util.GUISizeHelper;
import mage.client.util.gui.GuiDisplayUtil;
import mage.client.util.gui.GuiDisplayUtil.TextLines;
import mage.components.CardInfoPane;
@ -13,20 +13,43 @@ import mage.view.CardView;
import org.mage.card.arcane.UI;
/**
* Card info pane for displaying card rules.
* Supports drawing mana symbols.
* Card info pane for displaying card rules. Supports drawing mana symbols.
*
* @author nantuko
*/
public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
public static final int TOOLTIP_WIDTH_MIN = 160;
public static final int TOOLTIP_HEIGHT_MIN = 120;
public static final int TOOLTIP_HEIGHT_MAX = 300;
public static final int TOOLTIP_BORDER_WIDTH = 80;
private CardView currentCard;
private int type;
private int addWidth;
private int addHeight;
private boolean setSize = false;
public CardInfoPaneImpl() {
UI.setHTMLEditorKit(this);
setEditable(false);
setBackground(Color.white);
setGUISize();
}
public void changeGUISize() {
setGUISize();
this.revalidate();
this.repaint();
}
private void setGUISize() {
addWidth = 20 * GUISizeHelper.cardTooltipFontSize;
addHeight = 12 * GUISizeHelper.cardTooltipFontSize;
setSize = true;
}
@Override
@ -42,8 +65,8 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
try {
if (!card.equals(currentCard)) {
return;
}
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@ -70,20 +93,29 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
return;
}
boolean makeBig = (rules > 5 || ruleLength > 350);
if (setSize) {
if (makeBig) {
type = 0;
} else {
type = 1;
}
}
if (makeBig && type == 0) {
type = 1;
container.setSize(
org.mage.plugins.card.constants.Constants.TOOLTIP_WIDTH_MIN + org.mage.plugins.card.constants.Constants.TOOLTIP_BORDER_WIDTH,
org.mage.plugins.card.constants.Constants.TOOLTIP_HEIGHT_MAX + org.mage.plugins.card.constants.Constants.TOOLTIP_BORDER_WIDTH
addWidth + TOOLTIP_WIDTH_MIN + TOOLTIP_BORDER_WIDTH,
addHeight + TOOLTIP_HEIGHT_MAX + TOOLTIP_BORDER_WIDTH
);
this.setSize(org.mage.plugins.card.constants.Constants.TOOLTIP_WIDTH_MIN, org.mage.plugins.card.constants.Constants.TOOLTIP_HEIGHT_MAX);
this.setSize(addWidth + TOOLTIP_WIDTH_MIN,
addHeight + TOOLTIP_HEIGHT_MAX);
} else if (!makeBig && type == 1) {
type = 0;
container.setSize(
org.mage.plugins.card.constants.Constants.TOOLTIP_WIDTH_MIN + org.mage.plugins.card.constants.Constants.TOOLTIP_BORDER_WIDTH,
org.mage.plugins.card.constants.Constants.TOOLTIP_HEIGHT_MIN + org.mage.plugins.card.constants.Constants.TOOLTIP_BORDER_WIDTH
addWidth + TOOLTIP_WIDTH_MIN + TOOLTIP_BORDER_WIDTH,
addHeight + TOOLTIP_HEIGHT_MIN + TOOLTIP_BORDER_WIDTH
);
this.setSize(org.mage.plugins.card.constants.Constants.TOOLTIP_WIDTH_MIN, org.mage.plugins.card.constants.Constants.TOOLTIP_HEIGHT_MIN);
this.setSize(addWidth + TOOLTIP_WIDTH_MIN,
addHeight + TOOLTIP_HEIGHT_MIN);
}
}