mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
GUI: improved GUI scale support (fixed font sizes in card icons popup, ability picker dialog, part of #969)
This commit is contained in:
parent
393dbc4047
commit
ba929d5692
6 changed files with 19 additions and 14 deletions
|
|
@ -327,8 +327,10 @@ public class CardIconsPanel extends JPanel {
|
||||||
BufferedImage iconImageWithText = ImageManagerImpl.deepCopy(iconImageCached); // must copy cached value before modify
|
BufferedImage iconImageWithText = ImageManagerImpl.deepCopy(iconImageCached); // must copy cached value before modify
|
||||||
|
|
||||||
// text
|
// text
|
||||||
|
String hint = ManaSymbols.replaceSymbolsWithHTML(icon.getHint(), ManaSymbols.Type.CARD_ICON_HINT);
|
||||||
|
hint = GUISizeHelper.textToHtmlWithSize(hint, GUISizeHelper.cardTooltipFontSize);
|
||||||
JLabel label = new JLabel();
|
JLabel label = new JLabel();
|
||||||
label.setToolTipText("<html>" + ManaSymbols.replaceSymbolsWithHTML(icon.getHint(), ManaSymbols.Type.CARD_ICON_HINT));
|
label.setToolTipText("<html>" + hint);
|
||||||
if (!icon.getText().isEmpty()) {
|
if (!icon.getText().isEmpty()) {
|
||||||
Graphics2D g2 = iconImageWithText.createGraphics();
|
Graphics2D g2 = iconImageWithText.createGraphics();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -568,7 +568,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
createSizeSetting(4, KEY_GUI_CARD_EDITOR_SIZE,14, false, "Size of cards in editor and draft panels", "The size of the card in editor and the picked zone of the draft panel ");
|
createSizeSetting(4, KEY_GUI_CARD_EDITOR_SIZE,14, false, "Size of cards in editor and draft panels", "The size of the card in editor and the picked zone of the draft panel ");
|
||||||
createSizeSetting(5, KEY_GUI_CARD_OFFSET_SIZE,14, false, "Offset of card's image", "The vertical offset of card images in editor areas "); // TODO: delete
|
createSizeSetting(5, KEY_GUI_CARD_OFFSET_SIZE,14, false, "Offset of card's image", "The vertical offset of card images in editor areas "); // TODO: delete
|
||||||
createSizeSetting(6, KEY_GUI_ENLARGED_IMAGE_SIZE, 20, false, "Size of popup card hint (image mode by mouse wheel)", "The size of the image shown for the card your mouse pointer<br>is located over while you turn the mouse wheel");
|
createSizeSetting(6, KEY_GUI_ENLARGED_IMAGE_SIZE, 20, false, "Size of popup card hint (image mode by mouse wheel)", "The size of the image shown for the card your mouse pointer<br>is located over while you turn the mouse wheel");
|
||||||
createSizeSetting(7, KEY_GUI_TOOLTIP_SIZE,14, false, "Size of popup card hint (text mode)", "The size of the tooltip window for cards or permanents"); // TODO: share with popup image
|
createSizeSetting(7, KEY_GUI_TOOLTIP_SIZE,14, true, "Size of popup card hint (text mode)", "The size of the tooltip window for cards or permanents"); // TODO: share with popup image
|
||||||
// game
|
// game
|
||||||
createSizeSetting(8, KEY_GUI_PLAYER_PANEL_SIZE,14, false, "Size of player panel", "The size of the player panels on battlefield");
|
createSizeSetting(8, KEY_GUI_PLAYER_PANEL_SIZE,14, false, "Size of player panel", "The size of the player panels on battlefield");
|
||||||
createSizeSetting(9, KEY_GUI_CARD_HAND_SIZE,14, false, "Size of cards in hand and stack", "The size of the card images in hand and on the stack");
|
createSizeSetting(9, KEY_GUI_CARD_HAND_SIZE,14, false, "Size of cards in hand and stack", "The size of the card images in hand and on the stack");
|
||||||
|
|
|
||||||
|
|
@ -1997,7 +1997,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
abilityPicker = new mage.client.components.ability.AbilityPicker();
|
abilityPicker = new mage.client.components.ability.AbilityPicker(GUISizeHelper.dialogsGuiScale);
|
||||||
jSplitPane1 = new javax.swing.JSplitPane();
|
jSplitPane1 = new javax.swing.JSplitPane();
|
||||||
jSplitPane0 = new javax.swing.JSplitPane();
|
jSplitPane0 = new javax.swing.JSplitPane();
|
||||||
jPanel2 = new javax.swing.JPanel();
|
jPanel2 = new javax.swing.JPanel();
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,9 @@ public final class GUISizeHelper {
|
||||||
cardTooltipFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_TOOLTIP_SIZE, 14);
|
cardTooltipFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_TOOLTIP_SIZE, 14);
|
||||||
symbolTooltipSize = cardTooltipFontSize;
|
symbolTooltipSize = cardTooltipFontSize;
|
||||||
|
|
||||||
|
// control's tooltip on mouse move
|
||||||
|
UIManager.put("ToolTip.font", getCardFont().deriveFont(cardTooltipFontSize * 1.0f));
|
||||||
|
|
||||||
int handCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_HAND_SIZE, 14);
|
int handCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_HAND_SIZE, 14);
|
||||||
handCardDimension = new Dimension(CARD_IMAGE_WIDTH * handCardSize / 42, CARD_IMAGE_HEIGHT * handCardSize / 42);
|
handCardDimension = new Dimension(CARD_IMAGE_WIDTH * handCardSize / 42, CARD_IMAGE_HEIGHT * handCardSize / 42);
|
||||||
stackWidth = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_STACK_WIDTH, 30);
|
stackWidth = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_STACK_WIDTH, 30);
|
||||||
|
|
@ -238,8 +241,12 @@ public final class GUISizeHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String textToHtmlWithSize(String text, Font font) {
|
public static String textToHtmlWithSize(String text, Font font) {
|
||||||
|
return textToHtmlWithSize(text, font.getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String textToHtmlWithSize(String text, int fontSize) {
|
||||||
if (text != null && !text.toLowerCase(Locale.ENGLISH).startsWith("<html>")) {
|
if (text != null && !text.toLowerCase(Locale.ENGLISH).startsWith("<html>")) {
|
||||||
return "<html><p style=\"font-size: " + font.getSize() + "pt;\">" + text + "</p>";
|
return "<html><p style=\"font-size: " + fontSize + "pt;\">" + text + "</p>";
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -621,9 +621,9 @@ public final class ManaSymbols {
|
||||||
symbolSize = GUISizeHelper.symbolDialogSize;
|
symbolSize = GUISizeHelper.symbolDialogSize;
|
||||||
break;
|
break;
|
||||||
case TOOLTIP:
|
case TOOLTIP:
|
||||||
|
case CARD_ICON_HINT:
|
||||||
symbolSize = GUISizeHelper.symbolTooltipSize;
|
symbolSize = GUISizeHelper.symbolTooltipSize;
|
||||||
break;
|
break;
|
||||||
case CARD_ICON_HINT:
|
|
||||||
default:
|
default:
|
||||||
symbolSize = 11;
|
symbolSize = 11;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -97,17 +97,13 @@ public class PlayerView implements Serializable {
|
||||||
sideboard.put(card.getId(), new CardView(card, game, CardUtil.canShowAsControlled(card, createdForPlayerId)));
|
sideboard.put(card.getId(), new CardView(card, game, CardUtil.canShowAsControlled(card, createdForPlayerId)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (Permanent permanent : state.getBattlefield().getAllPermanents()) {
|
||||||
try {
|
if (showInBattlefield(permanent, state)) {
|
||||||
for (Permanent permanent : state.getBattlefield().getAllPermanents()) {
|
PermanentView view = new PermanentView(permanent, game.getCard(permanent.getId()), createdForPlayerId, game);
|
||||||
if (showInBattlefield(permanent, state)) {
|
battlefield.put(view.getId(), view);
|
||||||
PermanentView view = new PermanentView(permanent, game.getCard(permanent.getId()), createdForPlayerId, game);
|
|
||||||
battlefield.put(view.getId(), view);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (ConcurrentModificationException e) {
|
|
||||||
// can happen as a player left battlefield while PlayerView is created
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Card cardOnTop = (player.isTopCardRevealed() && player.getLibrary().hasCards())
|
Card cardOnTop = (player.isTopCardRevealed() && player.getLibrary().hasCards())
|
||||||
? player.getLibrary().getFromTop(game) : null;
|
? player.getLibrary().getFromTop(game) : null;
|
||||||
this.topCard = cardOnTop != null ? new CardView(cardOnTop, game) : null;
|
this.topCard = cardOnTop != null ? new CardView(cardOnTop, game) : null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue