overte-HifiExperiments/scripts/system/mute.js
Anthony J. Thibault 1c783031b1 Removed ColorOverlay from TabletButton, added more icon & text states
Now uses separate images for each state. Now tabletButtonProxy has 4 state properties, one for icon and images.

  * icon
  * hoverIcon
  * activeIcon
  * activeHoverIcon

  * text
  * hoverText
  * activeText
  * activeHoverText

Updated scripts to set new button states, if necessary.
2017-02-13 15:09:46 -08:00

65 lines
1.7 KiB
JavaScript

"use strict";
//
// goto.js
// scripts/system/
//
// Created by Howard Stearns on 2 Jun 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() { // BEGIN LOCAL_SCOPE
var button;
var buttonName = "MUTE";
var toolBar = null;
var tablet = null;
function onMuteToggled() {
button.editProperties({isActive: AudioDevice.getMuted()});
}
function onClicked(){
var menuItem = "Mute Microphone";
Menu.setIsOptionChecked(menuItem, !Menu.isOptionChecked(menuItem));
}
if (Settings.getValue("HUDUIEnabled")) {
toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
button = toolBar.addButton({
objectName: buttonName,
imageURL: Script.resolvePath("assets/images/tools/mic.svg"),
visible: true,
alpha: 0.9
});
} else {
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
button = tablet.addButton({
icon: "icons/tablet-icons/mic-unmute-i.svg",
hoverIcon: "icons/tablet-icons/mic-mute-i.svg",
activeIcon: "icons/tablet-icons/mic-mute-a.svg",
activeHoverIcon: "icons/tablet-icons/mic-unmute-a.svg",
text: "MUTE",
activeText: "UNMUTE",
sortOrder: 1
});
}
onMuteToggled();
button.clicked.connect(onClicked);
AudioDevice.muteToggled.connect(onMuteToggled);
Script.scriptEnding.connect(function () {
button.clicked.disconnect(onClicked);
AudioDevice.muteToggled.disconnect(onMuteToggled);
if (tablet) {
tablet.removeButton(button);
}
if (toolBar) {
toolBar.removeButton(buttonName);
}
});
}()); // END LOCAL_SCOPE