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
|
|
|
|
//
|
2017-02-16 17:29:35 -08:00
|
|
|
/* globals Tablet, Script, HMD, Controller, Menu */
|
2016-11-02 16:50:37 -07:00
|
|
|
|
|
|
|
(function() { // BEGIN LOCAL_SCOPE
|
2017-03-22 19:14:53 +01:00
|
|
|
|
|
|
|
var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
|
2018-02-23 00:36:00 +03:00
|
|
|
var HELP_URL = Script.resourcesPath() + "html/tabletHelp.html";
|
2017-01-25 12:00:34 -08:00
|
|
|
var buttonName = "HELP";
|
2017-03-22 19:14:53 +01:00
|
|
|
var onHelpScreen = false;
|
2017-02-16 17:29:35 -08:00
|
|
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
|
|
|
var button = tablet.addButton({
|
|
|
|
icon: "icons/tablet-icons/help-i.svg",
|
|
|
|
activeIcon: "icons/tablet-icons/help-a.svg",
|
|
|
|
text: buttonName,
|
|
|
|
sortOrder: 6
|
|
|
|
});
|
|
|
|
|
2017-01-19 01:32:51 +00:00
|
|
|
var enabled = false;
|
2016-12-19 17:52:19 -08:00
|
|
|
function onClicked() {
|
2017-03-22 19:14:53 +01:00
|
|
|
if (onHelpScreen) {
|
|
|
|
tablet.gotoHomeScreen();
|
2017-01-19 01:32:51 +00:00
|
|
|
} else {
|
2018-02-08 09:51:48 +13:00
|
|
|
if (HMD.tabletID) {
|
|
|
|
Entities.editEntity(HMD.tabletID, {textures: JSON.stringify({"tex.close" : HOME_BUTTON_TEXTURE})});
|
2017-03-22 19:14:53 +01:00
|
|
|
}
|
2017-01-19 01:32:51 +00:00
|
|
|
Menu.triggerOption('Help...');
|
2017-03-22 19:14:53 +01:00
|
|
|
onHelpScreen = true;
|
2017-01-19 01:32:51 +00:00
|
|
|
}
|
2016-11-02 16:50:37 -07:00
|
|
|
}
|
|
|
|
|
2017-03-22 19:14:53 +01:00
|
|
|
function onScreenChanged(type, url) {
|
2018-04-03 13:22:47 -07:00
|
|
|
onHelpScreen = type === "Web" && (url.indexOf(HELP_URL) === 0);
|
2017-06-26 23:18:21 -07:00
|
|
|
button.editProperties({ isActive: onHelpScreen });
|
2017-03-22 19:14:53 +01:00
|
|
|
}
|
|
|
|
|
2016-11-02 16:50:37 -07:00
|
|
|
button.clicked.connect(onClicked);
|
2017-03-22 19:14:53 +01:00
|
|
|
tablet.screenChanged.connect(onScreenChanged);
|
2016-11-02 16:50:37 -07:00
|
|
|
|
|
|
|
Script.scriptEnding.connect(function () {
|
2017-03-28 18:14:05 +01:00
|
|
|
if (onHelpScreen) {
|
2017-03-22 19:14:53 +01:00
|
|
|
tablet.gotoHomeScreen();
|
2017-03-08 21:44:04 +00:00
|
|
|
}
|
2017-01-25 12:00:34 -08:00
|
|
|
button.clicked.disconnect(onClicked);
|
2017-08-14 17:34:32 -07:00
|
|
|
tablet.screenChanged.disconnect(onScreenChanged);
|
2017-01-25 12:00:34 -08:00
|
|
|
if (tablet) {
|
|
|
|
tablet.removeButton(button);
|
|
|
|
}
|
2016-11-02 16:50:37 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
}()); // END LOCAL_SCOPE
|