mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
thumbnails for choice editor
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@159 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -46,6 +46,12 @@ ScriptImageP to_script_image(const ScriptValueP& value) {
|
||||
} else {
|
||||
throw ScriptError(_("Unable to load image '") + filename + _("' from '" + pkg->name() + _("'")));
|
||||
}
|
||||
} else if (value->type() == SCRIPT_NIL) {
|
||||
// error, return blank image
|
||||
Image i(1,1);
|
||||
i.InitAlpha();
|
||||
i.SetAlpha(0,0,0);
|
||||
return new_intrusive1<ScriptImage>(i);
|
||||
} else {
|
||||
throw ScriptError(_("Can not convert from '") + value->typeName() + _("' to image"));
|
||||
}
|
||||
@@ -129,6 +135,7 @@ ScriptImageP ScriptableImage::update(Context& ctx, Package& pkg, UInt width, UIn
|
||||
}
|
||||
|
||||
bool ScriptableImage::upToDate(Context& ctx, Age age) const {
|
||||
if (!script) return true;
|
||||
try {
|
||||
WITH_DYNAMIC_ARG(last_update_age, age.get());
|
||||
return script_image_up_to_date(script.invoke(ctx));
|
||||
|
||||
@@ -63,6 +63,13 @@ Context& SetScriptContext::getContext(const StyleSheetP& stylesheet) {
|
||||
ctx->setVariable(_("stylesheet"), toScript(stylesheet));
|
||||
ctx->setVariable(_("card"), set.cards.empty() ? script_nil : toScript(set.cards.front())); // dummy value
|
||||
ctx->setVariable(_("styling"), toScript(&set.stylingDataFor(*stylesheet)));
|
||||
try {
|
||||
// perform init scripts, don't use a scope, variables stay bound in the context
|
||||
set.game ->init_script.invoke(*ctx, false);
|
||||
stylesheet->init_script.invoke(*ctx, false);
|
||||
} catch (const Error& e) {
|
||||
handle_error(e, false, false);
|
||||
}
|
||||
onInit(stylesheet, ctx);
|
||||
return *ctx;
|
||||
}
|
||||
@@ -94,13 +101,10 @@ void SetScriptManager::onInit(const StyleSheetP& stylesheet, Context* ctx) {
|
||||
assert(wxThread::IsMain());
|
||||
// initialize dependencies
|
||||
try {
|
||||
// perform init scripts, don't use a scope, variables stay bound in the context
|
||||
set.game ->init_script.invoke(*ctx, false);
|
||||
stylesheet->init_script.invoke(*ctx, false);
|
||||
// find script dependencies
|
||||
initDependencies(*ctx, *set.game);
|
||||
initDependencies(*ctx, *stylesheet);
|
||||
} catch (Error e) {
|
||||
} catch (const Error& e) {
|
||||
handle_error(e, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user