2016-11-02 16:50:37 -07:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
//
|
|
|
|
// help.js
|
|
|
|
// scripts/system/
|
|
|
|
//
|
|
|
|
// Created by Howard Stearns on 2 Nov 2016
|
|
|
|
// Copyright 2016 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
|
|
|
|
//
|
2016-12-19 17:52:19 -08:00
|
|
|
/* globals Tablet */
|
2016-11-02 16:50:37 -07:00
|
|
|
|
|
|
|
(function() { // BEGIN LOCAL_SCOPE
|
|
|
|
|
2016-12-14 17:05:47 -08:00
|
|
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
|
|
|
var button = tablet.addButton({
|
2016-12-21 23:25:40 +00:00
|
|
|
icon: "icons/tablet-icons/help-i.svg",
|
2016-12-14 17:05:47 -08:00
|
|
|
text: "HELP"
|
2016-11-02 16:50:37 -07:00
|
|
|
});
|
2017-01-19 01:32:51 +00:00
|
|
|
var enabled = false;
|
2016-12-19 17:52:19 -08:00
|
|
|
function onClicked() {
|
|
|
|
var HELP_URL = Script.resourcesPath() + "html/help.html";
|
|
|
|
|
|
|
|
// Similar logic to Application::showHelp()
|
|
|
|
var defaultTab = "kbm";
|
|
|
|
var handControllerName = "vive";
|
|
|
|
if (HMD.active) {
|
|
|
|
if ("Vive" in Controller.Hardware) {
|
|
|
|
defaultTab = "handControllers";
|
|
|
|
handControllerName = "vive";
|
|
|
|
} else if ("OculusTouch" in Controller.Hardware) {
|
|
|
|
defaultTab = "handControllers";
|
|
|
|
handControllerName = "oculus";
|
|
|
|
}
|
|
|
|
} else if ("SDL2" in Controller.Hardware) {
|
|
|
|
defaultTab = "gamepad";
|
|
|
|
}
|
|
|
|
var queryParameters = "handControllerName=" + handControllerName + "&defaultTab=" + defaultTab;
|
2017-01-19 01:32:51 +00:00
|
|
|
print("Help enabled " + Menu.isMenuEnabled("Help..."))
|
|
|
|
|
|
|
|
if (enabled) {
|
|
|
|
Menu.closeInfoView('InfoView_html/help.html');
|
|
|
|
enabled = !enabled;
|
|
|
|
button.editProperties({isActive: enabled});
|
|
|
|
} else {
|
|
|
|
Menu.triggerOption('Help...');
|
|
|
|
enabled = !enabled;
|
|
|
|
button.editProperties({isActive: enabled});
|
|
|
|
}
|
2016-11-02 16:50:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
button.clicked.connect(onClicked);
|
|
|
|
|
2017-01-23 18:34:59 -08:00
|
|
|
var POLL_RATE = 500;
|
|
|
|
var interval = Script.setInterval(function () {
|
|
|
|
var visible = Menu.isInfoViewVisible('InfoView_html/help.html');
|
|
|
|
if (visible !== enabled) {
|
|
|
|
enabled = visible;
|
|
|
|
button.editProperties({isActive: enabled});
|
|
|
|
}
|
|
|
|
}, POLL_RATE);
|
|
|
|
|
2016-11-02 16:50:37 -07:00
|
|
|
Script.scriptEnding.connect(function () {
|
2017-01-23 18:34:59 -08:00
|
|
|
Script.clearInterval(interval);
|
2016-12-19 12:20:56 -08:00
|
|
|
tablet.removeButton(button);
|
2016-11-02 16:50:37 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
}()); // END LOCAL_SCOPE
|