Maerge broke the logic. Fixed now

This commit is contained in:
Vladyslav Stelmakhovskyi 2017-05-06 10:28:57 +02:00
parent e395a51c60
commit b2be22f0e0

View file

@ -25,9 +25,18 @@
var debugTablet = false; var debugTablet = false;
var tabletScalePercentage = 100.0; var tabletScalePercentage = 100.0;
UIWebTablet = null; UIWebTablet = null;
var MSECS_PER_SEC = 1000.0;
var MUTE_MICROPHONE_MENU_ITEM = "Mute Microphone";
var gTablet = null;
Script.include("../libraries/WebTablet.js"); Script.include("../libraries/WebTablet.js");
function checkTablet() {
if (gTablet === null) {
gTablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
}
}
function tabletIsValid() { function tabletIsValid() {
if (!UIWebTablet) { if (!UIWebTablet) {
return false; return false;
@ -49,6 +58,7 @@
} }
function getTabletScalePercentageFromSettings() { function getTabletScalePercentageFromSettings() {
checkTablet()
var toolbarMode = gTablet.toolbarMode; var toolbarMode = gTablet.toolbarMode;
var tabletScalePercentage = DEFAULT_TABLET_SCALE; var tabletScalePercentage = DEFAULT_TABLET_SCALE;
if (!toolbarMode) { if (!toolbarMode) {
@ -77,9 +87,7 @@
if (debugTablet) { if (debugTablet) {
print("TABLET rezzing"); print("TABLET rezzing");
} }
if (gTablet === null) { checkTablet()
gTablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
}
tabletScalePercentage = getTabletScalePercentageFromSettings(); tabletScalePercentage = getTabletScalePercentageFromSettings();
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml",
@ -95,6 +103,7 @@
} }
function showTabletUI() { function showTabletUI() {
checkTablet()
gTablet.tabletShown = true; gTablet.tabletShown = true;
if (!tabletRezzed || !tabletIsValid()) { if (!tabletRezzed || !tabletIsValid()) {
@ -117,6 +126,7 @@
} }
function hideTabletUI() { function hideTabletUI() {
checkTablet()
gTablet.tabletShown = false; gTablet.tabletShown = false;
if (!UIWebTablet) { if (!UIWebTablet) {
return; return;
@ -133,6 +143,7 @@
} }
function closeTabletUI() { function closeTabletUI() {
checkTablet()
gTablet.tabletShown = false; gTablet.tabletShown = false;
if (UIWebTablet) { if (UIWebTablet) {
if (UIWebTablet.onClose) { if (UIWebTablet.onClose) {
@ -159,9 +170,7 @@
function updateShowTablet() { function updateShowTablet() {
var now = Date.now(); var now = Date.now();
if (gTablet === null) { checkTablet()
gTablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
}
// close the WebTablet if it we go into toolbar mode. // close the WebTablet if it we go into toolbar mode.
var tabletShown = gTablet.tabletShown; var tabletShown = gTablet.tabletShown;
@ -223,6 +232,23 @@
closeTabletUI(); closeTabletUI();
rezTablet(); rezTablet();
tabletShown = false; tabletShown = false;
// also cause the stylus model to be loaded
var tmpStylusID = Overlays.addOverlay("model", {
name: "stylus",
url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",
loadPriority: 10.0,
position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.1, z: -2})),
dimensions: { x: 0.01, y: 0.01, z: 0.2 },
solid: true,
visible: true,
ignoreRayIntersection: true,
drawInFront: false,
lifetime: 3
});
Script.setTimeout(function() {
Overlays.deleteOverlay(tmpStylusID);
}, 300);
} else if (!tabletShown) { } else if (!tabletShown) {
hideTabletUI(); hideTabletUI();
} }
@ -237,6 +263,7 @@
} }
if (channel === "home") { if (channel === "home") {
if (UIWebTablet) { if (UIWebTablet) {
checkTablet()
gTablet.landscape = false; gTablet.landscape = false;
} }
} }