mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
Merge remote-tracking branch 'upstream/master' into gha
This commit is contained in:
commit
02f7f494fa
26 changed files with 514 additions and 389 deletions
|
@ -1238,7 +1238,7 @@ void DomainGatekeeper::requestDomainUser(const QString& username, const QString&
|
||||||
|
|
||||||
// Get data pertaining to "me", the user who generated the access token.
|
// Get data pertaining to "me", the user who generated the access token.
|
||||||
const QString WORDPRESS_USER_ROUTE = "wp/v2/users/me";
|
const QString WORDPRESS_USER_ROUTE = "wp/v2/users/me";
|
||||||
const QString WORDPRESS_USER_QUERY = "_fields=username,roles";
|
const QString WORDPRESS_USER_QUERY = "_fields=username,email,roles";
|
||||||
QUrl domainUserURL = apiBase + WORDPRESS_USER_ROUTE + (apiBase.contains("?") ? "&" : "?") + WORDPRESS_USER_QUERY;
|
QUrl domainUserURL = apiBase + WORDPRESS_USER_ROUTE + (apiBase.contains("?") ? "&" : "?") + WORDPRESS_USER_QUERY;
|
||||||
|
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
|
@ -1270,8 +1270,13 @@ void DomainGatekeeper::requestDomainUserFinished() {
|
||||||
if (200 <= httpStatus && httpStatus < 300) {
|
if (200 <= httpStatus && httpStatus < 300) {
|
||||||
|
|
||||||
QString username = rootObject.value("username").toString().toLower();
|
QString username = rootObject.value("username").toString().toLower();
|
||||||
if (_inFlightDomainUserIdentityRequests.contains(username)) {
|
QString email = rootObject.value("email").toString().toLower();
|
||||||
|
|
||||||
|
if (_inFlightDomainUserIdentityRequests.contains(username) || _inFlightDomainUserIdentityRequests.contains(email)) {
|
||||||
// Success! Verified user.
|
// Success! Verified user.
|
||||||
|
if (!_inFlightDomainUserIdentityRequests.contains(username)) {
|
||||||
|
username = email;
|
||||||
|
}
|
||||||
_verifiedDomainUserIdentities.insert(username, _inFlightDomainUserIdentityRequests.value(username));
|
_verifiedDomainUserIdentities.insert(username, _inFlightDomainUserIdentityRequests.value(username));
|
||||||
_inFlightDomainUserIdentityRequests.remove(username);
|
_inFlightDomainUserIdentityRequests.remove(username);
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ Item {
|
||||||
displayNameField.placeholderText = "Display Name (optional)";
|
displayNameField.placeholderText = "Display Name (optional)";
|
||||||
var savedDisplayName = Settings.getValue("Avatar/displayName", "");
|
var savedDisplayName = Settings.getValue("Avatar/displayName", "");
|
||||||
displayNameField.text = savedDisplayName;
|
displayNameField.text = savedDisplayName;
|
||||||
emailField.placeholderText = (!isLoggingInToDomain) ? "Username or Email" : "Username";
|
emailField.placeholderText = "Username or Email";
|
||||||
if (!isLoggingInToDomain) {
|
if (!isLoggingInToDomain) {
|
||||||
var savedUsername = Settings.getValue("keepMeLoggedIn/savedUsername", "");
|
var savedUsername = Settings.getValue("keepMeLoggedIn/savedUsername", "");
|
||||||
emailField.text = keepMeLoggedInCheckbox.checked ? savedUsername === "Unknown user" ? "" : savedUsername : "";
|
emailField.text = keepMeLoggedInCheckbox.checked ? savedUsername === "Unknown user" ? "" : savedUsername : "";
|
||||||
|
|
|
@ -312,9 +312,9 @@ Rectangle {
|
||||||
parent.color = hifi.colors.blueHighlight;
|
parent.color = hifi.colors.blueHighlight;
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
lightboxPopup.titleText = "Script Plugin Infrastructure by Kasen";
|
lightboxPopup.titleText = "Script Plugin Infrastructure";
|
||||||
lightboxPopup.bodyText = "Toggles the activation of scripting plugins in the 'plugins/scripting' folder. \n\n"
|
lightboxPopup.bodyText = "Toggles the activation of scripting plugins in the 'plugins/scripting' folder. \n\n"
|
||||||
+ "Created by https://kasen.io/";
|
+ "Created by:\n humbletim@gmail.com\n kasenvr@gmail.com";
|
||||||
lightboxPopup.button1text = "OK";
|
lightboxPopup.button1text = "OK";
|
||||||
lightboxPopup.button1method = function() {
|
lightboxPopup.button1method = function() {
|
||||||
lightboxPopup.visible = false;
|
lightboxPopup.visible = false;
|
||||||
|
|
|
@ -355,6 +355,7 @@ static const QString DESKTOP_DISPLAY_PLUGIN_NAME = "Desktop";
|
||||||
static const QString ACTIVE_DISPLAY_PLUGIN_SETTING_NAME = "activeDisplayPlugin";
|
static const QString ACTIVE_DISPLAY_PLUGIN_SETTING_NAME = "activeDisplayPlugin";
|
||||||
static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system";
|
static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system";
|
||||||
static const QString KEEP_ME_LOGGED_IN_SETTING_NAME = "keepMeLoggedIn";
|
static const QString KEEP_ME_LOGGED_IN_SETTING_NAME = "keepMeLoggedIn";
|
||||||
|
static const QString CACHEBUST_SCRIPT_REQUIRE_SETTING_NAME = "cachebustScriptRequire";
|
||||||
|
|
||||||
static const float FOCUS_HIGHLIGHT_EXPANSION_FACTOR = 1.05f;
|
static const float FOCUS_HIGHLIGHT_EXPANSION_FACTOR = 1.05f;
|
||||||
|
|
||||||
|
@ -1966,6 +1967,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
updateVerboseLogging();
|
updateVerboseLogging();
|
||||||
|
|
||||||
|
setCachebustRequire();
|
||||||
|
|
||||||
// Make sure we don't time out during slow operations at startup
|
// Make sure we don't time out during slow operations at startup
|
||||||
updateHeartbeat();
|
updateHeartbeat();
|
||||||
|
@ -2600,6 +2603,16 @@ void Application::updateVerboseLogging() {
|
||||||
QLoggingCategory::setFilterRules(rules);
|
QLoggingCategory::setFilterRules(rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setCachebustRequire() {
|
||||||
|
auto menu = Menu::getInstance();
|
||||||
|
if (!menu) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool enable = menu->isOptionChecked(MenuOption::CachebustRequire);
|
||||||
|
|
||||||
|
Setting::Handle<bool>{ CACHEBUST_SCRIPT_REQUIRE_SETTING_NAME, false }.set(enable);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {
|
void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {
|
||||||
DomainHandler::ConnectionRefusedReason reasonCode = static_cast<DomainHandler::ConnectionRefusedReason>(reasonCodeInt);
|
DomainHandler::ConnectionRefusedReason reasonCode = static_cast<DomainHandler::ConnectionRefusedReason>(reasonCodeInt);
|
||||||
|
|
||||||
|
|
|
@ -472,6 +472,8 @@ public slots:
|
||||||
void setIsInterstitialMode(bool interstitialMode);
|
void setIsInterstitialMode(bool interstitialMode);
|
||||||
|
|
||||||
void updateVerboseLogging();
|
void updateVerboseLogging();
|
||||||
|
|
||||||
|
void setCachebustRequire();
|
||||||
|
|
||||||
void changeViewAsNeeded(float boomLength);
|
void changeViewAsNeeded(float boomLength);
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
//
|
//
|
||||||
// Created by Stephen Birarda on 8/12/13.
|
// Created by Stephen Birarda on 8/12/13.
|
||||||
// Copyright 2013 High Fidelity, Inc.
|
// Copyright 2013 High Fidelity, Inc.
|
||||||
|
// Copyright 2020 Vircadia contributors.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
// For happ(ier) development of QML, use these two things:
|
||||||
// For happ(ier) development of QML, use these two things:
|
// This forces QML files to be pulled from the source as you edit it: set environment variable HIFI_USE_SOURCE_TREE_RESOURCES=1
|
||||||
// This forces QML files to be pulled from the source as you edit it: set environment variable HIFI_USE_SOURCE_TREE_RESOURCES=1
|
// Use this to live reload: DependencyManager::get<OffscreenUi>()->clearCache();
|
||||||
// Use this to live reload: DependencyManager::get<OffscreenUi>()->clearCache();
|
|
||||||
|
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
@ -365,6 +365,10 @@ Menu::Menu() {
|
||||||
// Developer > Scripting > Verbose Logging
|
// Developer > Scripting > Verbose Logging
|
||||||
addCheckableActionToQMenuAndActionHash(scriptingOptionsMenu, MenuOption::VerboseLogging, 0, false,
|
addCheckableActionToQMenuAndActionHash(scriptingOptionsMenu, MenuOption::VerboseLogging, 0, false,
|
||||||
qApp, SLOT(updateVerboseLogging()));
|
qApp, SLOT(updateVerboseLogging()));
|
||||||
|
|
||||||
|
// Developer > Scripting > Enable Cachebusting of Script.require
|
||||||
|
addCheckableActionToQMenuAndActionHash(scriptingOptionsMenu, MenuOption::CachebustRequire, 0, false,
|
||||||
|
qApp, SLOT(setCachebustRequire()));
|
||||||
|
|
||||||
// Developer > Scripting > Enable Speech Control API
|
// Developer > Scripting > Enable Speech Control API
|
||||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
//
|
//
|
||||||
// Created by Stephen Birarda on 8/12/13.
|
// Created by Stephen Birarda on 8/12/13.
|
||||||
// Copyright 2013 High Fidelity, Inc.
|
// Copyright 2013 High Fidelity, Inc.
|
||||||
|
// Copyright 2020 Vircadia contributors.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -54,6 +55,7 @@ namespace MenuOption {
|
||||||
const QString BookmarkAvatarEntities = "Bookmark Avatar Entities";
|
const QString BookmarkAvatarEntities = "Bookmark Avatar Entities";
|
||||||
const QString BookmarkLocation = "Bookmark Location";
|
const QString BookmarkLocation = "Bookmark Location";
|
||||||
const QString CalibrateCamera = "Calibrate Camera";
|
const QString CalibrateCamera = "Calibrate Camera";
|
||||||
|
const QString CachebustRequire = "Enable Cachebusting of Script.require";
|
||||||
const QString CenterPlayerInView = "Center Player In View";
|
const QString CenterPlayerInView = "Center Player In View";
|
||||||
const QString Chat = "Chat...";
|
const QString Chat = "Chat...";
|
||||||
const QString ClearDiskCaches = "Clear Disk Caches (requires restart)";
|
const QString ClearDiskCaches = "Clear Disk Caches (requires restart)";
|
||||||
|
|
|
@ -167,6 +167,13 @@ void EntityTreeRenderer::resetEntitiesScriptEngine() {
|
||||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||||
entityScriptingInterface->setEntitiesScriptEngine(entitiesScriptEngineProvider);
|
entityScriptingInterface->setEntitiesScriptEngine(entitiesScriptEngineProvider);
|
||||||
|
|
||||||
|
connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptPreloadFinished, [&](const EntityItemID& entityID) {
|
||||||
|
EntityItemPointer entity = getTree()->findEntityByID(entityID);
|
||||||
|
if (entity) {
|
||||||
|
entity->setScriptHasFinishedPreload(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Connect mouse events to entity script callbacks
|
// Connect mouse events to entity script callbacks
|
||||||
if (!_mouseAndPreloadSignalHandlersConnected) {
|
if (!_mouseAndPreloadSignalHandlersConnected) {
|
||||||
|
|
||||||
|
@ -205,13 +212,6 @@ void EntityTreeRenderer::resetEntitiesScriptEngine() {
|
||||||
_entitiesScriptEngine->callEntityScriptMethod(entityID, "hoverLeaveEntity", event);
|
_entitiesScriptEngine->callEntityScriptMethod(entityID, "hoverLeaveEntity", event);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptPreloadFinished, [&](const EntityItemID& entityID) {
|
|
||||||
EntityItemPointer entity = getTree()->findEntityByID(entityID);
|
|
||||||
if (entity) {
|
|
||||||
entity->setScriptHasFinishedPreload(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
_mouseAndPreloadSignalHandlersConnected = true;
|
_mouseAndPreloadSignalHandlersConnected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1941,9 +1941,12 @@ QScriptValue ScriptEngine::require(const QString& moduleId) {
|
||||||
// modules get cached in `Script.require.cache` and (similar to Node.js) users can access it
|
// modules get cached in `Script.require.cache` and (similar to Node.js) users can access it
|
||||||
// to inspect particular entries and invalidate them by deleting the key:
|
// to inspect particular entries and invalidate them by deleting the key:
|
||||||
// `delete Script.require.cache[Script.require.resolve(moduleId)];`
|
// `delete Script.require.cache[Script.require.resolve(moduleId)];`
|
||||||
|
|
||||||
|
// Check to see if we should invalidate the cache based on a user setting.
|
||||||
|
Setting::Handle<bool> getCachebustSetting {"cachebustScriptRequire", false };
|
||||||
|
|
||||||
// cacheMeta is just used right now to tell deleted keys apart from undefined ones
|
// cacheMeta is just used right now to tell deleted keys apart from undefined ones
|
||||||
bool invalidateCache = module.isUndefined() && cacheMeta.property(moduleId).isValid();
|
bool invalidateCache = getCachebustSetting.get() || (module.isUndefined() && cacheMeta.property(moduleId).isValid());
|
||||||
|
|
||||||
// reset the cacheMeta record so invalidation won't apply next time, even if the module fails to load
|
// reset the cacheMeta record so invalidation won't apply next time, even if the module fails to load
|
||||||
cacheMeta.setProperty(modulePath, QScriptValue());
|
cacheMeta.setProperty(modulePath, QScriptValue());
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
//
|
//
|
||||||
// Created by Brad Hefta-Gaub on 12/14/13.
|
// Created by Brad Hefta-Gaub on 12/14/13.
|
||||||
// Copyright 2013 High Fidelity, Inc.
|
// Copyright 2013 High Fidelity, Inc.
|
||||||
|
// Copyright 2020 Vircadia contributors.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
|
@ -53,5 +53,5 @@ set(DIR "opusCodec")
|
||||||
add_subdirectory(${DIR})
|
add_subdirectory(${DIR})
|
||||||
|
|
||||||
# example plugins
|
# example plugins
|
||||||
set(DIR "KasenAPIExample")
|
set(DIR "JSAPIExample")
|
||||||
add_subdirectory(${DIR})
|
add_subdirectory(${DIR})
|
||||||
|
|
3
plugins/JSAPIExample/CMakeLists.txt
Normal file
3
plugins/JSAPIExample/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
set(TARGET_NAME JSAPIExample)
|
||||||
|
setup_hifi_client_server_plugin(scripting)
|
||||||
|
link_hifi_libraries(shared plugins)
|
251
plugins/JSAPIExample/src/JSAPIExample.cpp
Normal file
251
plugins/JSAPIExample/src/JSAPIExample.cpp
Normal file
|
@ -0,0 +1,251 @@
|
||||||
|
//
|
||||||
|
// JSAPIExample.cpp
|
||||||
|
// plugins/JSAPIExample/src
|
||||||
|
//
|
||||||
|
// Copyright (c) 2019-2020 humbletim (humbletim@gmail.com)
|
||||||
|
// Copyright (c) 2019 Kalila L. (kasenvr@gmail.com)
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
// Example of prototyping new JS APIs by leveraging the existing plugin system.
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtCore/QJsonObject>
|
||||||
|
#include <QtCore/QLoggingCategory>
|
||||||
|
#include <QtCore/QThread>
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
#include <QtScript/QScriptEngine>
|
||||||
|
#include <QtScript/QScriptable>
|
||||||
|
|
||||||
|
#include <SettingHelpers.h> // for ::settingsFilename()
|
||||||
|
#include <SharedUtil.h> // for ::usecTimestampNow()
|
||||||
|
#include <shared/ScriptInitializerMixin.h>
|
||||||
|
|
||||||
|
// NOTE: replace this with your own namespace when starting a new plugin (to avoid .so/.dll symbol clashes)
|
||||||
|
namespace REPLACE_ME_WITH_UNIQUE_NAME {
|
||||||
|
|
||||||
|
static constexpr auto JSAPI_SEMANTIC_VERSION = "0.0.1";
|
||||||
|
static constexpr auto JSAPI_EXPORT_NAME = "JSAPIExample";
|
||||||
|
|
||||||
|
QLoggingCategory logger { "jsapiexample" };
|
||||||
|
|
||||||
|
inline QVariant raiseScriptingError(QScriptContext* context, const QString& message, const QVariant& returnValue = QVariant()) {
|
||||||
|
if (context) {
|
||||||
|
// when a QScriptContext is available throw an actual JS Exception (which can be caught using try/catch on JS side)
|
||||||
|
context->throwError(message);
|
||||||
|
} else {
|
||||||
|
// otherwise just log the error
|
||||||
|
qCWarning(logger) << "error:" << message;
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject* createScopedSettings(const QString& scope, QObject* parent, QString& error);
|
||||||
|
|
||||||
|
class JSAPIExample : public QObject, public QScriptable {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "JSAPIExample" FILE "plugin.json")
|
||||||
|
Q_PROPERTY(QString version MEMBER _version CONSTANT)
|
||||||
|
public:
|
||||||
|
JSAPIExample() {
|
||||||
|
setObjectName(JSAPI_EXPORT_NAME);
|
||||||
|
auto scriptInit = DependencyManager::get<ScriptInitializers>();
|
||||||
|
if (!scriptInit) {
|
||||||
|
qCWarning(logger) << "COULD NOT INITIALIZE (ScriptInitializers unavailable)" << qApp << this;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qCWarning(logger) << "registering w/ScriptInitializerMixin..." << scriptInit.data();
|
||||||
|
scriptInit->registerScriptInitializer([this](QScriptEngine* engine) {
|
||||||
|
auto value = engine->newQObject(this, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater);
|
||||||
|
engine->globalObject().setProperty(objectName(), value);
|
||||||
|
// qCDebug(logger) << "setGlobalInstance" << objectName() << engine->property("fileName");
|
||||||
|
});
|
||||||
|
// qCInfo(logger) << "plugin loaded" << qApp << toString() << QThread::currentThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTES: everything within the "public slots:" section below will be available from JS via overall plugin QObject
|
||||||
|
// also, to demonstrate future-proofing JS API code, QVariant's are used throughout most of these examples --
|
||||||
|
// which still makes them very Qt-specific, but avoids depending directly on deprecated QtScript/QScriptValue APIs.
|
||||||
|
// (as such this plugin class and its methods remain forward-compatible with other engines like QML's QJSEngine)
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
// pretty-printed representation for logging eg: print(JSAPIExample)
|
||||||
|
// (note: Qt script engines automatically look for a ".toString" method on native classes when coercing values to strings)
|
||||||
|
QString toString() const { return QString("[%1 version=%2]").arg(objectName()).arg(_version); }
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Returns current microseconds (usecs) since Epoch. note: 1000usecs == 1ms
|
||||||
|
* @example <caption>Measure current setTimeout accuracy.</caption>
|
||||||
|
* var expected = 1000;
|
||||||
|
* var start = JSAPIExample.now();
|
||||||
|
* Script.setTimeout(function () {
|
||||||
|
* var elapsed = (JSAPIExample.now() - start)/1000;
|
||||||
|
* print("expected (ms):", expected, "actual (ms):", elapsed);
|
||||||
|
* }, expected);
|
||||||
|
*/
|
||||||
|
QVariant now() const { return usecTimestampNow(); }
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Example of returning a JS Object key-value map
|
||||||
|
* @example <caption>"zip" a list of keys and corresponding values to form key-value map</caption>
|
||||||
|
* print(JSON.stringify(JSAPIExample.zip(["a","b"], [1,2])); // { "a": 1, "b": 2 }
|
||||||
|
*/
|
||||||
|
QVariant zip(const QStringList& keys, const QVariantList& values) const {
|
||||||
|
QVariantMap out;
|
||||||
|
for (int i = 0; i < keys.size(); i++) {
|
||||||
|
out[keys[i]] = i < values.size() ? values[i] : QVariant();
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Example of returning a JS Array result
|
||||||
|
* @example <caption>emulate Object.values(keyValues)</caption>
|
||||||
|
* print(JSON.stringify(JSAPIExample.values({ "a": 1, "b": 2 }))); // [1,2]
|
||||||
|
*/
|
||||||
|
QVariant values(const QVariantMap& keyValues) const {
|
||||||
|
QVariantList values = keyValues.values();
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Another example of returning JS Array data
|
||||||
|
* @example <caption>generate an integer sequence (inclusive of [from, to])</caption>
|
||||||
|
* print(JSON.stringify(JSAPIExample.seq(1,5)));// [1,2,3,4,5]
|
||||||
|
*/
|
||||||
|
QVariant seq(int from, int to) const {
|
||||||
|
QVariantList out;
|
||||||
|
for (int i = from; i <= to; i++) {
|
||||||
|
out.append(i);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Example of returning arbitrary binary data from C++ (resulting in a JS ArrayBuffer)
|
||||||
|
* see also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer#Examples
|
||||||
|
* @example <caption>return compressed/decompressed versions of the input data</caption>
|
||||||
|
* var data = "testing 1 2 3";
|
||||||
|
* var z = JSAPIExample.qCompressString(data); // z will be an ArrayBuffer
|
||||||
|
* var u = JSAPIExample.qUncompressString(z); // u will be a String value
|
||||||
|
* print(JSON.stringify({ input: data, compressed: z.byteLength, output: u, uncompressed: u.length }));
|
||||||
|
*/
|
||||||
|
QVariant qCompressString(const QString& jsString, int compress_level = -1) const {
|
||||||
|
QByteArray arrayBuffer = qCompress(jsString.toUtf8(), compress_level);
|
||||||
|
return arrayBuffer;
|
||||||
|
}
|
||||||
|
QVariant qUncompressString(const QByteArray& arrayBuffer) const {
|
||||||
|
QString jsString = QString::fromUtf8(qUncompress(arrayBuffer));
|
||||||
|
return jsString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example of exposing a custom "managed" C++ QObject to JS
|
||||||
|
* The lifecycle of the created QObject* instance becomes managed by the invoking QScriptEngine --
|
||||||
|
* it will be automatically cleaned up once no longer reachable from any JS variables/closures.
|
||||||
|
* @example <caption>access persistent settings stored in separate .json files</caption>
|
||||||
|
* var settings = JSAPIExample.getScopedSettings("example");
|
||||||
|
* print("example settings stored in:", settings.fileName());
|
||||||
|
* print("(before) example::timestamp", settings.getValue("timestamp"));
|
||||||
|
* settings.setValue("timestamp", Date.now());
|
||||||
|
* print("(after) example::timestamp", settings.getValue("timestamp"));
|
||||||
|
* print("all example::* keys", settings.allKeys());
|
||||||
|
* settings = null; // optional best pratice; allows the object to be reclaimed ASAP by the JS garbage collector
|
||||||
|
*/
|
||||||
|
QScriptValue getScopedSettings(const QString& scope) {
|
||||||
|
auto engine = QScriptable::engine();
|
||||||
|
if (!engine) {
|
||||||
|
return QScriptValue::NullValue;
|
||||||
|
}
|
||||||
|
QString error;
|
||||||
|
auto cppValue = createScopedSettings(scope, engine, error);
|
||||||
|
if (!cppValue) {
|
||||||
|
raiseScriptingError(context(), "error creating scoped settings instance: " + error);
|
||||||
|
return QScriptValue::NullValue;
|
||||||
|
}
|
||||||
|
return engine->newQObject(cppValue, QScriptEngine::ScriptOwnership, QScriptEngine::ExcludeDeleteLater);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QString _version { JSAPI_SEMANTIC_VERSION };
|
||||||
|
};
|
||||||
|
|
||||||
|
// JSSettingsHelper wraps a scoped (prefixed/separate) QSettings and exposes a subset of QSetting APIs as slots
|
||||||
|
class JSSettingsHelper : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
JSSettingsHelper(const QString& scope, QObject* parent = nullptr);
|
||||||
|
~JSSettingsHelper();
|
||||||
|
operator bool() const;
|
||||||
|
public slots:
|
||||||
|
QString fileName() const;
|
||||||
|
QString toString() const;
|
||||||
|
QVariant getValue(const QString& key, const QVariant& defaultValue = QVariant());
|
||||||
|
bool setValue(const QString& key, const QVariant& value);
|
||||||
|
QStringList allKeys() const;
|
||||||
|
protected:
|
||||||
|
QString _scope;
|
||||||
|
QString _fileName;
|
||||||
|
QSharedPointer<QSettings> _settings;
|
||||||
|
QString getLocalSettingsPath(const QString& scope) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
// verifies the requested scope is sensible and creates/returns a scoped JSSettingsHelper instance
|
||||||
|
QObject* createScopedSettings(const QString& scope, QObject* parent, QString& error) {
|
||||||
|
const QRegExp VALID_SETTINGS_SCOPE { "[-_A-Za-z0-9]{1,64}" };
|
||||||
|
if (!VALID_SETTINGS_SCOPE.exactMatch(scope)) {
|
||||||
|
error = QString("invalid scope (expected alphanumeric <= 64 chars not '%1')").arg(scope);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return new JSSettingsHelper(scope, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------
|
||||||
|
// ----- inline JSSettingsHelper implementation -----
|
||||||
|
JSSettingsHelper::operator bool() const {
|
||||||
|
return (bool)_settings;
|
||||||
|
}
|
||||||
|
JSSettingsHelper::JSSettingsHelper(const QString& scope, QObject* parent) :
|
||||||
|
QObject(parent), _scope(scope), _fileName(getLocalSettingsPath(scope)),
|
||||||
|
_settings(_fileName.isEmpty() ? nullptr : new QSettings(_fileName, JSON_FORMAT)) {
|
||||||
|
}
|
||||||
|
JSSettingsHelper::~JSSettingsHelper() {
|
||||||
|
qCDebug(logger) << "~JSSettingsHelper" << _scope << _fileName << this;
|
||||||
|
}
|
||||||
|
QString JSSettingsHelper::fileName() const {
|
||||||
|
return _settings ? _settings->fileName() : "";
|
||||||
|
}
|
||||||
|
QString JSSettingsHelper::toString() const {
|
||||||
|
return QString("[JSSettingsHelper scope=%1 valid=%2]").arg(_scope).arg((bool)_settings);
|
||||||
|
}
|
||||||
|
QVariant JSSettingsHelper::getValue(const QString& key, const QVariant& defaultValue) {
|
||||||
|
return _settings ? _settings->value(key, defaultValue) : defaultValue;
|
||||||
|
}
|
||||||
|
bool JSSettingsHelper::setValue(const QString& key, const QVariant& value) {
|
||||||
|
if (_settings) {
|
||||||
|
if (value.isValid()) {
|
||||||
|
_settings->setValue(key, value);
|
||||||
|
} else {
|
||||||
|
_settings->remove(key);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QStringList JSSettingsHelper::allKeys() const {
|
||||||
|
return _settings ? _settings->allKeys() : QStringList{};
|
||||||
|
}
|
||||||
|
QString JSSettingsHelper::getLocalSettingsPath(const QString& scope) const {
|
||||||
|
// generate a prefixed filename (relative to the main application's Interface.json file)
|
||||||
|
const QString fileName = QString("jsapi_%1.json").arg(scope);
|
||||||
|
return QFileInfo(::settingsFilename()).dir().filePath(fileName);
|
||||||
|
}
|
||||||
|
// ----- /inline JSSettingsHelper implementation -----
|
||||||
|
|
||||||
|
} // namespace REPLACE_ME_WITH_UNIQUE_NAME
|
||||||
|
|
||||||
|
#include "JSAPIExample.moc"
|
4
plugins/JSAPIExample/src/plugin.json
Normal file
4
plugins/JSAPIExample/src/plugin.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"name":"JS API Example",
|
||||||
|
"version": 1
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
set(TARGET_NAME KasenAPIExample)
|
|
||||||
setup_hifi_client_server_plugin(scripting)
|
|
||||||
link_hifi_libraries(shared plugins avatars networking graphics gpu)
|
|
|
@ -1,58 +0,0 @@
|
||||||
//
|
|
||||||
// ExampleScriptPlugin.h
|
|
||||||
// plugins/KasenAPIExample/src
|
|
||||||
//
|
|
||||||
// Created by Kasen IO on 2019.07.14 | realities.dev | kasenvr@gmail.com
|
|
||||||
// Copyright 2019 Kasen IO
|
|
||||||
//
|
|
||||||
// Authored by: Humbletim (humbletim@gmail.com)
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
// Supporting file containing all QtScript specific integration.
|
|
||||||
|
|
||||||
#ifndef EXAMPLE_SCRIPT_PLUGIN_H
|
|
||||||
#define EXAMPLE_SCRIPT_PLUGIN_H
|
|
||||||
|
|
||||||
#if DEV_BUILD
|
|
||||||
#pragma message("QtScript is deprecated see: doc.qt.io/qt-5/topics-scripting.html")
|
|
||||||
#endif
|
|
||||||
#include <QtScript/QScriptEngine>
|
|
||||||
|
|
||||||
#include <QtCore/QLoggingCategory>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <shared/ScriptInitializerMixin.h>
|
|
||||||
|
|
||||||
namespace example {
|
|
||||||
|
|
||||||
extern const QLoggingCategory& logger;
|
|
||||||
|
|
||||||
inline void setGlobalInstance(QScriptEngine* engine, const QString& name, QObject* object) {
|
|
||||||
auto value = engine->newQObject(object, QScriptEngine::QtOwnership);
|
|
||||||
engine->globalObject().setProperty(name, value);
|
|
||||||
qCDebug(logger) << "setGlobalInstance" << name << engine->property("fileName");
|
|
||||||
}
|
|
||||||
|
|
||||||
class ScriptPlugin : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
QString _version;
|
|
||||||
Q_PROPERTY(QString version MEMBER _version CONSTANT)
|
|
||||||
protected:
|
|
||||||
inline ScriptPlugin(const QString& name, const QString& version) : _version(version) {
|
|
||||||
setObjectName(name);
|
|
||||||
if (!DependencyManager::get<ScriptInitializers>()) {
|
|
||||||
qCWarning(logger) << "COULD NOT INITIALIZE (ScriptInitializers unavailable)" << qApp << this;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
qCWarning(logger) << "registering w/ScriptInitializerMixin..." << DependencyManager::get<ScriptInitializers>().data();
|
|
||||||
DependencyManager::get<ScriptInitializers>()->registerScriptInitializer(
|
|
||||||
[this](QScriptEngine* engine) { setGlobalInstance(engine, objectName(), this); });
|
|
||||||
}
|
|
||||||
public slots:
|
|
||||||
inline QString toString() const { return QString("[%1 version=%2]").arg(objectName()).arg(_version); }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace example
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,141 +0,0 @@
|
||||||
//
|
|
||||||
// KasenAPIExample.cpp
|
|
||||||
// plugins/KasenAPIExample/src
|
|
||||||
//
|
|
||||||
// Created by Kasen IO on 2019.07.14 | realities.dev | kasenvr@gmail.com
|
|
||||||
// Copyright 2019 Kasen IO
|
|
||||||
//
|
|
||||||
// Authored by: Humbletim (humbletim@gmail.com)
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
// Example of prototyping new JS APIs by leveraging the existing plugin system.
|
|
||||||
|
|
||||||
#include "ExampleScriptPlugin.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtCore/QJsonObject>
|
|
||||||
#include <QtCore/QLoggingCategory>
|
|
||||||
#include <QtCore/QThread>
|
|
||||||
#include <QtCore/QTimer>
|
|
||||||
|
|
||||||
#include <SharedUtil.h>
|
|
||||||
#include <AvatarHashMap.h>
|
|
||||||
|
|
||||||
namespace custom_api_example {
|
|
||||||
|
|
||||||
QLoggingCategory logger{ "custom_api_example" };
|
|
||||||
|
|
||||||
class KasenAPIExample : public example::ScriptPlugin {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID "KasenAPIExample" FILE "plugin.json")
|
|
||||||
public:
|
|
||||||
KasenAPIExample() : example::ScriptPlugin("KasenAPIExample", "0.0.1") {
|
|
||||||
qCInfo(logger) << "plugin loaded" << qApp << toString() << QThread::currentThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
/**jsdoc
|
|
||||||
* Returns current microseconds (usecs) since Epoch. note: 1000usecs == 1ms
|
|
||||||
* @example <caption>Measure current setTimeout accuracy.</caption>
|
|
||||||
* var expected = 1000;
|
|
||||||
* var start = KasenAPIExample.now();
|
|
||||||
* Script.setTimeout(function () {
|
|
||||||
* var elapsed = (KasenAPIExample.now() - start)/1000;
|
|
||||||
* print("expected (ms):", expected, "actual (ms):", elapsed);
|
|
||||||
* }, expected);
|
|
||||||
*/
|
|
||||||
QVariant now() const {
|
|
||||||
return usecTimestampNow();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**jsdoc
|
|
||||||
* Returns the available blendshape names for an avatar.
|
|
||||||
* @example <caption>Get blendshape names</caption>
|
|
||||||
* print(JSON.stringify(KasenAPIExample.getBlendshapeNames(MyAvatar.sessionUUID)));
|
|
||||||
*/
|
|
||||||
QStringList getBlendshapeNames(const QUuid& avatarID) const {
|
|
||||||
QVector<QString> out;
|
|
||||||
if (auto head = getAvatarHead(avatarID)) {
|
|
||||||
for (const auto& kv : head->getBlendshapeMap().toStdMap()) {
|
|
||||||
if (kv.second >= out.size()) out.resize(kv.second+1);
|
|
||||||
out[kv.second] = kv.first;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**jsdoc
|
|
||||||
* Returns a key-value object with active (non-zero) blendshapes.
|
|
||||||
* eg: { JawOpen: 1.0, ... }
|
|
||||||
* @example <caption>Get active blendshape map</caption>
|
|
||||||
* print(JSON.stringify(KasenAPIExample.getActiveBlendshapes(MyAvatar.sessionUUID)));
|
|
||||||
*/
|
|
||||||
QVariant getActiveBlendshapes(const QUuid& avatarID) const {
|
|
||||||
if (auto head = getAvatarHead(avatarID)) {
|
|
||||||
return head->toJson()["blendShapes"].toVariant();
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant getBlendshapeMapping(const QUuid& avatarID) const {
|
|
||||||
QVariantMap out;
|
|
||||||
if (auto head = getAvatarHead(avatarID)) {
|
|
||||||
for (const auto& kv : head->getBlendshapeMap().toStdMap()) {
|
|
||||||
out[kv.first] = kv.second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant getBlendshapes(const QUuid& avatarID) const {
|
|
||||||
QVariantMap result;
|
|
||||||
if (auto head = getAvatarHead(avatarID)) {
|
|
||||||
QStringList names = getBlendshapeNames(avatarID);
|
|
||||||
auto states = head->getBlendshapeStates();
|
|
||||||
result = {
|
|
||||||
{ "base", zipNonZeroValues(names, states.base) },
|
|
||||||
{ "summed", zipNonZeroValues(names, states.summed) },
|
|
||||||
{ "transient", zipNonZeroValues(names, states.transient) },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static QVariantMap zipNonZeroValues(const QStringList& keys, const QVector<float>& values) {
|
|
||||||
QVariantMap out;
|
|
||||||
for (int i=1; i < values.size(); i++) {
|
|
||||||
if (fabs(values[i]) > 1.0e-6f) {
|
|
||||||
out[keys.value(i)] = values[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
struct _HeadHelper : public HeadData {
|
|
||||||
QMap<QString,int> getBlendshapeMap() const {
|
|
||||||
return BLENDSHAPE_LOOKUP_MAP;
|
|
||||||
}
|
|
||||||
struct States { QVector<float> base, summed, transient; };
|
|
||||||
States getBlendshapeStates() const {
|
|
||||||
return {
|
|
||||||
_blendshapeCoefficients,
|
|
||||||
_summedBlendshapeCoefficients,
|
|
||||||
_transientBlendshapeCoefficients
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
static const _HeadHelper* getAvatarHead(const QUuid& avatarID) {
|
|
||||||
auto avatars = DependencyManager::get<AvatarHashMap>();
|
|
||||||
auto avatar = avatars ? avatars->getAvatarBySessionID(avatarID) : nullptr;
|
|
||||||
auto head = avatar ? avatar->getHeadData() : nullptr;
|
|
||||||
return reinterpret_cast<const _HeadHelper*>(head);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const QLoggingCategory& example::logger{ custom_api_example::logger };
|
|
||||||
|
|
||||||
#include "KasenAPIExample.moc"
|
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"name":"Kasen JS API Example",
|
|
||||||
"version": 1,
|
|
||||||
"package": {
|
|
||||||
"author": "Revofire",
|
|
||||||
"homepage": "www.realities.dev",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"engines": {
|
|
||||||
"hifi-interface": ">= 0.83.0",
|
|
||||||
"hifi-assignment-client": ">= 0.83.0"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"client": true,
|
|
||||||
"entity_client": true,
|
|
||||||
"entity_server": true,
|
|
||||||
"edit_filter": true,
|
|
||||||
"agent": true,
|
|
||||||
"avatar": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -146,20 +146,23 @@ var DEFAULT_DIMENSIONS = {
|
||||||
|
|
||||||
var DEFAULT_LIGHT_DIMENSIONS = Vec3.multiply(20, DEFAULT_DIMENSIONS);
|
var DEFAULT_LIGHT_DIMENSIONS = Vec3.multiply(20, DEFAULT_DIMENSIONS);
|
||||||
|
|
||||||
|
var SUBMENU_ENTITY_EDITOR_PREFERENCES = "Edit > Create Application - Preferences";
|
||||||
var MENU_AUTO_FOCUS_ON_SELECT = "Auto Focus on Select";
|
var MENU_AUTO_FOCUS_ON_SELECT = "Auto Focus on Select";
|
||||||
var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus";
|
var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus";
|
||||||
var MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "Show Lights and Particle Systems in Create Mode";
|
var MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "Show Lights and Particle Systems in Create Mode";
|
||||||
var MENU_SHOW_ZONES_IN_EDIT_MODE = "Show Zones in Create Mode";
|
var MENU_SHOW_ZONES_IN_EDIT_MODE = "Show Zones in Create Mode";
|
||||||
|
|
||||||
var MENU_CREATE_ENTITIES_GRABBABLE = "Create Entities As Grabbable (except Zones, Particles, and Lights)";
|
var MENU_CREATE_ENTITIES_GRABBABLE = "Create Entities As Grabbable (except Zones, Particles, and Lights)";
|
||||||
var MENU_ALLOW_SELECTION_LARGE = "Allow Selecting of Large Models";
|
var MENU_ALLOW_SELECTION_LARGE = "Allow Selecting of Large Models";
|
||||||
var MENU_ALLOW_SELECTION_SMALL = "Allow Selecting of Small Models";
|
var MENU_ALLOW_SELECTION_SMALL = "Allow Selecting of Small Models";
|
||||||
var MENU_ALLOW_SELECTION_LIGHTS = "Allow Selecting of Lights";
|
var MENU_ALLOW_SELECTION_LIGHTS = "Allow Selecting of Lights";
|
||||||
|
var MENU_ENTITY_LIST_DEFAULT_RADIUS = "Entity List Default Radius";
|
||||||
|
|
||||||
var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect";
|
var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect";
|
||||||
var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus";
|
var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus";
|
||||||
var SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "showLightsAndParticlesInEditMode";
|
var SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "showLightsAndParticlesInEditMode";
|
||||||
var SETTING_SHOW_ZONES_IN_EDIT_MODE = "showZonesInEditMode";
|
var SETTING_SHOW_ZONES_IN_EDIT_MODE = "showZonesInEditMode";
|
||||||
|
var SETTING_EDITOR_COLUMNS_SETUP = "editorColumnsSetup";
|
||||||
|
var SETTING_ENTITY_LIST_DEFAULT_RADIUS = "entityListDefaultRadius";
|
||||||
|
|
||||||
var SETTING_EDIT_PREFIX = "Edit/";
|
var SETTING_EDIT_PREFIX = "Edit/";
|
||||||
|
|
||||||
|
@ -267,8 +270,6 @@ function adjustPositionPerBoundingBox(position, direction, registration, dimensi
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
var GRABBABLE_ENTITIES_MENU_CATEGORY = "Edit";
|
|
||||||
|
|
||||||
// Handles any edit mode updates required when domains have switched
|
// Handles any edit mode updates required when domains have switched
|
||||||
function checkEditPermissionsAndUpdate() {
|
function checkEditPermissionsAndUpdate() {
|
||||||
if ((createButton === null) || (createButton === undefined)) {
|
if ((createButton === null) || (createButton === undefined)) {
|
||||||
|
@ -878,7 +879,12 @@ var toolBar = (function () {
|
||||||
|
|
||||||
addButton("importEntitiesButton", function() {
|
addButton("importEntitiesButton", function() {
|
||||||
Window.browseChanged.connect(onFileOpenChanged);
|
Window.browseChanged.connect(onFileOpenChanged);
|
||||||
Window.browseAsync("Select Model to Import", "", "*.json");
|
Window.browseAsync("Select .json to Import", "", "*.json");
|
||||||
|
});
|
||||||
|
|
||||||
|
addButton("importEntitiesFromUrlButton", function() {
|
||||||
|
Window.promptTextChanged.connect(onPromptTextChanged);
|
||||||
|
Window.promptAsync("URL of a .json to import", "");
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton("openAssetBrowserButton", function() {
|
addButton("openAssetBrowserButton", function() {
|
||||||
|
@ -1378,11 +1384,9 @@ Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||||
// In order for editVoxels and editModels to play nice together, they each check to see if a "delete" menu item already
|
// In order for editVoxels and editModels to play nice together, they each check to see if a "delete" menu item already
|
||||||
// exists. If it doesn't they add it. If it does they don't. They also only delete the menu item if they were the one that
|
// exists. If it doesn't they add it. If it does they don't. They also only delete the menu item if they were the one that
|
||||||
// added it.
|
// added it.
|
||||||
var modelMenuAddedDelete = false;
|
|
||||||
var originalLightsArePickable = Entities.getLightsArePickable();
|
var originalLightsArePickable = Entities.getLightsArePickable();
|
||||||
|
|
||||||
function setupModelMenus() {
|
function setupModelMenus() {
|
||||||
// adj our menuitems
|
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: "Edit",
|
||||||
menuItemName: "Undo",
|
menuItemName: "Undo",
|
||||||
|
@ -1396,118 +1400,69 @@ function setupModelMenus() {
|
||||||
position: 1,
|
position: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
Menu.addMenuItem({
|
Menu.addMenu(SUBMENU_ENTITY_EDITOR_PREFERENCES);
|
||||||
menuName: "Edit",
|
|
||||||
menuItemName: "Entities",
|
|
||||||
isSeparator: true
|
|
||||||
});
|
|
||||||
if (!Menu.menuItemExists("Edit", "Delete")) {
|
|
||||||
Menu.addMenuItem({
|
|
||||||
menuName: "Edit",
|
|
||||||
menuItemName: "Delete",
|
|
||||||
shortcutKeyEvent: {
|
|
||||||
text: "delete"
|
|
||||||
},
|
|
||||||
afterItem: "Entities",
|
|
||||||
});
|
|
||||||
modelMenuAddedDelete = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: SUBMENU_ENTITY_EDITOR_PREFERENCES,
|
||||||
menuItemName: "Parent Entity to Last",
|
|
||||||
afterItem: "Entities"
|
|
||||||
});
|
|
||||||
|
|
||||||
Menu.addMenuItem({
|
|
||||||
menuName: "Edit",
|
|
||||||
menuItemName: "Unparent Entity",
|
|
||||||
afterItem: "Parent Entity to Last"
|
|
||||||
});
|
|
||||||
|
|
||||||
Menu.addMenuItem({
|
|
||||||
menuName: GRABBABLE_ENTITIES_MENU_CATEGORY,
|
|
||||||
menuItemName: MENU_CREATE_ENTITIES_GRABBABLE,
|
menuItemName: MENU_CREATE_ENTITIES_GRABBABLE,
|
||||||
afterItem: "Unparent Entity",
|
position: 0,
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_CREATE_ENTITIES_GRABBABLE, false)
|
isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_CREATE_ENTITIES_GRABBABLE, false)
|
||||||
});
|
});
|
||||||
|
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: SUBMENU_ENTITY_EDITOR_PREFERENCES,
|
||||||
menuItemName: MENU_ALLOW_SELECTION_LARGE,
|
menuItemName: MENU_ALLOW_SELECTION_LARGE,
|
||||||
afterItem: MENU_CREATE_ENTITIES_GRABBABLE,
|
afterItem: MENU_CREATE_ENTITIES_GRABBABLE,
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LARGE, true)
|
isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LARGE, true)
|
||||||
});
|
});
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: SUBMENU_ENTITY_EDITOR_PREFERENCES,
|
||||||
menuItemName: MENU_ALLOW_SELECTION_SMALL,
|
menuItemName: MENU_ALLOW_SELECTION_SMALL,
|
||||||
afterItem: MENU_ALLOW_SELECTION_LARGE,
|
afterItem: MENU_ALLOW_SELECTION_LARGE,
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_SMALL, true)
|
isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_SMALL, true)
|
||||||
});
|
});
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: SUBMENU_ENTITY_EDITOR_PREFERENCES,
|
||||||
menuItemName: MENU_ALLOW_SELECTION_LIGHTS,
|
menuItemName: MENU_ALLOW_SELECTION_LIGHTS,
|
||||||
afterItem: MENU_ALLOW_SELECTION_SMALL,
|
afterItem: MENU_ALLOW_SELECTION_SMALL,
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LIGHTS, false)
|
isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LIGHTS, false)
|
||||||
});
|
});
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: SUBMENU_ENTITY_EDITOR_PREFERENCES,
|
||||||
menuItemName: "Select All Entities In Box",
|
|
||||||
afterItem: "Allow Selecting of Lights"
|
|
||||||
});
|
|
||||||
Menu.addMenuItem({
|
|
||||||
menuName: "Edit",
|
|
||||||
menuItemName: "Select All Entities Touching Box",
|
|
||||||
afterItem: "Select All Entities In Box"
|
|
||||||
});
|
|
||||||
|
|
||||||
Menu.addMenuItem({
|
|
||||||
menuName: "Edit",
|
|
||||||
menuItemName: "Export Entities",
|
|
||||||
afterItem: "Entities"
|
|
||||||
});
|
|
||||||
Menu.addMenuItem({
|
|
||||||
menuName: "Edit",
|
|
||||||
menuItemName: "Import Entities",
|
|
||||||
afterItem: "Export Entities"
|
|
||||||
});
|
|
||||||
Menu.addMenuItem({
|
|
||||||
menuName: "Edit",
|
|
||||||
menuItemName: "Import Entities from URL",
|
|
||||||
afterItem: "Import Entities"
|
|
||||||
});
|
|
||||||
|
|
||||||
Menu.addMenuItem({
|
|
||||||
menuName: "Edit",
|
|
||||||
menuItemName: MENU_AUTO_FOCUS_ON_SELECT,
|
menuItemName: MENU_AUTO_FOCUS_ON_SELECT,
|
||||||
|
afterItem: MENU_ALLOW_SELECTION_LIGHTS,
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: Settings.getValue(SETTING_AUTO_FOCUS_ON_SELECT) === "true"
|
isChecked: Settings.getValue(SETTING_AUTO_FOCUS_ON_SELECT) === "true"
|
||||||
});
|
});
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: SUBMENU_ENTITY_EDITOR_PREFERENCES,
|
||||||
menuItemName: MENU_EASE_ON_FOCUS,
|
menuItemName: MENU_EASE_ON_FOCUS,
|
||||||
afterItem: MENU_AUTO_FOCUS_ON_SELECT,
|
afterItem: MENU_AUTO_FOCUS_ON_SELECT,
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) === "true"
|
isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) === "true"
|
||||||
});
|
});
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: SUBMENU_ENTITY_EDITOR_PREFERENCES,
|
||||||
menuItemName: MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE,
|
menuItemName: MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE,
|
||||||
afterItem: MENU_EASE_ON_FOCUS,
|
afterItem: MENU_EASE_ON_FOCUS,
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: Settings.getValue(SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE) !== "false"
|
isChecked: Settings.getValue(SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE) !== "false"
|
||||||
});
|
});
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: "Edit",
|
menuName: SUBMENU_ENTITY_EDITOR_PREFERENCES,
|
||||||
menuItemName: MENU_SHOW_ZONES_IN_EDIT_MODE,
|
menuItemName: MENU_SHOW_ZONES_IN_EDIT_MODE,
|
||||||
afterItem: MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE,
|
afterItem: MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE,
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: Settings.getValue(SETTING_SHOW_ZONES_IN_EDIT_MODE) !== "false"
|
isChecked: Settings.getValue(SETTING_SHOW_ZONES_IN_EDIT_MODE) !== "false"
|
||||||
});
|
});
|
||||||
|
Menu.addMenuItem({
|
||||||
|
menuName: SUBMENU_ENTITY_EDITOR_PREFERENCES,
|
||||||
|
menuItemName: MENU_ENTITY_LIST_DEFAULT_RADIUS,
|
||||||
|
afterItem: MENU_SHOW_ZONES_IN_EDIT_MODE
|
||||||
|
});
|
||||||
|
|
||||||
Entities.setLightsArePickable(false);
|
Entities.setLightsArePickable(false);
|
||||||
}
|
}
|
||||||
|
@ -1518,29 +1473,16 @@ function cleanupModelMenus() {
|
||||||
Menu.removeMenuItem("Edit", "Undo");
|
Menu.removeMenuItem("Edit", "Undo");
|
||||||
Menu.removeMenuItem("Edit", "Redo");
|
Menu.removeMenuItem("Edit", "Redo");
|
||||||
|
|
||||||
Menu.removeSeparator("Edit", "Entities");
|
Menu.removeMenuItem(SUBMENU_ENTITY_EDITOR_PREFERENCES, MENU_ALLOW_SELECTION_LARGE);
|
||||||
if (modelMenuAddedDelete) {
|
Menu.removeMenuItem(SUBMENU_ENTITY_EDITOR_PREFERENCES, MENU_ALLOW_SELECTION_SMALL);
|
||||||
// delete our menuitems
|
Menu.removeMenuItem(SUBMENU_ENTITY_EDITOR_PREFERENCES, MENU_ALLOW_SELECTION_LIGHTS);
|
||||||
Menu.removeMenuItem("Edit", "Delete");
|
Menu.removeMenuItem(SUBMENU_ENTITY_EDITOR_PREFERENCES, MENU_AUTO_FOCUS_ON_SELECT);
|
||||||
}
|
Menu.removeMenuItem(SUBMENU_ENTITY_EDITOR_PREFERENCES, MENU_EASE_ON_FOCUS);
|
||||||
|
Menu.removeMenuItem(SUBMENU_ENTITY_EDITOR_PREFERENCES, MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE);
|
||||||
Menu.removeMenuItem("Edit", "Parent Entity to Last");
|
Menu.removeMenuItem(SUBMENU_ENTITY_EDITOR_PREFERENCES, MENU_SHOW_ZONES_IN_EDIT_MODE);
|
||||||
Menu.removeMenuItem("Edit", "Unparent Entity");
|
Menu.removeMenuItem(SUBMENU_ENTITY_EDITOR_PREFERENCES, MENU_CREATE_ENTITIES_GRABBABLE);
|
||||||
Menu.removeMenuItem("Edit", "Allow Selecting of Large Models");
|
Menu.removeMenuItem(SUBMENU_ENTITY_EDITOR_PREFERENCES, MENU_ENTITY_LIST_DEFAULT_RADIUS);
|
||||||
Menu.removeMenuItem("Edit", "Allow Selecting of Small Models");
|
Menu.removeMenu(SUBMENU_ENTITY_EDITOR_PREFERENCES);
|
||||||
Menu.removeMenuItem("Edit", "Allow Selecting of Lights");
|
|
||||||
Menu.removeMenuItem("Edit", "Select All Entities In Box");
|
|
||||||
Menu.removeMenuItem("Edit", "Select All Entities Touching Box");
|
|
||||||
|
|
||||||
Menu.removeMenuItem("Edit", "Export Entities");
|
|
||||||
Menu.removeMenuItem("Edit", "Import Entities");
|
|
||||||
Menu.removeMenuItem("Edit", "Import Entities from URL");
|
|
||||||
|
|
||||||
Menu.removeMenuItem("Edit", MENU_AUTO_FOCUS_ON_SELECT);
|
|
||||||
Menu.removeMenuItem("Edit", MENU_EASE_ON_FOCUS);
|
|
||||||
Menu.removeMenuItem("Edit", MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE);
|
|
||||||
Menu.removeMenuItem("Edit", MENU_SHOW_ZONES_IN_EDIT_MODE);
|
|
||||||
Menu.removeMenuItem("Edit", MENU_CREATE_ENTITIES_GRABBABLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
|
@ -1881,48 +1823,39 @@ function onPromptTextChanged(prompt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onPromptTextChangedDefaultRadiusUserPref(prompt) {
|
||||||
|
Window.promptTextChanged.disconnect(onPromptTextChangedDefaultRadiusUserPref);
|
||||||
|
if (prompt !== "") {
|
||||||
|
var radius = parseInt(prompt);
|
||||||
|
if (radius < 0 || isNaN(radius)){
|
||||||
|
radius = 100;
|
||||||
|
}
|
||||||
|
Settings.setValue(SETTING_ENTITY_LIST_DEFAULT_RADIUS, radius);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleMenuEvent(menuItem) {
|
function handleMenuEvent(menuItem) {
|
||||||
if (menuItem === "Allow Selecting of Small Models") {
|
if (menuItem === MENU_ALLOW_SELECTION_SMALL) {
|
||||||
allowSmallModels = Menu.isOptionChecked("Allow Selecting of Small Models");
|
allowSmallModels = Menu.isOptionChecked(MENU_ALLOW_SELECTION_SMALL);
|
||||||
} else if (menuItem === "Allow Selecting of Large Models") {
|
} else if (menuItem === MENU_ALLOW_SELECTION_LARGE) {
|
||||||
allowLargeModels = Menu.isOptionChecked("Allow Selecting of Large Models");
|
allowLargeModels = Menu.isOptionChecked(MENU_ALLOW_SELECTION_LARGE);
|
||||||
} else if (menuItem === "Allow Selecting of Lights") {
|
} else if (menuItem === MENU_ALLOW_SELECTION_LIGHTS) {
|
||||||
Entities.setLightsArePickable(Menu.isOptionChecked("Allow Selecting of Lights"));
|
Entities.setLightsArePickable(Menu.isOptionChecked(MENU_ALLOW_SELECTION_LIGHTS));
|
||||||
} else if (menuItem === "Delete") {
|
} else if (menuItem === "Delete") {
|
||||||
deleteSelectedEntities();
|
deleteSelectedEntities();
|
||||||
} else if (menuItem === "Undo") {
|
} else if (menuItem === "Undo") {
|
||||||
undoHistory.undo();
|
undoHistory.undo();
|
||||||
} else if (menuItem === "Redo") {
|
} else if (menuItem === "Redo") {
|
||||||
undoHistory.redo();
|
undoHistory.redo();
|
||||||
} else if (menuItem === "Parent Entity to Last") {
|
|
||||||
parentSelectedEntities();
|
|
||||||
} else if (menuItem === "Unparent Entity") {
|
|
||||||
unparentSelectedEntities();
|
|
||||||
} else if (menuItem === "Export Entities") {
|
|
||||||
if (!selectionManager.hasSelection()) {
|
|
||||||
Window.notifyEditError("No entities have been selected.");
|
|
||||||
} else {
|
|
||||||
Window.saveFileChanged.connect(onFileSaveChanged);
|
|
||||||
Window.saveAsync("Select Where to Save", "", "*.json");
|
|
||||||
}
|
|
||||||
} else if (menuItem === "Import Entities" || menuItem === "Import Entities from URL") {
|
|
||||||
if (menuItem === "Import Entities") {
|
|
||||||
Window.browseChanged.connect(onFileOpenChanged);
|
|
||||||
Window.browseAsync("Select Model to Import", "", "*.json");
|
|
||||||
} else {
|
|
||||||
Window.promptTextChanged.connect(onPromptTextChanged);
|
|
||||||
Window.promptAsync("URL of SVO to import", "");
|
|
||||||
}
|
|
||||||
} else if (menuItem === "Select All Entities In Box") {
|
|
||||||
selectAllEntitiesInCurrentSelectionBox(false);
|
|
||||||
} else if (menuItem === "Select All Entities Touching Box") {
|
|
||||||
selectAllEntitiesInCurrentSelectionBox(true);
|
|
||||||
} else if (menuItem === MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE) {
|
} else if (menuItem === MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE) {
|
||||||
entityIconOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE));
|
entityIconOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE));
|
||||||
} else if (menuItem === MENU_SHOW_ZONES_IN_EDIT_MODE) {
|
} else if (menuItem === MENU_SHOW_ZONES_IN_EDIT_MODE) {
|
||||||
Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
|
Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
|
||||||
} else if (menuItem === MENU_CREATE_ENTITIES_GRABBABLE) {
|
} else if (menuItem === MENU_CREATE_ENTITIES_GRABBABLE) {
|
||||||
Settings.setValue(SETTING_EDIT_PREFIX + menuItem, Menu.isOptionChecked(menuItem));
|
Settings.setValue(SETTING_EDIT_PREFIX + menuItem, Menu.isOptionChecked(menuItem));
|
||||||
|
} else if (menuItem === MENU_ENTITY_LIST_DEFAULT_RADIUS) {
|
||||||
|
Window.promptTextChanged.connect(onPromptTextChangedDefaultRadiusUserPref);
|
||||||
|
Window.promptAsync("Entity List Default Radius (in meters)", "" + Settings.getValue(SETTING_ENTITY_LIST_DEFAULT_RADIUS, 100));
|
||||||
}
|
}
|
||||||
tooltip.show(false);
|
tooltip.show(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,6 +371,16 @@ EntityListTool = function(shouldUseEditTabletApp) {
|
||||||
SelectionManager.teleportToEntity();
|
SelectionManager.teleportToEntity();
|
||||||
} else if (data.type === 'moveEntitySelectionToAvatar') {
|
} else if (data.type === 'moveEntitySelectionToAvatar') {
|
||||||
SelectionManager.moveEntitiesSelectionToAvatar();
|
SelectionManager.moveEntitiesSelectionToAvatar();
|
||||||
|
} else if (data.type === 'loadConfigSetting') {
|
||||||
|
var columnsData = Settings.getValue(SETTING_EDITOR_COLUMNS_SETUP, "NO_DATA");
|
||||||
|
var defaultRadius = Settings.getValue(SETTING_ENTITY_LIST_DEFAULT_RADIUS, 100);
|
||||||
|
emitJSONScriptEvent({
|
||||||
|
"type": "loadedConfigSetting",
|
||||||
|
"columnsData": columnsData,
|
||||||
|
"defaultRadius": defaultRadius
|
||||||
|
});
|
||||||
|
} else if (data.type === 'saveColumnsConfigSetting') {
|
||||||
|
Settings.setValue(SETTING_EDITOR_COLUMNS_SETUP, data.columnsData);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@
|
||||||
<div class = "menu-item-caption">Move Selected Entities to Avatar</div>
|
<div class = "menu-item-caption">Move Selected Entities to Avatar</div>
|
||||||
<div class = "menu-item-shortcut"></div>
|
<div class = "menu-item-shortcut"></div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="entity-list-menu" id="selection-menu" >
|
<div class="entity-list-menu" id="selection-menu" >
|
||||||
<button class="menu-button" id="selectall" >
|
<button class="menu-button" id="selectall" >
|
||||||
|
@ -209,23 +209,23 @@
|
||||||
</button>
|
</button>
|
||||||
<button class="menu-button" id="selectfamily" >
|
<button class="menu-button" id="selectfamily" >
|
||||||
<div class = "menu-item">
|
<div class = "menu-item">
|
||||||
<div class = "menu-item-caption">Select Family</div>
|
<div class = "menu-item-caption">Select Parent And All Its Children</div>
|
||||||
<div class = "menu-item-shortcut"></div>
|
<div class = "menu-item-shortcut"></div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button class="menu-button" id="selecttopfamily" >
|
<button class="menu-button" id="selecttopfamily" >
|
||||||
<div class = "menu-item">
|
<div class = "menu-item">
|
||||||
<div class = "menu-item-caption">Select Top Family</div>
|
<div class = "menu-item-caption">Select Top Parent And All Its Children</div>
|
||||||
<div class = "menu-item-shortcut"></div>
|
<div class = "menu-item-shortcut"></div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<div class="menu-separator"></div>
|
<div class="menu-separator"></div>
|
||||||
<button class="menu-button" id="teleport-to-entity" >
|
<button class="menu-button" id="teleport-to-entity" >
|
||||||
<div class = "menu-item">
|
<div class = "menu-item">
|
||||||
<div class = "menu-item-caption">Teleport To Selected Entities</div>
|
<div class = "menu-item-caption">Teleport To Selected Entities</div>
|
||||||
<div class = "menu-item-shortcut"></div>
|
<div class = "menu-item-shortcut"></div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="menuBackgroundOverlay" ></div>
|
<div id="menuBackgroundOverlay" ></div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -20,7 +20,7 @@ const EMPTY_ENTITY_ID = "0";
|
||||||
const MAX_LENGTH_RADIUS = 9;
|
const MAX_LENGTH_RADIUS = 9;
|
||||||
const MINIMUM_COLUMN_WIDTH = 24;
|
const MINIMUM_COLUMN_WIDTH = 24;
|
||||||
const SCROLLBAR_WIDTH = 20;
|
const SCROLLBAR_WIDTH = 20;
|
||||||
const RESIZER_WIDTH = 10;
|
const RESIZER_WIDTH = 13; //Must be the number of COLUMNS - 1.
|
||||||
const DELTA_X_MOVE_COLUMNS_THRESHOLD = 2;
|
const DELTA_X_MOVE_COLUMNS_THRESHOLD = 2;
|
||||||
const DELTA_X_COLUMN_SWAP_POSITION = 5;
|
const DELTA_X_COLUMN_SWAP_POSITION = 5;
|
||||||
const CERTIFIED_PLACEHOLDER = "** Certified **";
|
const CERTIFIED_PLACEHOLDER = "** Certified **";
|
||||||
|
@ -188,6 +188,8 @@ let selectedEntities = [];
|
||||||
let entityList = null; // The ListView
|
let entityList = null; // The ListView
|
||||||
|
|
||||||
let hmdMultiSelectMode = false;
|
let hmdMultiSelectMode = false;
|
||||||
|
|
||||||
|
let lastSelectedEntity;
|
||||||
/**
|
/**
|
||||||
* @type EntityListContextMenu
|
* @type EntityListContextMenu
|
||||||
*/
|
*/
|
||||||
|
@ -283,6 +285,9 @@ const PROFILE = !ENABLE_PROFILING ? PROFILE_NOOP : function(name, fn, args) {
|
||||||
|
|
||||||
function loaded() {
|
function loaded() {
|
||||||
openEventBridge(function() {
|
openEventBridge(function() {
|
||||||
|
|
||||||
|
var isColumnsSettingLoaded = false;
|
||||||
|
|
||||||
elEntityTable = document.getElementById("entity-table");
|
elEntityTable = document.getElementById("entity-table");
|
||||||
elEntityTableHeader = document.getElementById("entity-table-header");
|
elEntityTableHeader = document.getElementById("entity-table-header");
|
||||||
elEntityTableBody = document.getElementById("entity-table-body");
|
elEntityTableBody = document.getElementById("entity-table-body");
|
||||||
|
@ -331,7 +336,7 @@ function loaded() {
|
||||||
elColumnsMultiselectBox = document.getElementById("entity-table-columns-multiselect-box");
|
elColumnsMultiselectBox = document.getElementById("entity-table-columns-multiselect-box");
|
||||||
elColumnsOptions = document.getElementById("entity-table-columns-options");
|
elColumnsOptions = document.getElementById("entity-table-columns-options");
|
||||||
elToggleSpaceMode = document.getElementById('toggle-space-mode');
|
elToggleSpaceMode = document.getElementById('toggle-space-mode');
|
||||||
|
|
||||||
document.body.onclick = onBodyClick;
|
document.body.onclick = onBodyClick;
|
||||||
elToggleLocked.onclick = function() {
|
elToggleLocked.onclick = function() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleLocked' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleLocked' }));
|
||||||
|
@ -618,9 +623,9 @@ function loaded() {
|
||||||
|
|
||||||
++columnIndex;
|
++columnIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
elEntityTableHeaderRow = document.querySelectorAll("#entity-table thead th");
|
elEntityTableHeaderRow = document.querySelectorAll("#entity-table thead th");
|
||||||
|
|
||||||
entityList = new ListView(elEntityTableBody, elEntityTableScroll, elEntityTableHeaderRow, createRow, updateRow,
|
entityList = new ListView(elEntityTableBody, elEntityTableScroll, elEntityTableHeaderRow, createRow, updateRow,
|
||||||
clearRow, preRefresh, postRefresh, preRefresh, WINDOW_NONVARIABLE_HEIGHT);
|
clearRow, preRefresh, postRefresh, preRefresh, WINDOW_NONVARIABLE_HEIGHT);
|
||||||
|
|
||||||
|
@ -765,10 +770,10 @@ function loaded() {
|
||||||
let selectedIndex = selectedEntities.indexOf(entityID);
|
let selectedIndex = selectedEntities.indexOf(entityID);
|
||||||
if (selectedIndex >= 0) {
|
if (selectedIndex >= 0) {
|
||||||
selection = [];
|
selection = [];
|
||||||
selection = selection.concat(selectedEntities);
|
selection = selectedEntities.concat(selection);
|
||||||
selection.splice(selectedIndex, 1);
|
selection.splice(selectedIndex, 1);
|
||||||
} else {
|
} else {
|
||||||
selection = selection.concat(selectedEntities);
|
selection = selectedEntities.concat(selection);
|
||||||
}
|
}
|
||||||
} else if (clickEvent.shiftKey && selectedEntities.length > 0) {
|
} else if (clickEvent.shiftKey && selectedEntities.length > 0) {
|
||||||
let previousItemFound = -1;
|
let previousItemFound = -1;
|
||||||
|
@ -1044,6 +1049,8 @@ function loaded() {
|
||||||
function updateSelectedEntities(selectedIDs, autoScroll) {
|
function updateSelectedEntities(selectedIDs, autoScroll) {
|
||||||
let notFound = false;
|
let notFound = false;
|
||||||
|
|
||||||
|
lastSelectedEntity = selectedIDs[selectedIDs.length - 1];
|
||||||
|
|
||||||
// reset all currently selected entities and their rows first
|
// reset all currently selected entities and their rows first
|
||||||
selectedEntities.forEach(function(id) {
|
selectedEntities.forEach(function(id) {
|
||||||
let entity = entitiesByID[id];
|
let entity = entitiesByID[id];
|
||||||
|
@ -1063,7 +1070,11 @@ function loaded() {
|
||||||
if (entity !== undefined) {
|
if (entity !== undefined) {
|
||||||
entity.selected = true;
|
entity.selected = true;
|
||||||
if (entity.elRow) {
|
if (entity.elRow) {
|
||||||
entity.elRow.className = 'selected';
|
if (id === lastSelectedEntity) {
|
||||||
|
entity.elRow.className = 'last-selected';
|
||||||
|
} else {
|
||||||
|
entity.elRow.className = 'selected';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
notFound = true;
|
notFound = true;
|
||||||
|
@ -1132,7 +1143,11 @@ function loaded() {
|
||||||
|
|
||||||
// if this entity was previously selected flag it's row as selected
|
// if this entity was previously selected flag it's row as selected
|
||||||
if (itemData.selected) {
|
if (itemData.selected) {
|
||||||
elRow.className = 'selected';
|
if (itemData.id === lastSelectedEntity) {
|
||||||
|
elRow.className = 'last-selected';
|
||||||
|
} else {
|
||||||
|
elRow.className = 'selected';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
elRow.className = '';
|
elRow.className = '';
|
||||||
}
|
}
|
||||||
|
@ -1409,6 +1424,10 @@ function loaded() {
|
||||||
column.elResizer.style.visibility = columnVisible && visibleColumns > 0 ? "visible" : "hidden";
|
column.elResizer.style.visibility = columnVisible && visibleColumns > 0 ? "visible" : "hidden";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isColumnsSettingLoaded) {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'saveColumnsConfigSetting', columnsData: columns }));
|
||||||
|
}
|
||||||
|
|
||||||
entityList.refresh();
|
entityList.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1660,14 +1679,63 @@ function loaded() {
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("hmdmultiselect").style.display = "none";
|
document.getElementById("hmdmultiselect").style.display = "none";
|
||||||
}
|
}
|
||||||
|
} else if (data.type === "loadedConfigSetting") {
|
||||||
|
if (typeof(data.defaultRadius) === "number") {
|
||||||
|
elFilterRadius.value = data.defaultRadius;
|
||||||
|
onRadiusChange();
|
||||||
|
}
|
||||||
|
if (data.columnsData !== "NO_DATA" && typeof(data.columnsData) === "object") {
|
||||||
|
var isValid = true;
|
||||||
|
var originalColumnIDs = [];
|
||||||
|
for (let originalColumnID in COLUMNS) {
|
||||||
|
originalColumnIDs.push(originalColumnID);
|
||||||
|
}
|
||||||
|
for (let columnSetupIndex in data.columnsData) {
|
||||||
|
var checkPresence = originalColumnIDs.indexOf(data.columnsData[columnSetupIndex].columnID);
|
||||||
|
if (checkPresence === -1) {
|
||||||
|
isValid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isValid) {
|
||||||
|
for (var columnIndex = 0; columnIndex < data.columnsData.length; columnIndex++) {
|
||||||
|
if (data.columnsData[columnIndex].data.alwaysShown !== true) {
|
||||||
|
var columnDropdownID = "entity-table-column-" + data.columnsData[columnIndex].columnID;
|
||||||
|
if (data.columnsData[columnIndex].width !== 0) {
|
||||||
|
document.getElementById(columnDropdownID).checked = false;
|
||||||
|
document.getElementById(columnDropdownID).click();
|
||||||
|
} else {
|
||||||
|
document.getElementById(columnDropdownID).checked = true;
|
||||||
|
document.getElementById(columnDropdownID).click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (columnIndex = 0; columnIndex < data.columnsData.length; columnIndex++) {
|
||||||
|
let currentColumnIndex = originalColumnIDs.indexOf(data.columnsData[columnIndex].columnID);
|
||||||
|
if (currentColumnIndex !== -1 && columnIndex !== currentColumnIndex) {
|
||||||
|
for (var i = currentColumnIndex; i > columnIndex; i--) {
|
||||||
|
swapColumns(i - 1, i);
|
||||||
|
var swappedContent = originalColumnIDs[i - 1];
|
||||||
|
originalColumnIDs[i - 1] = originalColumnIDs[i];
|
||||||
|
originalColumnIDs[i] = swappedContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'saveColumnsConfigSetting', columnsData: "" }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isColumnsSettingLoaded = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshSortOrder();
|
refreshSortOrder();
|
||||||
refreshEntities();
|
refreshEntities();
|
||||||
|
|
||||||
window.addEventListener("resize", updateColumnWidths);
|
window.addEventListener("resize", updateColumnWidths);
|
||||||
|
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'loadConfigSetting' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
augmentSpinButtons();
|
augmentSpinButtons();
|
||||||
|
@ -1683,6 +1751,7 @@ function loaded() {
|
||||||
// close context menu when switching focus to another window
|
// close context menu when switching focus to another window
|
||||||
$(window).blur(function() {
|
$(window).blur(function() {
|
||||||
entityListContextMenu.close();
|
entityListContextMenu.close();
|
||||||
|
closeAllEntityListMenu();
|
||||||
});
|
});
|
||||||
|
|
||||||
function closeAllEntityListMenu() {
|
function closeAllEntityListMenu() {
|
||||||
|
|
|
@ -668,6 +668,7 @@ SelectionManager = (function() {
|
||||||
var newPosition = Vec3.sum(relativePosition, targetPosition);
|
var newPosition = Vec3.sum(relativePosition, targetPosition);
|
||||||
Entities.editEntity(id, { "position": newPosition });
|
Entities.editEntity(id, { "position": newPosition });
|
||||||
}
|
}
|
||||||
|
pushCommandForSelections();
|
||||||
that._update(false, this);
|
that._update(false, this);
|
||||||
} else {
|
} else {
|
||||||
audioFeedback.rejection();
|
audioFeedback.rejection();
|
||||||
|
@ -797,6 +798,7 @@ SelectionDisplay = (function() {
|
||||||
const COLOR_ROTATE_CURRENT_RING = { red: 255, green: 99, blue: 9 };
|
const COLOR_ROTATE_CURRENT_RING = { red: 255, green: 99, blue: 9 };
|
||||||
const COLOR_BOUNDING_EDGE = { red: 160, green: 160, blue: 160 };
|
const COLOR_BOUNDING_EDGE = { red: 160, green: 160, blue: 160 };
|
||||||
const COLOR_BOUNDING_EDGE_PARENT = { red: 194, green: 123, blue: 0 };
|
const COLOR_BOUNDING_EDGE_PARENT = { red: 194, green: 123, blue: 0 };
|
||||||
|
const COLOR_BOUNDING_EDGE_PARENT_AND_CHILDREN = { red: 179, green: 0, blue: 134 };
|
||||||
const COLOR_BOUNDING_EDGE_CHILDREN = { red: 0, green: 168, blue: 214 };
|
const COLOR_BOUNDING_EDGE_CHILDREN = { red: 0, green: 168, blue: 214 };
|
||||||
const COLOR_SCALE_CUBE = { red: 192, green: 192, blue: 192 };
|
const COLOR_SCALE_CUBE = { red: 192, green: 192, blue: 192 };
|
||||||
const COLOR_DEBUG_PICK_PLANE = { red: 255, green: 255, blue: 255 };
|
const COLOR_DEBUG_PICK_PLANE = { red: 255, green: 255, blue: 255 };
|
||||||
|
@ -1933,10 +1935,10 @@ SelectionDisplay = (function() {
|
||||||
var parentState = getParentState(SelectionManager.selections[0]);
|
var parentState = getParentState(SelectionManager.selections[0]);
|
||||||
if (parentState === "CHILDREN") {
|
if (parentState === "CHILDREN") {
|
||||||
handleBoundingBoxColor = COLOR_BOUNDING_EDGE_CHILDREN;
|
handleBoundingBoxColor = COLOR_BOUNDING_EDGE_CHILDREN;
|
||||||
} else {
|
} else if (parentState === "PARENT") {
|
||||||
if (parentState === "PARENT" || parentState === "PARENT_CHILDREN") {
|
handleBoundingBoxColor = COLOR_BOUNDING_EDGE_PARENT;
|
||||||
handleBoundingBoxColor = COLOR_BOUNDING_EDGE_PARENT;
|
} else if (parentState === "PARENT_CHILDREN") {
|
||||||
}
|
handleBoundingBoxColor = COLOR_BOUNDING_EDGE_PARENT_AND_CHILDREN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,11 +201,11 @@ TabBar {
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
id: importButton
|
id: importButton
|
||||||
text: "Import Entities (.json)"
|
text: "Import Entities (.json) from a File"
|
||||||
color: hifi.buttons.black
|
color: hifi.buttons.black
|
||||||
colorScheme: hifi.colorSchemes.dark
|
colorScheme: hifi.colorSchemes.dark
|
||||||
anchors.right: parent.right
|
anchors.right: parent.horizontalCenter
|
||||||
anchors.rightMargin: 30
|
anchors.rightMargin: 10
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 30
|
anchors.leftMargin: 30
|
||||||
anchors.top: assetServerButton.bottom
|
anchors.top: assetServerButton.bottom
|
||||||
|
@ -217,6 +217,25 @@ TabBar {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HifiControls.Button {
|
||||||
|
id: importButtonFromUrl
|
||||||
|
text: "Import Entities (.json) from a URL"
|
||||||
|
color: hifi.buttons.black
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: 30
|
||||||
|
anchors.left: parent.horizontalCenter
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.top: assetServerButton.bottom
|
||||||
|
anchors.topMargin: 20
|
||||||
|
onClicked: {
|
||||||
|
editRoot.sendToScript({
|
||||||
|
method: "newEntityButtonClicked",
|
||||||
|
params: { buttonName: "importEntitiesFromUrlButton" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // Flickable
|
} // Flickable
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,11 +207,11 @@ TabBar {
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
id: importButton
|
id: importButton
|
||||||
text: "Import Entities (.json)"
|
text: "Import Entities (.json) from a File"
|
||||||
color: hifi.buttons.black
|
color: hifi.buttons.black
|
||||||
colorScheme: hifi.colorSchemes.dark
|
colorScheme: hifi.colorSchemes.dark
|
||||||
anchors.right: parent.right
|
anchors.right: parent.horizontalCenter
|
||||||
anchors.rightMargin: 55
|
anchors.rightMargin: 10
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 55
|
anchors.leftMargin: 55
|
||||||
anchors.top: assetServerButton.bottom
|
anchors.top: assetServerButton.bottom
|
||||||
|
@ -223,6 +223,25 @@ TabBar {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HifiControls.Button {
|
||||||
|
id: importButtonFromUrl
|
||||||
|
text: "Import Entities (.json) from a URL"
|
||||||
|
color: hifi.buttons.black
|
||||||
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: 55
|
||||||
|
anchors.left: parent.horizontalCenter
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.top: assetServerButton.bottom
|
||||||
|
anchors.topMargin: 20
|
||||||
|
onClicked: {
|
||||||
|
editRoot.sendToScript({
|
||||||
|
method: "newEntityButtonClicked",
|
||||||
|
params: { buttonName: "importEntitiesFromUrlButton" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // Flickable
|
} // Flickable
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,6 @@ table {
|
||||||
thead {
|
thead {
|
||||||
font-family: Raleway-Regular;
|
font-family: Raleway-Regular;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
text-transform: uppercase;
|
|
||||||
background-color: #1c1c1c;
|
background-color: #1c1c1c;
|
||||||
padding: 1px 0;
|
padding: 1px 0;
|
||||||
border-bottom: 1px solid #575757;
|
border-bottom: 1px solid #575757;
|
||||||
|
@ -184,6 +183,15 @@ tr.selected + tr.selected {
|
||||||
border-top: 1px solid #2e2e2e;
|
border-top: 1px solid #2e2e2e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr.last-selected {
|
||||||
|
color: #000000;
|
||||||
|
background-color: #0064ef;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.last-selected + tr.last-selected {
|
||||||
|
border-top: 1px solid #2e2e2e;
|
||||||
|
}
|
||||||
|
|
||||||
th {
|
th {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
word-wrap: nowrap;
|
word-wrap: nowrap;
|
||||||
|
|
Loading…
Reference in a new issue