mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Type registeration fixes for scripting engine
This commit is contained in:
parent
50a6a63cc3
commit
0a3ec92031
34 changed files with 266 additions and 67 deletions
|
@ -7463,7 +7463,7 @@ void Application::registerScriptEngineWithApplicationServices(const ScriptManage
|
|||
scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
|
||||
|
||||
// hook our avatar and avatar hash map object into this script engine
|
||||
getMyAvatar()->registerMetaTypes(scriptEngine);
|
||||
getMyAvatar()->registerProperties(scriptEngine);
|
||||
|
||||
scriptEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarManager>().data());
|
||||
|
||||
|
@ -7479,8 +7479,6 @@ void Application::registerScriptEngineWithApplicationServices(const ScriptManage
|
|||
connect(scriptManager.get(), &ScriptManager::finished, clipboardScriptable, &ClipboardScriptingInterface::deleteLater);
|
||||
|
||||
scriptEngine->registerGlobalObject("Overlays", &_overlays);
|
||||
scriptRegisterMetaType(scriptEngine.get(), RayToOverlayIntersectionResultToScriptValue,
|
||||
RayToOverlayIntersectionResultFromScriptValue);
|
||||
|
||||
bool clientScript = scriptManager->isClientScript();
|
||||
|
||||
|
@ -7497,14 +7495,8 @@ void Application::registerScriptEngineWithApplicationServices(const ScriptManage
|
|||
}
|
||||
#endif
|
||||
|
||||
scriptRegisterMetaType(scriptEngine.get(), wrapperToScriptValue<ToolbarProxy>, wrapperFromScriptValue<ToolbarProxy>);
|
||||
scriptRegisterMetaType(scriptEngine.get(),
|
||||
wrapperToScriptValue<ToolbarButtonProxy>, wrapperFromScriptValue<ToolbarButtonProxy>);
|
||||
scriptEngine->registerGlobalObject("Toolbars", DependencyManager::get<ToolbarScriptingInterface>().data());
|
||||
|
||||
scriptRegisterMetaType(scriptEngine.get(), wrapperToScriptValue<TabletProxy>, wrapperFromScriptValue<TabletProxy>);
|
||||
scriptRegisterMetaType(scriptEngine.get(),
|
||||
wrapperToScriptValue<TabletButtonProxy>, wrapperFromScriptValue<TabletButtonProxy>);
|
||||
scriptEngine->registerGlobalObject("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
|
||||
// FIXME remove these deprecated names for the tablet scripting interface
|
||||
scriptEngine->registerGlobalObject("tabletInterface", DependencyManager::get<TabletScriptingInterface>().data());
|
||||
|
@ -7554,12 +7546,10 @@ void Application::registerScriptEngineWithApplicationServices(const ScriptManage
|
|||
scriptEngine->registerGlobalObject("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
|
||||
scriptEngine->registerGlobalObject("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
|
||||
scriptEngine->registerGlobalObject("AccountServices", AccountServicesScriptingInterface::getInstance());
|
||||
scriptRegisterMetaType(scriptEngine.get(), DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue);
|
||||
|
||||
scriptEngine->registerGlobalObject("AvatarManager", DependencyManager::get<AvatarManager>().data());
|
||||
|
||||
scriptEngine->registerGlobalObject("LODManager", DependencyManager::get<LODManager>().data());
|
||||
scriptRegisterMetaType(scriptEngine.get(), worldDetailQualityToScriptValue, worldDetailQualityFromScriptValue);
|
||||
|
||||
scriptEngine->registerGlobalObject("Keyboard", DependencyManager::get<KeyboardScriptingInterface>().data());
|
||||
scriptEngine->registerGlobalObject("Performance", new PerformanceScriptingInterface());
|
||||
|
@ -7574,7 +7564,6 @@ void Application::registerScriptEngineWithApplicationServices(const ScriptManage
|
|||
scriptEngine->registerGlobalObject("Render", RenderScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("Workload", _gameWorkload._engine->getConfiguration().get());
|
||||
|
||||
GraphicsScriptingInterface::registerMetaTypes(scriptEngine.get());
|
||||
scriptEngine->registerGlobalObject("Graphics", DependencyManager::get<GraphicsScriptingInterface>().data());
|
||||
|
||||
scriptEngine->registerGlobalObject("ScriptDiscoveryService", DependencyManager::get<ScriptEngines>().data());
|
||||
|
@ -7606,10 +7595,8 @@ void Application::registerScriptEngineWithApplicationServices(const ScriptManage
|
|||
scriptEngine->registerGlobalObject("HifiAbout", AboutUtil::getInstance()); // Deprecated.
|
||||
scriptEngine->registerGlobalObject("ResourceRequestObserver", DependencyManager::get<ResourceRequestObserver>().data());
|
||||
|
||||
registerInteractiveWindowMetaType(scriptEngine.get());
|
||||
|
||||
auto pickScriptingInterface = DependencyManager::get<PickScriptingInterface>();
|
||||
pickScriptingInterface->registerMetaTypes(scriptEngine.get());
|
||||
pickScriptingInterface->registerProperties(scriptEngine.get());
|
||||
|
||||
// connect this script engines printedMessage signal to the global ScriptEngines these various messages
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// Created by Clement on 1/16/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
// Copyright 2021 Vircadia contributors.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -15,11 +16,18 @@
|
|||
#include <SettingHandle.h>
|
||||
#include <Util.h>
|
||||
#include <shared/GlobalAppProperties.h>
|
||||
#include <ScriptEngineCast.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "ui/DialogsManager.h"
|
||||
#include "InterfaceLogging.h"
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, worldDetailQualityToScriptValue, worldDetailQualityFromScriptValue);
|
||||
});
|
||||
|
||||
const QString LOD_SETTINGS_PREFIX { "lodManager/" };
|
||||
|
||||
Setting::Handle<bool> automaticLODAdjust(LOD_SETTINGS_PREFIX + "automaticLODAdjust", (bool)DEFAULT_LOD_AUTO_ADJUST);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Dante Ruiz on 2019-04-15.
|
||||
// Copyright 2019 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -13,7 +14,15 @@
|
|||
#include "RefreshRateManager.h"
|
||||
|
||||
#include <array>
|
||||
#include <ScriptEngineCast.h>
|
||||
#include <ScriptManager.h>
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, scriptValueFromEnumClass<RefreshRateManager::RefreshRateRegime>, scriptValueToEnumClass<RefreshRateManager::RefreshRateRegime>, "RefreshRateRegime");
|
||||
scriptRegisterMetaType(scriptEngine, scriptValueFromEnumClass<RefreshRateManager::UXMode>, scriptValueToEnumClass<RefreshRateManager::UXMode>, "UXMode");
|
||||
});
|
||||
|
||||
static const int VR_TARGET_RATE = 90;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Dante Ruiz on 2019-04-15.
|
||||
// Copyright 2019 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -19,9 +20,12 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
#include <ScriptEngineCast.h>
|
||||
#include <ScriptManager.h>
|
||||
#include <shared/ReadWriteLockable.h>
|
||||
|
||||
class RefreshRateManager {
|
||||
class RefreshRateManager : QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum RefreshRateProfile {
|
||||
ECO = 0,
|
||||
|
@ -29,6 +33,7 @@ public:
|
|||
REALTIME,
|
||||
PROFILE_NUM
|
||||
};
|
||||
Q_ENUM(RefreshRateProfile)
|
||||
static bool isValidRefreshRateProfile(RefreshRateProfile value) { return (value >= RefreshRateProfile::ECO && value <= RefreshRateProfile::REALTIME); }
|
||||
|
||||
/*@jsdoc
|
||||
|
@ -57,6 +62,7 @@ public:
|
|||
SHUTDOWN,
|
||||
REGIME_NUM
|
||||
};
|
||||
Q_ENUM(RefreshRateRegime)
|
||||
static bool isValidRefreshRateRegime(RefreshRateRegime value) { return (value >= RefreshRateRegime::FOCUS_ACTIVE && value <= RefreshRateRegime::SHUTDOWN); }
|
||||
|
||||
/*@jsdoc
|
||||
|
@ -77,6 +83,7 @@ public:
|
|||
VR,
|
||||
UX_NUM
|
||||
};
|
||||
Q_ENUM(UXMode)
|
||||
static bool isValidUXMode(UXMode value) { return (value >= UXMode::DESKTOP && value <= UXMode::VR); }
|
||||
|
||||
RefreshRateManager();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// Created by Mark Peng on 8/16/13.
|
||||
// Copyright 2012 High Fidelity, Inc.
|
||||
// Copyright 2020 Vircadia contributors.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -112,6 +113,12 @@ const QString POINT_BLEND_LINEAR_ALPHA_NAME = "pointBlendAlpha";
|
|||
const QString POINT_REF_JOINT_NAME = "RightShoulder";
|
||||
const float POINT_ALPHA_BLENDING = 1.0f;
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
registerMetaTypes(scriptEngine);
|
||||
});
|
||||
|
||||
const std::array<QString, static_cast<uint>(MyAvatar::AllowAvatarStandingPreference::Count)>
|
||||
MyAvatar::allowAvatarStandingPreferenceStrings = {
|
||||
QStringLiteral("WhenUserIsStanding"),
|
||||
|
@ -439,6 +446,11 @@ void MyAvatar::enableHandTouchForID(const QUuid& entityID) {
|
|||
}
|
||||
|
||||
void MyAvatar::registerMetaTypes(ScriptEnginePointer engine) {
|
||||
scriptRegisterMetaType(engine.get(), audioListenModeToScriptValue, audioListenModeFromScriptValue);
|
||||
scriptRegisterMetaType(engine.get(), driveKeysToScriptValue, driveKeysFromScriptValue);
|
||||
}
|
||||
|
||||
void MyAvatar::registerProperties(ScriptEnginePointer engine) {
|
||||
ScriptValue value = engine->newQObject(this, ScriptEngine::QtOwnership);
|
||||
engine->globalObject().setProperty("MyAvatar", value);
|
||||
|
||||
|
@ -448,11 +460,9 @@ void MyAvatar::registerMetaTypes(ScriptEnginePointer engine) {
|
|||
driveKeys.setProperty(metaEnum.key(i), metaEnum.value(i));
|
||||
}
|
||||
engine->globalObject().setProperty("DriveKeys", driveKeys);
|
||||
|
||||
scriptRegisterMetaType(engine.get(), audioListenModeToScriptValue, audioListenModeFromScriptValue);
|
||||
scriptRegisterMetaType(engine.get(), driveKeysToScriptValue, driveKeysFromScriptValue);
|
||||
}
|
||||
|
||||
|
||||
void MyAvatar::setOrientationVar(const QVariant& newOrientationVar) {
|
||||
Avatar::setWorldOrientation(quatFromVariant(newOrientationVar));
|
||||
}
|
||||
|
|
|
@ -584,7 +584,8 @@ public:
|
|||
virtual ~MyAvatar();
|
||||
|
||||
void instantiableAvatar() override {};
|
||||
void registerMetaTypes(ScriptEnginePointer engine);
|
||||
static void registerMetaTypes(ScriptEnginePointer engine);
|
||||
void registerProperties(ScriptEnginePointer engine);
|
||||
|
||||
virtual void simulateAttachments(float deltaTime) override;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//
|
||||
// Created by Sam Gondelman 10/20/2017
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -32,6 +33,12 @@
|
|||
#include <ScriptEngineCast.h>
|
||||
#include <ScriptValueUtils.h>
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
PickScriptingInterface::registerMetaTypes(scriptEngine);
|
||||
});
|
||||
|
||||
static const float WEB_TOUCH_Y_OFFSET = 0.105f; // how far forward (or back with a negative number) to slide stylus in hand
|
||||
static const glm::vec3 TIP_OFFSET = glm::vec3(0.0f, StylusPick::WEB_STYLUS_LENGTH - WEB_TOUCH_Y_OFFSET, 0.0f);
|
||||
|
||||
|
@ -457,14 +464,16 @@ bool pickTypesFromScriptValue(const ScriptValue& object, PickQuery::PickType& pi
|
|||
}
|
||||
|
||||
void PickScriptingInterface::registerMetaTypes(ScriptEngine* engine) {
|
||||
scriptRegisterMetaType(engine, pickTypesToScriptValue, pickTypesFromScriptValue);
|
||||
}
|
||||
|
||||
void PickScriptingInterface::registerProperties(ScriptEngine* engine) {
|
||||
ScriptValue pickTypes = engine->newObject();
|
||||
auto metaEnum = QMetaEnum::fromType<PickQuery::PickType>();
|
||||
for (int i = 0; i < PickQuery::PickType::NUM_PICK_TYPES; ++i) {
|
||||
pickTypes.setProperty(metaEnum.key(i), metaEnum.value(i));
|
||||
}
|
||||
engine->globalObject().setProperty("PickType", pickTypes);
|
||||
|
||||
scriptRegisterMetaType(engine, pickTypesToScriptValue, pickTypesFromScriptValue);
|
||||
}
|
||||
|
||||
unsigned int PickScriptingInterface::getPerFrameTimeBudget() const {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//
|
||||
// Created by Sam Gondelman 10/20/2017
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -106,7 +107,8 @@ class PickScriptingInterface : public QObject, public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
void registerMetaTypes(ScriptEngine* engine);
|
||||
static void registerMetaTypes(ScriptEngine* engine);
|
||||
void registerProperties(ScriptEngine* engine);
|
||||
|
||||
/*@jsdoc
|
||||
* Creates a new pick. Different {@link PickType}s use different properties, and within one PickType the properties you
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Thijs Wenker on 9/10/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -11,11 +12,19 @@
|
|||
|
||||
#include "AccountServicesScriptingInterface.h"
|
||||
|
||||
#include <ScriptEngineCast.h>
|
||||
|
||||
#include "AccountManager.h"
|
||||
#include "Application.h"
|
||||
#include "DiscoverabilityManager.h"
|
||||
#include "ResourceCache.h"
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue);
|
||||
});
|
||||
|
||||
AccountServicesScriptingInterface::AccountServicesScriptingInterface() {
|
||||
auto accountManager = DependencyManager::get<AccountManager>();
|
||||
connect(accountManager.data(), &AccountManager::usernameChanged, this, &AccountServicesScriptingInterface::onUsernameChanged);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "../Application.h"
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager){
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, scriptValueFromEnumClass<PerformanceScriptingInterface::PerformancePreset>, scriptValueToEnumClass<PerformanceScriptingInterface::PerformancePreset>, "PerformancePreset");
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <sstream>
|
||||
#endif
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager){
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, scriptValueFromEnumClass<PlatformInfoScriptingInterface::PlatformTier>, scriptValueToEnumClass<PlatformInfoScriptingInterface::PlatformTier>, "PlatformTier");
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
#include <QScreen>
|
||||
#include "ScreenName.h"
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager){
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, scriptValueFromEnumClass<RenderScriptingInterface::RenderMethod>, scriptValueToEnumClass<RenderScriptingInterface::RenderMethod>, "RenderMethod");
|
||||
scriptRegisterMetaType(scriptEngine, scriptValueFromEnumClass<AntialiasingConfig::Mode>, scriptValueToEnumClass<AntialiasingConfig::Mode>, "Mode");
|
||||
});
|
||||
|
||||
RenderScriptingInterface* RenderScriptingInterface::getInstance() {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Thijs Wenker on 2018-06-25
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -35,6 +36,12 @@
|
|||
#include <WinUser.h>
|
||||
#endif
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
registerInteractiveWindowMetaType(scriptEngine);
|
||||
});
|
||||
|
||||
static auto CONTENT_WINDOW_QML = QUrl("InteractiveWindow.qml");
|
||||
|
||||
static const char* const ADDITIONAL_FLAGS_PROPERTY = "additionalFlags";
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// interface/src/ui/overlays
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -42,6 +43,13 @@ Q_LOGGING_CATEGORY(trace_render_overlays, "trace.render.overlays")
|
|||
std::unordered_map<QString, QString> Overlays::_entityToOverlayTypes;
|
||||
std::unordered_map<QString, QString> Overlays::_overlayToEntityTypes;
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
|
||||
RayToOverlayIntersectionResultFromScriptValue);
|
||||
});
|
||||
|
||||
Overlays::Overlays() : _scriptEngine(newScriptEngine()) {
|
||||
ADD_TYPE_MAP(Box, cube);
|
||||
ADD_TYPE_MAP(Sphere, sphere);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Andrzej Kapolka on 4/17/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -18,10 +19,14 @@
|
|||
|
||||
#include "AnimationCache.h"
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager) {
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager) {
|
||||
registerAnimationTypes(manager->engine().get());
|
||||
});
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager) {
|
||||
registerAnimationPrototypes(manager->engine().get());
|
||||
});
|
||||
|
||||
QStringList AnimationObject::getJointNames() const {
|
||||
return scriptvalue_cast<AnimationPointer>(thisObject())->getJointNames();
|
||||
}
|
||||
|
@ -36,9 +41,11 @@ QVector<glm::quat> AnimationFrameObject::getRotations() const {
|
|||
|
||||
void registerAnimationTypes(ScriptEngine* engine) {
|
||||
scriptRegisterSequenceMetaType<QVector<HFMAnimationFrame> >(engine);
|
||||
}
|
||||
|
||||
void registerAnimationPrototypes(ScriptEngine* engine) {
|
||||
engine->setDefaultPrototype(qMetaTypeId<HFMAnimationFrame>(), engine->newQObject(
|
||||
new AnimationFrameObject(), ScriptEngine::ScriptOwnership));
|
||||
engine->setDefaultPrototype(qMetaTypeId<AnimationPointer>(), engine->newQObject(
|
||||
new AnimationObject(), ScriptEngine::ScriptOwnership));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Andrzej Kapolka on 4/17/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -87,5 +88,6 @@ public:
|
|||
};
|
||||
|
||||
void registerAnimationTypes(ScriptEngine* engine);
|
||||
void registerAnimationPrototypes(ScriptEngine* engine);
|
||||
|
||||
#endif // hifi_AnimationObject_h
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// libraries/audio/src
|
||||
//
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -14,14 +15,31 @@
|
|||
#include <ScriptEngine.h>
|
||||
#include <ScriptManager.h>
|
||||
#include <ScriptValue.h>
|
||||
#include <ScriptEngineCast.h>
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager) {
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, audioEffectOptionsToScriptValue, audioEffectOptionsFromScriptValue);
|
||||
});
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager) {
|
||||
auto scriptEngine = manager->engine();
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
ScriptValue audioEffectOptionsConstructorValue = scriptEngine->newFunction(AudioEffectOptions::constructor);
|
||||
scriptEngine->globalObject().setProperty("AudioEffectOptions", audioEffectOptionsConstructorValue);
|
||||
});
|
||||
|
||||
ScriptValue audioEffectOptionsToScriptValue(ScriptEngine* scriptEngine, const AudioEffectOptions& audioEffectOptions) {
|
||||
qCritical() << "Conversion of AudioEffectOptions to ScriptValue should never happen.";
|
||||
return ScriptValue();
|
||||
}
|
||||
|
||||
bool audioEffectOptionsFromScriptValue(const ScriptValue& scriptValue, AudioEffectOptions& audioEffectOptions) {
|
||||
audioEffectOptions = AudioEffectOptions(scriptValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
static const QString BANDWIDTH_HANDLE = "bandwidth";
|
||||
static const QString PRE_DELAY_HANDLE = "preDelay";
|
||||
static const QString LATE_DELAY_HANDLE = "lateDelay";
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// libraries/audio/src
|
||||
//
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -182,4 +183,10 @@ private:
|
|||
float _wetDryMix; // [0, 100] percent
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(AudioEffectOptions);
|
||||
|
||||
ScriptValue audioEffectOptionsToScriptValue(ScriptEngine* scriptEngine, const AudioEffectOptions& audioEffectOptions);
|
||||
|
||||
bool audioEffectOptionsFromScriptValue(const ScriptValue& scriptValue, AudioEffectOptions& audioEffectOptions);
|
||||
|
||||
#endif // hifi_AudioEffectOptions_h
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Stephen Birarda on 1/2/2014.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -21,15 +22,18 @@
|
|||
#include <ScriptEngineLogging.h>
|
||||
#include <ScriptManager.h>
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
registerAudioMetaTypes(scriptEngine);
|
||||
});
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
registerAudioMetaTypes(scriptEngine);
|
||||
scriptEngine->registerGlobalObject("Audio", DependencyManager::get<AudioScriptingInterface>().data());
|
||||
});
|
||||
|
||||
|
||||
void registerAudioMetaTypes(ScriptEngine* engine) {
|
||||
scriptRegisterMetaType(engine, injectorOptionsToScriptValue, injectorOptionsFromScriptValue);
|
||||
scriptRegisterMetaType(engine, soundSharedPointerToScriptValue, soundSharedPointerFromScriptValue);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Stephen Birarda on 2015-02-11.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -17,7 +18,7 @@
|
|||
#include <ScriptManager.h>
|
||||
#include <ScriptValue.h>
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager) {
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager) {
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, injectorToScriptValue, injectorFromScriptValue);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Stephen Birarda on 4/9/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -68,7 +69,7 @@ static const float DEFAULT_AVATAR_DENSITY = 1000.0f; // density of water
|
|||
|
||||
#define ASSERT(COND) do { if (!(COND)) { abort(); } } while(0)
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager) {
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager) {
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
registerAvatarTypes(scriptEngine);
|
||||
|
@ -76,6 +77,12 @@ STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager) {
|
|||
scriptRegisterMetaType(scriptEngine, AvatarEntityMapToScriptValue, AvatarEntityMapFromScriptValue);
|
||||
});
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager) {
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
registerAvatarPrototypes(scriptEngine);
|
||||
});
|
||||
|
||||
size_t AvatarDataPacket::maxFaceTrackerInfoSize(size_t numBlendshapeCoefficients) {
|
||||
return FACE_TRACKER_INFO_SIZE + numBlendshapeCoefficients * sizeof(float);
|
||||
}
|
||||
|
@ -2609,6 +2616,9 @@ bool AttachmentDataObject::getIsSoft() const {
|
|||
|
||||
void registerAvatarTypes(ScriptEngine* engine) {
|
||||
scriptRegisterSequenceMetaType<QVector<AttachmentData> >(engine);
|
||||
}
|
||||
|
||||
void registerAvatarPrototypes(ScriptEngine* engine) {
|
||||
engine->setDefaultPrototype(qMetaTypeId<AttachmentData>(), engine->newQObject(
|
||||
new AttachmentDataObject(), ScriptEngine::ScriptOwnership));
|
||||
}
|
||||
|
|
|
@ -1958,6 +1958,7 @@ public:
|
|||
};
|
||||
|
||||
void registerAvatarTypes(ScriptEngine* engine);
|
||||
void registerAvatarPrototypes(ScriptEngine* engine);
|
||||
|
||||
class RayToAvatarIntersectionResult {
|
||||
public:
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Zach Fox on 2017-04-10.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -25,7 +26,7 @@ bool avatarDataFromScriptValue(const ScriptValue& object, ScriptAvatarData*& out
|
|||
return false;
|
||||
}
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager) {
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager) {
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, avatarDataToScriptValue, avatarDataFromScriptValue);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis 2015/10/09
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -40,7 +41,7 @@ bool inputControllerFromScriptValue(const ScriptValue& object, controller::Input
|
|||
return true;
|
||||
}
|
||||
|
||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager) {
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager) {
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, inputControllerToScriptValue, inputControllerFromScriptValue);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Brad Hefta-Gaub on 12/6/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -48,13 +49,9 @@
|
|||
const QString GRABBABLE_USER_DATA = "{\"grabbableKey\":{\"grabbable\":true}}";
|
||||
const QString NOT_GRABBABLE_USER_DATA = "{\"grabbableKey\":{\"grabbable\":false}}";
|
||||
|
||||
void staticEntityScriptInitializer(ScriptManager* manager) {
|
||||
void staticEntityScriptTypesInitializer(ScriptManager* manager) {
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||
entityScriptingInterface->init();
|
||||
auto interfacePtr = entityScriptingInterface.data(); // using this when we don't want to leak a reference
|
||||
|
||||
registerMetaTypes(scriptEngine);
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, EntityPropertyFlagsToScriptValue, EntityPropertyFlagsFromScriptValue);
|
||||
|
@ -62,6 +59,15 @@ void staticEntityScriptInitializer(ScriptManager* manager) {
|
|||
scriptRegisterMetaType(scriptEngine, EntityPropertyInfoToScriptValue, EntityPropertyInfoFromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, EntityItemIDtoScriptValue, EntityItemIDfromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, RayToEntityIntersectionResultToScriptValue, RayToEntityIntersectionResultFromScriptValue);
|
||||
}
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(staticEntityScriptTypesInitializer);
|
||||
|
||||
void staticEntityScriptInitializer(ScriptManager* manager) {
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||
entityScriptingInterface->init();
|
||||
auto interfacePtr = entityScriptingInterface.data(); // using this when we don't want to leak a reference
|
||||
|
||||
scriptEngine->registerGlobalObject("Entities", entityScriptingInterface.data());
|
||||
scriptEngine->registerFunction("Entities", "getMultipleEntityProperties", EntityScriptingInterface::getMultipleEntityProperties);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// libraries/graphics-scripting/src
|
||||
//
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -19,6 +20,7 @@
|
|||
#include <QUuid>
|
||||
#include <ScriptEngine.h>
|
||||
#include <ScriptEngineCast.h>
|
||||
#include <ScriptManager.h>
|
||||
#include <ScriptValue.h>
|
||||
#include <ScriptValueUtils.h>
|
||||
#include <graphics/BufferViewHelpers.h>
|
||||
|
@ -26,6 +28,13 @@
|
|||
#include <shared/QtHelpers.h>
|
||||
#include <SpatiallyNestable.h>
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
GraphicsScriptingInterface::registerMetaTypes(scriptEngine);
|
||||
});
|
||||
|
||||
|
||||
GraphicsScriptingInterface::GraphicsScriptingInterface(QObject* parent) : QObject(parent), Scriptable() {
|
||||
}
|
||||
|
||||
|
|
|
@ -214,6 +214,7 @@ public:
|
|||
Suggestions,
|
||||
VisitUserFromPAL
|
||||
};
|
||||
Q_ENUM(LookupTrigger)
|
||||
|
||||
bool isConnected();
|
||||
QString getProtocol() const;
|
||||
|
|
|
@ -76,12 +76,12 @@ int scriptRegisterMetaType(ScriptEngine* eng,
|
|||
if (strlen(name) > 0) { // make sure it's registered
|
||||
id = qRegisterMetaType<T>(name);
|
||||
} else {
|
||||
if (!QMetaType::fromType<T>().name().isNull()) {
|
||||
qDebug() << "scriptRegisterMetaType: " << QMetaType::fromType<T>().name();
|
||||
id = qRegisterMetaType<T>(QMetaType::fromType<T>().name());
|
||||
}else{
|
||||
//if (!QMetaType::fromType<T>().name().isNull()) {
|
||||
//qDebug() << "scriptRegisterMetaType: " << QMetaType::fromType<T>().name();
|
||||
//id = qRegisterMetaType<T>(QMetaType::fromType<T>().name());
|
||||
//}else{
|
||||
id = qRegisterMetaType<T>();
|
||||
}
|
||||
//}
|
||||
}
|
||||
eng->registerCustomType(id, reinterpret_cast<ScriptEngine::MarshalFunction>(toScriptValue),
|
||||
reinterpret_cast<ScriptEngine::DemarshalFunction>(fromScriptValue));
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Brad Hefta-Gaub on 12/14/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -88,6 +89,7 @@ Q_DECLARE_METATYPE(ScriptValue);
|
|||
// --- Static script initialization registry
|
||||
|
||||
static ScriptManager::StaticInitializerNode* rootInitializer = nullptr;
|
||||
static ScriptManager::StaticTypesInitializerNode* rootTypesInitializer = nullptr;
|
||||
|
||||
void ScriptManager::registerNewStaticInitializer(StaticInitializerNode* dest) {
|
||||
// this function is assumed to be called on LoadLibrary, where we are explicitly operating in single-threaded mode
|
||||
|
@ -102,6 +104,19 @@ static void runStaticInitializers(ScriptManager* manager) {
|
|||
here = here->prev;
|
||||
}
|
||||
}
|
||||
void ScriptManager::registerNewStaticTypesInitializer(StaticTypesInitializerNode* dest) {
|
||||
// this function is assumed to be called on LoadLibrary, where we are explicitly operating in single-threaded mode
|
||||
// Therefore there is no mutex or threadsafety here and the structure is assumed not to change after loading
|
||||
dest->prev = rootTypesInitializer;
|
||||
rootTypesInitializer = dest;
|
||||
}
|
||||
static void runStaticTypesInitializers(ScriptManager* manager) {
|
||||
ScriptManager::StaticTypesInitializerNode* here = rootTypesInitializer;
|
||||
while (here != nullptr) {
|
||||
(*here->init)(manager);
|
||||
here = here->prev;
|
||||
}
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
|
@ -210,12 +225,11 @@ ScriptManagerPointer newScriptManager(ScriptManager::Context context,
|
|||
const QString& fileNameString) {
|
||||
ScriptManagerPointer manager(new ScriptManager(context, scriptContents, fileNameString),
|
||||
[](ScriptManager* obj) { obj->deleteLater(); });
|
||||
ScriptEnginePointer engine = newScriptEngine(manager.get());
|
||||
manager->_engine = engine;
|
||||
return manager;
|
||||
}
|
||||
|
||||
int ScriptManager::processLevelMaxRetries { ScriptRequest::MAX_RETRIES };
|
||||
|
||||
ScriptManager::ScriptManager(Context context, const QString& scriptContents, const QString& fileNameString) :
|
||||
QObject(),
|
||||
_context(context),
|
||||
|
@ -267,6 +281,10 @@ ScriptManager::ScriptManager(Context context, const QString& scriptContents, con
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!_areMetaTypesInitialized) {
|
||||
initMetaTypes();
|
||||
}
|
||||
}
|
||||
|
||||
QString ScriptManager::getTypeAsString() const {
|
||||
|
@ -615,17 +633,13 @@ void ScriptManager::resetModuleCache(bool deleteScriptCache) {
|
|||
jsRequire.setProperty("cache", cache, READONLY_PROP_FLAGS);
|
||||
}
|
||||
|
||||
void ScriptManager::init() {
|
||||
if (_isInitialized) {
|
||||
return; // only initialize once
|
||||
void ScriptManager::initMetaTypes() {
|
||||
if (_areMetaTypesInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
_isInitialized = true;
|
||||
runStaticInitializers(this);
|
||||
|
||||
_areMetaTypesInitialized = true;
|
||||
auto scriptEngine = _engine.get();
|
||||
|
||||
// register various meta-types
|
||||
runStaticTypesInitializers(this);
|
||||
registerMIDIMetaTypes(scriptEngine);
|
||||
registerEventTypes(scriptEngine);
|
||||
registerMenuItemProperties(scriptEngine);
|
||||
|
@ -636,6 +650,29 @@ void ScriptManager::init() {
|
|||
scriptRegisterSequenceMetaType<QVector<glm::vec2>>(scriptEngine);
|
||||
scriptRegisterSequenceMetaType<QVector<glm::quat>>(scriptEngine);
|
||||
scriptRegisterSequenceMetaType<QVector<QString>>(scriptEngine);
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, animationDetailsToScriptValue, animationDetailsFromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, webSocketToScriptValue, webSocketFromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, qWSCloseCodeToScriptValue, qWSCloseCodeFromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, wscReadyStateToScriptValue, wscReadyStateFromScriptValue);
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, externalResourceBucketToScriptValue, externalResourceBucketFromScriptValue);
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, scriptableResourceToScriptValue, scriptableResourceFromScriptValue);
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, meshToScriptValue, meshFromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, meshesToScriptValue, meshesFromScriptValue);
|
||||
}
|
||||
|
||||
void ScriptManager::init() {
|
||||
if (_isInitialized) {
|
||||
return; // only initialize once
|
||||
}
|
||||
|
||||
_isInitialized = true;
|
||||
runStaticInitializers(this);
|
||||
|
||||
auto scriptEngine = _engine.get();
|
||||
|
||||
ScriptValue xmlHttpRequestConstructorValue = scriptEngine->newFunction(XMLHttpRequestClass::constructor);
|
||||
scriptEngine->globalObject().setProperty("XMLHttpRequest", xmlHttpRequestConstructorValue);
|
||||
|
@ -652,11 +689,6 @@ void ScriptManager::init() {
|
|||
*/
|
||||
scriptEngine->globalObject().setProperty("print", scriptEngine->newFunction(debugPrint));
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, animationDetailsToScriptValue, animationDetailsFromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, webSocketToScriptValue, webSocketFromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, qWSCloseCodeToScriptValue, qWSCloseCodeFromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, wscReadyStateToScriptValue, wscReadyStateFromScriptValue);
|
||||
|
||||
// NOTE: You do not want to end up creating new instances of singletons here. They will be on the ScriptManager thread
|
||||
// and are likely to be unusable if we "reset" the ScriptManager by creating a new one (on a whole new thread).
|
||||
|
||||
|
@ -671,7 +703,6 @@ void ScriptManager::init() {
|
|||
resetModuleCache();
|
||||
}
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, externalResourceBucketToScriptValue, externalResourceBucketFromScriptValue);
|
||||
scriptEngine->registerEnum("Script.ExternalPaths", QMetaEnum::fromType<ExternalResource::Bucket>());
|
||||
|
||||
scriptEngine->registerGlobalObject("Quat", &_quatLibrary);
|
||||
|
@ -696,7 +727,6 @@ void ScriptManager::init() {
|
|||
auto resourcePrototype = createScriptableResourcePrototype(shared_from_this());
|
||||
scriptEngine->globalObject().setProperty("Resource", resourcePrototype);
|
||||
scriptEngine->setDefaultPrototype(qMetaTypeId<ScriptableResource*>(), resourcePrototype);
|
||||
scriptRegisterMetaType(scriptEngine, scriptableResourceToScriptValue, scriptableResourceFromScriptValue);
|
||||
|
||||
// constants
|
||||
scriptEngine->globalObject().setProperty("TREE_SCALE", scriptEngine->newValue(TREE_SCALE));
|
||||
|
@ -706,9 +736,6 @@ void ScriptManager::init() {
|
|||
|
||||
scriptEngine->registerGlobalObject("DebugDraw", &DebugDraw::getInstance());
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, meshToScriptValue, meshFromScriptValue);
|
||||
scriptRegisterMetaType(scriptEngine, meshesToScriptValue, meshesFromScriptValue);
|
||||
|
||||
scriptEngine->registerGlobalObject("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
|
||||
|
||||
#if DEV_BUILD || PR_BUILD
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// Created by Brad Hefta-Gaub on 12/14/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
// Copyright 2020 Vircadia contributors.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -104,7 +105,10 @@ public:
|
|||
QUrl definingSandboxURL { QUrl("about:EntityScript") };
|
||||
};
|
||||
|
||||
// declare a static script initializer
|
||||
// declare a static script initializers
|
||||
#define STATIC_SCRIPT_TYPES_INITIALIZER(init) \
|
||||
static ScriptManager::StaticTypesInitializerNode static_script_types_initializer_(init);
|
||||
|
||||
#define STATIC_SCRIPT_INITIALIZER(init) \
|
||||
static ScriptManager::StaticInitializerNode static_script_initializer_(init);
|
||||
|
||||
|
@ -179,6 +183,13 @@ public:
|
|||
};
|
||||
static void registerNewStaticInitializer(StaticInitializerNode* dest);
|
||||
|
||||
class StaticTypesInitializerNode {
|
||||
public:
|
||||
ScriptManagerInitializer init;
|
||||
StaticTypesInitializerNode* prev;
|
||||
inline StaticTypesInitializerNode(ScriptManagerInitializer&& pInit) : init(std::move(pInit)),prev(nullptr) { registerNewStaticTypesInitializer(this); }
|
||||
};
|
||||
static void registerNewStaticTypesInitializer(StaticTypesInitializerNode* dest);
|
||||
/// run the script in a dedicated thread. This will have the side effect of evalulating
|
||||
/// the current script contents and calling run(). Callers will likely want to register the script with external
|
||||
/// services before calling this.
|
||||
|
@ -874,6 +885,9 @@ signals:
|
|||
void releaseEntityPacketSenderMessages(bool wait);
|
||||
|
||||
protected:
|
||||
// Is called by the constructor, bceause all types need to be registered before method discovery with ScriptObjectQtProxy::investigate()
|
||||
void initMetaTypes();
|
||||
|
||||
void init();
|
||||
|
||||
/**jsdoc
|
||||
|
@ -934,6 +948,7 @@ protected:
|
|||
std::atomic<bool> _isFinished { false };
|
||||
std::atomic<bool> _isRunning { false };
|
||||
std::atomic<bool> _isStopping { false };
|
||||
bool _areMetaTypesInitialized { false };
|
||||
bool _isInitialized { false };
|
||||
QHash<QTimer*, CallbackData> _timerFunctionMap;
|
||||
QSet<QUrl> _includedURLs;
|
||||
|
|
|
@ -42,6 +42,7 @@ void ScriptEngineQtScript::registerCustomType(int type,
|
|||
CustomMarshal& customType = _customTypes.insert(type, CustomMarshal()).value();
|
||||
customType.demarshalFunc = demarshalFunc;
|
||||
customType.marshalFunc = marshalFunc;
|
||||
qDebug() << "registerCustomType: " << QMetaType(type).name() << " type: " << type << " map size: " << _customTypes.size();
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(ScriptValue);
|
||||
|
@ -209,6 +210,13 @@ bool ScriptEngineQtScript::castValueToVariant(const QScriptValue& val, QVariant&
|
|||
}
|
||||
}
|
||||
}
|
||||
/* if (QMetaType(destTypeId).name() == "MenuItemProperties") {
|
||||
qDebug() << "castValueToVariant MenuItemProperties " << destTypeId << "map size: " << _customTypes.size();
|
||||
for (auto iter = _customTypes.keyBegin(); iter != _customTypes.keyEnd(); iter++){
|
||||
qDebug() << (*iter);
|
||||
}
|
||||
printf("castValueToVariant MenuItemProperties");
|
||||
}*/
|
||||
|
||||
if (destTypeId == qMetaTypeId<ScriptValue>()) {
|
||||
dest = QVariant::fromValue(ScriptValue(new ScriptValueQtWrapper(this, val)));
|
||||
|
|
|
@ -134,6 +134,7 @@ void ScriptObjectQtProxy::investigate() {
|
|||
if (!qobject) return;
|
||||
|
||||
const QMetaObject* metaObject = qobject->metaObject();
|
||||
qDebug() << "ScriptObjectQtProxy::investigate: " << metaObject->className();
|
||||
|
||||
// discover properties
|
||||
int startIdx = _wrapOptions & ScriptEngine::ExcludeSuperClassProperties ? metaObject->propertyOffset() : 0;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//
|
||||
// Created by Anthony J. Thibault on 2016-12-12
|
||||
// Copyright 2013-2016 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -17,6 +18,8 @@
|
|||
#include <DependencyManager.h>
|
||||
#include <AccountManager.h>
|
||||
#include <RegisteredMetaTypes.h>
|
||||
#include <ScriptManager.h>
|
||||
#include <ScriptEngineCast.h>
|
||||
|
||||
#include "../QmlWindowClass.h"
|
||||
#include "../OffscreenUi.h"
|
||||
|
@ -28,6 +31,14 @@
|
|||
|
||||
#include "SettingHandle.h"
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, wrapperToScriptValue<TabletProxy>, wrapperFromScriptValue<TabletProxy>);
|
||||
scriptRegisterMetaType(scriptEngine,
|
||||
wrapperToScriptValue<TabletButtonProxy>, wrapperFromScriptValue<TabletButtonProxy>);
|
||||
});
|
||||
|
||||
// FIXME move to global app properties
|
||||
const QString SYSTEM_TOOLBAR = "com.highfidelity.interface.toolbar.system";
|
||||
const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis on 2016-06-16
|
||||
// Copyright 2013-2016 High Fidelity, Inc.
|
||||
// Copyright 2022 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -12,10 +13,20 @@
|
|||
#include <QtQuick/QQuickItem>
|
||||
#include <ScriptValue.h>
|
||||
#include <ScriptEngine.h>
|
||||
#include <ScriptEngineCast.h>
|
||||
#include <ScriptManager.h>
|
||||
|
||||
#include <shared/QtHelpers.h>
|
||||
#include "../OffscreenUi.h"
|
||||
|
||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||
auto scriptEngine = manager->engine().get();
|
||||
|
||||
scriptRegisterMetaType(scriptEngine, wrapperToScriptValue<ToolbarProxy>, wrapperFromScriptValue<ToolbarProxy>);
|
||||
scriptRegisterMetaType(scriptEngine,
|
||||
wrapperToScriptValue<ToolbarButtonProxy>, wrapperFromScriptValue<ToolbarButtonProxy>);
|
||||
});
|
||||
|
||||
ScriptValue toolbarToScriptValue(ScriptEngine* engine, ToolbarProxy* const &in) {
|
||||
if (!in) {
|
||||
return engine->undefinedValue();
|
||||
|
|
Loading…
Reference in a new issue