From c3e10f2ccf4a05f4be9151636589607cd73f58a8 Mon Sep 17 00:00:00 2001 From: twanvl Date: Thu, 23 Aug 2007 16:58:08 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@618 0fc631ac-6414-0410-93d0-97cfa31319b6 --- .../symbol-font | 4 +- .../symbol-font | 4 +- .../symbol-font | 4 +- .../symbol-font | 4 +- data/magic.mse-game/game | 135 ++++++++++++------ doc/type/symbol_font.txt | 4 +- src/data/symbol_font.cpp | 20 ++- src/data/symbol_font.hpp | 3 + src/util/version.cpp | 5 +- 9 files changed, 125 insertions(+), 58 deletions(-) diff --git a/data/magic-mana-beveled.mse-symbol-font/symbol-font b/data/magic-mana-beveled.mse-symbol-font/symbol-font index 62e6b897..67775c89 100644 --- a/data/magic-mana-beveled.mse-symbol-font/symbol-font +++ b/data/magic-mana-beveled.mse-symbol-font/symbol-font @@ -1,4 +1,4 @@ -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 diff --git a/data/magic-mana-future.mse-symbol-font/symbol-font b/data/magic-mana-future.mse-symbol-font/symbol-font index a105fdd2..9dc52222 100644 --- a/data/magic-mana-future.mse-symbol-font/symbol-font +++ b/data/magic-mana-future.mse-symbol-font/symbol-font @@ -1,4 +1,4 @@ -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 diff --git a/data/magic-mana-large.mse-symbol-font/symbol-font b/data/magic-mana-large.mse-symbol-font/symbol-font index 70b379b1..0f14699f 100644 --- a/data/magic-mana-large.mse-symbol-font/symbol-font +++ b/data/magic-mana-large.mse-symbol-font/symbol-font @@ -1,4 +1,4 @@ -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 diff --git a/data/magic-mana-small.mse-symbol-font/symbol-font b/data/magic-mana-small.mse-symbol-font/symbol-font index 1b0e8a21..329dc431 100644 --- a/data/magic-mana-small.mse-symbol-font/symbol-font +++ b/data/magic-mana-small.mse-symbol-font/symbol-font @@ -1,4 +1,4 @@ -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 diff --git a/data/magic.mse-game/game b/data/magic.mse-game/game index 27c2bc32..6db58c3b 100644 --- a/data/magic.mse-game/game +++ b/data/magic.mse-game/game @@ -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: "(^|[^/])($|[^/])", + 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: "") 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: "{input}" } + + sub_type_filter := + tag_remove_rule(tag: "{ input}" + else if is_land(type) then "{ input}" + else if is_artifact(type) then "{ input}" + else if is_enchantment(type) then "{input}" + else if is_spell(type) then "{ input}" + 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: 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 types -# word: Goblin -# word: Elf -# word: Wizard -# word: Human +word list: + name: creature + word: Goblin + word: Elf + word: Wizard + word: Human + # TODO: lots more -#word list: -# name: enchantment types -# word: -# word: Aura +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 diff --git a/doc/type/symbol_font.txt b/doc/type/symbol_font.txt index cf44d6d0..6d5a0569 100644 --- a/doc/type/symbol_font.txt +++ b/doc/type/symbol_font.txt @@ -46,7 +46,9 @@ Such a package contains a [[file:format|data file]] called symbol-font | @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?
+ 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. diff --git a/src/data/symbol_font.cpp b/src/data/symbol_font.cpp index a3e6cd49..138048d7 100644 --- a/src/data/symbol_font.cpp +++ b/src/data/symbol_font.cpp @@ -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:; diff --git a/src/data/symbol_font.hpp b/src/data/symbol_font.hpp index 1b4f1feb..59d1d09e 100644 --- a/src/data/symbol_font.hpp +++ b/src/data/symbol_font.hpp @@ -13,6 +13,7 @@ #include #include #include +#include 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; diff --git a/src/util/version.cpp b/src/util/version.cpp index cb527994..0670b641 100644 --- a/src/util/version.cpp +++ b/src/util/version.cpp @@ -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