From 571783b90d2876b73dcc074ce7bf39a4e6aae7ae Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Dec 2016 17:18:46 +0000 Subject: [PATCH 1/9] fixed home buttons issues --- scripts/system/libraries/WebTablet.js | 14 +++++++++++--- scripts/system/tablet-ui/tabletUI.js | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 6607b044ff..401bbe050f 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -8,6 +8,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // + +Script.include(Script.resolvePath("../libraries/utils.js")); var RAD_TO_DEG = 180 / Math.PI; var X_AXIS = {x: 1, y: 0, z: 0}; var Y_AXIS = {x: 0, y: 1, z: 0}; @@ -15,7 +17,7 @@ var DEFAULT_DPI = 32; var DEFAULT_WIDTH = 0.5; var TABLET_URL = "https://s3.amazonaws.com/hifi-public/tony/tablet.fbx"; - +var sound = SoundCache.getSound(Script.resolvePath("assets/sounds/hello.wav")); // returns object with two fields: // * position - position in front of the user // * rotation - rotation of entity so it faces the user. @@ -104,12 +106,18 @@ WebTablet = function (url, width, dpi, location, clientOnly) { dimensions: {x: 0.05, y: 0.05, z: 0.05}, parentID: this.tabletEntityID, script: "https://people.ucsc.edu/~druiz4/scripts/homeButton.js" - }, clientOnly); + }, clientOnly); + + + setEntityCustomData('grabbableKey', this.homeButtonEntity, {wantsTrigger: true}); + + this.receive = function (channel, senderID, senderUUID, localOnly) { if (_this.homeButtonEntity == senderID) { + //var homePosition = Entities.getEntityProperties(_this.homeButtonEntity, ["position"]); if (_this.clicked) { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); + Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); _this.clicked = false; } else { Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); diff --git a/scripts/system/tablet-ui/tabletUI.js b/scripts/system/tablet-ui/tabletUI.js index 5b61575926..c49ed54345 100644 --- a/scripts/system/tablet-ui/tabletUI.js +++ b/scripts/system/tablet-ui/tabletUI.js @@ -24,6 +24,7 @@ tabletShown = true; print("show tablet-ui"); UIWebTablet = new WebTablet("qml/hifi/tablet/Tablet.qml", null, null, tabletLocation); + UIWebTablet.register(); HMD.tabletID = UIWebTablet.webEntityID; var setUpTabletUI = function() { @@ -48,6 +49,7 @@ } tabletLocation = UIWebTablet.getLocation(); + UIWebTablet.unregister(); UIWebTablet.destroy(); UIWebTablet = null; HMD.tabletID = null; From 40a79867be653fcaced226279693b4eb4f7a3270 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Dec 2016 17:24:09 +0000 Subject: [PATCH 2/9] removed unnessary comments --- scripts/system/libraries/WebTablet.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 401bbe050f..5aaa523e2b 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -115,7 +115,6 @@ WebTablet = function (url, width, dpi, location, clientOnly) { this.receive = function (channel, senderID, senderUUID, localOnly) { if (_this.homeButtonEntity == senderID) { - //var homePosition = Entities.getEntityProperties(_this.homeButtonEntity, ["position"]); if (_this.clicked) { Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); _this.clicked = false; From 889e9e854c895e501f56fe651d88b2de11931bee Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Dec 2016 17:24:53 +0000 Subject: [PATCH 3/9] clean up --- scripts/system/libraries/WebTablet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 5aaa523e2b..955be2d896 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -116,7 +116,7 @@ WebTablet = function (url, width, dpi, location, clientOnly) { this.receive = function (channel, senderID, senderUUID, localOnly) { if (_this.homeButtonEntity == senderID) { if (_this.clicked) { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); + Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); _this.clicked = false; } else { Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); From f2d9f34993b1f12234d1d162e99b4693e13624c9 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Dec 2016 17:25:38 +0000 Subject: [PATCH 4/9] more clean up --- scripts/system/libraries/WebTablet.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 955be2d896..3a2c5d4989 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -116,11 +116,11 @@ WebTablet = function (url, width, dpi, location, clientOnly) { this.receive = function (channel, senderID, senderUUID, localOnly) { if (_this.homeButtonEntity == senderID) { if (_this.clicked) { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); - _this.clicked = false; + Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); + _this.clicked = false; } else { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); - _this.clicked = true; + Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); + _this.clicked = true; } } } From a0a8ecc1585755a1c3ec715f9293bcbf2fdea108 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Dec 2016 17:28:02 +0000 Subject: [PATCH 5/9] even more clean up --- scripts/system/libraries/WebTablet.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 3a2c5d4989..d0ffdcc7d3 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -17,7 +17,6 @@ var DEFAULT_DPI = 32; var DEFAULT_WIDTH = 0.5; var TABLET_URL = "https://s3.amazonaws.com/hifi-public/tony/tablet.fbx"; -var sound = SoundCache.getSound(Script.resolvePath("assets/sounds/hello.wav")); // returns object with two fields: // * position - position in front of the user // * rotation - rotation of entity so it faces the user. From cb4b2473e10de654e276e32438d17c8d3a55d116 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Dec 2016 18:30:15 +0000 Subject: [PATCH 6/9] remmoved tabs as whitespace --- scripts/system/libraries/WebTablet.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index d0ffdcc7d3..0b5e2048ed 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -105,7 +105,7 @@ WebTablet = function (url, width, dpi, location, clientOnly) { dimensions: {x: 0.05, y: 0.05, z: 0.05}, parentID: this.tabletEntityID, script: "https://people.ucsc.edu/~druiz4/scripts/homeButton.js" - }, clientOnly); + }, clientOnly); setEntityCustomData('grabbableKey', this.homeButtonEntity, {wantsTrigger: true}); @@ -115,11 +115,11 @@ WebTablet = function (url, width, dpi, location, clientOnly) { this.receive = function (channel, senderID, senderUUID, localOnly) { if (_this.homeButtonEntity == senderID) { if (_this.clicked) { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); - _this.clicked = false; + Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); + _this.clicked = false; } else { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); - _this.clicked = true; + Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); + _this.clicked = true; } } } From f7df9a64b2663c593cda27fc8b38a3413c1f7a59 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Dec 2016 18:32:05 +0000 Subject: [PATCH 7/9] remmoved tabs --- scripts/system/libraries/WebTablet.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 0b5e2048ed..10c8e48d1d 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -115,11 +115,11 @@ WebTablet = function (url, width, dpi, location, clientOnly) { this.receive = function (channel, senderID, senderUUID, localOnly) { if (_this.homeButtonEntity == senderID) { if (_this.clicked) { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); - _this.clicked = false; + Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); + _this.clicked = false; } else { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); - _this.clicked = true; + Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); + _this.clicked = true; } } } From 8f36090884f79935ecbf24c413cfe8de73b1f238 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Dec 2016 21:45:53 +0000 Subject: [PATCH 8/9] removed tabs and also remove script from host --- scripts/system/libraries/WebTablet.js | 16 ++++++------- scripts/system/tablet-ui/HomeButton.js | 32 ++++++++++++++++++++++++++ scripts/system/tablet-ui/tabletUI.js | 4 ++-- 3 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 scripts/system/tablet-ui/HomeButton.js diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 10c8e48d1d..0dc52c2c1c 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -98,28 +98,26 @@ WebTablet = function (url, width, dpi, location, clientOnly) { this.createWebEntity(url); + this.homeButtonEntity = Entities.addEntity({ name: "homeButton", type: "Sphere", localPosition: {x: 0, y: HOME_BUTTON_Y_OFFSET, z: 0}, dimensions: {x: 0.05, y: 0.05, z: 0.05}, parentID: this.tabletEntityID, - script: "https://people.ucsc.edu/~druiz4/scripts/homeButton.js" + script: Script.resolvePath("../tablet-ui/HomeButton.js") }, clientOnly); - - setEntityCustomData('grabbableKey', this.homeButtonEntity, {wantsTrigger: true}); - - + setEntityCustomData('grabbableKey', this.homeButtonEntity, {wantsTrigger: true}); this.receive = function (channel, senderID, senderUUID, localOnly) { if (_this.homeButtonEntity == senderID) { if (_this.clicked) { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); - _this.clicked = false; + Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); + _this.clicked = false; } else { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); - _this.clicked = true; + Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); + _this.clicked = true; } } } diff --git a/scripts/system/tablet-ui/HomeButton.js b/scripts/system/tablet-ui/HomeButton.js new file mode 100644 index 0000000000..e3b4c78329 --- /dev/null +++ b/scripts/system/tablet-ui/HomeButton.js @@ -0,0 +1,32 @@ +// +// HomeButton.js +// +// Created by Dante Ruiz on 12/6/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 +// + +(function(){ + _this = this; + + this.preload = function(entityID) { + print(entityID); + this.entityID = entityID; + } + + this.clickDownOnEntity = function(entityID, mouseEvent) { + Messages.sendLocalMessage("home", _this.entityID); + } + + this.startNearTrigger = function() { + Messages.sendLocalMessage("home", _this.entityID); + } + + + this.startFarTrigger = function() { + Messages.sendLocalMessage("home", _this.entityID); + } + +}); diff --git a/scripts/system/tablet-ui/tabletUI.js b/scripts/system/tablet-ui/tabletUI.js index c49ed54345..19eb7f3726 100644 --- a/scripts/system/tablet-ui/tabletUI.js +++ b/scripts/system/tablet-ui/tabletUI.js @@ -24,7 +24,7 @@ tabletShown = true; print("show tablet-ui"); UIWebTablet = new WebTablet("qml/hifi/tablet/Tablet.qml", null, null, tabletLocation); - UIWebTablet.register(); + UIWebTablet.register(); HMD.tabletID = UIWebTablet.webEntityID; var setUpTabletUI = function() { @@ -49,7 +49,7 @@ } tabletLocation = UIWebTablet.getLocation(); - UIWebTablet.unregister(); + UIWebTablet.unregister(); UIWebTablet.destroy(); UIWebTablet = null; HMD.tabletID = null; From 61e2fb2366835122a270dc4e266ec64755d8f727 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Dec 2016 21:51:01 +0000 Subject: [PATCH 9/9] correct indentation for HomeButton.js --- scripts/system/tablet-ui/HomeButton.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/system/tablet-ui/HomeButton.js b/scripts/system/tablet-ui/HomeButton.js index e3b4c78329..02748020c0 100644 --- a/scripts/system/tablet-ui/HomeButton.js +++ b/scripts/system/tablet-ui/HomeButton.js @@ -12,21 +12,21 @@ _this = this; this.preload = function(entityID) { - print(entityID); - this.entityID = entityID; + print(entityID); + this.entityID = entityID; } this.clickDownOnEntity = function(entityID, mouseEvent) { - Messages.sendLocalMessage("home", _this.entityID); + Messages.sendLocalMessage("home", _this.entityID); } this.startNearTrigger = function() { - Messages.sendLocalMessage("home", _this.entityID); + Messages.sendLocalMessage("home", _this.entityID); } this.startFarTrigger = function() { - Messages.sendLocalMessage("home", _this.entityID); + Messages.sendLocalMessage("home", _this.entityID); } });