added native look editor and the set info panel

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@82 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-11-20 17:26:34 +00:00
parent 141400d8aa
commit 3cbf2577c1
32 changed files with 458 additions and 48 deletions
+23
View File
@@ -10,6 +10,7 @@
#include <script/context.hpp>
#include <util/dynamic_arg.hpp>
#include <util/io/package.hpp>
#include <gui/util.hpp> // load_resource_image
// image generating functions have two modes
// if last_update_age > 0 they return whether the image is still up to date
@@ -59,6 +60,10 @@ bool script_image_up_to_date(const ScriptValueP& value) {
// ----------------------------------------------------------------------------- : ScriptableImage
ScriptableImage::ScriptableImage(const String& script_)
: script(script_)
{}
ScriptImageP ScriptableImage::generate(Context& ctx, Package& pkg) const {
try {
WITH_DYNAMIC_ARG(load_images_from, &pkg);
@@ -200,3 +205,21 @@ SCRIPT_FUNCTION(set_mask) {
);
}
}
SCRIPT_FUNCTION(buildin_image) {
if (last_update_age() == 0) {
SCRIPT_PARAM(String, input);
Image img = load_resource_image(input);
if (!img.Ok()) throw ScriptError(_("There is no build in image '") + input + _("'"));
return new_intrusive1<ScriptImage>(img);
} else {
SCRIPT_RETURN(true);
}
}
void init_script_image_functions(Context& ctx) {
ctx.setVariable(_("linear blend"), script_linear_blend);
ctx.setVariable(_("masked blend"), script_masked_blend);
ctx.setVariable(_("set mask"), script_set_mask);
ctx.setVariable(_("buildin image"), script_buildin_image);
}
+3
View File
@@ -46,6 +46,9 @@ class ScriptImage : public ScriptValue {
*/
class ScriptableImage {
public:
inline ScriptableImage() {}
ScriptableImage(const String& script);
/// Is there an image set?
inline operator bool() const { return script; }
+2
View File
@@ -26,6 +26,7 @@ DECLARE_TYPEOF_NO_REV(IndexMap_FieldP_ValueP);
// initialize functions, from functions.cpp
void init_script_functions(Context& ctx);
void init_script_image_functions(Context& ctx);
// ----------------------------------------------------------------------------- : ScriptManager : initialization
@@ -57,6 +58,7 @@ Context& ScriptManager::getContext(const StyleSheetP& stylesheet) {
// NOTE: do not use a smart pointer for the pointer to the set, because the set owns this
// which would lead to a reference cycle.
init_script_functions(*ctx);
init_script_image_functions(*ctx);
ctx->setVariable(_("set"), new_intrusive1<ScriptObject<Set*> >(&set));
ctx->setVariable(_("game"), toScript(set.game));
ctx->setVariable(_("stylesheet"), toScript(stylesheet));
+5
View File
@@ -23,6 +23,11 @@ void store(const ScriptValueP& val, Defaultable<String>& var) { var.assign(*val)
// ----------------------------------------------------------------------------- : OptionalScript
OptionalScript::OptionalScript(const String& script_)
: unparsed(script_)
, script(::parse(script_))
{}
OptionalScript::~OptionalScript() {}
ScriptValueP OptionalScript::invoke(Context& ctx, bool open_scope) const {
+4
View File
@@ -33,6 +33,8 @@ void store(const ScriptValueP& val, Defaultable<String>& var);
/// An optional script,
class OptionalScript {
public:
inline OptionalScript() {}
OptionalScript(const String& script_);
~OptionalScript();
/// Is the script set?
inline operator bool() const { return !!script; }
@@ -96,6 +98,8 @@ class Scriptable {
inline operator const T& () const { return value; }
inline const T& operator ()() const { return value; }
inline bool isScripted() const { return script; }
/// Has this value been read from a Reader?
inline bool hasBeenRead() const { return !script.unparsed.empty(); }
/// Updates the value by executing the script, returns true if the value has changed
inline bool update(Context& ctx) {