made a start with script functions

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@62 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-31 12:17:36 +00:00
parent 0caaf01a78
commit 1ffaa5bd58
20 changed files with 372 additions and 29 deletions
+7 -3
View File
@@ -111,7 +111,7 @@ ScriptImageP ScriptableImage::generate(Context& ctx, UInt width, UInt height, Pr
ScriptImageP ScriptableImage::update(Context& ctx, UInt width, UInt height, PreserveAspect preserve_aspect, bool saturate) {
// up to date?
if (!cache || (UInt)cache->image.GetWidth() != width || (UInt)cache->image.GetHeight() == height || !upToDate(ctx, last_update)) {
if (!cache || (UInt)cache->image.GetWidth() != width || (UInt)cache->image.GetHeight() != height || !upToDate(ctx, last_update)) {
// cache must be updated
cache = generate(ctx, width, height, preserve_aspect, saturate);
last_update.update();
@@ -120,8 +120,12 @@ ScriptImageP ScriptableImage::update(Context& ctx, UInt width, UInt height, Pres
}
bool ScriptableImage::upToDate(Context& ctx, Age age) const {
WITH_DYNAMIC_ARG(last_update_age, age.get());
return (int)*script.invoke(ctx);
try {
WITH_DYNAMIC_ARG(last_update_age, age.get());
return (int)*script.invoke(ctx);
} catch (Error e) {
return true; // script gives errors, don't update
}
}
// ----------------------------------------------------------------------------- : Reflection