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

@ -63,6 +63,7 @@ public class ButtonColumn extends AbstractCellEditor implements TableCellRendere
editButton = new JButton();
editButton.setFocusPainted(false);
editButton.addActionListener(this);
setGUISize();
TableColumnModel columnModel = table.getColumnModel();
columnModel.getColumn(column).setCellRenderer(this);
@ -70,6 +71,15 @@ public class ButtonColumn extends AbstractCellEditor implements TableCellRendere
table.addMouseListener(this);
}
public void changeGUISize() {
setGUISize();
}
private void setGUISize() {
renderButton.setFont(GUISizeHelper.tableFont);
editButton.setFont(GUISizeHelper.tableFont);
}
@Override
public Object getCellEditorValue() {
return text;

View file

@ -36,21 +36,19 @@ public class GUISizeHelper {
public static int flagHeight;
public static int cardTooltipFontSize = 15;
public static Font chatFont = new java.awt.Font("Arial", 0, 12);
public static Font tableFont = new java.awt.Font("Arial", 0, 12);
public static Font tooltipFont = new java.awt.Font("Arial", 0, 12);
public static Font balloonTooltipFont = new java.awt.Font("Arial", 0, 12);
public static Font menuFont = new java.awt.Font("Arial", 0, 12);
public static Font gameRequestsFont = new java.awt.Font("Arial", 0, 12);
public static Font gameDialogAreaFontBig = new java.awt.Font("Arial", 0, 12);
public static Font gameDialogAreaFontSmall = new java.awt.Font("Arial", 0, 12);
public static Dimension handCardDimension;
public static Font getToolbarFont() {
int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_TABLE_FONT_SIZE, 14);
return new java.awt.Font("Arial", 0, fontSize);
}
public static int getTableRowHeight() {
int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_TABLE_FONT_SIZE, 14);
return fontSize + 6;
@ -71,47 +69,49 @@ public class GUISizeHelper {
tableFont = new java.awt.Font("Arial", 0, tableFontSize);
tableRowHeight = tableFontSize + 4;
tableHeaderHeight = tableFontSize + 10;
tooltipFont = new java.awt.Font("Arial", 0, tableFontSize - 2);
// used for popup menus
menuFont = new java.awt.Font("Arial", 0, tableFontSize);
int chatFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CHAT_FONT_SIZE, 14);
chatFont = new java.awt.Font("Arial", 0, chatFontSize);
// Set basic symbol size
if (tableFontSize > 24) {
flagHeight = tableFontSize - 4;
} else {
flagHeight = 11;
}
if (tableFontSize < 25) {
basicSymbolSize = "small";
} else if (tableFontSize < 45) {
basicSymbolSize = "medium";
} else {
basicSymbolSize = "large";
}
flagHeight = tableFontSize - 2;
balloonTooltipFont = new Font("Arial", 0, tableFontSize);
if (tableFontSize > 15) {
symbolTooltipSize = tableFontSize - 5;
symbolEditorSize = tableFontSize - 5;
symbolPaySize = tableFontSize - 5;
symbolCardSize = 15;
dividerBarSize = 10 + (tableFontSize / 4);
scrollBarSize = 14 + (tableFontSize / 4);
} else {
symbolTooltipSize = tableFontSize;
symbolEditorSize = tableFontSize;
symbolPaySize = tableFontSize;
symbolCardSize = 15;
dividerBarSize = 10;
scrollBarSize = 14;
}
// used for popup menus
int dialogFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_DIALOG_FONT_SIZE, 14);
menuFont = new Font("Arial", 0, dialogFontSize);
gameRequestsFont = new Font("Arial", 0, dialogFontSize);
int chatFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CHAT_FONT_SIZE, 14);
chatFont = new java.awt.Font("Arial", 0, chatFontSize);
int symbolSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_SYMBOL_SIZE, 14);
// Set basic symbol size
if (symbolSize < 25) {
basicSymbolSize = "small";
} else if (symbolSize < 45) {
basicSymbolSize = "medium";
} else {
basicSymbolSize = "large";
}
if (symbolSize < 16) {
symbolTooltipSize = 15;
symbolPaySize = 15;
symbolCardSize = 15;
} else {
symbolTooltipSize = symbolSize;
symbolPaySize = symbolSize;
symbolCardSize = symbolSize;
}
cardTooltipFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_TOOLTIP_SIZE, 14);
int handCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_HAND_SIZE, 14);
int width = CARD_IMAGE_WIDTH * handCardSize / 42;
int height = CARD_IMAGE_HEIGHT * handCardSize / 42;
handCardDimension = new Dimension(width, height);
}
}

View file

@ -13,6 +13,7 @@ import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import mage.client.MageFrame;
import mage.client.util.GUISizeHelper;
import mage.constants.CardType;
import mage.constants.MageObjectType;
import mage.constants.Rarity;
@ -157,10 +158,8 @@ public class GuiDisplayUtil {
if (((PermanentView) card).getCounters() != null) {
counters = new ArrayList<>(((PermanentView) card).getCounters());
}
} else {
if (card.getCounters() != null) {
counters = new ArrayList<>(card.getCounters());
}
} else if (card.getCounters() != null) {
counters = new ArrayList<>(card.getCounters());
}
if (!counters.isEmpty()) {
StringBuilder sb = new StringBuilder();
@ -204,15 +203,14 @@ public class GuiDisplayUtil {
symbolCount++;
}
int fontSize = 11;
String fontFamily = "tahoma";
int fontSize = GUISizeHelper.cardTooltipFontSize;
/*if (prefs.fontFamily == CardFontFamily.arial)
fontFamily = "arial";
else if (prefs.fontFamily == CardFontFamily.verdana) {
fontFamily = "verdana";
}*/
final StringBuilder buffer = new StringBuilder(512);
buffer.append("<html><body style='font-family:");
buffer.append(fontFamily);
@ -226,7 +224,7 @@ public class GuiDisplayUtil {
buffer.append(" [").append(card.getId().toString().substring(0, 3)).append("]");
}
buffer.append("</b></td><td align='right' valign='top' style='width:");
buffer.append(symbolCount * 11 + 1);
buffer.append(symbolCount * GUISizeHelper.symbolTooltipSize + 1);
buffer.append("px'>");
if (!card.isSplitCard()) {
buffer.append(castingCost);
@ -307,7 +305,7 @@ public class GuiDisplayUtil {
rule.append("<tr><td valign='top'><b>");
rule.append(card.getLeftSplitName());
rule.append("</b></td><td align='right' valign='top' style='width:");
rule.append(card.getLeftSplitCosts().getSymbols().size() * 11 + 1);
rule.append(card.getLeftSplitCosts().getSymbols().size() * GUISizeHelper.symbolTooltipSize + 1);
rule.append("px'>");
rule.append(card.getLeftSplitCosts().getText());
rule.append("</td></tr></table>");
@ -320,7 +318,7 @@ public class GuiDisplayUtil {
rule.append("<tr><td valign='top'><b>");
rule.append(card.getRightSplitName());
rule.append("</b></td><td align='right' valign='top' style='width:");
rule.append(card.getRightSplitCosts().getSymbols().size() * 11 + 1);
rule.append(card.getRightSplitCosts().getSymbols().size() * GUISizeHelper.symbolTooltipSize + 1);
rule.append("px'>");
rule.append(card.getRightSplitCosts().getText());
rule.append("</td></tr></table>");