Merge pull request #14225 from wayne-chen/interstitialHideProgressJS-RC75

hide progress overlays if interstitial mode
This commit is contained in:
Brad Hefta-Gaub 2018-10-19 16:35:42 -07:00 committed by GitHub
commit 1ff69844f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 7 deletions

View file

@ -3534,6 +3534,7 @@ void Application::setIsInterstitialMode(bool interstitialMode) {
if (enableInterstitial) { if (enableInterstitial) {
if (_interstitialMode != interstitialMode) { if (_interstitialMode != interstitialMode) {
_interstitialMode = interstitialMode; _interstitialMode = interstitialMode;
emit interstitialModeChanged(_interstitialMode);
DependencyManager::get<AudioClient>()->setAudioPaused(_interstitialMode); DependencyManager::get<AudioClient>()->setAudioPaused(_interstitialMode);
DependencyManager::get<AvatarManager>()->setMyAvatarDataPacketsPaused(_interstitialMode); DependencyManager::get<AvatarManager>()->setMyAvatarDataPacketsPaused(_interstitialMode);

View file

@ -335,6 +335,8 @@ signals:
void uploadRequest(QString path); void uploadRequest(QString path);
void interstitialModeChanged(bool isInInterstitialMode);
void loginDialogPoppedUp(); void loginDialogPoppedUp();
public slots: public slots:

View file

@ -54,6 +54,9 @@ WindowScriptingInterface::WindowScriptingInterface() {
}); });
connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &WindowScriptingInterface::onWindowGeometryChanged); connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &WindowScriptingInterface::onWindowGeometryChanged);
connect(qApp, &Application::interstitialModeChanged, [this] (bool interstitialMode) {
emit interstitialModeChanged(interstitialMode);
});
} }
WindowScriptingInterface::~WindowScriptingInterface() { WindowScriptingInterface::~WindowScriptingInterface() {

View file

@ -619,6 +619,14 @@ signals:
*/ */
void redirectErrorStateChanged(bool isInErrorState); void redirectErrorStateChanged(bool isInErrorState);
/**jsdoc
* Triggered when interstitial mode changes.
* @function Window.interstitialModeChanged
* @param {bool} interstitialMode - The mode of the interstitial is changed to.
* @returns {Signal}
*/
void interstitialModeChanged(bool interstitialMode);
/**jsdoc /**jsdoc
* Triggered when a still snapshot has been taken by calling {@link Window.takeSnapshot|takeSnapshot} with * Triggered when a still snapshot has been taken by calling {@link Window.takeSnapshot|takeSnapshot} with
* <code>includeAnimated = false</code> or {@link Window.takeSecondaryCameraSnapshot|takeSecondaryCameraSnapshot}. * <code>includeAnimated = false</code> or {@link Window.takeSecondaryCameraSnapshot|takeSecondaryCameraSnapshot}.

View file

@ -14,6 +14,7 @@
(function() { (function() {
Script.include("/~/system/libraries/Xform.js"); Script.include("/~/system/libraries/Xform.js");
Script.include("/~/system/libraries/globals.js");
var DEBUG = false; var DEBUG = false;
var MIN_LOADING_PROGRESS = 3.6; var MIN_LOADING_PROGRESS = 3.6;
var TOTAL_LOADING_PROGRESS = 3.8; var TOTAL_LOADING_PROGRESS = 3.8;
@ -379,6 +380,12 @@
var currentProgress = 0.1; var currentProgress = 0.1;
function updateOverlays(physicsEnabled) { function updateOverlays(physicsEnabled) {
if (isInterstitialOverlaysVisible !== !physicsEnabled && !physicsEnabled === true) {
// visible changed to true.
isInterstitialOverlaysVisible = !physicsEnabled;
}
var properties = { var properties = {
visible: !physicsEnabled visible: !physicsEnabled
}; };
@ -425,6 +432,11 @@
if (physicsEnabled) { if (physicsEnabled) {
Camera.mode = previousCameraMode; Camera.mode = previousCameraMode;
} }
if (isInterstitialOverlaysVisible !== !physicsEnabled && !physicsEnabled === false) {
// visible changed to false.
isInterstitialOverlaysVisible = !physicsEnabled;
}
} }
function scaleInterstitialPage(sensorToWorldScale) { function scaleInterstitialPage(sensorToWorldScale) {

View file

@ -9,3 +9,5 @@
// //
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
isInterstitialOverlaysVisible = false;

View file

@ -14,11 +14,11 @@
// //
(function () { // BEGIN LOCAL_SCOPE (function () { // BEGIN LOCAL_SCOPE
function debug() { function debug() {
//print.apply(null, arguments); //print.apply(null, arguments);
} }
Script.include("/~/system/libraries/globals.js");
var rawProgress = 100, // % raw value. var rawProgress = 100, // % raw value.
displayProgress = 100, // % smoothed value to display. displayProgress = 100, // % smoothed value to display.
alpha = 0.0, alpha = 0.0,
@ -83,7 +83,9 @@
// The initial delay cooldown keeps us from tracking progress before the allotted time // The initial delay cooldown keeps us from tracking progress before the allotted time
// has passed. // has passed.
INITIAL_DELAY_COOLDOWN_TIME = 1000, INITIAL_DELAY_COOLDOWN_TIME = 1000,
initialDelayCooldown = 0; initialDelayCooldown = 0,
isInInterstitialMode = false;
function fade() { function fade() {
@ -265,7 +267,7 @@
// Update state // Update state
if (!visible) { // Not visible because no recent downloads if (!visible) { // Not visible because no recent downloads
if (displayProgress < 100 || gpuTextures > 0) { // Have started downloading so fade in if ((displayProgress < 100 || gpuTextures > 0) && !isInInterstitialMode && !isInterstitialOverlaysVisible) { // Have started downloading so fade in
visible = true; visible = true;
alphaDelta = ALPHA_DELTA_IN; alphaDelta = ALPHA_DELTA_IN;
fadeTimer = Script.setInterval(fade, FADE_INTERVAL); fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
@ -305,10 +307,13 @@
} else { } else {
x = x * BAR_HMD_REPEAT; x = x * BAR_HMD_REPEAT;
} }
if (isInInterstitialMode || isInterstitialOverlaysVisible) {
visible = false;
}
// Update progress bar // Update progress bar
Overlays.editOverlay(barDesktop.overlay, { Overlays.editOverlay(barDesktop.overlay, {
visible: !isHMD, visible: !isHMD && visible,
bounds: { bounds: {
x: barDesktop.repeat - x, x: barDesktop.repeat - x,
y: windowHeight - barDesktop.height, y: windowHeight - barDesktop.height,
@ -318,7 +323,7 @@
}); });
Overlays.editOverlay(barHMD.overlay, { Overlays.editOverlay(barHMD.overlay, {
visible: isHMD, visible: isHMD && visible,
bounds: { bounds: {
x: BAR_HMD_REPEAT - x, x: BAR_HMD_REPEAT - x,
y: windowHeight - BAR_HMD_HEIGHT, y: windowHeight - BAR_HMD_HEIGHT,
@ -328,11 +333,11 @@
}); });
Overlays.editOverlay(textDesktop.overlay, { Overlays.editOverlay(textDesktop.overlay, {
visible: !isHMD visible: !isHMD && visible
}); });
Overlays.editOverlay(textHMD.overlay, { Overlays.editOverlay(textHMD.overlay, {
visible: isHMD visible: isHMD && visible
}); });
// Update 2D overlays to maintain positions at bottom middle of window // Update 2D overlays to maintain positions at bottom middle of window
@ -344,6 +349,10 @@
} }
} }
function interstitialModeChanged(inMode) {
isInInterstitialMode = inMode;
}
function setUp() { function setUp() {
var is4k = Window.innerWidth > 3000; var is4k = Window.innerWidth > 3000;
@ -369,6 +378,7 @@
} }
setUp(); setUp();
Window.interstitialModeChanged.connect(interstitialModeChanged);
GlobalServices.downloadInfoChanged.connect(onDownloadInfoChanged); GlobalServices.downloadInfoChanged.connect(onDownloadInfoChanged);
GlobalServices.updateDownloadInfo(); GlobalServices.updateDownloadInfo();
Script.setInterval(update, 1000 / 60); Script.setInterval(update, 1000 / 60);