mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
'ported' scripting code to work with unicode and the rest of MSE
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@14 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/io/get_member.hpp>
|
||||
#include <util/vector2d.hpp>
|
||||
#include <script/value.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : GetMember
|
||||
@@ -20,3 +21,7 @@ void GetMember::store(const int v) { value = toScript(v); }
|
||||
void GetMember::store(const unsigned int v) { value = toScript((int)v); }
|
||||
void GetMember::store(const double v) { value = toScript(v); }
|
||||
void GetMember::store(const bool v) { value = toScript(v); }
|
||||
|
||||
void GetMember::store(const Vector2D& v) {
|
||||
value = toScript(String::Format(_("(%.10lf,%.10lf)"), v.x, v.y));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ typedef boost::intrusive_ptr<ScriptValue> ScriptValueP;
|
||||
inline void intrusive_ptr_add_ref(ScriptValue* p);
|
||||
inline void intrusive_ptr_release(ScriptValue* p);
|
||||
|
||||
class Vector2D;
|
||||
|
||||
// ----------------------------------------------------------------------------- : GetMember
|
||||
|
||||
/// Find a member with a specific name using reflection
|
||||
@@ -43,6 +45,7 @@ class GetMember {
|
||||
|
||||
/// Store something in the return value
|
||||
void store(const String& v);
|
||||
void store(const Vector2D& v);
|
||||
void store(const int v);
|
||||
void store(const unsigned int v);
|
||||
void store(const double v);
|
||||
@@ -71,9 +74,9 @@ class GetMember {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Reflection for enumerations
|
||||
|
||||
/// Implement enum reflection as used by Writer
|
||||
#define REFLECT_ENUM_WRITER(Enum) \
|
||||
template<> void Writer::handle<Enum>(const Enum& enum_) { \
|
||||
/// Implement enum reflection as used by GetMember
|
||||
#define REFLECT_ENUM_GET_MEMBER(Enum) \
|
||||
template<> void GetMember::handle<Enum>(const Enum& enum_) {\
|
||||
EnumGetMember gm(*this); \
|
||||
reflect_ ## Enum(const_cast<Enum&>(enum_), gm); \
|
||||
}
|
||||
@@ -88,7 +91,7 @@ class EnumGetMember {
|
||||
template <typename Enum>
|
||||
inline void handle(const Char* name, Enum value, Enum enum_) {
|
||||
if (enum_ == value) {
|
||||
writer.store(name);
|
||||
getMember.store(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,5 @@ template <> void Writer::handle(const bool& value) {
|
||||
// ----------------------------------------------------------------------------- : Handling less basic util types
|
||||
|
||||
template <> void Writer::handle(const Vector2D& vec) {
|
||||
String formated;
|
||||
formated.Printf(_("(%.10lf,%.10lf)"), vec.x, vec.y);
|
||||
handle(formated);
|
||||
handle(String::Format(_("(%.10lf,%.10lf)"), vec.x, vec.y));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user