Added support for custom colors for graphs;

Moved 'choice colors' from styel to field, split into 'choice colors' and 'choice colors cardlist';
Added support for pie graphs (no gui to use them, though);
Fixed bugs caused by selecting a card before the set was changed on all panels.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@336 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-05-11 14:10:29 +00:00
parent f9eade95eb
commit 3b6743b110
33 changed files with 634 additions and 186 deletions
+11 -12
View File
@@ -176,6 +176,7 @@ void CardListBase::rebuild() {
column_fields.clear();
selected_item_pos = -1;
onRebuild();
if (!set) return;
// determine column order
map<int,FieldP> new_column_fields;
FOR_EACH(f, set->game->card_fields) {
@@ -197,7 +198,7 @@ void CardListBase::rebuild() {
column_fields.push_back(f.second);
}
// find field that determines color
color_style = findColorStyle();
color_field = findColorField();
// determine sort settings
GameSettings& gs = settings.gameSettingsFor(*set->game);
sort_ascending = gs.sort_cards_ascending;
@@ -216,18 +217,16 @@ void CardListBase::rebuild() {
++i;
}
refreshList();
// select a card if possible
selectItemPos(0, true);
}
ChoiceStyleP CardListBase::findColorStyle() {
FOR_EACH(s, set->stylesheet->card_style) {
ChoiceStyleP cs = dynamic_pointer_cast<ChoiceStyle>(s);
if (cs && cs->colors_card_list) {
return cs;
ChoiceFieldP CardListBase::findColorField() {
FOR_EACH(s, set->game->card_fields) {
ChoiceFieldP cf = dynamic_pointer_cast<ChoiceField>(s);
if (cf && !cf->choice_colors_cardlist.empty()) {
return cf;
}
}
return ChoiceStyleP();
return ChoiceFieldP();
}
// ----------------------------------------------------------------------------- : CardListBase : Columns
@@ -270,10 +269,10 @@ int CardListBase::OnGetItemImage(long pos) const {
}
wxListItemAttr* CardListBase::OnGetItemAttr(long pos) const {
if (!color_style) return nullptr;
ChoiceValueP val = static_pointer_cast<ChoiceValue>( getCard(pos)->data[color_style->fieldP]);
if (!color_field) return nullptr;
ChoiceValueP val = static_pointer_cast<ChoiceValue>( getCard(pos)->data[color_field]);
assert(val);
item_attr.SetTextColour(color_style->choice_colors[val->value()]); // if it doesn't exist we get black
item_attr.SetTextColour(color_field->choice_colors_cardlist[val->value()]); // if it doesn't exist we get black
return &item_attr;
}