mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 02:36:54 +02:00
Goto now uses AppUi; lint
This commit is contained in:
parent
01073ca18d
commit
5a1d074e2f
5 changed files with 131 additions and 155 deletions
|
@ -1,5 +1,5 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/*jslint vars:true, plusplus:true, forin:true*/
|
/* jslint vars:true, plusplus:true, forin:true */
|
||||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
//
|
//
|
||||||
// wallet.js
|
// wallet.js
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
//
|
//
|
||||||
// help.js
|
// help.js
|
||||||
// scripts/system/
|
// scripts/system/
|
||||||
|
@ -13,16 +13,17 @@
|
||||||
/* globals Tablet, Script, HMD, Controller, Menu */
|
/* globals Tablet, Script, HMD, Controller, Menu */
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
var AppUi = Script.require('appUi');
|
var AppUi = Script.require('appUi');
|
||||||
|
|
||||||
var HELP_URL = Script.resourcesPath() + "html/tabletHelp.html";
|
var HELP_URL = Script.resourcesPath() + "html/tabletHelp.html";
|
||||||
var HELP_BUTTON_NAME = "HELP";
|
var HELP_BUTTON_NAME = "HELP";
|
||||||
function startup() {
|
var ui;
|
||||||
ui = new AppUi({
|
function startup() {
|
||||||
buttonName: HELP_BUTTON_NAME,
|
ui = new AppUi({
|
||||||
sortOrder: 6,
|
buttonName: HELP_BUTTON_NAME,
|
||||||
home: HELP_URL
|
sortOrder: 6,
|
||||||
});
|
home: HELP_URL
|
||||||
}
|
});
|
||||||
startup();
|
}
|
||||||
|
startup();
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/*jslint vars:true, plusplus:true, forin:true*/
|
/* jslint vars:true, plusplus:true, forin:true */
|
||||||
/*global Tablet, Settings, Script, AvatarList, Users, Entities, MyAvatar, Camera, Overlays, Vec3, Quat, HMD, Controller, Account, UserActivityLogger, Messages, Window, XMLHttpRequest, print, location, getControllerWorldLocation*/
|
/* global Tablet, Settings, Script, AvatarList, Users, Entities,
|
||||||
|
MyAvatar, Camera, Overlays, Vec3, Quat, HMD, Controller, Account,
|
||||||
|
UserActivityLogger, Messages, Window, XMLHttpRequest, print, location, getControllerWorldLocation
|
||||||
|
*/
|
||||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
//
|
//
|
||||||
// pal.js
|
// pal.js
|
||||||
|
@ -20,7 +23,7 @@ var AppUi = Script.require('appUi');
|
||||||
var populateNearbyUserList, color, textures, removeOverlays,
|
var populateNearbyUserList, color, textures, removeOverlays,
|
||||||
controllerComputePickRay, off,
|
controllerComputePickRay, off,
|
||||||
receiveMessage, avatarDisconnected, clearLocalQMLDataAndClosePAL,
|
receiveMessage, avatarDisconnected, clearLocalQMLDataAndClosePAL,
|
||||||
CHANNEL, getConnectionData, findableByChanged,
|
CHANNEL, getConnectionData,
|
||||||
avatarAdded, avatarRemoved, avatarSessionChanged; // forward references;
|
avatarAdded, avatarRemoved, avatarSessionChanged; // forward references;
|
||||||
|
|
||||||
// hardcoding these as it appears we cannot traverse the originalTextures in overlays??? Maybe I've missed
|
// hardcoding these as it appears we cannot traverse the originalTextures in overlays??? Maybe I've missed
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
// Distributed under the Apache License, Version 2.0
|
// Distributed under the Apache License, Version 2.0
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
/* globals Tablet, Script, HMD, Settings, DialogsManager, Menu, Reticle, OverlayWebWindow, Desktop, Account, MyAvatar, Snapshot */
|
/* globals Tablet, Script, HMD, Settings, DialogsManager, Menu, Reticle,
|
||||||
|
OverlayWebWindow, Desktop, Account, MyAvatar, Snapshot */
|
||||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/*jslint vars:true, plusplus:true, forin:true*/
|
/* jslint vars:true, plusplus:true, forin:true */
|
||||||
/*global Window, Script, Tablet, HMD, Controller, Account, XMLHttpRequest, location, print*/
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
|
/* global Window, Script, Tablet, HMD, Controller, Account, XMLHttpRequest, location, print */
|
||||||
|
|
||||||
//
|
//
|
||||||
// goto.js
|
// tablet-goto.js
|
||||||
// scripts/system/
|
// scripts/system/
|
||||||
//
|
//
|
||||||
// Created by Dante Ruiz on 8 February 2017
|
// Created by Dante Ruiz on 8 February 2017
|
||||||
|
@ -14,148 +15,118 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
|
var request = Script.require('request').request;
|
||||||
|
var AppUi = Script.require('appUi');
|
||||||
|
var DEBUG = false;
|
||||||
|
function debug() {
|
||||||
|
if (!DEBUG) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
print('tablet-goto.js:', [].map.call(arguments, JSON.stringify));
|
||||||
|
}
|
||||||
|
|
||||||
var request = Script.require('request').request;
|
var stories = {}, pingPong = false;
|
||||||
var DEBUG = false;
|
function expire(id) {
|
||||||
function debug() {
|
var options = {
|
||||||
if (!DEBUG) {
|
uri: Account.metaverseServerURL + '/api/v1/user_stories/' + id,
|
||||||
|
method: 'PUT',
|
||||||
|
json: true,
|
||||||
|
body: {expire: "true"}
|
||||||
|
};
|
||||||
|
request(options, function (error, response) {
|
||||||
|
debug('expired story', options, 'error:', error, 'response:', response);
|
||||||
|
if (error || (response.status !== 'success')) {
|
||||||
|
print("ERROR expiring story: ", error || response.status);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var PER_PAGE_DEBUG = 10;
|
||||||
|
var PER_PAGE_NORMAL = 100;
|
||||||
|
function pollForAnnouncements() {
|
||||||
|
// We could bail now if !Account.isLoggedIn(), but what if we someday have system-wide announcments?
|
||||||
|
var actions = 'announcement';
|
||||||
|
var count = DEBUG ? PER_PAGE_DEBUG : PER_PAGE_NORMAL;
|
||||||
|
var options = [
|
||||||
|
'now=' + new Date().toISOString(),
|
||||||
|
'include_actions=' + actions,
|
||||||
|
'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'),
|
||||||
|
'require_online=true',
|
||||||
|
'protocol=' + encodeURIComponent(Window.protocolSignature()),
|
||||||
|
'per_page=' + count
|
||||||
|
];
|
||||||
|
var url = Account.metaverseServerURL + '/api/v1/user_stories?' + options.join('&');
|
||||||
|
request({
|
||||||
|
uri: url
|
||||||
|
}, function (error, data) {
|
||||||
|
debug(url, error, data);
|
||||||
|
if (error || (data.status !== 'success')) {
|
||||||
|
print("Error: unable to get", url, error || data.status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print('tablet-goto.js:', [].map.call(arguments, JSON.stringify));
|
var didNotify = false, key;
|
||||||
}
|
pingPong = !pingPong;
|
||||||
|
data.user_stories.forEach(function (story) {
|
||||||
var gotoQmlSource = "hifi/tablet/TabletAddressDialog.qml";
|
var stored = stories[story.id], storedOrNew = stored || story;
|
||||||
var buttonName = "GOTO";
|
debug('story exists:', !!stored, storedOrNew);
|
||||||
var onGotoScreen = false;
|
if ((storedOrNew.username === Account.username) && (storedOrNew.place_name !== location.placename)) {
|
||||||
var shouldActivateButton = false;
|
if (storedOrNew.audience === 'for_connections') { // Only expire if we haven't already done so.
|
||||||
function ignore() { }
|
expire(story.id);
|
||||||
|
}
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
return; // before marking
|
||||||
var NORMAL_ICON = "icons/tablet-icons/goto-i.svg";
|
|
||||||
var NORMAL_ACTIVE = "icons/tablet-icons/goto-a.svg";
|
|
||||||
var WAITING_ICON = "icons/tablet-icons/goto-msg.svg";
|
|
||||||
var button = tablet.addButton({
|
|
||||||
icon: NORMAL_ICON,
|
|
||||||
activeIcon: NORMAL_ACTIVE,
|
|
||||||
text: buttonName,
|
|
||||||
sortOrder: 8
|
|
||||||
});
|
|
||||||
|
|
||||||
function messagesWaiting(isWaiting) {
|
|
||||||
button.editProperties({
|
|
||||||
icon: isWaiting ? WAITING_ICON : NORMAL_ICON
|
|
||||||
// No need for a different activeIcon, because we issue messagesWaiting(false) when the button goes active anyway.
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
tablet.screenChanged.connect(onScreenChanged);
|
|
||||||
|
|
||||||
var stories = {}, pingPong = false;
|
|
||||||
function expire(id) {
|
|
||||||
var options = {
|
|
||||||
uri: Account.metaverseServerURL + '/api/v1/user_stories/' + id,
|
|
||||||
method: 'PUT',
|
|
||||||
json: true,
|
|
||||||
body: {expire: "true"}
|
|
||||||
};
|
|
||||||
request(options, function (error, response) {
|
|
||||||
debug('expired story', options, 'error:', error, 'response:', response);
|
|
||||||
if (error || (response.status !== 'success')) {
|
|
||||||
print("ERROR expiring story: ", error || response.status);
|
|
||||||
}
|
}
|
||||||
});
|
storedOrNew.pingPong = pingPong;
|
||||||
}
|
if (stored) { // already seen
|
||||||
function pollForAnnouncements() {
|
|
||||||
// We could bail now if !Account.isLoggedIn(), but what if we someday have system-wide announcments?
|
|
||||||
var actions = 'announcement';
|
|
||||||
var count = DEBUG ? 10 : 100;
|
|
||||||
var options = [
|
|
||||||
'now=' + new Date().toISOString(),
|
|
||||||
'include_actions=' + actions,
|
|
||||||
'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'),
|
|
||||||
'require_online=true',
|
|
||||||
'protocol=' + encodeURIComponent(Window.protocolSignature()),
|
|
||||||
'per_page=' + count
|
|
||||||
];
|
|
||||||
var url = Account.metaverseServerURL + '/api/v1/user_stories?' + options.join('&');
|
|
||||||
request({
|
|
||||||
uri: url
|
|
||||||
}, function (error, data) {
|
|
||||||
debug(url, error, data);
|
|
||||||
if (error || (data.status !== 'success')) {
|
|
||||||
print("Error: unable to get", url, error || data.status);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var didNotify = false, key;
|
stories[story.id] = story;
|
||||||
pingPong = !pingPong;
|
var message = story.username + " " + story.action_string + " in " +
|
||||||
data.user_stories.forEach(function (story) {
|
story.place_name + ". Open GOTO to join them.";
|
||||||
var stored = stories[story.id], storedOrNew = stored || story;
|
Window.displayAnnouncement(message);
|
||||||
debug('story exists:', !!stored, storedOrNew);
|
didNotify = true;
|
||||||
if ((storedOrNew.username === Account.username) && (storedOrNew.place_name !== location.placename)) {
|
|
||||||
if (storedOrNew.audience == 'for_connections') { // Only expire if we haven't already done so.
|
|
||||||
expire(story.id);
|
|
||||||
}
|
|
||||||
return; // before marking
|
|
||||||
}
|
|
||||||
storedOrNew.pingPong = pingPong;
|
|
||||||
if (stored) { // already seen
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
stories[story.id] = story;
|
|
||||||
var message = story.username + " " + story.action_string + " in " + story.place_name + ". Open GOTO to join them.";
|
|
||||||
Window.displayAnnouncement(message);
|
|
||||||
didNotify = true;
|
|
||||||
});
|
|
||||||
for (key in stories) { // Any story we were tracking that was not marked, has expired.
|
|
||||||
if (stories[key].pingPong !== pingPong) {
|
|
||||||
debug('removing story', key);
|
|
||||||
delete stories[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (didNotify) {
|
|
||||||
messagesWaiting(true);
|
|
||||||
if (HMD.isHandControllerAvailable()) {
|
|
||||||
var STRENGTH = 1.0, DURATION_MS = 60, HAND = 2; // both hands
|
|
||||||
Controller.triggerHapticPulse(STRENGTH, DURATION_MS, HAND);
|
|
||||||
}
|
|
||||||
} else if (!Object.keys(stories).length) { // If there's nothing being tracked, then any messageWaiting has expired.
|
|
||||||
messagesWaiting(false);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
for (key in stories) { // Any story we were tracking that was not marked, has expired.
|
||||||
var ANNOUNCEMENTS_POLL_TIME_MS = (DEBUG ? 10 : 60) * 1000;
|
if (stories[key].pingPong !== pingPong) {
|
||||||
var pollTimer = Script.setInterval(pollForAnnouncements, ANNOUNCEMENTS_POLL_TIME_MS);
|
debug('removing story', key);
|
||||||
|
delete stories[key];
|
||||||
Script.scriptEnding.connect(function () {
|
}
|
||||||
Script.clearInterval(pollTimer);
|
}
|
||||||
button.clicked.disconnect(onClicked);
|
if (didNotify) {
|
||||||
tablet.removeButton(button);
|
ui.messagesWaiting(true);
|
||||||
tablet.screenChanged.disconnect(onScreenChanged);
|
if (HMD.isHandControllerAvailable()) {
|
||||||
|
var STRENGTH = 1.0, DURATION_MS = 60, HAND = 2; // both hands
|
||||||
|
Controller.triggerHapticPulse(STRENGTH, DURATION_MS, HAND);
|
||||||
|
}
|
||||||
|
} else if (!Object.keys(stories).length) { // If there's nothing being tracked, then any messageWaiting has expired.
|
||||||
|
ui.messagesWaiting(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
var MS_PER_SEC = 1000;
|
||||||
|
var DEBUG_POLL_TIME_SEC = 10;
|
||||||
|
var NORMAL_POLL_TIME_SEC = 60;
|
||||||
|
var ANNOUNCEMENTS_POLL_TIME_MS = (DEBUG ? DEBUG_POLL_TIME_SEC : NORMAL_POLL_TIME_SEC) * MS_PER_SEC;
|
||||||
|
var pollTimer = Script.setInterval(pollForAnnouncements, ANNOUNCEMENTS_POLL_TIME_MS);
|
||||||
|
|
||||||
|
function gotoOpened() {
|
||||||
|
ui.messagesWaiting(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var ui;
|
||||||
|
var GOTO_QML_SOURCE = "hifi/tablet/TabletAddressDialog.qml";
|
||||||
|
var BUTTON_NAME = "GOTO";
|
||||||
|
function startup() {
|
||||||
|
ui = new AppUi({
|
||||||
|
buttonName: BUTTON_NAME,
|
||||||
|
sortOrder: 8,
|
||||||
|
onOpened: gotoOpened,
|
||||||
|
home: GOTO_QML_SOURCE
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function shutdown() {
|
||||||
|
Script.clearInterval(pollTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
startup();
|
||||||
|
Script.scriptEnding.connect(shutdown);
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
Loading…
Reference in a new issue