mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
check for stylesheet in import scripts
This commit is contained in:
@@ -60,9 +60,18 @@ SCRIPT_FUNCTION(new_card) {
|
||||
ScriptValueP script_input = field->import_script.invoke(ctx, true);
|
||||
// if the script result is a collection, iterate on the key/value pairs
|
||||
// treat the keys as field names and the values as what to populate those fields with
|
||||
if (script_input->type() == SCRIPT_COLLECTION) {
|
||||
if (script_input->type() == SCRIPT_COLLECTION) {
|
||||
// check for a stylesheet first, since other things depend on it
|
||||
ScriptValueP script_it = script_input->makeIterator();
|
||||
ScriptValueP script_key;
|
||||
while (ScriptValueP script_value = script_it->next(&script_key)) {
|
||||
assert(script_key);
|
||||
if (script_key == script_nil) continue;
|
||||
String script_key_name = script_key->toString();
|
||||
if (set_stylesheet_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) break;
|
||||
}
|
||||
// iterate on the rest of the key/value pairs given by the script
|
||||
script_it = script_input->makeIterator();
|
||||
while (ScriptValueP script_value = script_it->next(&script_key)) {
|
||||
assert(script_key);
|
||||
if (script_key == script_nil) continue;
|
||||
@@ -94,10 +103,18 @@ SCRIPT_FUNCTION(new_card) {
|
||||
ScriptValueP ctx_card = ctx.getVariableOpt(SCRIPT_VAR_card);
|
||||
ctx.setVariable(SCRIPT_VAR_card, to_script(new_card));
|
||||
ScriptValueP script_input = game->import_script.invoke(ctx, true);
|
||||
if (script_input->type() == SCRIPT_COLLECTION) {
|
||||
// iterate on the key/value pairs given by the script
|
||||
if (script_input->type() == SCRIPT_COLLECTION) {
|
||||
// check for a stylesheet first, since other things depend on it
|
||||
ScriptValueP script_it = script_input->makeIterator();
|
||||
ScriptValueP script_key;
|
||||
while (ScriptValueP script_value = script_it->next(&script_key)) {
|
||||
assert(script_key);
|
||||
if (script_key == script_nil) continue;
|
||||
String script_key_name = script_key->toString();
|
||||
if (set_stylesheet_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) break;
|
||||
}
|
||||
// iterate on the rest of the key/value pairs given by the script
|
||||
script_it = script_input->makeIterator();
|
||||
while (ScriptValueP script_value = script_it->next(&script_key)) {
|
||||
assert(script_key);
|
||||
if (script_key == script_nil) continue;
|
||||
|
||||
Reference in New Issue
Block a user