Make tablet highlight not display if editing an entity with hand

This commit is contained in:
David Rowe 2018-10-25 15:04:59 +13:00
parent 0eead13fb9
commit 1460e43f6e

View file

@ -11,7 +11,7 @@
//
/* global LEFT_HAND, RIGHT_HAND, makeDispatcherModuleParameters, makeRunningValues, enableDispatcherModule,
* disableDispatcherModule */
* disableDispatcherModule, HIFI_EDIT_MANIPULATION_CHANNEL */
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@ -66,12 +66,17 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
100
);
this.isEditing = false;
this.setIsEditing = function (editing) {
this.isEditing = editing;
};
this.isNearTablet = function (controllerData) {
return HMD.tabletID && controllerData.nearbyOverlayIDs[this.hand].indexOf(HMD.tabletID) !== -1;
};
this.isReady = function (controllerData) {
if (this.isNearTablet(controllerData)) {
if (!this.isEditing && this.isNearTablet(controllerData)) {
return makeRunningValues(true, [], []);
}
setTabletNearGrabbable(this.hand, false);
@ -79,7 +84,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
};
this.run = function (controllerData) {
if (!this.isNearTablet(controllerData)) {
if (this.isEditing || !this.isNearTablet(controllerData)) {
setTabletNearGrabbable(this.hand, false);
return makeRunningValues(false, [], []);
}
@ -111,6 +116,28 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
HMD.mountedChanged.connect(onDisplayModeChanged);
onDisplayModeChanged();
function onMessageReceived(channel, data, senderID) {
var message;
if (channel !== HIFI_EDIT_MANIPULATION_CHANNEL || senderID !== MyAvatar.sessionUUID) {
return;
}
try {
message = JSON.parse(data);
} catch (e) {
return;
}
if (message.hand === Controller.Standard.LeftHand) {
leftNearTabletHighlight.setIsEditing(message.action === "startEdit");
} else if (message.hand === Controller.Standard.RightHand) {
rightNearTabletHighlight.setIsEditing(message.action === "startEdit");
}
}
Messages.subscribe(HIFI_EDIT_MANIPULATION_CHANNEL);
Messages.messageReceived.connect(onMessageReceived);
function cleanUp() {
disableDispatcherModule("LeftNearTabletHighlight");
disableDispatcherModule("RightNearTabletHighlight");