Commit ced4ee14 authored by twanvl's avatar twanvl

Added as_text regex to symbol font as a more flexible replacement for merge_numbers.

 This fixes "31/2" which is now rendered as "(3)(1/2)".
Reverted the mana_sort_guild change
Time for a version bump
parent 21feb691
mse version: 0.3.2
mse version: 0.3.5
# Symbol font in the beveled style used for casting costs on FPM cards
# Note:
# Define small_mana_t:="mana_t(_old)?.png" in the init script of the style
......@@ -175,7 +175,7 @@ symbol:
symbol:
code: S
image: mana_s.png
merge numbers: true
as text: .|[0-9]+(?!/)
text font:
name: MPlantin
size: 15
......
mse version: 0.3.3
mse version: 0.3.5
# Symbol font in the 'futuristic' style, used for casting costs on futureshift cards
image font size: 135
......@@ -136,7 +136,7 @@ symbol:
symbol:
code: S
image: mana_s.png
merge numbers: true
as text: .|[0-9]+(?!/)
text font:
name: MPlantin
size: 15
......
mse version: 0.3.2
mse version: 0.3.5
# Symbol font in the 'popup' style, used for casting costs on modern cards
image font size: 135
......@@ -188,7 +188,7 @@ symbol:
symbol:
code: S
image: mana_s.png
merge numbers: true
as text: .|[0-9]+(?!/)
text font:
name: MPlantin
size: 15
......
mse version: 0.3.2
mse version: 0.3.5
# Symbol font in the normal, flat, style, used for text boxes and on old style cards
# Note:
# Define mana_t := {"new|old|older"} in the init script of the style
......@@ -195,7 +195,7 @@ symbol:
symbol:
code: S
image: mana_s.png
merge numbers: true
as text: .|[0-9]+(?!/)
text font:
name: MPlantin
size: 15
......
......@@ -12,20 +12,20 @@ init script:
############################################################## Sorting mana symbols
# correctly sort mana symbols
mana_sort := sort_rule(order: "ordered(XYZ)"
+ "mixed(0123456789)"
+ "ordered(S)"
+ "reverse_order("
+ " pattern(./././. cycle(WUBRG))"
+ " pattern(././. cycle(WUBRG))"
+ " pattern(./. cycle(WUBRG))"
+ " pattern(|. WUBRG)|"
+ " pattern(./ WUBRG)"
+ " pattern(/. WUBRG)"
+ " cycle(WUBRG)"
+ ")")
mana_filter := to_upper + mana_sort
# correctly sort a mana symbol (no guild mana)
mana_sort := sort_rule(order: "XYZ[0123456789]S(WUBRG)")
# correctly sort guild mana
mana_sort_guild := replace_rule(
match: "./.|././.|./././.|.[|]",
in_context: "(^|[^/])<match>($|[^/])",
replace: {sort_text(order:"in_place((WUBRG)")}
)
mana_has_guild := match_rule(match: "[/|]") # Is there guild or half mana in the input?
# A mana cost can contain both normal and guild mana
mana_filter := to_upper + {
if mana_has_guild() then mana_sort_guild()
else mana_sort()
}
# Like mana filter, only also allow tap symbols:
tap_filter := sort_rule(order: "<T>")
mana_filter_t := replace_rule( # Remove [] used for forcing mana symbols
......@@ -122,8 +122,11 @@ init script:
}
# The color of a card
is_artifact := match_rule(match: "(?i)Artifact")
is_land := match_rule(match: "(?i)Land")
is_creature := match_rule(match: "(?i)Creature|Tribal")
is_artifact := match_rule(match: "(?i)Artifact")
is_land := match_rule(match: "(?i)Land")
is_enchantment := match_rule(match: "(?i)Enchantment")
is_spell := match_rule(match: "(?i)Instant|Sorcery")
card_color := {
# usually the color of mana
text_color := text_to_color(rules_text, land: is_land(type), card_name: card_name);
......@@ -174,11 +177,11 @@ init script:
# land
if card.rarity != "basic land" then "K" # nonbasic land
else (
if contains(card.name, match:"Plains") then "M"
else if contains(card.name, match:"Island") then "N"
else if contains(card.name, match:"Swamp") then "O"
if contains(card.name, match:"Plains") then "M"
else if contains(card.name, match:"Island") then "N"
else if contains(card.name, match:"Swamp") then "O"
else if contains(card.name, match:"Mountain") then "P"
else if contains(card.name, match:"Forest") then "Q"
else if contains(card.name, match:"Forest") then "Q"
else "L" # other basic land
)
) else if is_null_cost(casting_cost) then (
......@@ -410,11 +413,26 @@ init script:
replace_rule(
match: " - ",
replace: " — ");
# Move the cursor past the separator in the p/t and type boxes
type_over_pt := replace_rule(match:"/$", replace:"")
type_over_type := replace_rule(match:" ?-$", replace:"")
super_type_filter :=
type_over_type +
tag_remove_rule(tag: "<word-list-") +
{ "<word-list-type>{input}</word-list-type>" }
sub_type_filter :=
tag_remove_rule(tag: "<word-list-") +
{ if is_creature(type) then "<word-list-creature>{ input}</word-list-creature>"
else if is_land(type) then "<word-list-land>{ input}</word-list-land>"
else if is_artifact(type) then "<word-list-artifact>{ input}</word-list-artifact>"
else if is_enchantment(type) then "<word-list-enchantment>{input}</word-list-enchantment>"
else if is_spell(type) then "<word-list-spell>{ input}</word-list-spell>"
else input
}
# Shape of cards, can be changed in style files
card_shape := { "normal" }
......@@ -711,11 +729,12 @@ card field:
name: super type
icon: stats/creature_type.png
editable: false
script: type_over_type(value)
script: super_type_filter(value)
card field:
type: text
name: sub type
icon: stats/creature_type.png
script: sub_type_filter(value, type:card.super_type)
editable: false
card field:
type: text
......@@ -930,13 +949,14 @@ card field:
icon: stats/creature_type.png
editable: false
show statistics: false
script: type_over_type(value)
script: super_type_filter(value)
card field:
type: text
name: sub type 2
icon: stats/creature_type.png
editable: false
show statistics: false
script: sub_type_filter(value, type:card.super_type_2)
card field:
type: text
name: type 2
......@@ -1205,32 +1225,57 @@ statistics category:
# The following (until keywords) doesn't do anything yet
############################################################## Word lists
#word list:
# name: card types
# word: Creature
# word: Artifact
# word: Enchantment
# word: Instant
# word: Sorcery
# word: Land
# word: Legendary Creature
# word: Legendary Artifact
# word: Legendary Enchantment
# word: Legendary Land
#word list:
# name: creature types
# word: Goblin
# word: Elf
# word: Wizard
# word: Human
#word list:
# name: enchantment types
# word:
# word: Aura
word list:
name: type
word:
name: Basic
is prefix: true
word:
name: Legendary
line below: true
is prefix: true
word: Creature
word: Artifact
word: Enchantment
word: Instant
word: Sorcery
word: Land
word list:
name: creature
word: Goblin
word: Elf
word: Wizard
word: Human
# TODO: lots more
word list:
name: artifact
word:
word: Equipment
word list:
name: land
word:
word: Plains
word: Island
word: Swamp
word: Mountain
word: Forest
word list:
name: enchantment
word:
word: Aura
word list:
name: spell
word:
word: Arcane
......
......@@ -46,7 +46,9 @@ Such a package contains a [[file:format|data file]] called <tt>symbol-font</tt>
| @symbols@ [[type:list]] of [[type:symbol font symbol]]s Symbols that make up this font.
| @text font@ [[type:font]] Font to use for drawing text on symbols, only used if there is a default symbol.
| @scale text@ [[type:boolean]] @false@ Should text be scaled down to fit in a symbol?
| @merge numbers@ [[type:boolean]] @false@ Should a numeric value of multiple digits be rendered as a single symbol?
| @merge numbers@ [[type:boolean]] @false@ Should a numeric value of multiple digits be rendered as a single symbol?<br/>
Note: @merge numbers@ is deprecated, use @as text: [0-9]+@ instead.
| @as text@ [[type:regex]] @"."@ What should be rendered as a single piece of text?
| @text margin left@ [[type:double]] @0@ Margin on the left of the text in pixels.
| @text margin right@ [[type:double]] @0@ Margin on the right of the text in pixels.
| @text margin top@ [[type:double]] @0@ Margin on the top of the text in pixels.
......
......@@ -57,7 +57,7 @@ IMPLEMENT_REFLECTION(SymbolFont) {
REFLECT(symbols);
REFLECT(text_font);
REFLECT(scale_text);
REFLECT(merge_numbers);
REFLECT(as_text);
REFLECT(text_margin_left);
REFLECT(text_margin_right);
REFLECT(text_margin_top);
......@@ -192,7 +192,23 @@ void SymbolFont::split(const String& text, SplitSymbols& out) const {
goto next_symbol; // continue two levels
}
}
// 3. unknown code, draw single character as text
// 3. draw multiple together as text?
if (!as_text.empty()) {
if (!as_text_r.IsValid()) {
as_text_r.Compile(_("^") + as_text, wxRE_ADVANCED);
}
if (as_text_r.IsValid()) {
if (as_text_r.Matches(text.substr(pos))) {
size_t start, len;
if (as_text_r.GetMatch(&start,&len) && start == 0) {
out.push_back(DrawableSymbol(text.substr(pos, len), 0));
pos += len;
goto next_symbol;
}
}
}
}
// 4. unknown code, draw single character as text
out.push_back(DrawableSymbol(text.substr(pos, 1), 0));
pos += 1;
next_symbol:;
......
......@@ -13,6 +13,7 @@
#include <util/alignment.hpp>
#include <util/io/package.hpp>
#include <data/font.hpp>
#include <wx/regex.h>
DECLARE_POINTER_TYPE(Font);
DECLARE_POINTER_TYPE(SymbolFont);
......@@ -88,6 +89,8 @@ class SymbolFont : public Packaged {
double text_margin_bottom;
Alignment text_alignment;
bool merge_numbers; ///< Merge numbers? e.g. "11" is a single symbol ('1' must not exist as a symbol)
String as_text; ///< Things to render as text
mutable wxRegEx as_text_r;
InsertSymbolMenuP insert_symbol_menu;
wxMenu* processed_insert_symbol_menu;
......
......@@ -49,7 +49,7 @@ template <> void GetDefaultMember::handle(const Version& v) {
// ----------------------------------------------------------------------------- : Versions
// NOTE: Don't use leading zeroes, they mean octal
const Version app_version = 304; // 0.3.4
const Version app_version = 305; // 0.3.5
#ifdef UNICODE
const Char* version_suffix = _(" (beta)");
#else
......@@ -66,5 +66,6 @@ const Char* version_suffix = _(" (beta, ascii build)");
* 0.3.2 : package dependencies
* 0.3.3 : keyword separator before/after
* 0.3.4 : html export; choice rendering based on scripted 'image'
* 0.3.5 : word lists, symbol font 'as text'
*/
const Version file_version = 304; // 0.3.4
const Version file_version = 305; // 0.3.5
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment