overte/scripts/system/notifications.js

436 lines
19 KiB
JavaScript
Raw Permalink Normal View History

2016-08-23 12:34:32 -07:00
"use strict";
//
// notifications.js
//
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
// Created by Adrian McCarlie on October 8th, 2014
// Copyright 2014 High Fidelity, Inc.
// Copyright 2022-2024 Overte e.V.
//
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
// Display notifications to the user for some specific events.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
2023-02-26 22:12:47 +01:00
// SPDX-License-Identifier: Apache-2.0
//
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
(function () {
Script.include([
"create/audioFeedback/audioFeedback.js"
]);
2023-02-26 22:12:47 +01:00
var controllerStandard = Controller.Standard;
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
var NOTIFICATIONS_MESSAGE_CHANNEL = "Hifi-Notifications";
var SETTING_ACTIVATION_SNAPSHOT_NOTIFICATIONS = "snapshotNotifications";
var NOTIFICATION_LIFE_DURATION = 10000; //10 seconds (in millisecond) before expiration.
var FADE_OUT_DURATION = 1000; //1 seconds (in millisecond) to fade out.
var NOTIFICATION_ALPHA = 0.9; // a value between: 0.0 (transparent) and 1.0 (fully opaque).
var MAX_LINE_LENGTH = 42;
var notifications = [];
var newEventDetected = false;
var isOnHMD = HMD.active;
2017-04-26 08:20:12 -07:00
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
var textColor = { "red": 228, "green": 228, "blue": 228};
var backColor = { "red": 2, "green": 2, "blue": 2};
2017-04-26 08:20:12 -07:00
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
//DESKTOP OVERLAY PROPERTIES
var overlayWidth = 340.0; //width in pixel of notification overlay in desktop
var overlayLocationX = (Window.innerWidth - (overlayWidth + 20.0)); // positions window 20px from the right of the interface window
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
var overlayLocationY = 20.0; // position down from top of interface window
var overlayTopMargin = 13.0;
var overlayLeftMargin = 10.0;
var overlayFontSize = 12.0;
var TEXT_OVERLAY_FONT_SIZE_IN_PIXELS = 18.0; // taken from TextOverlay::textSize
var DESKTOP_INTER_SPACE_NOTIFICATION = 5; //5 px
//HMD NOTIFICATION PANEL PROPERTIES
var HMD_UI_SCALE_FACTOR = 1.0; //This define the size of all the notification system in HMD.
2024-02-24 13:49:44 -05:00
var hmdPanelLocalPosition = {"x": 0.3, "y": 0.25, "z": -1.5};
var hmdPanelLocalRotation = Quat.fromVec3Degrees({"x": 0, "y": -3, "z": 0});
2024-10-19 19:06:16 +02:00
var mainHMDnotificationContainerID = Uuid.NONE;
var CAMERA_MATRIX_INDEX = -7;
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
//HMD LOCAL ENTITY PROPERTIES
var entityWidth = 0.8; //in meter
var HMD_LINE_HEIGHT = 0.03;
var entityTopMargin = 0.02;
var entityLeftMargin = 0.02;
var HMD_INTER_SPACE_NOTIFICATION = 0.05;
//ACTIONS
// handles clicks on notifications overlays to delete notifications. (DESKTOP only)
function mousePressEvent(event) {
if (!isOnHMD) {
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
for (var i = 0; i < notifications.length; i += 1) {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
if (clickedOverlay === notifications[i].overlayID || clickedOverlay === notifications[i].imageOverlayID) {
deleteSpecificNotification(i);
notifications.splice(i, 1);
newEventDetected = true;
2017-04-26 08:20:12 -07:00
}
2016-11-17 09:51:45 -08:00
}
}
2017-04-26 08:20:12 -07:00
}
function checkHands() {
var myLeftHand = Controller.getPoseValue(controllerStandard.LeftHand);
var myRightHand = Controller.getPoseValue(controllerStandard.RightHand);
var eyesPosition = MyAvatar.getEyePosition();
var hipsPosition = MyAvatar.getJointPosition("Hips");
var eyesRelativeHeight = eyesPosition.y - hipsPosition.y;
if (myLeftHand.translation.y > eyesRelativeHeight || myRightHand.translation.y > eyesRelativeHeight) {
audioFeedback.action();
deleteAllExistingNotificationsDisplayed();
notifications = [];
}
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
//DISPLAY
function renderNotifications(remainingTime) {
overlayLocationX = (Window.innerWidth - (overlayWidth + 20.0));
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
var alpha = NOTIFICATION_ALPHA;
if (remainingTime < FADE_OUT_DURATION) {
alpha = NOTIFICATION_ALPHA * (remainingTime/FADE_OUT_DURATION);
}
2023-02-20 18:14:00 +01:00
var properties, count, extraLine, breaks, height;
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
var breakPoint = MAX_LINE_LENGTH + 1;
var level = overlayLocationY;
var entityLevel = 0;
if (notifications.length > 0) {
for (var i = 0; i < notifications.length; i++) {
count = (notifications[i].dataText.match(/\n/g) || []).length,
extraLine = 0;
breaks = 0;
if (notifications[i].dataText.length >= breakPoint) {
breaks = count;
}
if (isOnHMD) {
//use HMD local entities
var sensorScaleFactor = MyAvatar.sensorToWorldScale * HMD_UI_SCALE_FACTOR;
var lineHeight = HMD_LINE_HEIGHT;
height = lineHeight + (2 * entityTopMargin);
extraLine = breaks * lineHeight;
height = (height + extraLine) * HMD_UI_SCALE_FACTOR;
entityLevel = entityLevel - (height/2);
properties = {
"type": "Text",
"parentID": mainHMDnotificationContainerID,
"localPosition": {"x": 0, "y": entityLevel, "z": 0},
"dimensions": {"x": (entityWidth * HMD_UI_SCALE_FACTOR), "y": height, "z": 0.01},
"isVisibleInSecondaryCamera": false,
"lineHeight": lineHeight * sensorScaleFactor,
"textColor": textColor,
"textAlpha": alpha,
"backgroundColor": backColor,
"backgroundAlpha": alpha,
"leftMargin": entityLeftMargin * sensorScaleFactor,
"topMargin": entityTopMargin * sensorScaleFactor,
"unlit": true,
"renderLayer": "hud"
};
2024-10-19 19:06:16 +02:00
if (notifications[i].entityID === Uuid.NONE){
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
properties.text = notifications[i].dataText;
notifications[i].entityID = Entities.addEntity(properties, "local");
} else {
Entities.editEntity(notifications[i].entityID, properties);
}
if (notifications[i].dataImage !== null) {
entityLevel = entityLevel - (height/2);
height = (entityWidth / notifications[i].dataImage.aspectRatio) * HMD_UI_SCALE_FACTOR;
entityLevel = entityLevel - (height/2);
properties = {
"type": "Image",
"parentID": mainHMDnotificationContainerID,
"localPosition": {"x": 0, "y": entityLevel, "z": 0},
"dimensions": {"x": (entityWidth * HMD_UI_SCALE_FACTOR), "y": height, "z": 0.01},
"isVisibleInSecondaryCamera": false,
"emissive": true,
"visible": true,
"alpha": alpha,
"renderLayer": "hud"
};
2024-10-19 19:06:16 +02:00
if (notifications[i].imageEntityID === Uuid.NONE){
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
properties.imageURL = notifications[i].dataImage.path;
notifications[i].imageEntityID = Entities.addEntity(properties, "local");
} else {
Entities.editEntity(notifications[i].imageEntityID, properties);
}
}
entityLevel = entityLevel - (height/2) - (HMD_INTER_SPACE_NOTIFICATION * HMD_UI_SCALE_FACTOR);
} else {
//use Desktop overlays
height = 40.0;
extraLine = breaks * TEXT_OVERLAY_FONT_SIZE_IN_PIXELS;
height = height + extraLine;
properties = {
"x": overlayLocationX,
"y": level,
"width": overlayWidth,
"height": height,
"color": textColor,
"backgroundColor": backColor,
"alpha": alpha,
"topMargin": overlayTopMargin,
"leftMargin": overlayLeftMargin,
"font": {"size": overlayFontSize}
};
2024-10-19 19:06:16 +02:00
if (notifications[i].overlayID === Uuid.NONE){
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
properties.text = notifications[i].dataText;
notifications[i].overlayID = Overlays.addOverlay("text", properties);
} else {
Overlays.editOverlay(notifications[i].overlayID, properties);
}
if (notifications[i].dataImage !== null) {
level = level + height;
height = overlayWidth / notifications[i].dataImage.aspectRatio;
properties = {
"x": overlayLocationX,
"y": level,
"width": overlayWidth,
"height": height,
"subImage": { "x": 0, "y": 0 },
"visible": true,
"alpha": alpha
};
2024-10-19 19:06:16 +02:00
if (notifications[i].imageOverlayID === Uuid.NONE){
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
properties.imageURL = notifications[i].dataImage.path;
notifications[i].imageOverlayID = Overlays.addOverlay("image", properties);
} else {
Overlays.editOverlay(notifications[i].imageOverlayID, properties);
}
}
level = level + height + DESKTOP_INTER_SPACE_NOTIFICATION;
2017-04-26 08:20:12 -07:00
}
}
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
}
2017-04-26 08:20:12 -07:00
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
function deleteAllExistingNotificationsDisplayed() {
if (notifications.length > 0) {
for (var i = 0; i < notifications.length; i++) {
deleteSpecificNotification(i);
}
2017-04-26 08:20:12 -07:00
}
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
function deleteSpecificNotification(indexNotification) {
2024-10-19 19:06:16 +02:00
if (notifications[indexNotification].entityID !== Uuid.NONE){
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
Entities.deleteEntity(notifications[indexNotification].entityID);
2024-10-19 19:06:16 +02:00
notifications[indexNotification].entityID = Uuid.NONE;
}
2024-10-19 19:06:16 +02:00
if (notifications[indexNotification].overlayID !== Uuid.NONE){
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
Overlays.deleteOverlay(notifications[indexNotification].overlayID);
2024-10-19 19:06:16 +02:00
notifications[indexNotification].overlayID = Uuid.NONE;
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
}
2024-10-19 19:06:16 +02:00
if (notifications[indexNotification].imageEntityID !== Uuid.NONE){
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
Entities.deleteEntity(notifications[indexNotification].imageEntityID);
2024-10-19 19:06:16 +02:00
notifications[indexNotification].imageEntityID = Uuid.NONE;
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
}
2024-10-19 19:06:16 +02:00
if (notifications[indexNotification].imageOverlayID !== Uuid.NONE){
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
Overlays.deleteOverlay(notifications[indexNotification].imageOverlayID);
2024-10-19 19:06:16 +02:00
notifications[indexNotification].imageOverlayID = Uuid.NONE;
2016-11-17 09:51:45 -08:00
}
2017-04-26 08:20:12 -07:00
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
function createMainHMDnotificationContainer() {
2024-10-19 19:06:16 +02:00
if (mainHMDnotificationContainerID === Uuid.NONE) {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
var properties = {
"type": "Shape",
"shape": "Cube",
"visible": false,
"dimensions": {"x": 0.1, "y": 0.1, "z":0.1},
"parentID": MyAvatar.sessionUUID,
"parentJointIndex": CAMERA_MATRIX_INDEX,
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
"localPosition": hmdPanelLocalPosition,
"localRotation": hmdPanelLocalRotation
};
mainHMDnotificationContainerID = Entities.addEntity(properties, "local");
}
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
function deleteMainHMDnotificationContainer() {
2024-10-19 19:06:16 +02:00
if (mainHMDnotificationContainerID !== Uuid.NONE) {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
Entities.deleteEntity(mainHMDnotificationContainerID);
2024-10-19 19:06:16 +02:00
mainHMDnotificationContainerID = Uuid.NONE;
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
}
}
//UTILITY FUNCTIONS
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
// Trims extra whitespace and breaks into lines of length no more
// than MAX_LINE_LENGTH, breaking at spaces. Trims extra whitespace.
2017-04-26 08:20:12 -07:00
function wordWrap(string) {
var finishedLines = [], currentLine = '';
string.split(/\s/).forEach(function (word) {
var tail = currentLine ? ' ' + word : word;
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
if ((currentLine.length + tail.length) <= MAX_LINE_LENGTH) {
2017-04-26 08:20:12 -07:00
currentLine += tail;
} else {
finishedLines.push(currentLine);
currentLine = word;
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
if (currentLine.length > MAX_LINE_LENGTH) {
finishedLines.push(currentLine.substring(0,MAX_LINE_LENGTH));
currentLine = currentLine.substring(MAX_LINE_LENGTH, currentLine.length);
}
2017-04-26 08:20:12 -07:00
}
});
if (currentLine) {
2017-04-07 07:08:19 -07:00
finishedLines.push(currentLine);
}
2017-04-26 08:20:12 -07:00
return finishedLines.join('\n');
2017-04-07 07:08:19 -07:00
}
2017-04-26 08:20:12 -07:00
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
//NOTIFICATION STACK MANAGEMENT
function addNotification (dataText, dataImage) {
var d = new Date();
var notification = {
"dataText": dataText,
"dataImage": dataImage,
"timestamp": d.getTime(),
2024-10-19 19:06:16 +02:00
"entityID": Uuid.NONE,
"imageEntityID": Uuid.NONE,
"overlayID": Uuid.NONE,
"imageOverlayID": Uuid.NONE
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
};
notifications.push(notification);
newEventDetected = true;
if (notifications.length === 1) {
createMainHMDnotificationContainer();
Script.update.connect(update);
Controller.mousePressEvent.connect(mousePressEvent);
2017-09-06 09:26:48 -07:00
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
2017-09-06 09:26:48 -07:00
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
function update(deltaTime) {
if (notifications.length === 0 && !newEventDetected) {
Script.update.disconnect(update);
Controller.mousePressEvent.disconnect(mousePressEvent);
deleteMainHMDnotificationContainer();
} else {
if (isOnHMD !== HMD.active) {
deleteAllExistingNotificationsDisplayed();
isOnHMD = HMD.active;
}
var d = new Date();
var immediatly = d.getTime();
var mostRecentRemainingTime = NOTIFICATION_LIFE_DURATION;
var expirationDetected = false;
for (var i = 0; i < notifications.length; i++) {
if ((immediatly - notifications[i].timestamp) > NOTIFICATION_LIFE_DURATION){
deleteSpecificNotification(i);
notifications.splice(i, 1);
expirationDetected = true;
} else {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
mostRecentRemainingTime = NOTIFICATION_LIFE_DURATION - (immediatly - notifications[i].timestamp);
2017-04-26 08:20:12 -07:00
}
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
if (newEventDetected || expirationDetected || mostRecentRemainingTime < FADE_OUT_DURATION) {
renderNotifications(mostRecentRemainingTime);
newEventDetected = false;
}
}
if (isOnHMD) {
checkHands();
}
}
2017-04-26 08:20:12 -07:00
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
//NOTIFICATION EVENTS FUNCTIONS
function onDomainConnectionRefused(reason, reasonCode) {
// the "login error" reason means that the DS couldn't decrypt the username signature
// since this eventually resolves itself for good actors we don't need to show a notification for it
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
var LoginErrorMetaverse_REASON_CODE = 2;
if (reasonCode !== LoginErrorMetaverse_REASON_CODE) {
addNotification("Connection refused: " + reason, null);
}
2017-04-26 08:20:12 -07:00
}
function onEditError(msg) {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
addNotification(wordWrap(msg), null);
2017-04-26 08:20:12 -07:00
}
function onNotify(msg) {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
// Generic notification system for user feedback, thus using this
addNotification(wordWrap(msg), null);
2017-04-26 08:20:12 -07:00
}
function onMessageReceived(channel, message) {
if (channel === NOTIFICATIONS_MESSAGE_CHANNEL) {
message = JSON.parse(message);
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
addNotification(wordWrap(message.message), null);
}
}
2017-04-26 08:20:12 -07:00
function onSnapshotTaken(pathStillSnapshot, notify) {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
if (Settings.getValue(SETTING_ACTIVATION_SNAPSHOT_NOTIFICATIONS, true)) {
if (notify) {
var imageProperties = {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
"path": "file:///" + pathStillSnapshot,
"aspectRatio": Window.innerWidth / Window.innerHeight
};
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
addNotification(wordWrap("Snapshot saved to " + pathStillSnapshot), imageProperties);
}
}
2015-01-21 21:44:55 -08:00
}
2017-04-26 08:20:12 -07:00
function tabletNotification() {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
addNotification("Tablet needs your attention", null);
2016-11-17 09:51:45 -08:00
}
2017-04-26 08:20:12 -07:00
function processingGif() {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
if (Settings.getValue(SETTING_ACTIVATION_SNAPSHOT_NOTIFICATIONS, true)) {
addNotification("Processing GIF snapshot...", null);
}
2017-04-26 08:20:12 -07:00
}
function connectionAdded(connectionName) {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
addNotification(connectionName, null);
}
2017-04-26 08:20:12 -07:00
function connectionError(error) {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
addNotification(wordWrap("Error trying to make connection: " + error), null);
2017-04-26 08:20:12 -07:00
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
//STARTING AND ENDING
2017-04-26 08:20:12 -07:00
function scriptEnding() {
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
//cleanup
deleteAllExistingNotificationsDisplayed();
//disconnecting
if (notifications.length > 0) {
Script.update.disconnect(update);
Controller.mousePressEvent.disconnect(mousePressEvent);
2017-04-26 08:20:12 -07:00
}
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
Script.scriptEnding.disconnect(scriptEnding);
Messages.unsubscribe(NOTIFICATIONS_MESSAGE_CHANNEL);
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
Window.domainConnectionRefused.disconnect(onDomainConnectionRefused);
Window.stillSnapshotTaken.disconnect(onSnapshotTaken);
Window.snapshot360Taken.disconnect(onSnapshotTaken);
Window.processingGifStarted.disconnect(processingGif);
Window.connectionAdded.disconnect(connectionAdded);
Window.connectionError.disconnect(connectionError);
Window.announcement.disconnect(onNotify);
Tablet.tabletNotification.disconnect(tabletNotification);
Messages.messageReceived.disconnect(onMessageReceived);
}
2017-04-26 08:20:12 -07:00
Script.scriptEnding.connect(scriptEnding);
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
//EVENTS TO NOTIFY
2017-04-26 08:20:12 -07:00
Window.domainConnectionRefused.connect(onDomainConnectionRefused);
Window.stillSnapshotTaken.connect(onSnapshotTaken);
2018-05-03 12:57:00 -07:00
Window.snapshot360Taken.connect(onSnapshotTaken);
2017-04-26 08:20:12 -07:00
Window.processingGifStarted.connect(processingGif);
Window.connectionAdded.connect(connectionAdded);
Window.connectionError.connect(connectionError);
Window.announcement.connect(onNotify);
Window.notifyEditError = onEditError;
Window.notify = onNotify;
Tablet.tabletNotification.connect(tabletNotification);
Messages.subscribe(NOTIFICATIONS_MESSAGE_CHANNEL);
Messages.messageReceived.connect(onMessageReceived);
Re-coded to be more stable. This is a an almost complete re-coding of the notifications script. The previous version had too useless complexities and was computing each element position independently causing the notifications to be unstably displayed in HMD if the user moved. There was also too many array used to achieved this. It was a bit painful. This new version use an invisible entity parented to the avatar as a "container" where the notification elements are parented to it, making the positioning easier and more stable if the avatar moves. I used only one array of objects to contain the the notification stack. There is also a better management of some signal to avoid useless computing when it wasn't necessary. I think the code is also more clear. I got rid of the little x buttons to close the notification, it was on each element, you had to target a very small square surface with the mouse if you wanted to absolutely close a notification within the 10 second of their existence. Now you can close a notification simply by clicking on it (on all its surface) But as before, the close function works only on desktop mode. (Apparently it's relatively complex to get the id of the entity that you click on in HMD. Maybe one day.) It's also easier now to adjust the scale of the notifications in HMD if we want too, (only one value to change in the script) The parenting using a container entity has also made all the notification UI in HMD scaling correctly according the avatar scale (it was free by parenting all those together).
2022-09-14 23:11:56 -04:00
}());