Commit da864989 authored by twanvl's avatar twanvl

implemented justification;

fixed initialization bug in item_list;
commented out statistics fields for debugging and added 'match' for all keywords in magic.mse-game
parent 37398185
...@@ -778,28 +778,28 @@ statistics dimension: ...@@ -778,28 +778,28 @@ statistics dimension:
numeric: true numeric: true
icon: stats/colored_casting_cost.png icon: stats/colored_casting_cost.png
statistics dimension: #statistics dimension:
name: power2 # name: power2
script: card.power # script: card.power
numeric: true # numeric: true
icon: stats/power.png # icon: stats/power.png
statistics dimension: #statistics dimension:
name: toughness2 # name: toughness2
script: card.toughness # script: card.toughness
numeric: true # numeric: true
icon: stats/toughness.png # icon: stats/toughness.png
statistics category: #statistics category:
name: color / rarity # name: color / rarity
dimension: card_color # dimension: card_color
dimension: rarity # dimension: rarity
statistics category: #statistics category:
name: power / toughness # name: power / toughness
type: scatter # type: scatter
dimension: power2 # dimension: power2
dimension: toughness2 # dimension: toughness2
#statistics field: #statistics field:
# name: creature type # name: creature type
...@@ -938,18 +938,22 @@ keyword parameter type: ...@@ -938,18 +938,22 @@ keyword parameter type:
keyword: keyword:
keyword: Flying keyword: Flying
match: Flying
mode: core mode: core
reminder: This creature can’t be blocked except by creatures with flying. reminder: This creature can’t be blocked except by creatures with flying.
keyword: keyword:
keyword: Haste keyword: Haste
match: Haste
mode: core mode: core
reminder: This creature can attack and tap the turn it comes under your control. reminder: This creature can attack and tap the turn it comes under your control.
keyword: keyword:
keyword: Fear keyword: Fear
match: Fear
mode: core mode: core
reminder: This creature can’t be blocked except by artifact creatures and/or black creatures. reminder: This creature can’t be blocked except by artifact creatures and/or black creatures.
keyword: keyword:
keyword: First strike keyword: First strike
match: First strike
mode: core mode: core
reminder: This creature deals combat damage before creatures without first strike. reminder: This creature deals combat damage before creatures without first strike.
keyword: keyword:
...@@ -964,10 +968,12 @@ keyword: ...@@ -964,10 +968,12 @@ keyword:
reminder: {param1}, Discard this card: Draw a card. reminder: {param1}, Discard this card: Draw a card.
keyword: keyword:
keyword: Trample keyword: Trample
match: Trample
mode: core 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. 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:
keyword: Banding keyword: Banding
match: Banding
mode: old 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. 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: keyword:
...@@ -977,10 +983,12 @@ 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. reminder: Whenever this creature becomes blocked, it gets +{param1}/+{param1} until end of turn for each creature blocking it beyond the first.
keyword: keyword:
keyword: Vigilance keyword: Vigilance
match: Vigilance
mode: core mode: core
reminder: Attacking doesn’t cause this creature to tap. reminder: Attacking doesn’t cause this creature to tap.
keyword: keyword:
keyword: Defender keyword: Defender
match: Defender
mode: core mode: core
reminder: This creature can’t attack. reminder: This creature can’t attack.
keyword: keyword:
...@@ -990,10 +998,12 @@ 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. 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:
keyword: Horsemanship keyword: Horsemanship
match: Horsemanship
mode: old mode: old
reminder: This creature can’t be blocked except by creatures with horsemanship. reminder: This creature can’t be blocked except by creatures with horsemanship.
keyword: keyword:
keyword: Phasing keyword: Phasing
match: Phasing
mode: old 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. 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: keyword:
...@@ -1003,6 +1013,7 @@ 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. reminder: Whenever a creature without flanking blocks this creature, the blocking creature gets -{param1}/-{param1} until end of turn.
keyword: keyword:
keyword: Shadow keyword: Shadow
match: Shadow
mode: core mode: core
reminder: This creature can block or be blocked by only creatures with shadow. reminder: This creature can block or be blocked by only creatures with shadow.
keyword: keyword:
...@@ -1012,6 +1023,7 @@ 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. 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:
keyword: Echo keyword: Echo
match: Echo
mode: expert 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. reminder: At the beginning of your next upkeep after this permanent comes under your control, sacrifice it unless you pay its mana cost.
keyword: keyword:
...@@ -1056,14 +1068,17 @@ 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. 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:
keyword: Double strike keyword: Double strike
match: Double strike
mode: expert mode: expert
reminder: This creature deals both first-strike and regular combat damage. reminder: This creature deals both first-strike and regular combat damage.
keyword: keyword:
keyword: Provoke keyword: Provoke
match: Provoke
mode: expert mode: expert
reminder: When this attacks, you may have target creature defending player controls untap and block it if able. reminder: When this attacks, you may have target creature defending player controls untap and block it if able.
keyword: keyword:
keyword: Storm keyword: Storm
match: Storm
mode: expert 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. 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: keyword:
...@@ -1098,6 +1113,7 @@ 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. 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:
keyword: Sunburst keyword: Sunburst
match: Sunburst
mode: expert 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. 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: keyword:
...@@ -1127,10 +1143,12 @@ 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. 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:
keyword: Epic keyword: Epic
match: Epic
mode: expert 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. 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:
keyword: Convoke keyword: Convoke
match: Convoke
mode: expert mode: expert
reminder: Each creature you tap while playing this spell reduces its cost by <sym>1</sym> or by one mana of that creature’s color. reminder: Each creature you tap while playing this spell reduces its cost by <sym>1</sym> or by one mana of that creature’s color.
keyword: keyword:
...@@ -1140,6 +1158,7 @@ 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. 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:
keyword: Haunt keyword: Haunt
match: Haunt
mode: expert mode: expert
reminder: When this card is put into a graveyard from play, remove it from the game haunting target creature. reminder: When this card is put into a graveyard from play, remove it from the game haunting target creature.
keyword: keyword:
...@@ -1154,18 +1173,22 @@ 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. 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:
keyword: Legendary Landwalk keyword: Legendary Landwalk
match: Legendary Landwalk
mode: core mode: core
reminder: This creature is unblockable as long as defending player controls a Legendary land. reminder: This creature is unblockable as long as defending player controls a Legendary land.
keyword: keyword:
keyword: Non-basic Landwalk keyword: Non-basic Landwalk
match: Non-basic Landwalk
mode: core mode: core
reminder: This creature is unblockable as long as defending player controls a non-basic land. reminder: This creature is unblockable as long as defending player controls a non-basic land.
keyword: keyword:
keyword: Snow-covered Landwalk keyword: Snow-covered Landwalk
match: Snow-covered Landwalk
mode: core mode: core
reminder: This creature is unblockable as long as defending player controls a Snow-covered land. reminder: This creature is unblockable as long as defending player controls a Snow-covered land.
keyword: keyword:
keyword: Denimwalk keyword: Denimwalk
match: Denimwalk
mode: core mode: core
reminder: If defending player is wearing any clothing made of denim, this creature is unblockable. reminder: If defending player is wearing any clothing made of denim, this creature is unblockable.
keyword: keyword:
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
ItemList::ItemList(Window* parent, int id, long additional_style) ItemList::ItemList(Window* parent, int id, long additional_style)
: wxListView(parent, id, wxDefaultPosition, wxDefaultSize, additional_style | wxLC_REPORT | wxLC_VIRTUAL | wxLC_SINGLE_SEL) : 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 // create image list
wxImageList* il = new wxImageList(18,14); wxImageList* il = new wxImageList(18,14);
......
...@@ -75,10 +75,18 @@ void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) { ...@@ -75,10 +75,18 @@ void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) {
// Draw the text, line by line // Draw the text, line by line
FOR_EACH(l, lines) { FOR_EACH(l, lines) {
if (l.visible(dc)) { if (l.visible(dc)) {
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); 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()); elements.draw(dc, scale, rect, &*l.positions.begin(), what, l.start, l.end());
} }
} }
}
} }
void TextViewer::drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end) { void TextViewer::drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end) {
...@@ -524,7 +532,7 @@ void TextViewer::alignLines(RotatedDC& dc, const vector<CharInfo>& chars, const ...@@ -524,7 +532,7 @@ void TextViewer::alignLines(RotatedDC& dc, const vector<CharInfo>& chars, const
if ((style.alignment & ALIGN_JUSTIFY) || if ((style.alignment & ALIGN_JUSTIFY) ||
(style.alignment & ALIGN_JUSTIFY_OVERFLOW && width > s.width)) { (style.alignment & ALIGN_JUSTIFY_OVERFLOW && width > s.width)) {
// justify text // justify text
// justifying = true; justifying = true;
double hdelta = s.width - width; // amount of space to distribute double hdelta = s.width - width; // amount of space to distribute
int count = (int)l.positions.size() - 1; // distribute it among this many characters int count = (int)l.positions.size() - 1; // distribute it among this many characters
if (count == 0) count = 1; // prevent div by 0 if (count == 0) count = 1; // prevent div by 0
...@@ -532,9 +540,9 @@ void TextViewer::alignLines(RotatedDC& dc, const vector<CharInfo>& chars, const ...@@ -532,9 +540,9 @@ void TextViewer::alignLines(RotatedDC& dc, const vector<CharInfo>& chars, const
FOR_EACH(c, l.positions) { FOR_EACH(c, l.positions) {
c += hdelta * i++ / count; c += hdelta * i++ / count;
} }
} else if (style.alignment & ALIGN_JUSTIFY) { } else if (style.alignment & ALIGN_JUSTIFY_WORDS) {
// justify text, by words // justify text, by words
// justifying = true; justifying = true;
double hdelta = s.width - width; // amount of space to distribute double hdelta = s.width - width; // amount of space to distribute
int count = 0; // distribute it among this many words int count = 0; // distribute it among this many words
for (size_t k = l.start + 1 ; k < l.end() - 1 ; ++k) { for (size_t k = l.start + 1 ; k < l.end() - 1 ; ++k) {
...@@ -548,7 +556,7 @@ void TextViewer::alignLines(RotatedDC& dc, const vector<CharInfo>& chars, const ...@@ -548,7 +556,7 @@ void TextViewer::alignLines(RotatedDC& dc, const vector<CharInfo>& chars, const
} }
} else { } else {
// simple alignment // simple alignment
// justifying = false; justifying = false;
double hdelta = align_delta_x(style.alignment, s.width, width); double hdelta = align_delta_x(style.alignment, s.width, width);
FOR_EACH(c, l.positions) { FOR_EACH(c, l.positions) {
c += hdelta; c += hdelta;
......
...@@ -117,7 +117,8 @@ class TextViewer { ...@@ -117,7 +117,8 @@ class TextViewer {
private: private:
// --------------------------------------------------- : More drawing // --------------------------------------------------- : More drawing
double scale; /// < Scale when drawing double scale; ///< Scale when drawing
bool justifying; ///< Is text justified?
// --------------------------------------------------- : Elements // --------------------------------------------------- : Elements
TextElements elements; ///< The elements of the prepared text TextElements elements; ///< The elements of the prepared text
......
...@@ -36,15 +36,15 @@ RealPoint align_in_rect(Alignment align, const RealSize& to_align, const RealRec ...@@ -36,15 +36,15 @@ RealPoint align_in_rect(Alignment align, const RealSize& to_align, const RealRec
/// Convert a String to an Alignment /// Convert a String to an Alignment
Alignment from_string(const String& s) { Alignment from_string(const String& s) {
int al = ALIGN_TOP_LEFT; int al = ALIGN_TOP_LEFT;
if (s.find(_("left")) !=String::npos) al = ALIGN_LEFT | (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_VERTICAL); if (s.find(_("center")) !=String::npos) al = ALIGN_CENTER | (al & ~ALIGN_HORIZONTAL);
if (s.find(_("right")) !=String::npos) al = ALIGN_RIGHT | (al & ALIGN_VERTICAL); if (s.find(_("right")) !=String::npos) al = ALIGN_RIGHT | (al & ~ALIGN_HORIZONTAL);
if (s.find(_("justify")) !=String::npos) al = ALIGN_JUSTIFY | (al & ALIGN_VERTICAL); 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_VERTICAL); 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(_("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(_("top")) !=String::npos) al = ALIGN_TOP | (al & ~ALIGN_VERTICAL);
if (s.find(_("middle")) !=String::npos) al = ALIGN_MIDDLE | (al & ALIGN_HORIZONTAL); if (s.find(_("middle")) !=String::npos) al = ALIGN_MIDDLE | (al & ~ALIGN_VERTICAL);
if (s.find(_("bottom")) !=String::npos) al = ALIGN_BOTTOM | (al & ALIGN_HORIZONTAL); if (s.find(_("bottom")) !=String::npos) al = ALIGN_BOTTOM | (al & ~ALIGN_VERTICAL);
if (s.find(_("stretch")) !=String::npos) al = ALIGN_STRETCH; if (s.find(_("stretch")) !=String::npos) al = ALIGN_STRETCH;
return static_cast<Alignment>(al); return static_cast<Alignment>(al);
} }
......
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