Fixed conversion from Values to other types: Values now report being of the contained type.

Added toImage function to ScriptValue.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1083 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-08-07 16:26:33 +00:00
parent 40719b7831
commit b5bdaedde2
8 changed files with 34 additions and 290 deletions
+13 -2
View File
@@ -8,6 +8,7 @@
#include <util/prec.hpp>
#include <data/field/image.hpp>
#include <gfx/generated_image.hpp>
// ----------------------------------------------------------------------------- : ImageField
@@ -38,6 +39,16 @@ String ImageValue::toString() const {
return filename.empty() ? wxEmptyString : _("<image>");
}
IMPLEMENT_REFLECTION_NAMELESS(ImageValue) {
if (fieldP->save_value || tag.scripting() || tag.reading()) REFLECT_NAMELESS(filename);
// custom reflection: convert to ScriptImageP for scripting
void ImageValue::reflect(Reader& tag) {
tag.handle(filename);
}
void ImageValue::reflect(Writer& tag) {
if (fieldP->save_value) tag.handle(filename);
}
void ImageValue::reflect(GetMember& tag) {}
void ImageValue::reflect(GetDefaultMember& tag) {
// convert to ScriptImageP for scripting
tag.handle( (ScriptValueP)new_intrusive2<ImageValueToImage>(filename, last_update) );
}