dependencies of extra card fields are now also added and updated;

this fixes combined_editor in extra fields.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1036 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-08-02 19:16:30 +00:00
parent 7aef2948e2
commit 2f5666ac5b
6 changed files with 47 additions and 10 deletions
+7
View File
@@ -102,6 +102,13 @@ SCRIPT_FUNCTION(to_int) {
} else if (t == SCRIPT_COLOR) {
AColor c = (AColor)*input;
result = (c.Red() + c.Blue() + c.Green()) / 3;
} else if (t == SCRIPT_STRING) {
long l;
if (input->toString().ToLong(&l)) {
result = l;
} else {
return new_intrusive1<ScriptDelayedError>(_ERROR_3_("can't convert value", input->toString(), input->typeName(), _TYPE_("integer")));
}
} else {
result = (int)*input;
}
+16 -1
View File
@@ -12,9 +12,12 @@
#include <util/tagged_string.hpp>
#include <data/set.hpp>
#include <data/game.hpp>
#include <data/card.hpp>
#include <data/stylesheet.hpp>
#include <data/field/text.hpp>
#include <data/field/choice.hpp>
#include <data/field/multiple_choice.hpp>
#include <data/action/value.hpp>
DECLARE_TYPEOF_COLLECTION(FieldP);
DECLARE_TYPEOF_COLLECTION(TextValue*);
@@ -81,8 +84,16 @@ SCRIPT_FUNCTION_WITH_DEP(combined_editor) {
FOR_EACH_2(v, values, nv, value_parts) {
//if (v->value() != nv.first && v->last_update < new_value_update) {
if (v->last_update < new_value_update) {
bool changed = v->value() != nv.first;
v->value.assign(nv.first);
v->update(ctx);
changed |= v->update(ctx);
v->last_update = new_value_update;
if (changed) { // notify of change
SCRIPT_OPTIONAL_PARAM_(CardP, card);
SCRIPT_PARAM(Set*, set);
ScriptValueEvent change(card.get(), v);
set->actions.tellListeners(change, false);
}
}
nv.first = v->value();
nv.second = index_to_untagged(nv.first, nv.first.size()) == 0;
@@ -153,6 +164,10 @@ SCRIPT_FUNCTION_DEPENDENCIES(combined_editor) {
FieldP target_field;
if (dep.type == DEP_CARD_FIELD) target_field = game->card_fields[dep.index];
else if (dep.type == DEP_SET_FIELD) target_field = game->set_fields[dep.index];
else if (dep.type == DEP_EXTRA_CARD_FIELD) {
SCRIPT_PARAM_C(StyleSheetP, stylesheet);
target_field = stylesheet->extra_card_fields[dep.index];
}
else throw InternalError(_("Finding dependencies of combined error for non card/set field"));
// Add dependencies, from target_field on field#
// For card fields