mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Script errors now have information on where the error occureed (what value);
Script operator "int + object" now uses string concatenation instead of converting the object to integer; Html export window uses a dummy set for editing options, so we don't pollute the set's undo stack; Choice rendererer in nativelook 'both' style always leaves room for the icon; Version bump git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@438 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+9
-11
@@ -240,14 +240,13 @@ void instrUnary (UnaryInstructionType i, ScriptValueP& a) {
|
||||
} \
|
||||
break
|
||||
|
||||
// operator on strings or doubles or ints
|
||||
// operator on strings or doubles or ints, when in doubt, uses strings
|
||||
#define OPERATOR_SDI(OP) \
|
||||
if (at == SCRIPT_STRING || bt == SCRIPT_STRING) { \
|
||||
a = to_script(a->toString() OP b->toString()); \
|
||||
} else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \
|
||||
a = to_script((double)*a OP (double)*b); \
|
||||
} else if (at == SCRIPT_INT || bt == SCRIPT_INT ) { \
|
||||
if (at == SCRIPT_INT && bt == SCRIPT_INT) { \
|
||||
a = to_script((int)*a OP (int)*b); \
|
||||
} else if ((at == SCRIPT_INT || at == SCRIPT_DOUBLE) && \
|
||||
(bt == SCRIPT_INT || bt == SCRIPT_DOUBLE)) { \
|
||||
a = to_script((double)*a OP (double)*b); \
|
||||
} else { \
|
||||
a = to_script(a->toString() OP b->toString()); \
|
||||
} \
|
||||
@@ -288,12 +287,11 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP&
|
||||
// a = a;
|
||||
} else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) {
|
||||
a = new_intrusive2<ScriptCompose>(a, b);
|
||||
} else if (at == SCRIPT_STRING || bt == SCRIPT_STRING) {
|
||||
a = to_script(a->toString() + b->toString());
|
||||
} else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) {
|
||||
a = to_script((double)*a + (double)*b);
|
||||
} else if (at == SCRIPT_INT || bt == SCRIPT_INT) {
|
||||
} else if (at == SCRIPT_INT && bt == SCRIPT_INT) {
|
||||
a = to_script((int)*a + (int)*b);
|
||||
} else if ((at == SCRIPT_INT || at == SCRIPT_DOUBLE) &&
|
||||
(bt == SCRIPT_INT || bt == SCRIPT_DOUBLE)) {
|
||||
a = to_script((double)*a + (double)*b);
|
||||
} else {
|
||||
a = to_script(a->toString() + b->toString());
|
||||
}
|
||||
|
||||
@@ -214,9 +214,13 @@ void SetScriptManager::updateStyles(const CardP& card) {
|
||||
}
|
||||
void SetScriptManager::updateStyles(Context& ctx, const IndexMap<FieldP,StyleP>& styles) {
|
||||
FOR_EACH_CONST(s, styles) {
|
||||
if (s->update(ctx)) {
|
||||
// style has changed, tell listeners
|
||||
s->tellListeners();
|
||||
try {
|
||||
if (s->update(ctx)) {
|
||||
// style has changed, tell listeners
|
||||
s->tellListeners();
|
||||
}
|
||||
} catch (const ScriptError& e) {
|
||||
throw ScriptError(e.what() + _("\nWhile updating styles for '") + s->fieldP->name + _("'"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,13 +255,21 @@ void SetScriptManager::updateAll() {
|
||||
// update set data
|
||||
Context& ctx = getContext(set.stylesheet);
|
||||
FOR_EACH(v, set.data) {
|
||||
v->update(ctx);
|
||||
try {
|
||||
v->update(ctx);
|
||||
} catch (const ScriptError& e) {
|
||||
throw ScriptError(e.what() + _("\nWhile updating set value '") + v->fieldP->name + _("'"));
|
||||
}
|
||||
}
|
||||
// update card data of all cards
|
||||
FOR_EACH(card, set.cards) {
|
||||
Context& ctx = getContext(card);
|
||||
FOR_EACH(v, card->data) {
|
||||
v->update(ctx);
|
||||
try {
|
||||
v->update(ctx);
|
||||
} catch (const ScriptError& e) {
|
||||
throw ScriptError(e.what() + _("\nWhile updating card value '") + v->fieldP->name + _("'"));
|
||||
}
|
||||
}
|
||||
}
|
||||
// update things that depend on the card list
|
||||
@@ -286,7 +298,13 @@ void SetScriptManager::updateToUpdate(const ToUpdate& u, deque<ToUpdate>& to_upd
|
||||
Age age = u.value->last_script_update;
|
||||
if (starting_age < age) return; // this value was already updated
|
||||
Context& ctx = getContext(u.card);
|
||||
if (u.value->update(ctx)) {
|
||||
bool changes;
|
||||
try {
|
||||
changes = u.value->update(ctx);
|
||||
} catch (const ScriptError& e) {
|
||||
throw ScriptError(e.what() + _("\nWhile updating value '") + u.value->fieldP->name + _("'"));
|
||||
}
|
||||
if (changes) {
|
||||
// changed, send event
|
||||
ScriptValueEvent change(u.card.get(), u.value);
|
||||
set.actions.tellListeners(change, false);
|
||||
|
||||
Reference in New Issue
Block a user