mirror of
https://github.com/lubosz/overte.git
synced 2025-04-19 17:03:43 +02:00
* add isInEditMode to utils.js
* update grab.js to use the latest Settings edit mode detection approach * add edit guards to handControllerGrab.js and grab.js * update edit.js to consistently initialize Setting's edit flag
This commit is contained in:
parent
b02a5f85ec
commit
15394056eb
4 changed files with 12 additions and 29 deletions
|
@ -45,8 +45,6 @@ var DEFAULT_GRABBABLE_DATA = {
|
|||
|
||||
var ACTION_TTL = 10; // seconds
|
||||
|
||||
var enabled = true;
|
||||
|
||||
function getTag() {
|
||||
return "grab-" + MyAvatar.sessionUUID;
|
||||
}
|
||||
|
@ -321,7 +319,7 @@ Grabber.prototype.computeNewGrabPlane = function() {
|
|||
}
|
||||
|
||||
Grabber.prototype.pressEvent = function(event) {
|
||||
if (!enabled) {
|
||||
if (isInEditMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -633,31 +631,10 @@ function keyReleaseEvent(event) {
|
|||
grabber.keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
function editEvent(channel, message, sender, localOnly) {
|
||||
if (channel != "edit-events") {
|
||||
return;
|
||||
}
|
||||
if (sender != MyAvatar.sessionUUID) {
|
||||
return;
|
||||
}
|
||||
if (!localOnly) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var data = JSON.parse(message);
|
||||
if ("enabled" in data) {
|
||||
enabled = !data["enabled"];
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
Controller.mousePressEvent.connect(pressEvent);
|
||||
Controller.mouseMoveEvent.connect(moveEvent);
|
||||
Controller.mouseReleaseEvent.connect(releaseEvent);
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Messages.subscribe("edit-events");
|
||||
Messages.messageReceived.connect(editEvent);
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
||||
|
|
|
@ -493,11 +493,9 @@ function removeMyAvatarFromCollidesWith(origCollidesWith) {
|
|||
// If another script is managing the reticle (as is done by HandControllerPointer), we should not be setting it here,
|
||||
// and we should not be showing lasers when someone else is using the Reticle to indicate a 2D minor mode.
|
||||
var EXTERNALLY_MANAGED_2D_MINOR_MODE = true;
|
||||
var EDIT_SETTING = "io.highfidelity.isEditting";
|
||||
|
||||
function isEditing() {
|
||||
var actualSettingValue = Settings.getValue(EDIT_SETTING) === "false" ? false : !!Settings.getValue(EDIT_SETTING);
|
||||
return EXTERNALLY_MANAGED_2D_MINOR_MODE && actualSettingValue;
|
||||
return EXTERNALLY_MANAGED_2D_MINOR_MODE && isInEditMode();
|
||||
}
|
||||
|
||||
function isIn2DMode() {
|
||||
|
@ -844,6 +842,9 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.callEntityMethodOnGrabbed = function(entityMethodName) {
|
||||
if (isInEditMode()) {
|
||||
return;
|
||||
}
|
||||
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
||||
Entities.callEntityMethod(this.grabbedEntity, entityMethodName, args);
|
||||
};
|
||||
|
|
|
@ -429,7 +429,6 @@ var toolBar = (function () {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
that.setActive(false);
|
||||
}
|
||||
|
||||
|
@ -446,6 +445,7 @@ var toolBar = (function () {
|
|||
};
|
||||
|
||||
that.setActive = function (active) {
|
||||
Settings.setValue(EDIT_SETTING, active);
|
||||
if (active === isActive) {
|
||||
return;
|
||||
}
|
||||
|
@ -457,7 +457,6 @@ var toolBar = (function () {
|
|||
enabled: active
|
||||
}));
|
||||
isActive = active;
|
||||
Settings.setValue(EDIT_SETTING, active);
|
||||
if (!isActive) {
|
||||
entityListTool.setVisible(false);
|
||||
gridTool.setVisible(false);
|
||||
|
|
|
@ -6,6 +6,12 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
// note: this constant is currently duplicated in edit.js
|
||||
EDIT_SETTING = "io.highfidelity.isEditting";
|
||||
isInEditMode = function isInEditMode() {
|
||||
return Settings.getValue(EDIT_SETTING) === "false" ? false : !!Settings.getValue(EDIT_SETTING);
|
||||
};
|
||||
|
||||
if (!Function.prototype.bind) {
|
||||
Function.prototype.bind = function(oThis) {
|
||||
if (typeof this !== 'function') {
|
||||
|
|
Loading…
Reference in a new issue