From f838e87f4891627ca64637395148964174a301fd Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 24 Apr 2017 15:59:19 -0700 Subject: [PATCH] Pretty stable... --- scripts/system/html/css/SnapshotReview.css | 1 + scripts/system/html/js/SnapshotReview.js | 12 +++--- scripts/system/snapshot.js | 44 +++++++++++++--------- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/scripts/system/html/css/SnapshotReview.css b/scripts/system/html/css/SnapshotReview.css index 1e233b22f3..859b4d8c90 100644 --- a/scripts/system/html/css/SnapshotReview.css +++ b/scripts/system/html/css/SnapshotReview.css @@ -11,6 +11,7 @@ body { padding: 0; margin: 0; + overflow: hidden; } /* diff --git a/scripts/system/html/js/SnapshotReview.js b/scripts/system/html/js/SnapshotReview.js index d5cc9faf74..9fa58e6d33 100644 --- a/scripts/system/html/js/SnapshotReview.js +++ b/scripts/system/html/js/SnapshotReview.js @@ -23,7 +23,7 @@ function clearImages() { imageCount = 0; idCounter = 0; } -function addImage(image_data, isGifLoading, canSharePreviousImages) { +function addImage(image_data, isGifLoading, isShowingPreviousImages, canSharePreviousImages) { if (!image_data.localPath) { return; } @@ -46,9 +46,9 @@ function addImage(image_data, isGifLoading, canSharePreviousImages) { document.getElementById("snapshot-images").appendChild(div); var isGif = img.src.split('.').pop().toLowerCase() === "gif"; paths.push(image_data.localPath); - if (!isGifLoading && !canSharePreviousImages) { + if (!isGifLoading && !isShowingPreviousImages) { shareForUrl(id); - } else if (canSharePreviousImages) { + } else if (isShowingPreviousImages && canSharePreviousImages) { appendShareBar(id, image_data.story_id, isGif) } } @@ -233,7 +233,7 @@ window.onload = function () { var messageOptions = message.options; imageCount = message.image_data.length; message.image_data.forEach(function (element, idx, array) { - addImage(element, true, message.canShare); + addImage(element, true, true, message.canShare); }); break; case 'addImages': @@ -247,7 +247,7 @@ window.onload = function () { imageCount = message.image_data.length + 1; // "+1" for the GIF that'll finish processing soon message.image_data.unshift({ localPath: messageOptions.loadingGifPath }); message.image_data.forEach(function (element, idx, array) { - addImage(element, idx === 0); + addImage(element, idx === 0, false, false); }); } else { var gifPath = message.image_data[0].localPath; @@ -260,7 +260,7 @@ window.onload = function () { } else { imageCount = message.image_data.length; message.image_data.forEach(function (element, idx, array) { - addImage(element, false); + addImage(element, false, false, false); }); } break; diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 39fc45556e..422c557391 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -240,6 +240,15 @@ function snapshotUploaded(isError, reply) { } var href, domainId; function takeSnapshot() { + tablet.emitScriptEvent(JSON.stringify({ + type: "snapshot", + action: "clearPreviousImages" + })); + Settings.setValue("previousStillSnapPath", ""); + Settings.setValue("previousStillSnapStoryID", ""); + Settings.setValue("previousAnimatedSnapPath", ""); + Settings.setValue("previousAnimatedSnapStoryID", ""); + // Raising the desktop for the share dialog at end will interact badly with clearOverlayWhenMoving. // Turn it off now, before we start futzing with things (and possibly moving). clearOverlayWhenMoving = MyAvatar.getClearOverlayWhenMoving(); // Do not use Settings. MyAvatar keeps a separate copy. @@ -252,22 +261,22 @@ function takeSnapshot() { Settings.setValue("previousSnapshotDomainID", domainId); maybeDeleteSnapshotStories(); - tablet.emitScriptEvent(JSON.stringify({ - type: "snapshot", - action: "clearPreviousImages" - })); - Settings.setValue("previousStillSnapPath", ""); - Settings.setValue("previousStillSnapStoryID", ""); - Settings.setValue("previousAnimatedSnapPath", ""); - Settings.setValue("previousAnimatedSnapStoryID", ""); // update button states - resetOverlays = Menu.isOptionChecked("Overlays"); // For completness. Certainly true if the button is visible to be clicked. + resetOverlays = Menu.isOptionChecked("Overlays"); // For completeness. Certainly true if the button is visible to be clicked. reticleVisible = Reticle.visible; Reticle.visible = false; - Window.stillSnapshotTaken.connect(stillSnapshotTaken); - Window.processingGifStarted.connect(processingGifStarted); - Window.processingGifCompleted.connect(processingGifCompleted); + + var includeAnimated = Settings.getValue("alsoTakeAnimatedSnapshot", true); + if (includeAnimated) { + Window.processingGifStarted.connect(processingGifStarted); + } else { + Window.stillSnapshotTaken.connect(stillSnapshotTaken); + } + if (buttonConnected) { + button.clicked.disconnect(openSnapApp); + buttonConnected = false; + } // hide overlays if they are on if (resetOverlays) { @@ -278,7 +287,7 @@ function takeSnapshot() { Script.setTimeout(function () { HMD.closeTablet(); Script.setTimeout(function () { - Window.takeSnapshot(false, Settings.getValue("alsoTakeAnimatedSnapshot", true), 1.91); + Window.takeSnapshot(false, includeAnimated, 1.91); }, SNAPSHOT_DELAY); }, FINISH_SOUND_DELAY); } @@ -315,6 +324,10 @@ function stillSnapshotTaken(pathStillSnapshot, notify) { Menu.setIsOptionChecked("Overlays", true); } Window.stillSnapshotTaken.disconnect(stillSnapshotTaken); + if (!buttonConnected) { + button.clicked.connect(openSnapApp); + buttonConnected = true; + } // A Snapshot Review dialog might be left open indefinitely after taking the picture, // during which time the user may have moved. So stash that info in the dialog so that @@ -343,10 +356,7 @@ function stillSnapshotTaken(pathStillSnapshot, notify) { function processingGifStarted(pathStillSnapshot) { Window.processingGifStarted.disconnect(processingGifStarted); - if (buttonConnected) { - button.clicked.disconnect(openSnapApp); - buttonConnected = false; - } + Window.processingGifCompleted.connect(processingGifCompleted); // show hud Reticle.visible = reticleVisible; // show overlays if they were on