mirror of
https://github.com/overte-org/overte.git
synced 2025-05-06 18:29:36 +02:00
75 lines
1.8 KiB
JavaScript
75 lines
1.8 KiB
JavaScript
"use strict";
|
|
|
|
//
|
|
// vr-edit.js
|
|
//
|
|
// Created by David Rowe on 27 Jun 2017.
|
|
// Copyright 2017 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
(function () {
|
|
|
|
var APP_NAME = "VR EDIT", // TODO: App name.
|
|
APP_ICON_INACTIVE = "icons/tablet-icons/edit-i.svg", // TODO: App icons.
|
|
APP_ICON_ACTIVE = "icons/tablet-icons/edit-a.svg",
|
|
tablet,
|
|
button,
|
|
isAppActive = false,
|
|
|
|
VR_EDIT_SETTING = "io.highfidelity.isVREditing"; // Note: This constant is duplicated in utils.js.
|
|
|
|
|
|
function updateHandControllerGrab() {
|
|
// Communicate status to handControllerGrab.js.
|
|
Settings.setValue(VR_EDIT_SETTING, isAppActive);
|
|
}
|
|
|
|
function onButtonClicked() {
|
|
isAppActive = !isAppActive;
|
|
updateHandControllerGrab();
|
|
button.editProperties({ isActive: isAppActive });
|
|
}
|
|
|
|
function setUp() {
|
|
updateHandControllerGrab();
|
|
|
|
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
|
if (!tablet) {
|
|
return;
|
|
}
|
|
|
|
// Tablet/toolbar button.
|
|
button = tablet.addButton({
|
|
icon: APP_ICON_INACTIVE,
|
|
activeIcon: APP_ICON_ACTIVE,
|
|
text: APP_NAME,
|
|
isActive: isAppActive
|
|
});
|
|
if (button) {
|
|
button.clicked.connect(onButtonClicked);
|
|
}
|
|
}
|
|
|
|
function tearDown() {
|
|
isAppActive = false;
|
|
updateHandControllerGrab();
|
|
|
|
if (!tablet) {
|
|
return;
|
|
}
|
|
|
|
if (button) {
|
|
button.clicked.disconnect(onButtonClicked);
|
|
tablet.removeButton(button);
|
|
button = null;
|
|
}
|
|
|
|
tablet = null;
|
|
}
|
|
|
|
setUp();
|
|
Script.scriptEnding.connect(tearDown);
|
|
}());
|