* Added console panel for evaluating scripts and showing error messages.

* Rewrite of error queue code: errors are now pulled, instead of being turned into messageboxes automatically.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1629 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2011-01-21 13:26:03 +00:00
parent 4079bc26b8
commit bd55326c7d
37 changed files with 1288 additions and 797 deletions
+4 -4
View File
@@ -23,10 +23,10 @@ DECLARE_TYPEOF_COLLECTION(pair<String COMMA ScriptValueP>);
SCRIPT_FUNCTION(trace) {
SCRIPT_PARAM_C(String, input);
#ifdef _DEBUG
#if defined(_DEBUG) && 0
wxLogDebug(_("Trace:\t") + input);
#else
handle_warning(_("Trace:\t") + input, false);
queue_message(MESSAGE_INFO, _("Trace: ") + input);
#endif
SCRIPT_RETURN(input);
}
@@ -35,7 +35,7 @@ SCRIPT_FUNCTION(warning) {
SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_DEFAULT_C(bool, condition, true);
if (condition) {
handle_warning(input, true);
queue_message(MESSAGE_WARNING, input);
}
return script_nil;
}
@@ -51,7 +51,7 @@ SCRIPT_FUNCTION(warning_if_neq) {
try {
s2 = v2->toCode();
} catch (...) {}
handle_warning(input + s1 + _(" != ") + s2, true);
queue_message(MESSAGE_WARNING, input + s1 + _(" != ") + s2);
}
return script_nil;
}
+6 -6
View File
@@ -67,7 +67,7 @@ Context& SetScriptContext::getContext(const StyleSheetP& stylesheet) {
set.game ->init_script.invoke(*ctx, false);
stylesheet->init_script.invoke(*ctx, false);
} catch (const Error& e) {
handle_error(e, false, false);
handle_error(e);
}
onInit(stylesheet, ctx);
return *ctx;
@@ -108,7 +108,7 @@ void SetScriptManager::onInit(const StyleSheetP& stylesheet, Context* ctx) {
initDependencies(*ctx, *set.game);
initDependencies(*ctx, *stylesheet);
} catch (const Error& e) {
handle_error(e, false, false);
handle_error(e);
}
}
@@ -258,7 +258,7 @@ void SetScriptManager::updateStyles(Context& ctx, const IndexMap<FieldP,StyleP>&
}
} catch (const ScriptError& e) {
// NOTE: don't handle errors now, we are likely in an onPaint handler
handle_error(ScriptError(e.what() + _("\n while updating styles for '") + s->fieldP->name + _("'")), false, false);
handle_error(ScriptError(e.what() + _("\n while updating styles for '") + s->fieldP->name + _("'")));
}
}
}
@@ -298,7 +298,7 @@ void SetScriptManager::updateAll() {
PROFILER2( v->fieldP.get(), _("update set.") + v->fieldP->name );
v->update(ctx);
} catch (const ScriptError& e) {
handle_error(ScriptError(e.what() + _("\n while updating set value '") + v->fieldP->name + _("'")), false, true);
handle_error(ScriptError(e.what() + _("\n while updating set value '") + v->fieldP->name + _("'")));
}
}
// update card data of all cards
@@ -312,7 +312,7 @@ void SetScriptManager::updateAll() {
#endif
v->update(ctx);
} catch (const ScriptError& e) {
handle_error(ScriptError(e.what() + _("\n while updating card value '") + v->fieldP->name + _("'")), false, true);
handle_error(ScriptError(e.what() + _("\n while updating card value '") + v->fieldP->name + _("'")));
}
}
}
@@ -347,7 +347,7 @@ void SetScriptManager::updateToUpdate(const ToUpdate& u, deque<ToUpdate>& to_upd
try {
changes = u.value->update(ctx);
} catch (const ScriptError& e) {
handle_error(ScriptError(e.what() + _("\n while updating value '") + u.value->fieldP->name + _("'")), false, true);
handle_error(ScriptError(e.what() + _("\n while updating value '") + u.value->fieldP->name + _("'")));
}
if (changes) {
// changed, send event