mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 18:06:57 +02:00
CanvasCommand serialisation fix, metatype still broken
This commit is contained in:
parent
5b573b6996
commit
0026a9f9d2
2 changed files with 8 additions and 6 deletions
|
@ -19,11 +19,12 @@
|
||||||
#include "ScriptValue.h"
|
#include "ScriptValue.h"
|
||||||
#include "ScriptManager.h"
|
#include "ScriptManager.h"
|
||||||
#include "ScriptValueUtils.h"
|
#include "ScriptValueUtils.h"
|
||||||
|
#include "v8/FastScriptValueUtils.h"
|
||||||
|
|
||||||
STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
|
STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
|
||||||
auto scriptEngine = manager->engine().get();
|
auto scriptEngine = manager->engine().get();
|
||||||
|
|
||||||
scriptRegisterMetaType<CanvasCommand, canvasCommandToScriptValue, canvasCommandFromScriptValue>(scriptEngine);
|
scriptRegisterMetaType<CanvasCommand, canvasCommandToScriptValue, canvasCommandFromScriptValue>(scriptEngine, "CanvasCommand");
|
||||||
scriptRegisterMetaType<CanvasImage, canvasImageToScriptValue, canvasImageFromScriptValue>(scriptEngine, "CanvasImage");
|
scriptRegisterMetaType<CanvasImage, canvasImageToScriptValue, canvasImageFromScriptValue>(scriptEngine, "CanvasImage");
|
||||||
scriptRegisterMetaType<QPainterPath, qPainterPathToScriptValue, qPainterPathFromScriptValue>(scriptEngine, "CanvasPath");
|
scriptRegisterMetaType<QPainterPath, qPainterPathToScriptValue, qPainterPathFromScriptValue>(scriptEngine, "CanvasPath");
|
||||||
scriptRegisterMetaType<QVector<CanvasCommand>, qVectorCanvasCommandToScriptValue, qVectorCanvasCommandFromScriptValue>(scriptEngine);
|
scriptRegisterMetaType<QVector<CanvasCommand>, qVectorCanvasCommandToScriptValue, qVectorCanvasCommandFromScriptValue>(scriptEngine);
|
||||||
|
@ -51,7 +52,7 @@ ScriptValue canvasCommandToScriptValue(ScriptEngine* engine, const CanvasCommand
|
||||||
|
|
||||||
case Variant::SetColor: {
|
case Variant::SetColor: {
|
||||||
auto props = cmd._setColor;
|
auto props = cmd._setColor;
|
||||||
obj.setProperty("color", props.color);
|
obj.setProperty("color", u8vec3ColorToScriptValue(engine, glm::u8vec3(props.color.red(), props.color.green(), props.color.blue())));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ ScriptValue canvasCommandToScriptValue(ScriptEngine* engine, const CanvasCommand
|
||||||
|
|
||||||
case Variant::FillPath: {
|
case Variant::FillPath: {
|
||||||
auto props = cmd._fillPath;
|
auto props = cmd._fillPath;
|
||||||
obj.setProperty("path", props.path);
|
obj.setProperty("path", qPainterPathToScriptValue(engine, props.path));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +114,7 @@ ScriptValue canvasCommandToScriptValue(ScriptEngine* engine, const CanvasCommand
|
||||||
|
|
||||||
case Variant::StrokePath: {
|
case Variant::StrokePath: {
|
||||||
auto props = cmd._strokePath;
|
auto props = cmd._strokePath;
|
||||||
obj.setProperty("path", props.path);
|
obj.setProperty("path", qPainterPathToScriptValue(engine, props.path));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +173,7 @@ ScriptValue canvasCommandToScriptValue(ScriptEngine* engine, const CanvasCommand
|
||||||
obj.setProperty("destY", props.dst.y());
|
obj.setProperty("destY", props.dst.y());
|
||||||
obj.setProperty("destW", props.dst.width());
|
obj.setProperty("destW", props.dst.width());
|
||||||
obj.setProperty("destH", props.dst.height());
|
obj.setProperty("destH", props.dst.height());
|
||||||
obj.setProperty("image", props.image);
|
obj.setProperty("image", canvasImageToScriptValue(engine, props.image));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +351,7 @@ ScriptValue canvasImageToScriptValue(ScriptEngine* engine, const CanvasImage& im
|
||||||
ScriptValue obj = engine->newObject();
|
ScriptValue obj = engine->newObject();
|
||||||
obj.setProperty(IMG_WIDTH_PROP_NAME, img.width);
|
obj.setProperty(IMG_WIDTH_PROP_NAME, img.width);
|
||||||
obj.setProperty(IMG_HEIGHT_PROP_NAME, img.height);
|
obj.setProperty(IMG_HEIGHT_PROP_NAME, img.height);
|
||||||
obj.setProperty(IMG_BUFFER_PROP_NAME, img.buffer);
|
obj.setProperty(IMG_BUFFER_PROP_NAME, qBytearrayToScriptValue(engine, img.buffer));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,7 @@ private:
|
||||||
|
|
||||||
void registerCanvasMetaTypes(ScriptEngine *engine);
|
void registerCanvasMetaTypes(ScriptEngine *engine);
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CanvasCommand)
|
||||||
ScriptValue canvasCommandToScriptValue(ScriptEngine* engine, const CanvasCommand& cmd);
|
ScriptValue canvasCommandToScriptValue(ScriptEngine* engine, const CanvasCommand& cmd);
|
||||||
bool canvasCommandFromScriptValue(const ScriptValue& object, CanvasCommand& cmd);
|
bool canvasCommandFromScriptValue(const ScriptValue& object, CanvasCommand& cmd);
|
||||||
CanvasCommand canvasCommandFromScriptValue(const ScriptValue& object);
|
CanvasCommand canvasCommandFromScriptValue(const ScriptValue& object);
|
||||||
|
|
Loading…
Reference in a new issue