From 508a3b37cd87cefe0fa4a8a0e7603ef8576b5403 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 12 Jan 2018 15:28:42 -0800 Subject: [PATCH] fix icon. button lights up when run in enabled --- scripts/system/assets/images/run.svg | 1 + scripts/system/run.js | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 scripts/system/assets/images/run.svg diff --git a/scripts/system/assets/images/run.svg b/scripts/system/assets/images/run.svg new file mode 100644 index 0000000000..0957166346 --- /dev/null +++ b/scripts/system/assets/images/run.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/system/run.js b/scripts/system/run.js index edd6e20021..054cca6d9c 100644 --- a/scripts/system/run.js +++ b/scripts/system/run.js @@ -3,18 +3,24 @@ /* global Script, Tablet, MyAvatar */ (function() { // BEGIN LOCAL_SCOPE + var WALK_SPEED = 2.6; + var RUN_SPEED = 4.5; + var MIDDLE_SPEED = (WALK_SPEED + RUN_SPEED) / 2.0; + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ - icon: Script.resolvePath("assets/images/icon-particles.svg"), - text: "Run", + icon: Script.resolvePath("assets/images/run.svg"), + text: "RUN", sortOrder: 15 }); function onClicked() { - if (MyAvatar.walkSpeed < 4) { - MyAvatar.walkSpeed = 4.5; + if (MyAvatar.walkSpeed < MIDDLE_SPEED) { + button.editProperties({isActive: true}); + MyAvatar.walkSpeed = RUN_SPEED; } else { - MyAvatar.walkSpeed = 2.6; + button.editProperties({isActive: false}); + MyAvatar.walkSpeed = WALK_SPEED; } } @@ -24,4 +30,10 @@ } button.clicked.connect(onClicked); + if (MyAvatar.walkSpeed < MIDDLE_SPEED) { + button.editProperties({isActive: false}); + } else { + button.editProperties({isActive: true}); + } + }());