diff --git a/interface/resources/qml/AvatarInputsBar.qml b/interface/resources/qml/AvatarInputsBar.qml index ead4fbc618..dfff103aa0 100644 --- a/interface/resources/qml/AvatarInputsBar.qml +++ b/interface/resources/qml/AvatarInputsBar.qml @@ -31,56 +31,7 @@ Item { standalone: true; dragTarget: parent; } - Rectangle { - id: bubbleRect - width: bubbleIcon.width + 10 - height: parent.height - radius: 5; - opacity: AvatarInputs.ignoreRadiusEnabled ? 0.7 : 0.3; - - color: "#00000000"; - border { - width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; - color: "#80FFFFFF"; - } - anchors { - left: root.right - top: root.top - } - - MouseArea { - id: mouseArea; - anchors.fill: parent - - hoverEnabled: true; - scrollGestureEnabled: false; - onClicked: { - Tablet.playSound(TabletEnums.ButtonClick); - Users.toggleIgnoreRadius(); - } - drag.target: root; - onContainsMouseChanged: { - if (containsMouse) { - Tablet.playSound(TabletEnums.ButtonHover); - } - } - } - Image { - id: bubbleIcon - source: "../icons/tablet-icons/bubble-i.svg"; - sourceSize: Qt.size(28, 28); - smooth: true; - visible: false - anchors.top: parent.top - anchors.topMargin: (parent.height - bubbleIcon.height) / 2 - anchors.left: parent.left - anchors.leftMargin: (parent.width - bubbleIcon.width) / 2 - } - ColorOverlay { - id: bubbleIconOverlay - anchors.fill: bubbleIcon - source: bubbleIcon - color: "#FFFFFF"; - } + BubbleIcon { + dragTarget: parent } } diff --git a/interface/resources/qml/BubbleIcon.qml b/interface/resources/qml/BubbleIcon.qml new file mode 100644 index 0000000000..f9c57697f0 --- /dev/null +++ b/interface/resources/qml/BubbleIcon.qml @@ -0,0 +1,82 @@ +// +// Created by Bradley Austin Davis on 2015/06/19 +// Copyright 2015 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 +// + +import Hifi 1.0 as Hifi +import QtQuick 2.5 +import QtGraphicalEffects 1.0 + +import "./hifi/audio" as HifiAudio + +import TabletScriptingInterface 1.0 + +Rectangle { + id: bubbleRect + width: bubbleIcon.width + 10 + height: bubbleIcon.height + 10 + radius: 5; + opacity: AvatarInputs.ignoreRadiusEnabled ? 0.7 : 0.3; + property var dragTarget: null; + + color: "#00000000"; + border { + width: mouseArea.containsMouse || mouseArea.containsPress ? 2 : 0; + color: "#80FFFFFF"; + } + anchors { + left: dragTarget ? dragTarget.right : undefined + top: dragTarget ? dragTarget.top : undefined + } + + // borders are painted over fill, so reduce the fill to fit inside the border + Rectangle { + color: "#55000000"; + width: 40; + height: 40; + + radius: 5; + + anchors { + verticalCenter: parent.verticalCenter; + horizontalCenter: parent.horizontalCenter; + } + } + + MouseArea { + id: mouseArea; + anchors.fill: parent + + hoverEnabled: true; + scrollGestureEnabled: false; + onClicked: { + Tablet.playSound(TabletEnums.ButtonClick); + Users.toggleIgnoreRadius(); + } + drag.target: dragTarget; + onContainsMouseChanged: { + if (containsMouse) { + Tablet.playSound(TabletEnums.ButtonHover); + } + } + } + Image { + id: bubbleIcon + source: "../icons/tablet-icons/bubble-i.svg"; + sourceSize: Qt.size(28, 28); + smooth: true; + anchors.top: parent.top + anchors.topMargin: (parent.height - bubbleIcon.height) / 2 + anchors.left: parent.left + anchors.leftMargin: (parent.width - bubbleIcon.width) / 2 + } + ColorOverlay { + id: bubbleIconOverlay + anchors.fill: bubbleIcon + source: bubbleIcon + color: "#FFFFFF"; + } +} diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index 7ed9451a04..fba06ac987 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -19,13 +19,18 @@ Rectangle { HifiConstants { id: hifi; } readonly property var level: AudioScriptingInterface.inputLevel; - + readonly property var clipping: AudioScriptingInterface.clipping; + readonly property var muted: AudioScriptingInterface.muted; + readonly property var pushToTalk: AudioScriptingInterface.pushToTalk; + readonly property var pushingToTalk: AudioScriptingInterface.pushingToTalk; + + readonly property var userSpeakingLevel: 0.4; property bool gated: false; Component.onCompleted: { AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; }); AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; }); } - + property bool standalone: false; property var dragTarget: null; @@ -70,7 +75,7 @@ Rectangle { if (AudioScriptingInterface.pushToTalk) { return; } - AudioScriptingInterface.muted = !AudioScriptingInterface.muted; + muted = !muted; Tablet.playSound(TabletEnums.ButtonClick); } drag.target: dragTarget; @@ -113,9 +118,12 @@ Rectangle { readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; readonly property string pushToTalkIcon: "../../../icons/tablet-icons/mic-ptt-i.svg"; + readonly property string clippingIcon: "../../../icons/tablet-icons/mic-clip-i.svg"; + readonly property string gatedIcon: "../../../icons/tablet-icons/mic-gate-i.svg"; id: image; - source: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? pushToTalkIcon : AudioScriptingInterface.muted ? mutedIcon : unmutedIcon; + source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : + clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; width: 30; height: 30; @@ -138,9 +146,9 @@ Rectangle { Item { id: status; - readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted; + readonly property string color: muted ? colors.muted : colors.unmuted; - visible: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) || (AudioScriptingInterface.muted && (level >= userSpeakingLevel)); + visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; @@ -159,7 +167,7 @@ Rectangle { color: parent.color; - text: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? (HMD.active ? "MUTED PTT" : "MUTED PTT-(T)") : (AudioScriptingInterface.muted ? "MUTED" : "MUTE"); + text: (pushToTalk && !pushingToTalk) ? (HMD.active ? "MUTED PTT" : "MUTED PTT-(T)") : (muted ? "MUTED" : "MUTE"); font.pointSize: 12; } @@ -235,12 +243,12 @@ Rectangle { } } } - + Rectangle { id: gatedIndicator; visible: gated && !AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: "#0080FF"; @@ -249,12 +257,12 @@ Rectangle { verticalCenter: parent.verticalCenter; } } - + Rectangle { id: clippingIndicator; visible: AudioScriptingInterface.clipping - - radius: 4; + + radius: 4; width: 2 * radius; height: 2 * radius; color: colors.red; diff --git a/interface/resources/qml/hifi/audio/MicBarApplication.qml b/interface/resources/qml/hifi/audio/MicBarApplication.qml index 30cef44bce..bfac278ee4 100644 --- a/interface/resources/qml/hifi/audio/MicBarApplication.qml +++ b/interface/resources/qml/hifi/audio/MicBarApplication.qml @@ -1,5 +1,5 @@ // -// MicBar.qml +// MicBarApplication.qml // qml/hifi/audio // // Created by Zach Pomerantz on 6/14/2017 @@ -16,9 +16,12 @@ import stylesUit 1.0 import TabletScriptingInterface 1.0 Rectangle { + id: micBar; readonly property var level: AudioScriptingInterface.inputLevel; readonly property var clipping: AudioScriptingInterface.clipping; readonly property var muted: AudioScriptingInterface.muted; + readonly property var pushToTalk: AudioScriptingInterface.pushToTalk; + readonly property var pushingToTalk: AudioScriptingInterface.pushingToTalk; readonly property var userSpeakingLevel: 0.4; property bool gated: false; Component.onCompleted: { @@ -28,6 +31,7 @@ Rectangle { readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; + readonly property string pushToTalkIcon: "../../../icons/tablet-icons/mic-ptt-i.svg"; readonly property string clippingIcon: "../../../icons/tablet-icons/mic-clip-i.svg"; readonly property string gatedIcon: "../../../icons/tablet-icons/mic-gate-i.svg"; property bool standalone: false; @@ -37,13 +41,16 @@ Rectangle { height: 44; radius: 5; + opacity: 0.7 onLevelChanged: { var rectOpacity = muted && (level >= userSpeakingLevel) ? 0.9 : 0.3; - if (mouseArea.containsMouse && rectOpacity != 0.9) { + if (pushToTalk && !pushingToTalk) { + rectOpacity = (level >= userSpeakingLevel) ? 0.9 : 0.7; + } else if (mouseArea.containsMouse && rectOpacity != 0.9) { rectOpacity = 0.5; } - opacity = rectOpacity; + micBar.opacity = rectOpacity; } color: "#00000000"; @@ -94,15 +101,15 @@ Rectangle { id: colors; readonly property string unmutedColor: "#FFF"; + readonly property string gatedColor: "#00BDFF"; readonly property string mutedColor: "#E2334D"; readonly property string gutter: "#575757"; readonly property string greenStart: "#39A38F"; readonly property string greenEnd: "#1FC6A6"; readonly property string yellow: "#C0C000"; - readonly property string red: colors.muted; readonly property string fill: "#55000000"; readonly property string border: standalone ? "#80FFFFFF" : "#55FFFFFF"; - readonly property string icon: muted ? mutedColor : unmutedColor; + readonly property string icon: (muted || clipping) ? mutedColor : gated ? gatedColor : unmutedColor; } Item { @@ -110,7 +117,7 @@ Rectangle { anchors { left: parent.left; - verticalCenter: parent.verticalCenter; + top: parent.top; } width: 40; @@ -119,8 +126,8 @@ Rectangle { Item { Image { id: image; - source: muted ? mutedIcon : clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; - + source: (pushToTalk && !pushingToTalk) ? pushToTalkIcon : muted ? mutedIcon : + clipping ? clippingIcon : gated ? gatedIcon : unmutedIcon; width: 29; height: 32; anchors { @@ -134,7 +141,8 @@ Rectangle { id: imageOverlay anchors { fill: image } source: image; - color: colors.icon; + color: (pushToTalk && !pushingToTalk) ? ((level >= userSpeakingLevel) ? colors.mutedColor : + colors.unmutedColor) : colors.icon; } } } @@ -142,26 +150,34 @@ Rectangle { Item { id: status; - visible: muted && (level >= userSpeakingLevel); + visible: (pushToTalk && !pushingToTalk) || (muted && (level >= userSpeakingLevel)); anchors { left: parent.left; - top: parent.bottom - topMargin: 5 + top: icon.bottom; + topMargin: 5; } - width: icon.width; - height: 8 + width: parent.width; + height: statusTextMetrics.height; + + TextMetrics { + id: statusTextMetrics + text: statusText.text + font: statusText.font + } RalewaySemiBold { + id: statusText anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; } - color: colors.mutedColor; + color: (level >= userSpeakingLevel && muted) ? colors.mutedColor : colors.unmutedColor; + font.bold: true - text: "MUTED"; + text: (pushToTalk && !pushingToTalk) ? (HMD.active ? "PTT" : "PTT-(T)") : (muted ? "MUTED" : "MUTE"); size: 12; } } @@ -172,7 +188,8 @@ Rectangle { anchors { right: parent.right; rightMargin: 7; - verticalCenter: parent.verticalCenter; + top: parent.top + topMargin: 5 } width: 8; @@ -219,34 +236,5 @@ Rectangle { } } } -/* - Rectangle { - id: gatedIndicator; - visible: gated && !clipping - - radius: 4; - width: 2 * radius; - height: 2 * radius; - color: "#0080FF"; - anchors { - right: parent.left; - verticalCenter: parent.verticalCenter; - } - } - - Rectangle { - id: clippingIndicator; - visible: clipping - - radius: 4; - width: 2 * radius; - height: 2 * radius; - color: colors.red; - anchors { - left: parent.right; - verticalCenter: parent.verticalCenter; - } - } -*/ } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e34ae4bcba..9fd0781eef 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -211,7 +211,6 @@ #include "ui/UpdateDialog.h" #include "ui/DomainConnectionModel.h" #include "ui/Keyboard.h" -#include "ui/PrivacyShield.h" #include "Util.h" #include "InterfaceParentFinder.h" #include "ui/OctreeStatsProvider.h" @@ -339,6 +338,10 @@ Setting::Handle maxOctreePacketsPerSecond{"maxOctreePPS", DEFAULT_MAX_OCTRE Setting::Handle loginDialogPoppedUp{"loginDialogPoppedUp", false}; +static const QUrl AVATAR_INPUTS_BAR_QML = PathUtils::qmlUrl("AvatarInputsBar.qml"); +static const QUrl MIC_BAR_ENTITY_QML = PathUtils::qmlUrl("hifi/audio/MicBarApplication.qml"); +static const QUrl BUBBLE_ICON_QML = PathUtils::qmlUrl("BubbleIcon.qml"); + static const QString STANDARD_TO_ACTION_MAPPING_NAME = "Standard to Action"; static const QString NO_MOVEMENT_MAPPING_NAME = "Standard to Action (No Movement)"; static const QString NO_MOVEMENT_MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/standard_nomovement.json"; @@ -928,7 +931,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); - DependencyManager::set(); return previousSessionCrashed; } @@ -1293,6 +1295,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo setCrashAnnotation("display_plugin", displayPlugin->getName().toStdString()); setCrashAnnotation("hmd", displayPlugin->isHmd() ? "1" : "0"); }); + connect(this, &Application::activeDisplayPluginChanged, this, [&](){ +#if !defined(Q_OS_ANDROID) + if (!getLoginDialogPoppedUp() && _desktopRootItemCreated) { + if (isHMDMode()) { + createAvatarInputsBar(); + auto offscreenUi = getOffscreenUI(); + offscreenUi->hide(AVATAR_INPUTS_BAR_QML.toString()); + } else { + destroyAvatarInputsBar(); + auto offscreenUi = getOffscreenUI(); + offscreenUi->show(AVATAR_INPUTS_BAR_QML.toString(), "AvatarInputsBar"); + } + } +#endif + }); connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode); connect(this, &Application::activeDisplayPluginChanged, this, [&](){ if (getLoginDialogPoppedUp()) { @@ -2378,7 +2395,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo }); }); auto rootItemLoadedFunctor = [webSurface, url, isTablet] { - Application::setupQmlSurface(webSurface->getSurfaceContext(), isTablet || url == LOGIN_DIALOG.toString()); + Application::setupQmlSurface(webSurface->getSurfaceContext(), isTablet || url == LOGIN_DIALOG.toString() || url == AVATAR_INPUTS_BAR_QML.toString() || + url == BUBBLE_ICON_QML.toString() || url == MIC_BAR_ENTITY_QML.toString() ); }; if (webSurface->getRootItem()) { rootItemLoadedFunctor(); @@ -2652,9 +2670,6 @@ void Application::cleanupBeforeQuit() { nodeList->getPacketReceiver().setShouldDropPackets(true); } - // destroy privacy shield before entity shutdown. - DependencyManager::get()->destroyPrivacyShield(); - getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) @@ -2733,7 +2748,6 @@ void Application::cleanupBeforeQuit() { DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); - DependencyManager::destroy(); DependencyManager::destroy(); qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete"; @@ -3301,6 +3315,7 @@ void Application::onDesktopRootItemCreated(QQuickItem* rootItem) { auto qml = PathUtils::qmlUrl("AvatarInputsBar.qml"); offscreenUi->show(qml, "AvatarInputsBar"); #endif + _desktopRootItemCreated = true; } void Application::userKickConfirmation(const QUuid& nodeID) { @@ -5534,8 +5549,6 @@ void Application::resumeAfterLoginDialogActionTaken() { menu->getMenu("Developer")->setVisible(_developerMenuVisible); _myCamera.setMode(_previousCameraMode); cameraModeChanged(); - - DependencyManager::get()->createPrivacyShield(); } void Application::loadAvatarScripts(const QVector& urls) { @@ -6494,8 +6507,6 @@ void Application::update(float deltaTime) { updateLoginDialogPosition(); } - DependencyManager::get()->update(deltaTime); - { PROFILE_RANGE_EX(app, "Overlays", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PerformanceTimer perfTimer("overlays"); @@ -8986,6 +8997,38 @@ void Application::updateLoginDialogPosition() { } } +void Application::createAvatarInputsBar() { + const glm::vec3 LOCAL_POSITION { 0.0, 0.0, -1.0 }; + // DEFAULT_DPI / tablet scale percentage + const float DPI = 31.0f / (75.0f / 100.0f); + + EntityItemProperties properties; + properties.setType(EntityTypes::Web); + properties.setName("AvatarInputsBarEntity"); + properties.setSourceUrl(AVATAR_INPUTS_BAR_QML.toString()); + properties.setParentID(getMyAvatar()->getSelfID()); + properties.setParentJointIndex(getMyAvatar()->getJointIndex("_CAMERA_MATRIX")); + properties.setPosition(LOCAL_POSITION); + properties.setLocalRotation(Quaternions::IDENTITY); + //properties.setDimensions(LOGIN_DIMENSIONS); + properties.setPrimitiveMode(PrimitiveMode::SOLID); + properties.getGrab().setGrabbable(false); + properties.setIgnorePickIntersection(false); + properties.setAlpha(1.0f); + properties.setDPI(DPI); + properties.setVisible(true); + + auto entityScriptingInterface = DependencyManager::get(); + _avatarInputsBarID = entityScriptingInterface->addEntityInternal(properties, entity::HostType::LOCAL); +} + +void Application::destroyAvatarInputsBar() { + auto entityScriptingInterface = DependencyManager::get(); + if (!_avatarInputsBarID.isNull()) { + entityScriptingInterface->deleteEntity(_avatarInputsBarID); + } +} + bool Application::hasRiftControllers() { return PluginUtils::isOculusTouchControllerAvailable(); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 762ac9585a..99e57f1866 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -330,6 +330,9 @@ public: void createLoginDialog(); void updateLoginDialogPosition(); + void createAvatarInputsBar(); + void destroyAvatarInputsBar(); + // Check if a headset is connected bool hasRiftControllers(); bool hasViveControllers(); @@ -704,12 +707,14 @@ private: int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS; bool _interstitialModeEnabled{ false }; - bool _loginDialogPoppedUp = false; + bool _loginDialogPoppedUp{ false }; + bool _desktopRootItemCreated{ false }; bool _developerMenuVisible{ false }; QString _previousAvatarSkeletonModel; float _previousAvatarTargetScale; CameraMode _previousCameraMode; QUuid _loginDialogID; + QUuid _avatarInputsBarID; LoginStateManager _loginStateManager; quint64 _lastFaceTrackerUpdate; diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index bf43db3044..434688e474 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -224,10 +224,10 @@ void Audio::saveData() { } void Audio::loadData() { - _desktopMuted = _desktopMutedSetting.get(); - _hmdMuted = _hmdMutedSetting.get(); - _pttDesktop = _pttDesktopSetting.get(); - _pttHMD = _pttHMDSetting.get(); + setMutedDesktop(_desktopMutedSetting.get()); + setMutedHMD(_hmdMutedSetting.get()); + setPTTDesktop(_pttDesktopSetting.get()); + setPTTHMD(_pttHMDSetting.get()); } bool Audio::getPTTHMD() const { diff --git a/interface/src/ui/PrivacyShield.cpp b/interface/src/ui/PrivacyShield.cpp deleted file mode 100644 index 279c05ee2d..0000000000 --- a/interface/src/ui/PrivacyShield.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// -// PrivacyShield.cpp -// interface/src/ui -// -// Created by Wayne Chen on 2/27/19. -// Copyright 2019 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 -// - -#include "PrivacyShield.h" - -#include -#include -#include -#include -#include -#include - -#include "Application.h" -#include "PathUtils.h" -#include "GLMHelpers.h" - -const int PRIVACY_SHIELD_VISIBLE_DURATION_MS = 3000; -const int PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS = 750; -const int PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS = 15000; -const float PRIVACY_SHIELD_HEIGHT_SCALE = 0.15f; - -PrivacyShield::PrivacyShield() { - auto usersScriptingInterface = DependencyManager::get(); - //connect(usersScriptingInterface.data(), &UsersScriptingInterface::ignoreRadiusEnabledChanged, [this](bool enabled) { - // onPrivacyShieldToggled(enabled); - //}); - //connect(usersScriptingInterface.data(), &UsersScriptingInterface::enteredIgnoreRadius, this, &PrivacyShield::enteredIgnoreRadius); -} - -void PrivacyShield::createPrivacyShield() { - // Affects bubble height - //auto myAvatar = DependencyManager::get()->getMyAvatar(); - //auto avatarScale = myAvatar->getTargetScale(); - //auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - //auto avatarWorldPosition = myAvatar->getWorldPosition(); - //auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - //EntityItemProperties properties; - //properties.setName("Privacy-Shield"); - //properties.setModelURL(PathUtils::resourcesUrl("assets/models/Bubble-v14.fbx").toString()); - //properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - //properties.setPosition(glm::vec3(avatarWorldPosition.x, - // -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - //properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); - //properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - //properties.setVisible(false); - - //_localPrivacyShieldID = DependencyManager::get()->addEntityInternal(properties, entity::HostType::LOCAL); - //_bubbleActivateSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl() + "assets/sounds/bubble.wav"); - - //onPrivacyShieldToggled(DependencyManager::get()->getIgnoreRadiusEnabled(), true); -} - -void PrivacyShield::destroyPrivacyShield() { - DependencyManager::get()->deleteEntity(_localPrivacyShieldID); -} - -void PrivacyShield::update(float deltaTime) { - //if (_updateConnected) { - // auto now = usecTimestampNow(); - // auto delay = (now - _privacyShieldTimestamp); - // auto privacyShieldAlpha = 1.0 - (delay / PRIVACY_SHIELD_VISIBLE_DURATION_MS); - // if (privacyShieldAlpha > 0) { - // auto myAvatar = DependencyManager::get()->getMyAvatar(); - // auto avatarScale = myAvatar->getTargetScale(); - // auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - // auto avatarWorldPosition = myAvatar->getWorldPosition(); - // auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - // EntityItemProperties properties; - // properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - // properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); - // if (delay < PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS) { - // properties.setPosition(glm::vec3(avatarWorldPosition.x, - // (-((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * avatarScale * 2.0 + - // avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - // properties.setModelScale(glm::vec3(2.0, - // ((1 - ((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * - // (0.5 * (avatarScale + 1.0))), 2.0)); - // } else { - // properties.setPosition(glm::vec3(avatarWorldPosition.x, avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - // properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - // } - // DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); - // } - // else { - // hidePrivacyShield(); - // if (_updateConnected) { - // _updateConnected = false; - // } - // } - //} -} - -void PrivacyShield::enteredIgnoreRadius() { - showPrivacyShield(); - DependencyManager::get()->privacyShieldActivated(); -} - -void PrivacyShield::onPrivacyShieldToggled(bool enabled, bool doNotLog) { - if (!doNotLog) { - DependencyManager::get()->privacyShieldToggled(enabled); - } - if (enabled) { - showPrivacyShield(); - } else { - hidePrivacyShield(); - if (_updateConnected) { - _updateConnected = false; - } - } -} - -void PrivacyShield::showPrivacyShield() { - auto now = usecTimestampNow(); - auto myAvatar = DependencyManager::get()->getMyAvatar(); - auto avatarScale = myAvatar->getTargetScale(); - auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); - auto avatarWorldPosition = myAvatar->getWorldPosition(); - auto avatarWorldOrientation = myAvatar->getWorldOrientation(); - if (now - _lastPrivacyShieldSoundTimestamp >= PRIVACY_SHIELD_SOUND_RATE_LIMIT_MS) { - AudioInjectorOptions options; - options.position = avatarWorldPosition; - options.localOnly = true; - options.volume = 0.2f; - AudioInjector::playSoundAndDelete(_bubbleActivateSound, options); - _lastPrivacyShieldSoundTimestamp = now; - } - hidePrivacyShield(); - if (_updateConnected) { - _updateConnected = false; - } - - EntityItemProperties properties; - properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); - properties.setPosition(glm::vec3(avatarWorldPosition.x, - -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); - properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); - properties.setVisible(true); - - DependencyManager::get()->editEntity(_localPrivacyShieldID, properties); - - _privacyShieldTimestamp = now; - _updateConnected = true; -} - -void PrivacyShield::hidePrivacyShield() { - EntityTreePointer entityTree = qApp->getEntities()->getTree(); - EntityItemPointer privacyShieldEntity = entityTree->findEntityByEntityItemID(EntityItemID(_localPrivacyShieldID)); - if (privacyShieldEntity) { - privacyShieldEntity->setVisible(false); - } -} diff --git a/interface/src/ui/PrivacyShield.h b/interface/src/ui/PrivacyShield.h deleted file mode 100644 index 5aecb661f7..0000000000 --- a/interface/src/ui/PrivacyShield.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// PrivacyShield.h -// interface/src/ui -// -// Created by Wayne Chen on 2/27/19. -// Copyright 2019 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 -// - -#pragma once - -#include -#include -#include - -#include -#include - -class PrivacyShield : public QObject, public Dependency { - Q_OBJECT - SINGLETON_DEPENDENCY - -public: - PrivacyShield(); - void createPrivacyShield(); - void destroyPrivacyShield(); - - bool isVisible() const { return _visible; } - void update(float deltaTime); - -protected slots: - void enteredIgnoreRadius(); - void onPrivacyShieldToggled(bool enabled, bool doNotLog = false); - -private: - void showPrivacyShield(); - void hidePrivacyShield(); - - SharedSoundPointer _bubbleActivateSound; - QUuid _localPrivacyShieldID; - quint64 _privacyShieldTimestamp; - quint64 _lastPrivacyShieldSoundTimestamp; - bool _visible { false }; - bool _updateConnected { false }; -}; diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index e392680df9..bd7e79dffc 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -32,8 +32,7 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/firstPersonHMD.js", "system/tablet-ui/tabletUI.js", "system/emote.js", - "system/miniTablet.js", - "system/audioMuteOverlay.js" + "system/miniTablet.js" ]; var DEFAULT_SCRIPTS_SEPARATE = [ "system/controllers/controllerScripts.js",