Card list colors are determined by a script instead of card_list_colors of a choice field (although that is still the default)

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@454 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-06-30 18:23:38 +00:00
parent 04f589637b
commit d5c27a4842
7 changed files with 47 additions and 36 deletions
+22 -1
View File
@@ -8,6 +8,7 @@
#include <data/game.hpp>
#include <data/field.hpp>
#include <data/field/choice.hpp>
#include <data/keyword.hpp>
#include <data/statistics.hpp>
#include <data/pack.hpp>
@@ -46,6 +47,7 @@ IMPLEMENT_REFLECTION(Game) {
}
REFLECT_NO_SCRIPT(default_set_style);
REFLECT_NO_SCRIPT(card_fields);
REFLECT_NO_SCRIPT(card_list_color_script);
REFLECT_NO_SCRIPT(statistics_dimensions);
REFLECT_NO_SCRIPT(statistics_categories);
REFLECT_NO_SCRIPT(pack_types);
@@ -79,7 +81,26 @@ void Game::validate(Version v) {
}
}
void addStatsDimensionsForFields();
void Game::initCardListColorScript() {
if (card_list_color_script) return; // already done
// find a field with choice_colors_cardlist
FOR_EACH(s, card_fields) {
ChoiceFieldP cf = dynamic_pointer_cast<ChoiceField>(s);
if (cf && !cf->choice_colors_cardlist.empty()) {
// found the field to use
// initialize script: field.colors[card.field-name] or else rgb(0,0,0)
Script& s = card_list_color_script.getScript();
s.addInstruction(I_PUSH_CONST, to_script(&cf->choice_colors_cardlist));
s.addInstruction(I_GET_VAR, string_to_variable(_("card")));
s.addInstruction(I_MEMBER_C, cf->name);
s.addInstruction(I_BINARY, I_MEMBER);
s.addInstruction(I_PUSH_CONST, to_script(Color(0,0,0)));
s.addInstruction(I_BINARY, I_OR_ELSE);
s.addInstruction(I_RET);
return;
}
}
}
// special behaviour of reading/writing GamePs: only read/write the name