From 0cf71bd3e13e70ee8c9dda6ca9557e8115cf1338 Mon Sep 17 00:00:00 2001 From: SilverfishVR <53531160+SilverfishVR@users.noreply.github.com> Date: Wed, 18 Aug 2021 22:19:10 +0200 Subject: [PATCH 1/3] make HUD bubble/shield button optional Adds an menu item in "Settings" to toggle the HUD shield/bubble button on or off. Shield button remains available in the tablet or toolbar, it is called "HUD shield button" but suggestions are welcome fixes https://github.com/vircadia/vircadia/issues/1210 --- scripts/system/bubble.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/system/bubble.js b/scripts/system/bubble.js index eca3b3dcd4..0c019f4e4b 100644 --- a/scripts/system/bubble.js +++ b/scripts/system/bubble.js @@ -46,6 +46,27 @@ }); } + //create a menu item in "Setings" to toggle the bubble/shield HUD button + var menuItemName = "HUD shield button"; + Menu.addMenuItem({ + menuName: "Settings", + menuItemName: menuItemName, + isCheckable: true, + isChecked: AvatarInputs.showBubbleTools + }); + Menu.menuItemEvent.connect(onToggleHudShieldButton); + AvatarInputs.showBubbleToolsChanged.connect(showBubbleToolsChanged); + + function onToggleHudShieldButton(menuItem) { + if (menuItem == menuItemName) { + AvatarInputs.setShowBubbleTools(Menu.isOptionChecked(menuItem)) + }; + } + + function showBubbleToolsChanged(show) { + Menu.setIsOptionChecked(menuItemName, show); + } + // Make the bubble overlay visible, set its position, and play the sound function createOverlays() { var nowTimestamp = Date.now(); @@ -191,6 +212,9 @@ // Cleanup the tablet button and overlays when script is stopped Script.scriptEnding.connect(function () { + Menu.menuItemEvent.disconnect(onToggleHudShieldButton); + AvatarInputs.showBubbleToolsChanged.disconnect(showBubbleToolsChanged); + Menu.removeMenuItem("Settings", menuItemName); button.clicked.disconnect(Users.toggleIgnoreRadius); if (tablet) { tablet.removeButton(button); From a7dee4bb8ab936fb8651da2bbf36bfd7c9c30e6a Mon Sep 17 00:00:00 2001 From: SilverfishVR <53531160+SilverfishVR@users.noreply.github.com> Date: Sat, 21 Aug 2021 17:54:10 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: David Rowe --- scripts/system/bubble.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/bubble.js b/scripts/system/bubble.js index 0c019f4e4b..260bbaa4bf 100644 --- a/scripts/system/bubble.js +++ b/scripts/system/bubble.js @@ -58,8 +58,8 @@ AvatarInputs.showBubbleToolsChanged.connect(showBubbleToolsChanged); function onToggleHudShieldButton(menuItem) { - if (menuItem == menuItemName) { - AvatarInputs.setShowBubbleTools(Menu.isOptionChecked(menuItem)) + if (menuItem === menuItemName) { + AvatarInputs.setShowBubbleTools(Menu.isOptionChecked(menuItem)); }; } From 4d21cedf9ddc5717237284ed23951a53036f1231 Mon Sep 17 00:00:00 2001 From: SilverfishVR <53531160+SilverfishVR@users.noreply.github.com> Date: Sun, 22 Aug 2021 10:04:37 +0200 Subject: [PATCH 3/3] Update menu item name Co-authored-by: Kalila <69767640+digisomni@users.noreply.github.com> --- scripts/system/bubble.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/bubble.js b/scripts/system/bubble.js index 260bbaa4bf..88dee88d62 100644 --- a/scripts/system/bubble.js +++ b/scripts/system/bubble.js @@ -47,7 +47,7 @@ } //create a menu item in "Setings" to toggle the bubble/shield HUD button - var menuItemName = "HUD shield button"; + var menuItemName = "HUD Shield Button"; Menu.addMenuItem({ menuName: "Settings", menuItemName: menuItemName,