From e9597a142c8028a6bc4d1a472848ce1406065655 Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 18 May 2007 22:22:18 +0000 Subject: [PATCH] Fixed bug in fields in style file; No longer doing GetTextExtent("\n"); Moved pt boxes to style files; git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@390 0fc631ac-6414-0410-93d0-97cfa31319b6 --- data/magic-extended-art.mse-style/style | 30 +++++--- .../style | 59 +++++++++------ data/magic-firepenguinmaster.mse-style/style | 33 +++++---- .../style | 35 +++++---- .../style | 61 +++++++++------- .../style | 35 +++++---- data/magic-new-flip.mse-style/style | 72 ++++++++++--------- data/magic-new-promo.mse-style/style | 43 +++++------ data/magic-new-split.mse-style/style | 53 ++++++++------ data/magic-new.mse-style/style | 41 ++++++++--- data/magic-planeshifted.mse-style/style | 28 +++++--- data/magic.mse-game/game | 42 ----------- src/render/text/font.cpp | 18 +++-- src/util/index_map.hpp | 6 +- 14 files changed, 316 insertions(+), 240 deletions(-) diff --git a/data/magic-extended-art.mse-style/style b/data/magic-extended-art.mse-style/style index d5a7bf44..9318beb9 100644 --- a/data/magic-extended-art.mse-style/style +++ b/data/magic-extended-art.mse-style/style @@ -234,17 +234,6 @@ card style: color: rgb(0,0,0) separator color: rgb(200,0,0) - pt box: - left: 271 - top: 461 - width: 81 - height: 42 - z index: 1 - visible: { card.pt != "" } - render style: image - mask: mask_pt.png - include file: magic-blends.mse-include/card-ptboxes - ############################# Copyright stuff illustrator: @@ -268,3 +257,22 @@ card style: name: MPlantin size: 6 color: { font_color() } + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt box + script: card.card_color + +extra card style: + pt box: + left: 271 + top: 461 + width: 81 + height: 42 + z index: 1 + visible: { card.pt != "" } + render style: image + mask: mask_pt.png + include file: magic-blends.mse-include/card-ptboxes diff --git a/data/magic-firepenguinmaster-flip.mse-style/style b/data/magic-firepenguinmaster-flip.mse-style/style index 4b417cba..44f079a2 100644 --- a/data/magic-firepenguinmaster-flip.mse-style/style +++ b/data/magic-firepenguinmaster-flip.mse-style/style @@ -119,9 +119,9 @@ card style: size: 20 color: rgb(0,0,0) casting cost: - left: 32 + left: 17 top : 150 - width: 10 + width: 25 height: 195 alignment: top right direction: vertical @@ -160,7 +160,7 @@ card style: casting cost 2: left: 334 top : 170 - width: 10 + width: 25 height: 170 alignment: top right direction: vertical @@ -335,16 +335,6 @@ card style: shadow color: rgb(0,0,0) shadow displacement x: 1 shadow displacement y: 1 - ptsymbols: - left: 24 - top: 340 - width: 19 - height: 103 - z index: 1 - visible: { card.power != "" or card.toughness != "" } - render style: image - choice images: - shieldsword: ptshieldsword.png power 2: z index: 4 left: 334 @@ -377,16 +367,6 @@ card style: shadow color: rgb(0,0,0) shadow displacement x: 1 shadow displacement y: 1 - ptsymbols 2: - left: 333 - top: 58 - width: 19 - height: 103 - z index: 1 - visible: { card.power_2 != "" or card.toughness_2 != "" } - render style: image - choice images: - shieldsword: ptshieldsword-2.png ############################# Copyright stuff illustrator: @@ -414,3 +394,36 @@ card style: name: MPlantin size: 7 color: { font_color() } + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt symbols + script: "shieldsword" +extra card field: + type: choice + name: pt symbols 2 + script: "shieldsword" + +extra card style: + pt symbols: + left: 24 + top: 340 + width: 19 + height: 103 + z index: 1 + visible: { card.power != "" or card.toughness != "" } + render style: image + choice images: + shieldsword: ptshieldsword.png + pt symbols 2: + left: 333 + top: 58 + width: 19 + height: 103 + z index: 1 + visible: { card.power_2 != "" or card.toughness_2 != "" } + render style: image + choice images: + shieldsword: ptshieldsword-2.png diff --git a/data/magic-firepenguinmaster.mse-style/style b/data/magic-firepenguinmaster.mse-style/style index e2329875..77a0d449 100644 --- a/data/magic-firepenguinmaster.mse-style/style +++ b/data/magic-firepenguinmaster.mse-style/style @@ -141,9 +141,9 @@ card style: size: 20 color: rgb(0,0,0) casting cost: - left: 35 + left: 18 top : 55 - width: 10 + width: 27 height: 250 direction: vertical alignment: top right @@ -271,16 +271,6 @@ card style: shadow color: rgb(0,0,0) shadow displacement x: 1 shadow displacement y: 1 - ptsymbols: - left: 25 - top: 362 - width: 19 - height: 103 - z index: 1 - visible: { card.power != "" or card.toughness != "" } - render style: image - choice images: - shieldsword: ptshieldsword.png ############################# Card sorting / numbering ############################# Copyright stuff @@ -311,3 +301,22 @@ card style: name: MPlantin size: 7 color: { font_color() } + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt symbols + script: "shieldsword" + +extra card style: + pt symbols: + left: 25 + top: 362 + width: 19 + height: 103 + z index: 1 + visible: { card.power != "" or card.toughness != "" } + render style: image + choice images: + shieldsword: ptshieldsword.png diff --git a/data/magic-firepenguinmasterpromo.mse-style/style b/data/magic-firepenguinmasterpromo.mse-style/style index 9a5135ed..e382e728 100644 --- a/data/magic-firepenguinmasterpromo.mse-style/style +++ b/data/magic-firepenguinmasterpromo.mse-style/style @@ -148,9 +148,9 @@ card style: size: 20 color: rgb(0,0,0) casting cost: - left: 25 + left: 18 top : 55 - width: 20 + width: 27 height: 250 direction: vertical alignment: top right @@ -270,17 +270,6 @@ card style: shadow displacement x: 1 shadow displacement y: 1 - ptsymbols: - left: 25 - top: 362 - width: 19 - height: 103 - z index: 1 - visible: { card.power != "" or card.toughness != "" } - render style: image - choice images: - shieldsword: ptshieldsword.png - ############################# Copyright stuff illustrator: @@ -315,3 +304,23 @@ card style: { if card.font_color = "white" then rgb(255,255,255) else if card.font_color = "black" then rgb(0,0,0) else rgb(0,0,0) } + + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt symbols + script: "shieldsword" + +extra card style: + pt symbols: + left: 25 + top: 362 + width: 19 + height: 103 + z index: 1 + visible: { card.power != "" or card.toughness != "" } + render style: image + choice images: + shieldsword: ptshieldsword.png diff --git a/data/magic-firepenguinmastersplit.mse-style/style b/data/magic-firepenguinmastersplit.mse-style/style index d90fdd46..f87a1420 100644 --- a/data/magic-firepenguinmastersplit.mse-style/style +++ b/data/magic-firepenguinmastersplit.mse-style/style @@ -163,9 +163,9 @@ card style: size: 13.85 color: rgb(0,0,0) casting cost: - left: 31.24 + left: 18.67 top : 45 - width: 6.93 + width: 19.5 height: 173.16 alignment: top right direction: vertical @@ -178,9 +178,9 @@ card style: padding top: 0 z index: 2 casting cost 2: - left: 284.73 + left: 272.16 top : 45 - width: 6.93 + width: 19.5 height: 173.16 alignment: top right direction: vertical @@ -412,26 +412,6 @@ card style: shadow color: rgb(0,0,0) shadow displacement x: 1 shadow displacement y: 1 - ptsymbols: - left: 23.32 - top: 256 - width: 13.16 - height: 71.34 - z index: 1 - visible: { card.power != "" or card.toughness != "" } - render style: image - choice images: - shieldsword: ptshieldsword.png - ptsymbols 2: - left: 276.81 - top: 256 - width: 13.16 - height: 71.34 - z index: 1 - visible: { card.power_2 != "" or card.toughness_2 != "" } - render style: image - choice images: - shieldsword: ptshieldsword.png ############################# Copyright stuff illustrator: @@ -484,3 +464,36 @@ card style: name: MPlantin size: 4.85 color: { font_color_2() } + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt symbols + script: "shieldsword" +extra card field: + type: choice + name: pt symbols 2 + script: "shieldsword" + +extra card style: + pt symbols: + left: 23.32 + top: 256 + width: 13.16 + height: 71.34 + z index: 1 + visible: { card.power != "" or card.toughness != "" } + render style: image + choice images: + shieldsword: ptshieldsword.png + pt symbols 2: + left: 276.81 + top: 256 + width: 13.16 + height: 71.34 + z index: 1 + visible: { card.power_2 != "" or card.toughness_2 != "" } + render style: image + choice images: + shieldsword: ptshieldsword.png diff --git a/data/magic-firepenguinmastertokens.mse-style/style b/data/magic-firepenguinmastertokens.mse-style/style index 2185ee61..67af1f54 100644 --- a/data/magic-firepenguinmastertokens.mse-style/style +++ b/data/magic-firepenguinmastertokens.mse-style/style @@ -144,9 +144,9 @@ card style: visible: script: styling.cardname_font == "Matrix" casting cost: - left: 25 + left: 18 top : 55 - width: 20 + width: 27 height: 250 alignment: top right direction: vertical @@ -301,17 +301,6 @@ card style: shadow displacement x: 1 shadow displacement y: 1 - ptsymbols: - left: 25 - top: 362 - width: 19 - height: 103 - z index: 1 - visible: { card.power != "" or card.toughness != "" } - render style: image - choice images: - shieldsword: ptshieldsword.png - ############################# Copyright stuff illustrator: @@ -340,3 +329,23 @@ card style: name: MPlantin size: 7 color: { font_color() } + + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt symbols + script: "shieldsword" + +extra card style: + pt symbols: + left: 25 + top: 362 + width: 19 + height: 103 + z index: 1 + visible: { card.power != "" or card.toughness != "" } + render style: image + choice images: + shieldsword: ptshieldsword.png diff --git a/data/magic-new-flip.mse-style/style b/data/magic-new-flip.mse-style/style index 7f38f165..5c55dc44 100644 --- a/data/magic-new-flip.mse-style/style +++ b/data/magic-new-flip.mse-style/style @@ -112,11 +112,9 @@ card style: ############################# Name line name: - left: - script: if card.card_symbol=="none" then 32 else 51 + left: {if card.card_symbol=="none" then 32 else 51} top : 30 - width: - script: if card.card_symbol=="none" then 246 else 227 + width: {if card.card_symbol=="none" then 246 else 227} height: 23 alignment: bottom shrink-overflow padding bottom: 0 @@ -171,8 +169,7 @@ card style: padding top: 0 card symbol: - left: - script: if card.card_symbol=="none" then 20 else 32 + left: {if card.card_symbol=="none" then 20 else 32} top : 31 height: 20 width: 14 @@ -338,30 +335,6 @@ card style: color: rgb(0,0,0) separator color: rgb(200,0,0) - ############################# PT, by Guinea Pig - ########### pt box 1 needs to be at 286/124 (captured at 285/123), pt box 2 at 17/342 (captured at 17/342) - pt box: - left: 286 - top: 123 - width: 70 - height: 38 - z index: 1 - visible: - script: card.pt != "" - render style: image - include file: magic-blends.mse-include/flip-ptboxes - - pt box 1b: - left: 17 - top: 342 - width: 70 - height: 38 - z index: 2 - visible: - script: card.pt_2 != "" - render style: image - include file: magic-blends.mse-include/flip-ptboxes2 - ############################# Card sorting / numbering ############################# Copyright stuff @@ -374,8 +347,7 @@ card style: font: name: Matrix size: 12 - color: - script: font_color() + color: { font_color() } copyright line: left: 26 @@ -386,5 +358,37 @@ card style: font: name: MPlantin size: 8 - color: - script: font_color() + color: { font_color() } + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt box + script: card.card_color + +extra card field: + type: choice + name: pt box 2 + script: card.card_color + +extra card style: + pt box: + left: 286 + top: 123 + width: 70 + height: 38 + z index: 1 + visible: { card.pt != "" } + render style: image + include file: magic-blends.mse-include/flip-ptboxes + + pt box 2: + left: 17 + top: 342 + width: 70 + height: 38 + z index: 2 + visible: { card.pt_2 != "" } + render style: image + include file: magic-blends.mse-include/flip-ptboxes2 diff --git a/data/magic-new-promo.mse-style/style b/data/magic-new-promo.mse-style/style index c1c6a77b..6e8fc77a 100644 --- a/data/magic-new-promo.mse-style/style +++ b/data/magic-new-promo.mse-style/style @@ -120,11 +120,9 @@ card style: ############################# Name line name: - left: - script: if card.card_symbol=="none" then 32 else 51 + left: { if card.card_symbol=="none" then 32 else 51 } top : 30 - width: - script: if card.card_symbol=="none" then 246 else 227 + width: { if card.card_symbol=="none" then 246 else 227 } height: 23 alignment: bottom shrink-overflow padding bottom: 0 @@ -148,8 +146,7 @@ card style: z index: 2 padding top: 0 card symbol: - left: - script: if card.card_symbol=="none" then 20 else 32 + left: { if card.card_symbol=="none" then 20 else 32 } top : 31 height: 20 width: 14 @@ -240,18 +237,6 @@ card style: color: rgb(0,0,0) separator color: rgb(200,0,0) - pt box: - left: 271 - top: 461 - width: 81 - height: 42 - z index: 1 - visible: - script: card.pt != "" - render style: image - mask: mask_pt.png - include file: magic-blends.mse-include/card-ptboxes - ############################# Card sorting / numbering ############################# Copyright stuff @@ -276,5 +261,23 @@ card style: font: name: MPlantin size: 8 - color: - script: font_color() + color: { font_color() } + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt box + script: card.card_color + +extra card style: + pt box: + left: 271 + top: 461 + width: 81 + height: 42 + z index: 1 + visible: { card.pt != "" } + render style: image + mask: mask_pt.png + include file: magic-blends.mse-include/card-ptboxes diff --git a/data/magic-new-split.mse-style/style b/data/magic-new-split.mse-style/style index 2cb92e82..dd29b9d8 100644 --- a/data/magic-new-split.mse-style/style +++ b/data/magic-new-split.mse-style/style @@ -357,26 +357,6 @@ card style: color: rgb(0,0,0) separator color: rgb(200,0,0) - pt box: - left: 194 - top: 326 - width: 56 - height: 29 - z index: 1 - visible: { card.pt != "" } - render style: image - include file: magic-blends.mse-include/card-ptboxes - - pt box 2: - left: 445 - top: 326 - width: 56 - height: 29 - z index: 1 - visible: { card.pt_2 != "" } - render style: image - include file: magic-blends.mse-include/card-ptboxes - ############################# Card sorting / numbering ############################# Copyright stuff @@ -423,3 +403,36 @@ card style: name: MPlantin size: 6 color: { font_color_2() } + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt box + script: card.card_color + +extra card field: + type: choice + name: pt box 2 + script: card.card_color_2 + +extra card style: + pt box: + left: 194 + top: 326 + width: 56 + height: 29 + z index: 1 + visible: { card.pt != "" } + render style: image + include file: magic-blends.mse-include/card-ptboxes + + pt box 2: + left: 445 + top: 326 + width: 56 + height: 29 + z index: 1 + visible: { card.pt_2 != "" } + render style: image + include file: magic-blends.mse-include/card-ptboxes diff --git a/data/magic-new.mse-style/style b/data/magic-new.mse-style/style index 83f1bb0c..7e72b6f7 100644 --- a/data/magic-new.mse-style/style +++ b/data/magic-new.mse-style/style @@ -92,6 +92,11 @@ styling field: choice: modern choice: old choice: diagonal T +styling field: + type: boolean + name: center short text + description: Center the text on cards with short rule text and no flavor text. + initial: yes styling style: artifact style: @@ -235,7 +240,13 @@ card style: then "magic-mana-large" else "magic-mana-small" size: 14 - alignment: middle left + alignment: + script: + if styling.center_short_text and + not contains(match:"\n", card.rule_text) and + card.flavor_text == "" + then "middle center" + else "middle left" z index: 2 padding left: 6 padding top: 2 @@ -269,16 +280,6 @@ card style: color: rgb(0,0,0) separator color: rgb(200,0,0) - pt box: - left: 271 - top: 461 - width: 81 - height: 42 - z index: 1 - visible: { card.pt != "" } - render style: image - include file: magic-blends.mse-include/card-ptboxes - ############################# Card sorting / numbering ############################# Copyright stuff @@ -304,3 +305,21 @@ card style: name: MPlantin size: 6.5 color: { font_color() } + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt box + script: card.card_color + +extra card style: + pt box: + left: 271 + top: 461 + width: 81 + height: 42 + z index: 1 + visible: { card.pt != "" } + render style: image + include file: magic-blends.mse-include/card-ptboxes diff --git a/data/magic-planeshifted.mse-style/style b/data/magic-planeshifted.mse-style/style index bd9051de..00b1b9ce 100644 --- a/data/magic-planeshifted.mse-style/style +++ b/data/magic-planeshifted.mse-style/style @@ -245,16 +245,6 @@ card style: shadow displacement y: 1 separator color: rgb(200,0,0) - pt box: - left: 271 - top: 461 - width: 81 - height: 42 - z index: 1 - visible: { card.pt != "" } - render style: image - include file: magic-blends.mse-include/card-ptboxes - ############################# Card sorting / numbering ############################# Copyright stuff @@ -280,3 +270,21 @@ card style: name: MPlantin size: 6.5 color: { font_color() } + +############################################################## Extra card fields + +extra card field: + type: choice + name: pt box + script: card.card_color + +extra card style: + pt box: + left: 271 + top: 461 + width: 81 + height: 42 + z index: 1 + visible: { card.pt != "" } + render style: image + include file: magic-blends.mse-include/card-ptboxes diff --git a/data/magic.mse-game/game b/data/magic.mse-game/game index ae87dcd8..98e43226 100644 --- a/data/magic.mse-game/game +++ b/data/magic.mse-game/game @@ -720,14 +720,6 @@ card field: type: text name: toughness icon: stats/toughness.png -#needed for FPM temps -card field: - type: choice - name: ptsymbols - choice: shieldsword - editable: false - save value: false - show statistics: false card field: type: text name: pt @@ -747,15 +739,6 @@ card field: description: Power/toughness show statistics: false -card field: # box for power/toughness - type: choice - name: pt box - include file: magic-blends.mse-include/card-colors - script: card.card_color - editable: false - save value: false - show statistics: false - ############################# Card sorting / numbering card field: type: text @@ -920,14 +903,6 @@ card field: name: toughness 2 icon: stats/toughness.png show statistics: false -#needed for FPM temps -card field: - type: choice - name: ptsymbols 2 - choice: shieldsword - editable: false - save value: false - show statistics: false card field: type: text name: pt 2 @@ -943,23 +918,6 @@ card field: card list width: 50 card list name: P/T2 show statistics: false -card field: - type: choice - name: pt box 2 - include file: magic-blends.mse-include/card-colors - script: card.card_color_2 - editable: false - save value: false - show statistics: false -card field: - # Another pt box witht the same value as pt box 1 - type: choice - name: pt box 1b - include file: magic-blends.mse-include/card-colors - script: card.card_color - editable: false - save value: false - show statistics: false card field: type: text name: illustrator 2 diff --git a/src/render/text/font.cpp b/src/render/text/font.cpp index 87e52cc2..64e76a61 100644 --- a/src/render/text/font.cpp +++ b/src/render/text/font.cpp @@ -33,14 +33,20 @@ void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector& dc.SetFont(*font, scale); // find sizes & breaks double prev_width = 0; + size_t line_start = start; // start of the current line for (size_t i = start ; i < end ; ++i) { Char c = content.GetChar(i - this->start); - RealSize s = dc.GetTextExtent(content.substr(start - this->start, i - start + 1)); - out.push_back(CharInfo(RealSize(s.width - prev_width, s.height), - c == _('\n') ? break_style : - c == _(' ') ? BREAK_SOFT : BREAK_MAYBE - )); - prev_width = s.width; + if (c == _('\n')) { + out.push_back(CharInfo(RealSize(0, dc.GetCharHeight()), break_style)); + line_start = i + 1; + prev_width = 0; + } else { + RealSize s = dc.GetTextExtent(content.substr(line_start - this->start, i - line_start + 1)); + out.push_back(CharInfo(RealSize(s.width - prev_width, s.height), + c == _(' ') ? BREAK_SOFT : BREAK_MAYBE + )); + prev_width = s.width; + } } } diff --git a/src/util/index_map.hpp b/src/util/index_map.hpp index 03504d6b..9b90db30 100644 --- a/src/util/index_map.hpp +++ b/src/util/index_map.hpp @@ -44,7 +44,11 @@ class IndexMap : private vector { /// Initialize this map with default values given a list of keys /** has no effect if already initialized with the given keys */ bool init(const vector& keys) { - if (this->size() == keys.size() && (this->empty() || get_key(this->front()) == keys.front())) return false; + if (!this->empty() && (keys.empty() || get_key(this->front()) != keys.front())) { + // switch to different keys + clear(); + } + if (this->size() == keys.size()) return false; this->reserve(keys.size()); for(typename vector::const_iterator it = keys.begin() ; it != keys.end() ; ++it) { const Key& key = *it;