From a15aef34dfc050faffcde02e7da9eeb39363ff8d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 27 Jul 2016 13:30:33 -0700 Subject: [PATCH] modify ignore script to handle kicking --- .../system/assets/images/ignore-target-01.svg | 37 ----- .../system/assets/images/ignore-target.svg | 52 +++++++ scripts/system/assets/images/kick-target.svg | 34 +++++ scripts/system/assets/images/tools/kick.svg | 140 ++++++++++++++++++ scripts/system/ignore.js | 23 ++- 5 files changed, 246 insertions(+), 40 deletions(-) delete mode 100644 scripts/system/assets/images/ignore-target-01.svg create mode 100644 scripts/system/assets/images/ignore-target.svg create mode 100644 scripts/system/assets/images/kick-target.svg create mode 100644 scripts/system/assets/images/tools/kick.svg diff --git a/scripts/system/assets/images/ignore-target-01.svg b/scripts/system/assets/images/ignore-target-01.svg deleted file mode 100644 index 98cee89ca1..0000000000 --- a/scripts/system/assets/images/ignore-target-01.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/scripts/system/assets/images/ignore-target.svg b/scripts/system/assets/images/ignore-target.svg new file mode 100644 index 0000000000..ca6aca3a5a --- /dev/null +++ b/scripts/system/assets/images/ignore-target.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/kick-target.svg b/scripts/system/assets/images/kick-target.svg new file mode 100644 index 0000000000..e1ff64d272 --- /dev/null +++ b/scripts/system/assets/images/kick-target.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/kick.svg b/scripts/system/assets/images/tools/kick.svg new file mode 100644 index 0000000000..1eed6e7f43 --- /dev/null +++ b/scripts/system/assets/images/tools/kick.svg @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/ignore.js b/scripts/system/ignore.js index 1c996a7fcc..fac20eb02f 100644 --- a/scripts/system/ignore.js +++ b/scripts/system/ignore.js @@ -12,10 +12,14 @@ // grab the toolbar var toolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); +function buttonImageURL() { + return Script.resolvePath("assets/images/tools/" + (Users.canKick ? 'kick.svg' : 'ignore.svg')); +} + // setup the ignore button and add it to the toolbar var button = toolbar.addButton({ objectName: 'ignore', - imageURL: Script.resolvePath("assets/images/tools/ignore.svg"), + imageURL: buttonImageURL(), visible: true, buttonState: 1, defaultState: 2, @@ -23,6 +27,11 @@ var button = toolbar.addButton({ alpha: 0.9 }); +// if this user's kick permissions change, change the state of the button in the HUD +Users.canKickChanged.connect(function(canKick){ + button.writeProperty('imageURL', buttonImageURL()); +}); + var isShowingOverlays = false; var ignoreOverlays = {}; @@ -54,6 +63,10 @@ function buttonClicked(){ button.clicked.connect(buttonClicked); +function overlayURL() { + return Script.resolvePath("assets/images/" + (Users.canKick ? "kick-target.svg" : "ignore-target.svg")); +} + function updateOverlays() { if (isShowingOverlays) { @@ -88,7 +101,7 @@ function updateOverlays() { } else { // add the overlay above this avatar var newOverlay = Overlays.addOverlay("image3d", { - url: Script.resolvePath("assets/images/ignore-target-01.svg"), + url: overlayURL(), position: overlayPosition, size: 0.4, scale: 0.4, @@ -130,7 +143,11 @@ function handleSelectedOverlay(clickedOverlay) { if (clickedOverlay.overlayID == ignoreOverlay) { // matched to an overlay, ask for the matching avatar to be ignored - Users.ignore(avatarID); + if (Users.canKick) { + Users.kick(avatarID); + } else { + Users.ignore(avatarID); + } // cleanup of the overlay is handled by the connection to avatarRemovedEvent }