mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Register metatype
This commit is contained in:
parent
89aa89e9d3
commit
2c84478dc1
3 changed files with 19 additions and 6 deletions
|
@ -48,8 +48,7 @@ public:
|
|||
* will be done to the Assets bucket instead. This should ease the transition and ensure a clean
|
||||
* separation.
|
||||
*/
|
||||
enum class Bucket
|
||||
{
|
||||
enum class Bucket {
|
||||
/** Assets that used to be in the hifi-public S3 bucket */
|
||||
HF_Public,
|
||||
|
||||
|
@ -62,7 +61,6 @@ public:
|
|||
/** Vircadia assets */
|
||||
Assets
|
||||
};
|
||||
|
||||
Q_ENUM(Bucket)
|
||||
|
||||
/**
|
||||
|
|
|
@ -108,6 +108,8 @@ int functionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature
|
|||
|
||||
int scriptEnginePointerMetaID = qRegisterMetaType<ScriptEnginePointer>();
|
||||
|
||||
Q_DECLARE_METATYPE(ExternalResource::Bucket);
|
||||
|
||||
static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) {
|
||||
QString message = "";
|
||||
for (int i = 0; i < context->argumentCount(); i++) {
|
||||
|
@ -663,6 +665,17 @@ void avatarDataFromScriptValue(const QScriptValue& object, ScriptAvatarData*& ou
|
|||
out = nullptr;
|
||||
}
|
||||
|
||||
QScriptValue externalResourceBucketToScriptValue(QScriptEngine* engine, ExternalResource::Bucket const& in) {
|
||||
//return engine->newQObject(in, QScriptEngine::ScriptOwnership, DEFAULT_QOBJECT_WRAP_OPTIONS);
|
||||
return QScriptValue((int)in);
|
||||
}
|
||||
|
||||
void externalResourceBucketFromScriptValue(const QScriptValue& object, ExternalResource::Bucket& out) {
|
||||
// This is not implemented because there are no slots/properties that take an AvatarSharedPointer from a script
|
||||
assert(false);
|
||||
out = ExternalResource::Bucket::Assets;
|
||||
}
|
||||
|
||||
void ScriptEngine::resetModuleCache(bool deleteScriptCache) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
executeOnScriptThread([=]() { resetModuleCache(deleteScriptCache); });
|
||||
|
@ -769,6 +782,8 @@ void ScriptEngine::init() {
|
|||
require.setProperty("resolve", resolve, READONLY_PROP_FLAGS);
|
||||
resetModuleCache();
|
||||
}
|
||||
|
||||
qScriptRegisterMetaType(this, externalResourceBucketToScriptValue, externalResourceBucketFromScriptValue);
|
||||
registerEnum("Script.ExternalPaths", QMetaEnum::fromType<ExternalResource::Bucket>());
|
||||
|
||||
registerGlobalObject("Audio", DependencyManager::get<AudioScriptingInterface>().data());
|
||||
|
@ -2871,6 +2886,6 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS
|
|||
}
|
||||
}
|
||||
|
||||
QString ScriptEngine::getExternalPath(ExternalResource::Bucket bucket, const QString &relative_path) {
|
||||
return ExternalResource::getInstance()->getUrl(bucket, relative_path);
|
||||
QString ScriptEngine::getExternalPath(ExternalResource::Bucket bucket, const QString& relativePath) {
|
||||
return ExternalResource::getInstance()->getUrl(bucket, relativePath);
|
||||
}
|
||||
|
|
|
@ -684,7 +684,7 @@ public:
|
|||
|
||||
void setScriptEngines(QSharedPointer<ScriptEngines>& scriptEngines) { _scriptEngines = scriptEngines; }
|
||||
|
||||
Q_INVOKABLE QString getExternalPath(ExternalResource::Bucket bucket, const QString &relative_path);
|
||||
Q_INVOKABLE QString getExternalPath(ExternalResource::Bucket bucket, const QString& relativePath);
|
||||
|
||||
public slots:
|
||||
|
||||
|
|
Loading…
Reference in a new issue