mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:01:09 +02:00
Merge pull request #6351 from huffman/script-path-resolution
Update script engine path resolution behavior to behave consistently
This commit is contained in:
commit
a2abc11df1
16 changed files with 30 additions and 22 deletions
|
@ -15,7 +15,7 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include('../utilities/tools/vector.js');
|
Script.include('../../utilities/tools/vector.js');
|
||||||
|
|
||||||
var URL = "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Scripts/planets/";
|
var URL = "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Scripts/planets/";
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include("libraries/overlayUtils.js");
|
Script.include("overlayUtils.js");
|
||||||
|
|
||||||
var MOUSE_SENSITIVITY = 0.9;
|
var MOUSE_SENSITIVITY = 0.9;
|
||||||
var SCROLL_SENSITIVITY = 0.05;
|
var SCROLL_SENSITIVITY = 0.05;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
var ENTITY_LIST_HTML_URL = Script.resolvePath('../html/entityList.html');
|
||||||
|
|
||||||
EntityListTool = function(opts) {
|
EntityListTool = function(opts) {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
var url = Script.resolvePath('html/entityList.html');
|
var url = ENTITY_LIST_HTML_URL;
|
||||||
var webView = new WebWindow('Entities', url, 200, 280, true);
|
var webView = new WebWindow('Entities', url, 200, 280, true);
|
||||||
|
|
||||||
var searchRadius = 100;
|
var searchRadius = 100;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html');
|
||||||
|
|
||||||
Grid = function(opts) {
|
Grid = function(opts) {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
|
@ -228,7 +230,7 @@ GridTool = function(opts) {
|
||||||
var verticalGrid = opts.verticalGrid;
|
var verticalGrid = opts.verticalGrid;
|
||||||
var listeners = [];
|
var listeners = [];
|
||||||
|
|
||||||
var url = Script.resolvePath('html/gridControls.html');
|
var url = GRID_CONTROLS_HTML_URL;
|
||||||
var webView = new WebWindow('Grid', url, 200, 280, true);
|
var webView = new WebWindow('Grid', url, 200, 280, true);
|
||||||
|
|
||||||
horizontalGrid.addListener(function(data) {
|
horizontalGrid.addListener(function(data) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include("../toys/breakdanceCore.js");
|
Script.include("../../../breakdanceCore.js");
|
||||||
|
|
||||||
OmniToolModules.Breakdance = function() {
|
OmniToolModules.Breakdance = function() {
|
||||||
print("OmniToolModules.Breakdance...");
|
print("OmniToolModules.Breakdance...");
|
||||||
|
@ -32,4 +32,4 @@ OmniToolModules.Breakdance.prototype.onUpdate = function(deltaTime) {
|
||||||
breakdanceEnd();
|
breakdanceEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
OmniToolModuleType = "Breakdance";
|
OmniToolModuleType = "Breakdance";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
Script.include("avatarRelativeOverlays.js");
|
Script.include("../../avatarRelativeOverlays.js");
|
||||||
|
|
||||||
OmniToolModules.Test = function(omniTool, activeEntityId) {
|
OmniToolModules.Test = function(omniTool, activeEntityId) {
|
||||||
this.omniTool = omniTool;
|
this.omniTool = omniTool;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// included here to ensure walkApi.js can be used as an API, separate from walk.js
|
// included here to ensure walkApi.js can be used as an API, separate from walk.js
|
||||||
Script.include("./libraries/walkConstants.js");
|
Script.include("walkConstants.js");
|
||||||
|
|
||||||
Avatar = function() {
|
Avatar = function() {
|
||||||
// if Hydras are connected, the only way to enable use is to never set any arm joint rotation
|
// if Hydras are connected, the only way to enable use is to never set any arm joint rotation
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var WALK_SETTINGS_HTML_URL = Script.resolvePath('../html/walkSettings.html');
|
||||||
|
|
||||||
WalkSettings = function() {
|
WalkSettings = function() {
|
||||||
var _visible = false;
|
var _visible = false;
|
||||||
var _innerWidth = Window.innerWidth;
|
var _innerWidth = Window.innerWidth;
|
||||||
|
@ -69,7 +71,7 @@ WalkSettings = function() {
|
||||||
// web window
|
// web window
|
||||||
const PANEL_WIDTH = 200;
|
const PANEL_WIDTH = 200;
|
||||||
const PANEL_HEIGHT = 180;
|
const PANEL_HEIGHT = 180;
|
||||||
var _url = Script.resolvePath('html/walkSettings.html');
|
var _url = WALK_SETTINGS_HTML_URL;
|
||||||
var _webWindow = new WebWindow('Walk Settings', _url, PANEL_WIDTH, PANEL_HEIGHT, false);
|
var _webWindow = new WebWindow('Walk Settings', _url, PANEL_WIDTH, PANEL_HEIGHT, false);
|
||||||
_webWindow.setVisible(false);
|
_webWindow.setVisible(false);
|
||||||
_webWindow.eventBridge.webEventReceived.connect(function(data) {
|
_webWindow.eventBridge.webEventReceived.connect(function(data) {
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// FIXME Script paths have to be relative to the caller, in this case libraries/OmniTool.js
|
// FIXME Script paths have to be relative to the caller, in this case libraries/OmniTool.js
|
||||||
Script.include("../magBalls/constants.js");
|
Script.include("magBalls/constants.js");
|
||||||
Script.include("../magBalls/graph.js");
|
Script.include("magBalls/graph.js");
|
||||||
Script.include("../magBalls/edgeSpring.js");
|
Script.include("magBalls/edgeSpring.js");
|
||||||
Script.include("../magBalls/magBalls.js");
|
Script.include("magBalls/magBalls.js");
|
||||||
Script.include("avatarRelativeOverlays.js");
|
Script.include("libraries/avatarRelativeOverlays.js");
|
||||||
|
|
||||||
OmniToolModuleType = "MagBallsController"
|
OmniToolModuleType = "MagBallsController"
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ MODE_INFO[BALL_EDIT_MODE_ADD] = {
|
||||||
},
|
},
|
||||||
colors: [ COLORS.GREEN, COLORS.BLUE ],
|
colors: [ COLORS.GREEN, COLORS.BLUE ],
|
||||||
// FIXME use an http path or find a way to get the relative path to the file
|
// FIXME use an http path or find a way to get the relative path to the file
|
||||||
url: Script.resolvePath('../html/magBalls/addMode.html'),
|
url: Script.resolvePath('html/magBalls/addMode.html'),
|
||||||
};
|
};
|
||||||
|
|
||||||
MODE_INFO[BALL_EDIT_MODE_DELETE] = {
|
MODE_INFO[BALL_EDIT_MODE_DELETE] = {
|
||||||
|
@ -45,7 +45,7 @@ MODE_INFO[BALL_EDIT_MODE_DELETE] = {
|
||||||
},
|
},
|
||||||
colors: [ COLORS.RED, COLORS.BLUE ],
|
colors: [ COLORS.RED, COLORS.BLUE ],
|
||||||
// FIXME use an http path or find a way to get the relative path to the file
|
// FIXME use an http path or find a way to get the relative path to the file
|
||||||
url: Script.resolvePath('../html/magBalls/deleteMode.html'),
|
url: Script.resolvePath('html/magBalls/deleteMode.html'),
|
||||||
};
|
};
|
||||||
|
|
||||||
var UI_POSITION_MODE_LABEL = Vec3.multiply(0.5,
|
var UI_POSITION_MODE_LABEL = Vec3.multiply(0.5,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include("libraries/utils.js");
|
Script.include("../libraries/utils.js");
|
||||||
|
|
||||||
|
|
||||||
var RIGHT_HAND = 1;
|
var RIGHT_HAND = 1;
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
// 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
|
||||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||||
|
|
||||||
Script.include("../../utilities.js");
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/models/bubblewand/wand.fbx';
|
var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/models/bubblewand/wand.fbx';
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
Script.include("../../utilities.js");
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/models/bubblewand/bubble.fbx";
|
var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/models/bubblewand/bubble.fbx";
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
Script.include("../../utilities.js");
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
var _this;
|
var _this;
|
||||||
// this is the "constructor" for the entity as a JS object we don't do much here
|
// this is the "constructor" for the entity as a JS object we don't do much here
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||||
Script.include("../../utilities.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var scriptURL = Script.resolvePath('pingPongGun.js');
|
var scriptURL = Script.resolvePath('pingPongGun.js');
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||||
Script.include("../../utilities.js");
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
var scriptURL = Script.resolvePath('wallTarget.js');
|
var scriptURL = Script.resolvePath('wallTarget.js');
|
||||||
|
|
||||||
|
|
|
@ -902,14 +902,19 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac
|
||||||
BatchLoader* loader = new BatchLoader(urls);
|
BatchLoader* loader = new BatchLoader(urls);
|
||||||
|
|
||||||
auto evaluateScripts = [=](const QMap<QUrl, QString>& data) {
|
auto evaluateScripts = [=](const QMap<QUrl, QString>& data) {
|
||||||
|
auto parentURL = _parentURL;
|
||||||
for (QUrl url : urls) {
|
for (QUrl url : urls) {
|
||||||
QString contents = data[url];
|
QString contents = data[url];
|
||||||
if (contents.isNull()) {
|
if (contents.isNull()) {
|
||||||
qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
|
qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
|
||||||
} else {
|
} else {
|
||||||
|
// Set the parent url so that path resolution will be relative
|
||||||
|
// to this script's url during its initial evaluation
|
||||||
|
_parentURL = url.toString();
|
||||||
QScriptValue result = evaluate(contents, url.toString());
|
QScriptValue result = evaluate(contents, url.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_parentURL = parentURL;
|
||||||
|
|
||||||
if (callback.isFunction()) {
|
if (callback.isFunction()) {
|
||||||
QScriptValue(callback).call();
|
QScriptValue(callback).call();
|
||||||
|
|
Loading…
Reference in a new issue