mirror of
https://github.com/correl/mage.git
synced 2024-12-27 03:00:13 +00:00
Merge pull request #6503 from SpeedProg/fix_rednering_tooltipmarktags
UI: fix for </font> in card renders at end of ToolTipMarkTags
This commit is contained in:
commit
a7de11345d
2 changed files with 26 additions and 0 deletions
|
@ -7,6 +7,7 @@ package org.mage.card.arcane;
|
||||||
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
import java.awt.Paint;
|
||||||
import java.awt.font.GraphicAttribute;
|
import java.awt.font.GraphicAttribute;
|
||||||
import java.awt.font.ImageGraphicAttribute;
|
import java.awt.font.ImageGraphicAttribute;
|
||||||
import java.awt.font.TextAttribute;
|
import java.awt.font.TextAttribute;
|
||||||
|
@ -47,6 +48,25 @@ public class TextboxRule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ColorRegion implements AttributeRegion {
|
||||||
|
|
||||||
|
ColorRegion(int start, int end, Paint color) {
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
private final int start;
|
||||||
|
private final int end;
|
||||||
|
private final Paint color;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyToAttributedString(AttributedString str, Font normal, Font italic) {
|
||||||
|
if (end > start + 1) {
|
||||||
|
str.addAttribute(TextAttribute.FOREGROUND, color, start, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// A special symbol embedded at some point in a string
|
// A special symbol embedded at some point in a string
|
||||||
public static class EmbeddedSymbol implements AttributeRegion {
|
public static class EmbeddedSymbol implements AttributeRegion {
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ public final class TextboxRuleParser {
|
||||||
private static final Pattern LevelAbilityPattern = Pattern.compile("Level (\\d+)-?(\\d*)(\\+?)");
|
private static final Pattern LevelAbilityPattern = Pattern.compile("Level (\\d+)-?(\\d*)(\\+?)");
|
||||||
private static final Pattern LoyaltyAbilityPattern = Pattern.compile("^(\\+|\\-)(\\d+|X): ");
|
private static final Pattern LoyaltyAbilityPattern = Pattern.compile("^(\\+|\\-)(\\d+|X): ");
|
||||||
private static final Pattern SimpleKeywordPattern = Pattern.compile("^(\\w+( \\w+)?)\\s*(\\([^\\)]*\\))?\\s*$");
|
private static final Pattern SimpleKeywordPattern = Pattern.compile("^(\\w+( \\w+)?)\\s*(\\([^\\)]*\\))?\\s*$");
|
||||||
|
private static final Pattern FontColorValuePattern = Pattern.compile("color\\s*=\\s*[\"'](\\w+)[\"']");
|
||||||
|
|
||||||
// Parse a given rule (given as a string) into a TextboxRule, replacing
|
// Parse a given rule (given as a string) into a TextboxRule, replacing
|
||||||
// symbol annotations, italics, etc, parsing out information such as
|
// symbol annotations, italics, etc, parsing out information such as
|
||||||
|
@ -200,6 +201,11 @@ public final class TextboxRuleParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "/font":
|
||||||
|
// Font it is an additional info of a card
|
||||||
|
// lets make it blue like it is in tooltip
|
||||||
|
regions.add(new TextboxRule.ColorRegion(openingIndex, outputIndex, Color.BLUE));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// Unknown
|
// Unknown
|
||||||
build.append('<').append(tag).append('>');
|
build.append('<').append(tag).append('>');
|
||||||
|
|
Loading…
Reference in a new issue