mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 09:42:23 +02:00
adding overlays to redirect domain
This commit is contained in:
parent
1394d06480
commit
26b6967ba6
5 changed files with 408 additions and 854 deletions
File diff suppressed because it is too large
Load diff
|
@ -311,6 +311,7 @@ void DomainHandler::setIsConnected(bool isConnected) {
|
|||
_isConnected = isConnected;
|
||||
|
||||
if (_isConnected) {
|
||||
_lastDomainConnectionError = -1;
|
||||
emit connectedToDomain(_domainURL);
|
||||
|
||||
if (_domainURL.scheme() == URL_SCHEME_HIFI && !_domainURL.host().isEmpty()) {
|
||||
|
|
|
@ -40,6 +40,7 @@ var DEFAULT_SCRIPTS_SEPARATE = [
|
|||
|
||||
if (Settings.getValue("enableInterstitialMode", false)) {
|
||||
DEFAULT_SCRIPTS_SEPARATE.push("system/interstitialPage.js");
|
||||
DEFAULT_SCRIPTS_SEPARATE.push("system/redirectOverlays.js");
|
||||
}
|
||||
|
||||
// add a menu item for debugging
|
||||
|
|
|
@ -178,7 +178,7 @@
|
|||
localOrientation: Quat.fromVec3Degrees({ x: 0.0, y: 180.0, z: 0.0 }),
|
||||
parentID: anchorOverlay
|
||||
});
|
||||
|
||||
|
||||
var TARGET_UPDATE_HZ = 60; // 50hz good enough, but we're using update
|
||||
var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ;
|
||||
var lastInterval = Date.now();
|
||||
|
@ -347,7 +347,6 @@
|
|||
Overlays.editOverlay(loadingBarPlacard, properties);
|
||||
Overlays.editOverlay(loadingBarProgress, loadingBarProperties);
|
||||
|
||||
|
||||
Menu.setIsOptionChecked("Show Overlays", physicsEnabled);
|
||||
if (!HMD.active) {
|
||||
toolbar.writeProperty("visible", physicsEnabled);
|
||||
|
@ -399,6 +398,18 @@
|
|||
};
|
||||
|
||||
Overlays.editOverlay(loadingBarProgress, properties);
|
||||
|
||||
|
||||
var hardRefusalErrorsIdx = hardRefusalErrors.indexOf(Window.getLastDomainConnectionError());
|
||||
|
||||
var redirectProperties = {
|
||||
visible: (hardRefusalErrorsIdx >= 0)
|
||||
};
|
||||
|
||||
Overlays.editOverlay(redirectOopsText, redirectProperties);
|
||||
Overlays.editOverlay(tryAgainImage, redirectProperties);
|
||||
Overlays.editOverlay(backImage, redirectProperties);
|
||||
|
||||
if ((physicsEnabled && (currentProgress >= (TOTAL_LOADING_PROGRESS - EPSILON)))) {
|
||||
updateOverlays((physicsEnabled || connectionToDomainFailed));
|
||||
endAudio();
|
||||
|
@ -457,6 +468,9 @@
|
|||
Overlays.deleteOverlay(loadingBarPlacard);
|
||||
Overlays.deleteOverlay(loadingBarProgress);
|
||||
Overlays.deleteOverlay(anchorOverlay);
|
||||
Overlays.deleteOverlay(redirectOopsText);
|
||||
Overlays.deleteOverlay(tryAgainImage);
|
||||
Overlays.deleteOverlay(backImage);
|
||||
|
||||
if (DEBUG) {
|
||||
tablet.removeButton(button);
|
||||
|
|
144
scripts/system/redirectOverlays.js
Normal file
144
scripts/system/redirectOverlays.js
Normal file
|
@ -0,0 +1,144 @@
|
|||
"use strict";
|
||||
(function() {
|
||||
|
||||
var ERROR_MESSAGE_MAP = [
|
||||
"Oops! Protocol version mismatch.",
|
||||
"Oops! Not authorized to join domain.",
|
||||
"Oops! Connection timed out.",
|
||||
"Oops! Something went wrong."
|
||||
];
|
||||
|
||||
var PROTOCOL_VERSION_MISMATCH = 1;
|
||||
var NOT_AUTHORIZED = 3;
|
||||
var TIMEOUT = 5;
|
||||
var hardRefusalErrors = [PROTOCOL_VERSION_MISMATCH,
|
||||
NOT_AUTHORIZED, TIMEOUT];
|
||||
var error = -1;
|
||||
var timer = null;
|
||||
|
||||
function getOopsText() {
|
||||
error = Window.getLastDomainConnectionError();
|
||||
if (hardRefusalErrors.indexOf(error) >= 0) {
|
||||
return ERROR_MESSAGE_MAP[error];
|
||||
} else {
|
||||
// some other text.
|
||||
return ERROR_MESSAGE_MAP[4];
|
||||
}
|
||||
};
|
||||
|
||||
var redirectOopsText = Overlays.addOverlay("text3d", {
|
||||
name: "oopsText",
|
||||
// position: { x: 0.2656, y: 1.6764, z: 1.4593},
|
||||
position: { x: 0.0, y: 1.6764, z: 1.4593},
|
||||
text: getOopsText(),
|
||||
textAlpha: 1,
|
||||
backgroundAlpha: 0,
|
||||
lineHeight: 0.13,
|
||||
// dimensions: {x: 2.58, y: 2.58},
|
||||
visible: false,
|
||||
emissive: true,
|
||||
ignoreRayIntersection: false,
|
||||
drawInFront: true,
|
||||
grabbable: false,
|
||||
orientation: {x: 0.0, y: 0.5, z: 0, w: 0.87},
|
||||
parentID: MyAvatar.SELF_ID
|
||||
});
|
||||
print("redirect oops text = " + redirectOopsText);
|
||||
|
||||
var tryAgainImage = Overlays.addOverlay("image3d", {
|
||||
name: "tryAgainImage",
|
||||
position: { x: 0.0, y: 1.0695, z: 1.9094},
|
||||
url: Script.resourcesPath() + "images/interstitialPage/button_tryAgain.png",
|
||||
alpha: 1,
|
||||
// dimensions: {x: 0.9, y: 0.4},
|
||||
visible: false,
|
||||
emissive: true,
|
||||
ignoreRayIntersection: false,
|
||||
drawInFront: true,
|
||||
grabbable: false,
|
||||
orientation: {x: 0.0, y: 0.5, z: 0, w: 0.87},
|
||||
parentID: MyAvatar.SELF_ID
|
||||
});
|
||||
print("try again image = " + tryAgainImage);
|
||||
|
||||
var backImage = Overlays.addOverlay("image3d", {
|
||||
name: "backImage",
|
||||
position: { x: 0.525, y: 1.0695, z: 1.0186},
|
||||
url: Script.resourcesPath() + "images/interstitialPage/button_back.png",
|
||||
alpha: 1,
|
||||
// dimensions: {x: 0.9, y: 0.4},
|
||||
visible: false,
|
||||
emissive: true,
|
||||
ignoreRayIntersection: false,
|
||||
drawInFront: true,
|
||||
grabbable: false,
|
||||
localOrientation: Quat.fromVec3Degrees({ x: 0.0, y: 180.0, z: 0.0 }),
|
||||
orientation: {x: 0.0, y: 0.5, z: 0, w: 0.87},
|
||||
parentID: MyAvatar.SELF_ID
|
||||
});
|
||||
print("back image = " + backImage);
|
||||
|
||||
var TARGET_UPDATE_HZ = 60;
|
||||
var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ;
|
||||
|
||||
function toggleOverlays() {
|
||||
var overlaysVisible = false;
|
||||
error = Window.getLastDomainConnectionError();
|
||||
var oopsText = "";
|
||||
if (error === -1) {
|
||||
overlaysVisible = false;
|
||||
} else if (hardRefusalErrors.indexOf(error) >= 0) {
|
||||
overlaysVisible = true;
|
||||
oopsText = ERROR_MESSAGE_MAP[error];
|
||||
} else {
|
||||
overlaysVisible = true;
|
||||
oopsText = ERROR_MESSAGE_MAP[4];
|
||||
}
|
||||
var properties = {
|
||||
visible: overlaysVisible
|
||||
};
|
||||
var oopsTextProperties = {
|
||||
visible: overlaysVisible,
|
||||
text: oopsText
|
||||
};
|
||||
|
||||
Overlays.editOverlay(redirectOopsText, oopsTextProperties);
|
||||
Overlays.editOverlay(tryAgainImage, properties);
|
||||
Overlays.editOverlay(backImage, properties)
|
||||
}
|
||||
|
||||
function clickedOnOverlay(overlayID, event) {
|
||||
if (tryAgainImage === overlayID) {
|
||||
location.goToLastAddress();
|
||||
} else if (backImage === overlayID) {
|
||||
location.goBack();
|
||||
}
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
timer = null;
|
||||
Overlays.deleteOverlay(redirectOopsText);
|
||||
Overlays.deleteOverlay(tryAgainImage);
|
||||
Overlays.deleteOverlay(backImage);
|
||||
}
|
||||
|
||||
var whiteColor = {red: 255, green: 255, blue: 255};
|
||||
var greyColor = {red: 125, green: 125, blue: 125};
|
||||
Overlays.mouseReleaseOnOverlay.connect(clickedOnOverlay);
|
||||
Overlays.hoverEnterOverlay.connect(function(overlayID, event) {
|
||||
if (overlayID === backImage || overlayID === tryAgainImage) {
|
||||
Overlays.editOverlay(overlayID, { color: greyColor });
|
||||
}
|
||||
});
|
||||
|
||||
Overlays.hoverLeaveOverlay.connect(function(overlayID, event) {
|
||||
if (overlayID === backImage || overlayID === tryAgainImage) {
|
||||
Overlays.editOverlay(overlayID, { color: whiteColor });
|
||||
}
|
||||
});
|
||||
|
||||
// timer = Script.setTimeout(update, BASIC_TIMER_INTERVAL_MS);
|
||||
Script.update.connect(toggleOverlays);
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
}());
|
Loading…
Reference in a new issue