mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
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:
+22
-1
@@ -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
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ class Game : public Packaged {
|
||||
vector<FieldP> set_fields; ///< Fields for set information
|
||||
IndexMap<FieldP,StyleP> default_set_style; ///< Default style for the set fields, because it is often the same
|
||||
vector<FieldP> card_fields; ///< Fields on each card
|
||||
OptionalScript card_list_color_script; ///< Script that determines the color of items in the card list
|
||||
vector<StatsDimensionP> statistics_dimensions; ///< (Additional) statistics dimensions
|
||||
vector<StatsCategoryP> statistics_categories; ///< (Additional) statistics categories
|
||||
vector<PackTypeP> pack_types; ///< Types of random card packs to generate
|
||||
@@ -59,6 +60,9 @@ class Game : public Packaged {
|
||||
/// Is this Magic the Gathering?
|
||||
bool isMagic() const;
|
||||
|
||||
/// Initialize card_list_color_script
|
||||
void initCardListColorScript();
|
||||
|
||||
static String typeNameStatic();
|
||||
virtual String typeName() const;
|
||||
|
||||
|
||||
+10
-8
@@ -14,6 +14,8 @@ DECLARE_TYPEOF_COLLECTION(String);
|
||||
DECLARE_TYPEOF_COLLECTION(StatsDimensionP);
|
||||
DECLARE_TYPEOF_COLLECTION(ChoiceField::ChoiceP);
|
||||
|
||||
extern ScriptValueP script_primary_choice;
|
||||
|
||||
// ----------------------------------------------------------------------------- : Statistics dimension
|
||||
|
||||
StatsDimension::StatsDimension()
|
||||
@@ -44,19 +46,19 @@ StatsDimension::StatsDimension(const Field& field)
|
||||
FOR_EACH_CONST(g, choice_field->choices->choices) {
|
||||
groups.push_back(g->name);
|
||||
}
|
||||
// initialize script, primary_choice(card.{field_name})
|
||||
// initialize script: primary_choice(card.{field_name})
|
||||
Script& s = script.getScript();
|
||||
s.addInstruction(I_GET_VAR, string_to_variable(_("primary choice")));
|
||||
s.addInstruction(I_GET_VAR, string_to_variable(_("card")));
|
||||
s.addInstruction(I_MEMBER_C, field.name);
|
||||
s.addInstruction(I_CALL, 1);
|
||||
s.addInstruction(I_NOP, string_to_variable(_("input")));
|
||||
s.addInstruction(I_PUSH_CONST, script_primary_choice);
|
||||
s.addInstruction(I_GET_VAR, string_to_variable(_("card")));
|
||||
s.addInstruction(I_MEMBER_C, field.name);
|
||||
s.addInstruction(I_CALL, 1);
|
||||
s.addInstruction(I_NOP, string_to_variable(_("input")));
|
||||
s.addInstruction(I_RET);
|
||||
} else {
|
||||
// initialize script, card.{field_name}
|
||||
Script& s = script.getScript();
|
||||
s.addInstruction(I_GET_VAR, string_to_variable(_("card")));
|
||||
s.addInstruction(I_MEMBER_C, field.name);
|
||||
s.addInstruction(I_GET_VAR, string_to_variable(_("card")));
|
||||
s.addInstruction(I_MEMBER_C, field.name);
|
||||
s.addInstruction(I_RET);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user