mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:12:46 +02: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
|
* will be done to the Assets bucket instead. This should ease the transition and ensure a clean
|
||||||
* separation.
|
* separation.
|
||||||
*/
|
*/
|
||||||
enum class Bucket
|
enum class Bucket {
|
||||||
{
|
|
||||||
/** Assets that used to be in the hifi-public S3 bucket */
|
/** Assets that used to be in the hifi-public S3 bucket */
|
||||||
HF_Public,
|
HF_Public,
|
||||||
|
|
||||||
|
@ -62,7 +61,6 @@ public:
|
||||||
/** Vircadia assets */
|
/** Vircadia assets */
|
||||||
Assets
|
Assets
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_ENUM(Bucket)
|
Q_ENUM(Bucket)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -108,6 +108,8 @@ int functionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature
|
||||||
|
|
||||||
int scriptEnginePointerMetaID = qRegisterMetaType<ScriptEnginePointer>();
|
int scriptEnginePointerMetaID = qRegisterMetaType<ScriptEnginePointer>();
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(ExternalResource::Bucket);
|
||||||
|
|
||||||
static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) {
|
static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) {
|
||||||
QString message = "";
|
QString message = "";
|
||||||
for (int i = 0; i < context->argumentCount(); i++) {
|
for (int i = 0; i < context->argumentCount(); i++) {
|
||||||
|
@ -663,6 +665,17 @@ void avatarDataFromScriptValue(const QScriptValue& object, ScriptAvatarData*& ou
|
||||||
out = nullptr;
|
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) {
|
void ScriptEngine::resetModuleCache(bool deleteScriptCache) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
executeOnScriptThread([=]() { resetModuleCache(deleteScriptCache); });
|
executeOnScriptThread([=]() { resetModuleCache(deleteScriptCache); });
|
||||||
|
@ -769,6 +782,8 @@ void ScriptEngine::init() {
|
||||||
require.setProperty("resolve", resolve, READONLY_PROP_FLAGS);
|
require.setProperty("resolve", resolve, READONLY_PROP_FLAGS);
|
||||||
resetModuleCache();
|
resetModuleCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qScriptRegisterMetaType(this, externalResourceBucketToScriptValue, externalResourceBucketFromScriptValue);
|
||||||
registerEnum("Script.ExternalPaths", QMetaEnum::fromType<ExternalResource::Bucket>());
|
registerEnum("Script.ExternalPaths", QMetaEnum::fromType<ExternalResource::Bucket>());
|
||||||
|
|
||||||
registerGlobalObject("Audio", DependencyManager::get<AudioScriptingInterface>().data());
|
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) {
|
QString ScriptEngine::getExternalPath(ExternalResource::Bucket bucket, const QString& relativePath) {
|
||||||
return ExternalResource::getInstance()->getUrl(bucket, relative_path);
|
return ExternalResource::getInstance()->getUrl(bucket, relativePath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -684,7 +684,7 @@ public:
|
||||||
|
|
||||||
void setScriptEngines(QSharedPointer<ScriptEngines>& scriptEngines) { _scriptEngines = scriptEngines; }
|
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:
|
public slots:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue