forked from External/mage
* UI: multiple improves for adventure/split cards:
* Split cards shows left and right mana cost (in deck editor, hand, etc); * Adventure cards shows adventure and normal cost (in deck editor, hand, etc); * Adventure cards shows adventure spell name in deck editor's list; * Fixed missing loading cursor in deck editor searching;
This commit is contained in:
parent
c4ad761ebb
commit
339c419d4b
18 changed files with 311 additions and 102 deletions
|
|
@ -525,7 +525,7 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
int manaX = getCardXOffset() + getCardWidth() - manaMarginRight - manaWidth;
|
||||
int manaY = getCardYOffset() + manaMarginTop;
|
||||
|
||||
ManaSymbols.draw(g, manaCost, manaX, manaY, getSymbolWidth(), Color.black, symbolMarginX);
|
||||
ManaSymbols.draw(g, manaCost, manaX, manaY, getSymbolWidth(), ModernCardRenderer.MANA_ICONS_TEXT_COLOR, symbolMarginX);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.mage.card.arcane;
|
||||
|
||||
import mage.abilities.hint.HintUtils;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.constants.Constants;
|
||||
|
|
@ -587,7 +588,7 @@ public final class ManaSymbols {
|
|||
}
|
||||
|
||||
public static void draw(Graphics g, String manaCost, int x, int y, int symbolWidth) {
|
||||
draw(g, manaCost, x, y, symbolWidth, Color.white, 0);
|
||||
draw(g, manaCost, x, y, symbolWidth, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 0);
|
||||
}
|
||||
|
||||
public static void draw(Graphics g, String manaCost, int x, int y, int symbolWidth, Color symbolsTextColor, int symbolMarginX) {
|
||||
|
|
@ -657,20 +658,24 @@ public final class ManaSymbols {
|
|||
|
||||
if (image == null) {
|
||||
// TEXT draw
|
||||
|
||||
labelRender.setText("{" + symbol + "}");
|
||||
labelRender.setForeground(symbolsTextColor);
|
||||
String sampleAutoFontText = "{W}"; // need same font size for all -- use max symbol ever, not current text
|
||||
if (symbol.equals(CardInfo.SPLIT_MANA_SEPARATOR_SHORT)) {
|
||||
labelRender.setText(CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
|
||||
sampleAutoFontText = CardInfo.SPLIT_MANA_SEPARATOR_RENDER; // separator must be big
|
||||
} else {
|
||||
labelRender.setText("{" + symbol + "}");
|
||||
}
|
||||
labelRender.setSize(symbolWidth, symbolWidth);
|
||||
labelRender.setVerticalAlignment(SwingConstants.CENTER);
|
||||
labelRender.setForeground(symbolsTextColor);
|
||||
labelRender.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
//labelRender.setBorder(new LineBorder(new Color(125, 250, 250), 1));
|
||||
//labelRender.setBorder(new LineBorder(new Color(125, 250, 250), 1)); // debug draw
|
||||
|
||||
// fix font size for mana text
|
||||
// work for labels WITHOUT borders
|
||||
// https://stackoverflow.com/questions/2715118/how-to-change-the-size-of-the-font-of-a-jlabel-to-take-the-maximum-size
|
||||
Font labelFont = labelRender.getFont();
|
||||
String labelText = "{W}"; //labelRender.getText(); // need same font size for all -- use max symbol ever, not current text
|
||||
int stringWidth = labelRender.getFontMetrics(labelFont).stringWidth(labelText);
|
||||
int stringWidth = labelRender.getFontMetrics(labelFont).stringWidth(sampleAutoFontText);
|
||||
int componentWidth = labelRender.getWidth();
|
||||
// Find out how much the font can grow in width.
|
||||
double widthRatio = (double) componentWidth / (double) stringWidth;
|
||||
|
|
@ -702,7 +707,11 @@ public final class ManaSymbols {
|
|||
for (String s : manaCost) {
|
||||
sb.append(s);
|
||||
}
|
||||
return sb.toString().replace("/", "").replace("{", "").replace("}", " ").trim();
|
||||
return sb.toString()
|
||||
.replace("/", "")
|
||||
.replace("{", "")
|
||||
.replace("}", " ")
|
||||
.trim();
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
|
@ -767,6 +776,7 @@ public final class ManaSymbols {
|
|||
htmlImagesPath = htmlImagesPath
|
||||
.replace("$", "@S@"); // paths with $ will rise error, need escape that
|
||||
|
||||
replaced = replaced.replace(CardInfo.SPLIT_MANA_SEPARATOR_FULL, CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
|
||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(replaced).replaceAll(
|
||||
"<img src='" + filePathToUrl(htmlImagesPath) + "$1$2" + ".png' alt='$1$2' width="
|
||||
+ symbolSize + " height=" + symbolSize + '>');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.mage.card.arcane;
|
||||
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
|
||||
import javax.swing.*;
|
||||
|
|
@ -45,17 +46,23 @@ public final class ManaSymbolsCellRenderer extends DefaultTableCellRenderer {
|
|||
String symbol = tok.nextToken();
|
||||
|
||||
JLabel symbolLabel = new JLabel();
|
||||
//symbolLabel.setBorder(new LineBorder(new Color(150, 150, 150))); // debug
|
||||
symbolLabel.setFont(GUISizeHelper.tableFont);
|
||||
symbolLabel.setBorder(new EmptyBorder(0, symbolHorizontalMargin, 0, 0));
|
||||
//symbolLabel.setBorder(new LineBorder(new Color(150, 150, 150))); // debug draw
|
||||
|
||||
BufferedImage image = ManaSymbols.getSizedManaSymbol(symbol, symbolWidth);
|
||||
if (image != null) {
|
||||
// icon
|
||||
symbolLabel.setIcon(new ImageIcon(image));
|
||||
} else {
|
||||
// text
|
||||
symbolLabel.setText("{" + symbol + "}");
|
||||
symbolLabel.setOpaque(baseComp.isOpaque());
|
||||
// text (mana symbols withoiut brackets like R U * B)
|
||||
// TODO: add auto-size text from ManaSymbols.draw
|
||||
if (symbol.equals(CardInfo.SPLIT_MANA_SEPARATOR_SHORT)) {
|
||||
symbolLabel.setText(CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
|
||||
} else {
|
||||
symbolLabel.setText("{" + symbol + "}");
|
||||
}
|
||||
symbolLabel.setOpaque(false);
|
||||
symbolLabel.setForeground(baseComp.getForeground());
|
||||
symbolLabel.setBackground(baseComp.getBackground());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
|
||||
private static final Logger LOGGER = Logger.getLogger(ModernCardRenderer.class);
|
||||
private static final GlowText glowTextRenderer = new GlowText();
|
||||
public static final Color MANA_ICONS_TEXT_COLOR = Color.DARK_GRAY; // text color of missing mana icons in IMAGE render mode
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Textures for modern frame cards
|
||||
|
|
@ -879,7 +880,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
|
||||
// Draw the mana symbols
|
||||
if (!cardView.isAbility() && !cardView.isFaceDown()) {
|
||||
ManaSymbols.draw(g, manaCost, x + w - manaCostWidth, y + boxTextOffset, boxTextHeight, Color.black, 2);
|
||||
ManaSymbols.draw(g, manaCost, x + w - manaCostWidth, y + boxTextOffset, boxTextHeight, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1256,18 +1257,18 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
String symbs = symbol;
|
||||
int symbHeight = (int) (0.8 * h);
|
||||
int manaCostWidth = CardRendererUtils.getManaCostWidth(symbs, symbHeight);
|
||||
ManaSymbols.draw(g, symbs, x + (w - manaCostWidth) / 2, y + (h - symbHeight) / 2, symbHeight, Color.black, 2);
|
||||
ManaSymbols.draw(g, symbs, x + (w - manaCostWidth) / 2, y + (h - symbHeight) / 2, symbHeight, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 2);
|
||||
}
|
||||
|
||||
private void drawBasicManaSymbol(Graphics2D g, int x, int y, int w, int h, String symbol) {
|
||||
String symbs = symbol;
|
||||
if (getSizedManaSymbol(symbol) != null) {
|
||||
ManaSymbols.draw(g, symbs, x, y, w, Color.black, 2);
|
||||
ManaSymbols.draw(g, symbs, x, y, w, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 2);
|
||||
}
|
||||
if (symbol.length() == 2) {
|
||||
String symbs2 = "" + symbol.charAt(1) + symbol.charAt(0);
|
||||
if (getSizedManaSymbol(symbs2) != null) {
|
||||
ManaSymbols.draw(g, symbs2, x, y, w, Color.black, 2);
|
||||
ManaSymbols.draw(g, symbs2, x, y, w, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.mage.card.arcane;
|
||||
|
||||
import java.awt.Image;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.view.CardView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import mage.view.CardView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author StravantUser
|
||||
*/
|
||||
public final class TextboxRuleParser {
|
||||
|
|
@ -120,11 +116,16 @@ public final class TextboxRuleParser {
|
|||
index = closeIndex + 1;
|
||||
} else {
|
||||
// Bad entry
|
||||
build.append('{');
|
||||
build.append(contents);
|
||||
build.append('}');
|
||||
if (contents.equals(CardInfo.SPLIT_MANA_SEPARATOR_FULL)) {
|
||||
build.append(CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
|
||||
outputIndex += contents.length() - CardInfo.SPLIT_MANA_SEPARATOR_RENDER.length();
|
||||
} else {
|
||||
build.append('{');
|
||||
build.append(contents);
|
||||
build.append('}');
|
||||
outputIndex += (contents.length() + 2);
|
||||
}
|
||||
index = closeIndex + 1;
|
||||
outputIndex += (contents.length() + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue