Merge pull request #10006 from druiz17/tablet-help

Ported help into the tablet
This commit is contained in:
Seth Alves 2017-03-25 08:33:41 -08:00 committed by GitHub
commit 3abd6b3948
7 changed files with 179 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

View file

@ -0,0 +1,157 @@
<!-- Copyright 2016 High Fidelity, Inc. -->
<html>
<head>
<meta charset="utf-8"/>
<input type="hidden" id="version" value="1"/>
<title>Welcome to Interface</title>
<style>
body {
background: black;
width: 100%;
overflow-x: hidden;
overflow-y: hidden;
margin: 0;
padding: 0;
}
#left_button {
position: absolute;
left: 70;
top: 70;
width: 160;
height: 80;
}
#right_button {
position: absolute;
left: 367;
top: 70;
width: 160;
height: 80;
}
#image_area {
width: 480;
height: 720;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
</style>
<script>
var handControllerImageURL = null;
var index = 0;
var count = 4;
function showKbm() {
document.getElementById("main_image").setAttribute("src", "img/tablet-help-keyboard.jpg");
}
function showHandControllers() {
document.getElementById("main_image").setAttribute("src", handControllerImageURL);
}
function showGamepad() {
document.getElementById("main_image").setAttribute("src", "img/tablet-help-gamepad.jpg");
}
function cycleRight() {
index = (index + count + 1) % count;
chooseIcon();
}
function cycleLeft() {
index = (index + count - 1) % count;
chooseIcon();
}
function chooseIcon() {
switch (index)
{
case 0:
handControllerImageURL = "img/tablet-help-keyboard.jpg";
showHandControllers();
break;
case 1:
handControllerImageURL = "img/tablet-help-vive.jpg";
showHandControllers();
break;
case 2:
showGamepad();
break;
case 3:
showKbm();
break;
default:
}
}
// This is not meant to be a complete or hardened query string parser - it only
// needs to handle the values we send in and have control over.
//
// queryString is a string of the form "key1=value1&key2=value2&key3&key4=value4"
function parseQueryString(queryString) {
var params = {};
var paramsParts = queryString.split("&");
for (var i = 0; i < paramsParts.length; ++i) {
var paramKeyValue = paramsParts[i].split("=");
if (paramKeyValue.length == 1) {
params[paramKeyValue[0]] = undefined;
} else if (paramKeyValue.length == 2) {
params[paramKeyValue[0]] = paramKeyValue[1];
} else {
console.error("Error parsing param keyvalue: ", paramParts);
}
}
return params;
}
function load() {
var parts = window.location.href.split("?");
var params = {};
if (parts.length > 0) {
params = parseQueryString(parts[1]);
}
switch (params.handControllerName) {
case "oculus":
handControllerImageURL = "img/tablet-help-oculus.jpg";
index = 0;
break;
case "vive":
default:
handControllerImageURL = "img/tablet-help-vive.jpg";
index = 1;
}
switch (params.defaultTab) {
case "gamepad":
showGamepad();
index = 2;
break;
case "handControllers":
showHandControllers();
break;
case "kbm":
default:
showKbm();
index = 3;
}
}
</script>
</head>
<body onload="load()">
<div id="image_area">
<img id="main_image" src="img/tablet-help-keyboard.jpg" width="480px" height="720px"></img>
<a href="#" id="left_button" onmousedown="cycleLeft()"></a>
<a href="#" id="right_button" onmousedown="cycleRight()"></a>
</div>
</body>
</html>

View file

@ -222,7 +222,7 @@ static const float MIRROR_FULLSCREEN_DISTANCE = 0.389f;
static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND;
static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html";
static const QString INFO_HELP_PATH = "html/help.html";
static const QString INFO_HELP_PATH = "../../../html/tabletHelp.html";
static const unsigned int THROTTLED_SIM_FRAMERATE = 15;
static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SIM_FRAMERATE;
@ -2397,8 +2397,10 @@ void Application::showHelp() {
QUrlQuery queryString;
queryString.addQueryItem("handControllerName", handControllerName);
queryString.addQueryItem("defaultTab", defaultTab);
InfoView::show(INFO_HELP_PATH, false, queryString.toString());
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
tablet->gotoWebScreen(INFO_HELP_PATH + "?" + queryString.toString());
//InfoView::show(INFO_HELP_PATH, false, queryString.toString());
}
void Application::resizeEvent(QResizeEvent* event) {

View file

@ -13,8 +13,10 @@
/* globals Tablet, Script, HMD, Controller, Menu */
(function() { // BEGIN LOCAL_SCOPE
var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
var buttonName = "HELP";
var onHelpScreen = false;
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({
icon: "icons/tablet-icons/help-i.svg",
@ -25,18 +27,24 @@
var enabled = false;
function onClicked() {
if (enabled) {
Menu.closeInfoView('InfoView_html/help.html');
enabled = !enabled;
button.editProperties({isActive: enabled});
if (onHelpScreen) {
tablet.gotoHomeScreen();
} else {
var tabletEntity = HMD.tabletID;
if (tabletEntity) {
Entities.editEntity(tabletEntity, {textures: JSON.stringify({"tex.close" : HOME_BUTTON_TEXTURE})});
}
Menu.triggerOption('Help...');
enabled = !enabled;
button.editProperties({isActive: enabled});
onHelpScreen = true;
}
}
function onScreenChanged(type, url) {
onHelpScreen = false;
}
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged);
var POLL_RATE = 500;
var interval = Script.setInterval(function () {
@ -48,8 +56,8 @@
}, POLL_RATE);
Script.scriptEnding.connect(function () {
if (enabled) {
Menu.closeInfoView('InfoView_html/help.html');
if (onUserScreen) {
tablet.gotoHomeScreen();
}
button.clicked.disconnect(onClicked);
Script.clearInterval(interval);