mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:12:53 +02:00
lint
This commit is contained in:
parent
ee9b953b1c
commit
0f8ee7051c
2 changed files with 571 additions and 568 deletions
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
/*jslint vars:true, plusplus:true, forin:true*/
|
||||||
|
/*global Script, Settings, Window, Controller, Overlays, SoundArray, LODManager, MyAvatar, Tablet, Camera, HMD, Menu, Quat, Vec3*/
|
||||||
//
|
//
|
||||||
// notifications.js
|
// notifications.js
|
||||||
// Version 0.801
|
// Version 0.801
|
||||||
|
@ -56,7 +57,6 @@
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/* global Script, Controller, Overlays, SoundArray, Quat, Vec3, MyAvatar, Menu, HMD, AudioDevice, LODManager, Settings, Camera */
|
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
|
|
||||||
|
@ -77,8 +77,6 @@ var PERSIST_TIME_2D = 10.0; // Time in seconds before notification fades
|
||||||
var PERSIST_TIME_3D = 15.0;
|
var PERSIST_TIME_3D = 15.0;
|
||||||
var persistTime = PERSIST_TIME_2D;
|
var persistTime = PERSIST_TIME_2D;
|
||||||
var frame = 0;
|
var frame = 0;
|
||||||
var ourWidth = Window.innerWidth;
|
|
||||||
var ourHeight = Window.innerHeight;
|
|
||||||
var ctrlIsPressed = false;
|
var ctrlIsPressed = false;
|
||||||
var ready = true;
|
var ready = true;
|
||||||
var MENU_NAME = 'Tools > Notifications';
|
var MENU_NAME = 'Tools > Notifications';
|
||||||
|
@ -105,13 +103,14 @@ var NotificationType = {
|
||||||
{ text: "Connection" }
|
{ text: "Connection" }
|
||||||
],
|
],
|
||||||
getTypeFromMenuItem: function (menuItemName) {
|
getTypeFromMenuItem: function (menuItemName) {
|
||||||
|
var type;
|
||||||
if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) {
|
if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) {
|
||||||
return NotificationType.UNKNOWN;
|
return NotificationType.UNKNOWN;
|
||||||
}
|
}
|
||||||
var preMenuItemName = menuItemName.substr(0, menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length);
|
var preMenuItemName = menuItemName.substr(0, menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length);
|
||||||
for (var type in this.properties) {
|
for (type in this.properties) {
|
||||||
if (this.properties[type].text === preMenuItemName) {
|
if (this.properties[type].text === preMenuItemName) {
|
||||||
return parseInt(type) + 1;
|
return parseInt(type, 10) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NotificationType.UNKNOWN;
|
return NotificationType.UNKNOWN;
|
||||||
|
@ -123,8 +122,9 @@ var NotificationType = {
|
||||||
|
|
||||||
var randomSounds = new SoundArray({ localOnly: true }, true);
|
var randomSounds = new SoundArray({ localOnly: true }, true);
|
||||||
var numberOfSounds = 2;
|
var numberOfSounds = 2;
|
||||||
for (var i = 1; i <= numberOfSounds; i++) {
|
var soundIndex;
|
||||||
randomSounds.addSound(Script.resolvePath("assets/sounds/notification-general"+ i + ".raw"));
|
for (soundIndex = 1; soundIndex <= numberOfSounds; soundIndex++) {
|
||||||
|
randomSounds.addSound(Script.resolvePath("assets/sounds/notification-general" + soundIndex + ".raw"));
|
||||||
}
|
}
|
||||||
|
|
||||||
var notifications = [];
|
var notifications = [];
|
||||||
|
@ -150,7 +150,7 @@ function createArrays(notice, button, createTime, height, myAlpha) {
|
||||||
|
|
||||||
// This handles the final dismissal of a notification after fading
|
// This handles the final dismissal of a notification after fading
|
||||||
function dismiss(firstNoteOut, firstButOut, firstOut) {
|
function dismiss(firstNoteOut, firstButOut, firstOut) {
|
||||||
if (firstNoteOut == lodTextID) {
|
if (firstNoteOut === lodTextID) {
|
||||||
lodTextID = false;
|
lodTextID = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,32 +290,33 @@ function notify(notice, button, height, imageProperties, image) {
|
||||||
avatarOrientation,
|
avatarOrientation,
|
||||||
notificationPosition,
|
notificationPosition,
|
||||||
notificationOrientation,
|
notificationOrientation,
|
||||||
buttonPosition;
|
buttonPosition,
|
||||||
|
notificationIndex;
|
||||||
|
|
||||||
if (isOnHMD && notifications.length > 0) {
|
if (isOnHMD && notifications.length > 0) {
|
||||||
// Update 3D overlays to maintain positions relative to avatar
|
// Update 3D overlays to maintain positions relative to avatar
|
||||||
defaultEyePosition = MyAvatar.getDefaultEyePosition();
|
defaultEyePosition = MyAvatar.getDefaultEyePosition();
|
||||||
avatarOrientation = MyAvatar.orientation;
|
avatarOrientation = MyAvatar.orientation;
|
||||||
|
|
||||||
for (i = 0; i < notifications.length; i += 1) {
|
for (notificationIndex = 0; notificationIndex < notifications.length; notificationIndex += 1) {
|
||||||
notificationPosition = Vec3.sum(defaultEyePosition,
|
notificationPosition = Vec3.sum(defaultEyePosition,
|
||||||
Vec3.multiplyQbyV(avatarOrientation,
|
Vec3.multiplyQbyV(avatarOrientation,
|
||||||
overlay3DDetails[i].notificationPosition));
|
overlay3DDetails[notificationIndex].notificationPosition));
|
||||||
notificationOrientation = Quat.multiply(avatarOrientation,
|
notificationOrientation = Quat.multiply(avatarOrientation,
|
||||||
overlay3DDetails[i].notificationOrientation);
|
overlay3DDetails[notificationIndex].notificationOrientation);
|
||||||
buttonPosition = Vec3.sum(defaultEyePosition,
|
buttonPosition = Vec3.sum(defaultEyePosition,
|
||||||
Vec3.multiplyQbyV(avatarOrientation,
|
Vec3.multiplyQbyV(avatarOrientation,
|
||||||
overlay3DDetails[i].buttonPosition));
|
overlay3DDetails[notificationIndex].buttonPosition));
|
||||||
Overlays.editOverlay(notifications[i], { position: notificationPosition,
|
Overlays.editOverlay(notifications[notificationIndex], { position: notificationPosition,
|
||||||
rotation: notificationOrientation });
|
rotation: notificationOrientation });
|
||||||
Overlays.editOverlay(buttons[i], { position: buttonPosition, rotation: notificationOrientation });
|
Overlays.editOverlay(buttons[notificationIndex], { position: buttonPosition, rotation: notificationOrientation });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!image) {
|
if (!image) {
|
||||||
notificationText = Overlays.addOverlay("text", notice);
|
notificationText = Overlays.addOverlay("text", notice);
|
||||||
notifications.push((notificationText));
|
notifications.push(notificationText);
|
||||||
} else {
|
} else {
|
||||||
notifications.push(Overlays.addOverlay("image", notice));
|
notifications.push(Overlays.addOverlay("image", notice));
|
||||||
}
|
}
|
||||||
|
@ -413,7 +414,7 @@ function createNotification(text, notificationType, imageProperties) {
|
||||||
|
|
||||||
function deleteNotification(index) {
|
function deleteNotification(index) {
|
||||||
var notificationTextID = notifications[index];
|
var notificationTextID = notifications[index];
|
||||||
if (notificationTextID == lodTextID) {
|
if (notificationTextID === lodTextID) {
|
||||||
lodTextID = false;
|
lodTextID = false;
|
||||||
}
|
}
|
||||||
Overlays.deleteOverlay(notificationTextID);
|
Overlays.deleteOverlay(notificationTextID);
|
||||||
|
@ -448,8 +449,7 @@ function wordWrap(string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
var nextOverlay,
|
var noticeOut,
|
||||||
noticeOut,
|
|
||||||
buttonOut,
|
buttonOut,
|
||||||
arraysOut,
|
arraysOut,
|
||||||
positions,
|
positions,
|
||||||
|
@ -470,7 +470,6 @@ function update() {
|
||||||
if ((frame % 60.0) === 0) { // only update once a second
|
if ((frame % 60.0) === 0) { // only update once a second
|
||||||
locationY = 20.0;
|
locationY = 20.0;
|
||||||
for (i = 0; i < arrays.length; i += 1) { //repositions overlays as others fade
|
for (i = 0; i < arrays.length; i += 1) { //repositions overlays as others fade
|
||||||
nextOverlay = Overlays.getOverlayAtPoint({ x: overlayLocationX, y: locationY });
|
|
||||||
Overlays.editOverlay(notifications[i], { x: overlayLocationX, y: locationY });
|
Overlays.editOverlay(notifications[i], { x: overlayLocationX, y: locationY });
|
||||||
Overlays.editOverlay(buttons[i], { x: buttonLocationX, y: locationY + 12.0 });
|
Overlays.editOverlay(buttons[i], { x: buttonLocationX, y: locationY + 12.0 });
|
||||||
if (isOnHMD) {
|
if (isOnHMD) {
|
||||||
|
@ -593,6 +592,7 @@ function keyPressEvent(key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
|
var type;
|
||||||
Menu.addMenu(MENU_NAME);
|
Menu.addMenu(MENU_NAME);
|
||||||
var checked = Settings.getValue(PLAY_NOTIFICATION_SOUNDS_SETTING);
|
var checked = Settings.getValue(PLAY_NOTIFICATION_SOUNDS_SETTING);
|
||||||
checked = checked === '' ? true : checked;
|
checked = checked === '' ? true : checked;
|
||||||
|
@ -603,8 +603,8 @@ function setup() {
|
||||||
isChecked: Settings.getValue(PLAY_NOTIFICATION_SOUNDS_SETTING)
|
isChecked: Settings.getValue(PLAY_NOTIFICATION_SOUNDS_SETTING)
|
||||||
});
|
});
|
||||||
Menu.addSeparator(MENU_NAME, "Play sounds for:");
|
Menu.addSeparator(MENU_NAME, "Play sounds for:");
|
||||||
for (var type in NotificationType.properties) {
|
for (type in NotificationType.properties) {
|
||||||
checked = Settings.getValue(PLAY_NOTIFICATION_SOUNDS_TYPE_SETTING_PRE + (parseInt(type) + 1));
|
checked = Settings.getValue(PLAY_NOTIFICATION_SOUNDS_TYPE_SETTING_PRE + (parseInt(type, 10) + 1));
|
||||||
checked = checked === '' ? true : checked;
|
checked = checked === '' ? true : checked;
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: MENU_NAME,
|
menuName: MENU_NAME,
|
||||||
|
@ -617,9 +617,10 @@ function setup() {
|
||||||
|
|
||||||
// When our script shuts down, we should clean up all of our overlays
|
// When our script shuts down, we should clean up all of our overlays
|
||||||
function scriptEnding() {
|
function scriptEnding() {
|
||||||
for (var i = 0; i < notifications.length; i++) {
|
var notificationIndex;
|
||||||
Overlays.deleteOverlay(notifications[i]);
|
for (notificationIndex = 0; notificationIndex < notifications.length; notificationIndex++) {
|
||||||
Overlays.deleteOverlay(buttons[i]);
|
Overlays.deleteOverlay(notifications[notificationIndex]);
|
||||||
|
Overlays.deleteOverlay(buttons[notificationIndex]);
|
||||||
}
|
}
|
||||||
Menu.removeMenu(MENU_NAME);
|
Menu.removeMenu(MENU_NAME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
/*jslint vars:true, plusplus:true, forin:true*/
|
||||||
|
/*global Window, Script, Tablet, HMD, Controller, Account, XMLHttpRequest, location, print*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// goto.js
|
// goto.js
|
||||||
|
@ -16,30 +18,7 @@
|
||||||
var buttonName = "GOTO";
|
var buttonName = "GOTO";
|
||||||
var onGotoScreen = false;
|
var onGotoScreen = false;
|
||||||
var shouldActivateButton = false;
|
var shouldActivateButton = false;
|
||||||
|
function ignore() { }
|
||||||
function onClicked() {
|
|
||||||
if (onGotoScreen) {
|
|
||||||
// for toolbar-mode: go back to home screen, this will close the window.
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
} else {
|
|
||||||
shouldActivateButton = true;
|
|
||||||
tablet.loadQMLSource(gotoQmlSource);
|
|
||||||
onGotoScreen = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onScreenChanged(type, url) {
|
|
||||||
if (url === gotoQmlSource) {
|
|
||||||
onGotoScreen = true;
|
|
||||||
shouldActivateButton = true;
|
|
||||||
button.editProperties({isActive: shouldActivateButton});
|
|
||||||
messagesWaiting(false);
|
|
||||||
} else {
|
|
||||||
shouldActivateButton = false;
|
|
||||||
onGotoScreen = false;
|
|
||||||
button.editProperties({isActive: shouldActivateButton});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
var NORMAL_ICON = "icons/tablet-icons/goto-i.svg";
|
var NORMAL_ICON = "icons/tablet-icons/goto-i.svg";
|
||||||
|
@ -58,10 +37,33 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onClicked() {
|
||||||
|
if (onGotoScreen) {
|
||||||
|
// for toolbar-mode: go back to home screen, this will close the window.
|
||||||
|
tablet.gotoHomeScreen();
|
||||||
|
} else {
|
||||||
|
shouldActivateButton = true;
|
||||||
|
tablet.loadQMLSource(gotoQmlSource);
|
||||||
|
onGotoScreen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onScreenChanged(type, url) {
|
||||||
|
ignore(type);
|
||||||
|
if (url === gotoQmlSource) {
|
||||||
|
onGotoScreen = true;
|
||||||
|
shouldActivateButton = true;
|
||||||
|
button.editProperties({isActive: shouldActivateButton});
|
||||||
|
messagesWaiting(false);
|
||||||
|
} else {
|
||||||
|
shouldActivateButton = false;
|
||||||
|
onGotoScreen = false;
|
||||||
|
button.editProperties({isActive: shouldActivateButton});
|
||||||
|
}
|
||||||
|
}
|
||||||
button.clicked.connect(onClicked);
|
button.clicked.connect(onClicked);
|
||||||
tablet.screenChanged.connect(onScreenChanged);
|
tablet.screenChanged.connect(onScreenChanged);
|
||||||
|
|
||||||
var METAVERSE_BASE = location.metaverseServerUrl;
|
|
||||||
function request(options, callback) { // cb(error, responseOfCorrectContentType) of url. A subset of npm request.
|
function request(options, callback) { // cb(error, responseOfCorrectContentType) of url. A subset of npm request.
|
||||||
var httpRequest = new XMLHttpRequest(), key;
|
var httpRequest = new XMLHttpRequest(), key;
|
||||||
// QT bug: apparently doesn't handle onload. Workaround using readyState.
|
// QT bug: apparently doesn't handle onload. Workaround using readyState.
|
||||||
|
@ -129,7 +131,7 @@
|
||||||
uri: url
|
uri: url
|
||||||
}, function (error, data) {
|
}, function (error, data) {
|
||||||
if (error || (data.status !== 'success')) {
|
if (error || (data.status !== 'success')) {
|
||||||
print("Error: unable to get", url, error || response.status);
|
print("Error: unable to get", url, error || data.status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var didNotify = false;
|
var didNotify = false;
|
||||||
|
|
Loading…
Reference in a new issue