From 61550b9e44d4a3889bb0b14dc386c48f2ebdca80 Mon Sep 17 00:00:00 2001 From: twanvl Date: Sat, 21 Apr 2007 20:41:44 +0000 Subject: [PATCH] implemented justification; fixed initialization bug in item_list; commented out statistics fields for debugging and added 'match' for all keywords in magic.mse-game git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@279 0fc631ac-6414-0410-93d0-97cfa31319b6 --- data/magic.mse-game/game | 61 ++++++++++++++++++++++++----------- src/gui/control/item_list.cpp | 2 ++ src/render/text/viewer.cpp | 20 ++++++++---- src/render/text/viewer.hpp | 3 +- src/util/alignment.cpp | 16 ++++----- 5 files changed, 68 insertions(+), 34 deletions(-) diff --git a/data/magic.mse-game/game b/data/magic.mse-game/game index 73dd6c08..a1405c2a 100644 --- a/data/magic.mse-game/game +++ b/data/magic.mse-game/game @@ -778,28 +778,28 @@ statistics dimension: numeric: true icon: stats/colored_casting_cost.png -statistics dimension: - name: power2 - script: card.power - numeric: true - icon: stats/power.png +#statistics dimension: +# name: power2 +# script: card.power +# numeric: true +# icon: stats/power.png -statistics dimension: - name: toughness2 - script: card.toughness - numeric: true - icon: stats/toughness.png +#statistics dimension: +# name: toughness2 +# script: card.toughness +# numeric: true +# icon: stats/toughness.png -statistics category: - name: color / rarity - dimension: card_color - dimension: rarity +#statistics category: +# name: color / rarity +# dimension: card_color +# dimension: rarity -statistics category: - name: power / toughness - type: scatter - dimension: power2 - dimension: toughness2 +#statistics category: +# name: power / toughness +# type: scatter +# dimension: power2 +# dimension: toughness2 #statistics field: # name: creature type @@ -938,18 +938,22 @@ keyword parameter type: keyword: keyword: Flying + match: Flying mode: core reminder: This creature can’t be blocked except by creatures with flying. keyword: keyword: Haste + match: Haste mode: core reminder: This creature can attack and tap the turn it comes under your control. keyword: keyword: Fear + match: Fear mode: core reminder: This creature can’t be blocked except by artifact creatures and/or black creatures. keyword: keyword: First strike + match: First strike mode: core reminder: This creature deals combat damage before creatures without first strike. keyword: @@ -964,10 +968,12 @@ keyword: reminder: {param1}, Discard this card: Draw a card. keyword: keyword: Trample + match: Trample mode: core reminder: If this creature would deal enough combat damage to its blockers to destroy them, you may have it deal the rest of its damage to defending player. keyword: keyword: Banding + match: Banding mode: old reminder: When declaring attackers or blockers this creature may group with others creatures with banding and one creature without banding. When damage is dealt, you decide where damage is dealt. keyword: @@ -977,10 +983,12 @@ keyword: reminder: Whenever this creature becomes blocked, it gets +{param1}/+{param1} until end of turn for each creature blocking it beyond the first. keyword: keyword: Vigilance + match: Vigilance mode: core reminder: Attacking doesn’t cause this creature to tap. keyword: keyword: Defender + match: Defender mode: core reminder: This creature can’t attack. keyword: @@ -990,10 +998,12 @@ keyword: reminder: At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you pay {param1} for each age counter on it. keyword: keyword: Horsemanship + match: Horsemanship mode: old reminder: This creature can’t be blocked except by creatures with horsemanship. keyword: keyword: Phasing + match: Phasing mode: old reminder: At the beginning of your upkeep, put this and any cards attached to it in the phased-out zone. If this is already in the phased-out zone, return it and any card attached to it to play. If there were counters on this card when it phased out, put that many counters on it when it returns to play. This ability does not cause comes-into-play or leaves play abilities to trigger. keyword: @@ -1003,6 +1013,7 @@ keyword: reminder: Whenever a creature without flanking blocks this creature, the blocking creature gets -{param1}/-{param1} until end of turn. keyword: keyword: Shadow + match: Shadow mode: core reminder: This creature can block or be blocked by only creatures with shadow. keyword: @@ -1012,6 +1023,7 @@ keyword: reminder: You may pay {param1} in addition to any other costs as you play this spell. If you do, put ~ into your hand instead of your graveyard as part of its resolution. keyword: keyword: Echo + match: Echo mode: expert reminder: At the beginning of your next upkeep after this permanent comes under your control, sacrifice it unless you pay its mana cost. keyword: @@ -1056,14 +1068,17 @@ keyword: reminder: As this card comes into play, put {english_number(param1)} +1/+1 counter(s) on it for each creature that shares a type with this that you reveal in your hand. keyword: keyword: Double strike + match: Double strike mode: expert reminder: This creature deals both first-strike and regular combat damage. keyword: keyword: Provoke + match: Provoke mode: expert reminder: When this attacks, you may have target creature defending player controls untap and block it if able. keyword: keyword: Storm + match: Storm mode: expert reminder: When you play this spell, copy it for each spell played before it this turn. You may choose new targets for the copies. keyword: @@ -1098,6 +1113,7 @@ keyword: reminder: Look at the top {english_number_multiple(param1)} card(s) of your library. Put any number of them on the bottom of your library in any order and the rest on top of your library in any order. keyword: keyword: Sunburst + match: Sunburst mode: expert reminder: This comes into play with a +1/+1 counter on it for each color of mana used to pay its cost. If it is not a creature, use charge counters instead. keyword: @@ -1127,10 +1143,12 @@ keyword: reminder: When this is put into a graveyard from play, you may return target Spirit card with converted mana cost {param1} or less from you graveyard to your hand. keyword: keyword: Epic + match: Epic mode: expert reminder: For the rest of the game, you can’t play spells. At the beginning of each of your upkeeps, copy this spell except for its epic ability. If the spell has any targets, you may choose new targets for the copy. keyword: keyword: Convoke + match: Convoke mode: expert reminder: Each creature you tap while playing this spell reduces its cost by 1 or by one mana of that creature’s color. keyword: @@ -1140,6 +1158,7 @@ keyword: reminder: {param1}, Discard this card: Search your library for a card with the same converted mana cost as this card, reveal it, and put it into your hand. Then shuffle your library. Play only as a sorcery. keyword: keyword: Haunt + match: Haunt mode: expert reminder: When this card is put into a graveyard from play, remove it from the game haunting target creature. keyword: @@ -1154,18 +1173,22 @@ keyword: reminder: When you play this spell, copy it for each time you paid its replicate cost. You may choose new targets for the copies. keyword: keyword: Legendary Landwalk + match: Legendary Landwalk mode: core reminder: This creature is unblockable as long as defending player controls a Legendary land. keyword: keyword: Non-basic Landwalk + match: Non-basic Landwalk mode: core reminder: This creature is unblockable as long as defending player controls a non-basic land. keyword: keyword: Snow-covered Landwalk + match: Snow-covered Landwalk mode: core reminder: This creature is unblockable as long as defending player controls a Snow-covered land. keyword: keyword: Denimwalk + match: Denimwalk mode: core reminder: If defending player is wearing any clothing made of denim, this creature is unblockable. keyword: diff --git a/src/gui/control/item_list.cpp b/src/gui/control/item_list.cpp index 0ea08d7c..bccd890a 100644 --- a/src/gui/control/item_list.cpp +++ b/src/gui/control/item_list.cpp @@ -13,6 +13,8 @@ ItemList::ItemList(Window* parent, int id, long additional_style) : wxListView(parent, id, wxDefaultPosition, wxDefaultSize, additional_style | wxLC_REPORT | wxLC_VIRTUAL | wxLC_SINGLE_SEL) + , selected_item_pos(-1) + , sort_by_column(-1), sort_ascending(true) { // create image list wxImageList* il = new wxImageList(18,14); diff --git a/src/render/text/viewer.cpp b/src/render/text/viewer.cpp index 423b15ba..e8ad1329 100644 --- a/src/render/text/viewer.cpp +++ b/src/render/text/viewer.cpp @@ -75,8 +75,16 @@ void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) { // Draw the text, line by line FOR_EACH(l, lines) { if (l.visible(dc)) { - RealRect rect(l.positions.front(), l.top, l.width(), l.line_height); - elements.draw(dc, scale, rect, &*l.positions.begin(), what, l.start, l.end()); + if (justifying) { + // Draw characters separatly + for (size_t i = 0 ; i < l.positions.size() - 1 ; ++i) { + RealRect rect(l.positions[i], l.top, l.positions[i+1] - l.positions[i] , l.line_height); + elements.draw(dc, scale, rect, &l.positions[i], what, l.start + i, l.start + i + 1); + } + } else { + RealRect rect(l.positions.front(), l.top, l.width(), l.line_height); + elements.draw(dc, scale, rect, &*l.positions.begin(), what, l.start, l.end()); + } } } } @@ -524,7 +532,7 @@ void TextViewer::alignLines(RotatedDC& dc, const vector& chars, const if ((style.alignment & ALIGN_JUSTIFY) || (style.alignment & ALIGN_JUSTIFY_OVERFLOW && width > s.width)) { // justify text -// justifying = true; + justifying = true; double hdelta = s.width - width; // amount of space to distribute int count = (int)l.positions.size() - 1; // distribute it among this many characters if (count == 0) count = 1; // prevent div by 0 @@ -532,9 +540,9 @@ void TextViewer::alignLines(RotatedDC& dc, const vector& chars, const FOR_EACH(c, l.positions) { c += hdelta * i++ / count; } - } else if (style.alignment & ALIGN_JUSTIFY) { + } else if (style.alignment & ALIGN_JUSTIFY_WORDS) { // justify text, by words -// justifying = true; + justifying = true; double hdelta = s.width - width; // amount of space to distribute int count = 0; // distribute it among this many words for (size_t k = l.start + 1 ; k < l.end() - 1 ; ++k) { @@ -548,7 +556,7 @@ void TextViewer::alignLines(RotatedDC& dc, const vector& chars, const } } else { // simple alignment -// justifying = false; + justifying = false; double hdelta = align_delta_x(style.alignment, s.width, width); FOR_EACH(c, l.positions) { c += hdelta; diff --git a/src/render/text/viewer.hpp b/src/render/text/viewer.hpp index b1a0a885..c631b95a 100644 --- a/src/render/text/viewer.hpp +++ b/src/render/text/viewer.hpp @@ -117,7 +117,8 @@ class TextViewer { private: // --------------------------------------------------- : More drawing - double scale; /// < Scale when drawing + double scale; ///< Scale when drawing + bool justifying; ///< Is text justified? // --------------------------------------------------- : Elements TextElements elements; ///< The elements of the prepared text diff --git a/src/util/alignment.cpp b/src/util/alignment.cpp index f37c80ab..9cc13231 100644 --- a/src/util/alignment.cpp +++ b/src/util/alignment.cpp @@ -36,15 +36,15 @@ RealPoint align_in_rect(Alignment align, const RealSize& to_align, const RealRec /// Convert a String to an Alignment Alignment from_string(const String& s) { int al = ALIGN_TOP_LEFT; - if (s.find(_("left")) !=String::npos) al = ALIGN_LEFT | (al & ALIGN_VERTICAL); - if (s.find(_("center")) !=String::npos) al = ALIGN_CENTER | (al & ALIGN_VERTICAL); - if (s.find(_("right")) !=String::npos) al = ALIGN_RIGHT | (al & ALIGN_VERTICAL); - if (s.find(_("justify")) !=String::npos) al = ALIGN_JUSTIFY | (al & ALIGN_VERTICAL); - if (s.find(_("justify-words")) !=String::npos) al = ALIGN_JUSTIFY_WORDS | (al & ALIGN_VERTICAL); + if (s.find(_("left")) !=String::npos) al = ALIGN_LEFT | (al & ~ALIGN_HORIZONTAL); + if (s.find(_("center")) !=String::npos) al = ALIGN_CENTER | (al & ~ALIGN_HORIZONTAL); + if (s.find(_("right")) !=String::npos) al = ALIGN_RIGHT | (al & ~ALIGN_HORIZONTAL); + if (s.find(_("justify")) !=String::npos) al = ALIGN_JUSTIFY | (al & ~ALIGN_HORIZONTAL); + if (s.find(_("justify-words")) !=String::npos) al = ALIGN_JUSTIFY_WORDS | (al & ~ALIGN_HORIZONTAL); if (s.find(_("shrink-overflow"))!=String::npos) al = ALIGN_JUSTIFY_OVERFLOW | (al & ~ALIGN_JUSTIFY_OVERFLOW); - if (s.find(_("top")) !=String::npos) al = ALIGN_TOP | (al & ALIGN_HORIZONTAL); - if (s.find(_("middle")) !=String::npos) al = ALIGN_MIDDLE | (al & ALIGN_HORIZONTAL); - if (s.find(_("bottom")) !=String::npos) al = ALIGN_BOTTOM | (al & ALIGN_HORIZONTAL); + if (s.find(_("top")) !=String::npos) al = ALIGN_TOP | (al & ~ALIGN_VERTICAL); + if (s.find(_("middle")) !=String::npos) al = ALIGN_MIDDLE | (al & ~ALIGN_VERTICAL); + if (s.find(_("bottom")) !=String::npos) al = ALIGN_BOTTOM | (al & ~ALIGN_VERTICAL); if (s.find(_("stretch")) !=String::npos) al = ALIGN_STRETCH; return static_cast(al); }