allowing bubble icon to toggle

This commit is contained in:
Wayne Chen 2019-03-01 09:12:03 -08:00 committed by Wayne Chen
parent d382893e75
commit 811fa8dcb2
2 changed files with 51 additions and 53 deletions

View file

@ -36,7 +36,7 @@ Item {
width: bubbleIcon.width + 10 width: bubbleIcon.width + 10
height: parent.height height: parent.height
radius: 5; radius: 5;
opacity: 0.5; opacity: AvatarInputs.ignoreRadiusEnabled ? 0.7 : 0.3;
color: "#00000000"; color: "#00000000";
border { border {
@ -56,14 +56,12 @@ Item {
scrollGestureEnabled: false; scrollGestureEnabled: false;
onClicked: { onClicked: {
Tablet.playSound(TabletEnums.ButtonClick); Tablet.playSound(TabletEnums.ButtonClick);
Users.toggleIgnoreRadius();
} }
drag.target: root; drag.target: root;
onContainsMouseChanged: { onContainsMouseChanged: {
if (containsMouse) { if (containsMouse) {
Tablet.playSound(TabletEnums.ButtonHover); Tablet.playSound(TabletEnums.ButtonHover);
bubbleRect.opacity = 0.7;
} else {
bubbleRect.opacity = 0.5;
} }
} }
} }
@ -82,7 +80,7 @@ Item {
id: bubbleIconOverlay id: bubbleIconOverlay
anchors.fill: bubbleIcon anchors.fill: bubbleIcon
source: bubbleIcon source: bubbleIcon
color: AvatarInputs.ignoreRadiusEnabled ? "#1FC6A6" : "#FFFFFF"; color: "#FFFFFF";
} }
} }
} }

View file

@ -37,22 +37,22 @@ PrivacyShield::PrivacyShield() {
void PrivacyShield::createPrivacyShield() { void PrivacyShield::createPrivacyShield() {
// Affects bubble height // Affects bubble height
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
auto avatarScale = myAvatar->getTargetScale(); //auto avatarScale = myAvatar->getTargetScale();
auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); //auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale();
auto avatarWorldPosition = myAvatar->getWorldPosition(); //auto avatarWorldPosition = myAvatar->getWorldPosition();
auto avatarWorldOrientation = myAvatar->getWorldOrientation(); //auto avatarWorldOrientation = myAvatar->getWorldOrientation();
EntityItemProperties properties; //EntityItemProperties properties;
properties.setName("Privacy-Shield"); //properties.setName("Privacy-Shield");
properties.setModelURL(PathUtils::resourcesUrl("assets/models/Bubble-v14.fbx").toString()); //properties.setModelURL(PathUtils::resourcesUrl("assets/models/Bubble-v14.fbx").toString());
properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); //properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale));
properties.setPosition(glm::vec3(avatarWorldPosition.x, //properties.setPosition(glm::vec3(avatarWorldPosition.x,
-avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); // -avatarScale * 2 + avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z));
properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); //properties.setRotation(avatarWorldOrientation * Quaternions::Y_180);
properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0)); //properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0));
properties.setVisible(false); //properties.setVisible(false);
_localPrivacyShieldID = DependencyManager::get<EntityScriptingInterface>()->addEntityInternal(properties, entity::HostType::LOCAL); //_localPrivacyShieldID = DependencyManager::get<EntityScriptingInterface>()->addEntityInternal(properties, entity::HostType::LOCAL);
//_bubbleActivateSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl() + "assets/sounds/bubble.wav"); //_bubbleActivateSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl() + "assets/sounds/bubble.wav");
//onPrivacyShieldToggled(DependencyManager::get<UsersScriptingInterface>()->getIgnoreRadiusEnabled(), true); //onPrivacyShieldToggled(DependencyManager::get<UsersScriptingInterface>()->getIgnoreRadiusEnabled(), true);
@ -63,39 +63,39 @@ void PrivacyShield::destroyPrivacyShield() {
} }
void PrivacyShield::update(float deltaTime) { void PrivacyShield::update(float deltaTime) {
if (_updateConnected) { //if (_updateConnected) {
auto now = usecTimestampNow(); // auto now = usecTimestampNow();
auto delay = (now - _privacyShieldTimestamp); // auto delay = (now - _privacyShieldTimestamp);
auto privacyShieldAlpha = 1.0 - (delay / PRIVACY_SHIELD_VISIBLE_DURATION_MS); // auto privacyShieldAlpha = 1.0 - (delay / PRIVACY_SHIELD_VISIBLE_DURATION_MS);
if (privacyShieldAlpha > 0) { // if (privacyShieldAlpha > 0) {
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); // auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
auto avatarScale = myAvatar->getTargetScale(); // auto avatarScale = myAvatar->getTargetScale();
auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale(); // auto avatarSensorToWorldScale = myAvatar->getSensorToWorldScale();
auto avatarWorldPosition = myAvatar->getWorldPosition(); // auto avatarWorldPosition = myAvatar->getWorldPosition();
auto avatarWorldOrientation = myAvatar->getWorldOrientation(); // auto avatarWorldOrientation = myAvatar->getWorldOrientation();
EntityItemProperties properties; // EntityItemProperties properties;
properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale)); // properties.setDimensions(glm::vec3(avatarSensorToWorldScale, 0.75 * avatarSensorToWorldScale, avatarSensorToWorldScale));
properties.setRotation(avatarWorldOrientation * Quaternions::Y_180); // properties.setRotation(avatarWorldOrientation * Quaternions::Y_180);
if (delay < PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS) { // if (delay < PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS) {
properties.setPosition(glm::vec3(avatarWorldPosition.x, // properties.setPosition(glm::vec3(avatarWorldPosition.x,
(-((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * avatarScale * 2.0 + // (-((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)); // avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z));
properties.setModelScale(glm::vec3(2.0, // properties.setModelScale(glm::vec3(2.0,
((1 - ((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) * // ((1 - ((PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS - delay) / PRIVACY_SHIELD_RAISE_ANIMATION_DURATION_MS)) *
(0.5 * (avatarScale + 1.0))), 2.0)); // (0.5 * (avatarScale + 1.0))), 2.0));
} else { // } else {
properties.setPosition(glm::vec3(avatarWorldPosition.x, avatarWorldPosition.y + avatarScale * PRIVACY_SHIELD_HEIGHT_SCALE, avatarWorldPosition.z)); // 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)); // properties.setModelScale(glm::vec3(2.0, 0.5 * (avatarScale + 1.0), 2.0));
} // }
DependencyManager::get<EntityScriptingInterface>()->editEntity(_localPrivacyShieldID, properties); // DependencyManager::get<EntityScriptingInterface>()->editEntity(_localPrivacyShieldID, properties);
} // }
else { // else {
hidePrivacyShield(); // hidePrivacyShield();
if (_updateConnected) { // if (_updateConnected) {
_updateConnected = false; // _updateConnected = false;
} // }
} // }
} //}
} }
void PrivacyShield::enteredIgnoreRadius() { void PrivacyShield::enteredIgnoreRadius() {