Added polaroids to snapshots

This commit is contained in:
seefo 2017-06-01 16:48:38 -07:00
parent 3fdad14ca4
commit 4e190434d1
6 changed files with 249 additions and 1 deletions

Binary file not shown.

View file

@ -28,7 +28,11 @@
</form>
</div>
<input type="button" id="snap-button" onclick="takeSnapshot()" />
<div id="snap-settings-right"></div>
<div id="snap-settings-right">
<button type="image" class="blueButton" id="print-button" onclick="printToPolaroid()">
<div id="print-icon" class="print-icon-enabled">
</button>
</div>
</div>
</body>
</html>

View file

@ -286,6 +286,50 @@ input[type=button].naked:active {
// END styling of snapshot controls (bottom panel) and its contents
*/
/*
// START polaroid styling
*/
#print-button {
width: 72px;
height: 72px;
margin-left: 30px;
margin-top: -10px;
box-sizing: content-box;
display: inline;
outline:none;
}
.print-icon-enabled {
background: url(../img/button-snap-print.svg);
background-repeat: no-repeat;
margin: auto;
width: 48px;
height: 48px;
}
.print-icon-loading {
background: url(../img/loader.gif);
background-repeat: no-repeat;
margin: auto;
width: 32px;
height: 32px;
}
.print-icon-disabled {
background: url(../img/button-snap-print.svg);
background-repeat: no-repeat;
margin: auto;
width: 48px;
height: 48px;
}
/*
// END polaroid styling
*/
/*
// START misc styling
*/

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 199.8 231" style="enable-background:new 0 0 199.8 231;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<g>
<g>
<path class="st0" d="M146.7,145.3H48V50.1h98.8V145.3z M56.2,122.8h83.1V57.6H56.2V122.8z"/>
<circle class="st0" cx="96.8" cy="83.5" r="10.9"/>
<path class="st0" d="M116.9,112.8h-40v-1.2c0-6.5,5.9-11.8,12.5-11.8H105c6.5,0,11.8,5.3,11.8,11.8V112.8z"/>
<polygon class="st0" points="155.5,80.6 155.5,125.7 170.9,39.2 74.6,19.6 70.3,43.7 78.3,43.7 81,28.8 161.7,45.6 "/>
</g>
<g>
<path class="st0" d="M12.4,213.7v-29.8h14c6.5,0,10,4.4,10,9.6c0,5.2-3.6,9.6-10,9.6h-7.6v10.6H12.4z M29.9,193.4
c0-2.5-1.9-4-4.4-4h-6.7v8h6.7C28,197.4,29.9,195.9,29.9,193.4z"/>
<path class="st0" d="M69.9,213.7L64,203.1h-4.7v10.6H53v-29.8h14c6.2,0,10.1,4.1,10.1,9.6c0,5.2-3.4,8.1-6.6,8.9l6.8,11.4H69.9z
M70.5,193.4c0-2.5-1.9-4-4.4-4h-6.7v8.1h6.7C68.6,197.5,70.5,195.9,70.5,193.4z"/>
<path class="st0" d="M94.4,213.7v-29.8h6.4v29.8H94.4z"/>
<path class="st0" d="M139.8,213.7l-14.2-19.5v19.5h-6.4v-29.8h6.5l13.8,18.7v-18.7h6.4v29.8H139.8z"/>
<path class="st0" d="M171.4,213.7v-24.2h-8.7v-5.6h23.8v5.6h-8.7v24.2H171.4z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -311,6 +311,9 @@ function addImage(image_data, isLoggedIn, canShare, isGifLoading, isShowingPrevi
if (isShowingPreviousImages && isLoggedIn && image_data.story_id) {
updateShareInfo(id, image_data.story_id);
}
if(isShowingPreviousImages) {
requestPrintButtonUpdate();
}
};
img.onerror = function () {
img.onload = null;
@ -670,10 +673,22 @@ window.onload = function () {
break;
case 'captureSettings':
handleCaptureSetting(message.setting);
break;
case 'setPrintButtonEnabled':
setPrintButtonEnabled();
break;
case 'setPrintButtonLoading':
setPrintButtonLoading();
break;
case 'setPrintButtonDisabled':
setPrintButtonDisabled();
break;
case 'snapshotUploadComplete':
var isGif = fileExtensionMatches(message.image_url, "gif");
updateShareInfo(isGif ? "p1" : "p0", message.story_id);
if (isPrintProcessing()) {
setPrintButtonEnabled();
}
break;
default:
console.log("Unknown message action received in SnapshotReview.js.");
@ -703,6 +718,48 @@ function takeSnapshot() {
}
}
function isPrintDisabled() { return document.getElementById('print-icon').className === "print-icon-disabled"; }
function isPrintProcessing() { return document.getElementById('print-icon').className === "print-icon-loading"; }
function isPrintEnabled() { return document.getElementById('print-icon').className === "print-icon-enabled"; }
function setPrintButtonLoading() {
document.getElementById('print-icon').className = "print-icon-loading";
document.getElementById('print-button').disabled = true;
}
function setPrintButtonDisabled() {
document.getElementById('print-icon').className = "print-icon-disabled";
document.getElementById('print-button').disabled = true;
}
function setPrintButtonEnabled() {
document.getElementById('print-button').disabled = false;
document.getElementById('print-icon').className = "print-icon-enabled";
}
function requestPrintButtonUpdate() {
EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot",
action: "requestPrintButtonUpdate"
}));
}
function printToPolaroid() {
if (isPrintEnabled()) {
EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot",
action: "printToPolaroid"
}));
//shareBarHelp.innerHTML = "Printed"
//shareBarHelp.style.backgroundColor = "#000000";
//shareBarHelp.style.opacity = "0.5";
} else {
setPrintButtonLoading();
}
}
function testInBrowser(test) {
if (test === 0) {
showSetupInstructions();

View file

@ -99,11 +99,13 @@ function onMessage(message) {
Settings.setValue("previousStillSnapStoryID", "");
Settings.setValue("previousStillSnapBlastingDisabled", false);
Settings.setValue("previousStillSnapHifiSharingDisabled", false);
Settings.setValue("previousStillSnapUrl", "");
Settings.setValue("previousAnimatedSnapPath", "");
Settings.setValue("previousAnimatedSnapStoryID", "");
Settings.setValue("previousAnimatedSnapBlastingDisabled", false);
Settings.setValue("previousAnimatedSnapHifiSharingDisabled", false);
}
updatePrintPermissions();
break;
case 'login':
openLoginWindow();
@ -144,6 +146,7 @@ function onMessage(message) {
isLoggedIn = Account.isLoggedIn();
if (isLoggedIn) {
print('Sharing snapshot with audience "for_url":', message.data);
isUploadingPrintableStill = true;
Window.shareSnapshot(message.data, Settings.getValue("previousSnapshotHref"));
var isGif = fileExtensionMatches(message.data, "gif");
if (isGif) {
@ -153,9 +156,14 @@ function onMessage(message) {
}
} else {
shareAfterLogin = true;
isUploadingPrintableStill = false;
snapshotToShareAfterLogin.push({ path: message.data, href: Settings.getValue("previousSnapshotHref") });
}
} else {
isUploadingPrintableStill = false;
}
updatePrintPermissions();
});
break;
case 'blastToConnections':
@ -214,6 +222,17 @@ function onMessage(message) {
}
});
}
break;
case 'requestPrintButtonUpdate':
updatePrintPermissions();
break;
case 'printToPolaroid':
if(Entities.canRez() || Entities.canRezTmp()) {
printToPolaroid(Settings.getValue("previousStillSnapUrl"));
removeFromStoryIDsToMaybeDelete(Settings.getValue("previousStillSnapStoryID"));
}
break;
case 'shareSnapshotWithEveryone':
isLoggedIn = Account.isLoggedIn();
@ -262,6 +281,54 @@ function onMessage(message) {
}
}
var polaroid_print_sound = SoundCache.getSound(Script.resolvePath("assets/sounds/sound-print-photo.wav"));
var model_url = 'http://hifi-content.s3.amazonaws.com/alan/dev/Test/snapshot.fbx';
function printToPolaroid(image_url) {
var polaroid_url = image_url;
var model_pos = Vec3.sum(MyAvatar.position, Vec3.multiply(0.75, Quat.getForward(MyAvatar.orientation)));
var model_q1 = MyAvatar.orientation;
var model_q2 = Quat.angleAxis(90, Quat.getRight(model_q1));
var model_rot = Quat.multiply(model_q2, model_q1);
var properties = {
"type": 'Model',
"shapeType": 'box',
"name": "New Snapshot",
"description": "Printed from Snaps",
"modelURL": model_url,
"position": model_pos,
"rotation": model_rot,
"textures": JSON.stringify( { "tex.picture": polaroid_url } ),
"density": 200,
"restitution": 0.15,
"gravity": { "x": 0, "y": -1, "z": 0 },
"linear_accleration" : { "x": 0, "y": 2.0, "z": 0 },
"dynamic": true,
"collisionsWillMove": true,
"userData": {
"grabbableKey": { "grabbable" : true }
}
};
var polaroid = Entities.addEntity(properties);
Audio.playSound(polaroid_print_sound, {
position: model_pos,
localOnly: false,
volume: 0.2
});
}
function fillImageDataFromPrevious() {
isLoggedIn = Account.isLoggedIn();
var previousStillSnapPath = Settings.getValue("previousStillSnapPath");
@ -349,6 +416,7 @@ function snapshotUploaded(isError, reply) {
Settings.setValue("previousAnimatedSnapStoryID", storyID);
} else {
Settings.setValue("previousStillSnapStoryID", storyID);
Settings.setValue("previousStillSnapUrl", imageURL);
}
} else {
print('Ignoring snapshotUploaded() callback for stale ' + (isGif ? 'GIF' : 'Still' ) + ' snapshot. Stale story ID:', storyID);
@ -356,6 +424,7 @@ function snapshotUploaded(isError, reply) {
} else {
print(reply);
}
isUploadingPrintableStill = false;
}
var href, domainId;
function takeSnapshot() {
@ -367,10 +436,13 @@ function takeSnapshot() {
Settings.setValue("previousStillSnapStoryID", "");
Settings.setValue("previousStillSnapBlastingDisabled", false);
Settings.setValue("previousStillSnapHifiSharingDisabled", false);
Settings.setValue("previousStillSnapUrl", "");
Settings.setValue("previousAnimatedSnapPath", "");
Settings.setValue("previousAnimatedSnapStoryID", "");
Settings.setValue("previousAnimatedSnapBlastingDisabled", false);
Settings.setValue("previousAnimatedSnapHifiSharingDisabled", false);
isUploadingPrintableStill = false;
// 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).
@ -442,6 +514,7 @@ function isDomainOpen(id, callback) {
status = response.total_entries ? true : false;
}
print("Domain open status:", status);
wasPreviousSnapshotShareable = status;
callback(status);
});
} else {
@ -604,7 +677,12 @@ function onUsernameChanged() {
numStillSnapshotUploadsPending++;
}
});
isUploadingPrintableStill = true;
} else {
isUploadingPrintableStill = false;
}
updatePrintPermissions();
});
shareAfterLogin = false;
@ -612,6 +690,7 @@ function onUsernameChanged() {
}
}
}
function snapshotLocationSet(location) {
if (location !== "") {
tablet.emitScriptEvent(JSON.stringify({
@ -621,12 +700,48 @@ function snapshotLocationSet(location) {
}
}
function updatePrintPermissions() {
processRezPermissionChange(Entities.canRez() || Entities.canRezTmp());
}
var isUploadingPrintableStill = false;
function processRezPermissionChange(canRez) {
print('can we rez0?' + canRez);
print('can we rez1?' + Settings.getValue("previousStillSnapUrl")) ;
print('can we rez2?' + isUploadingPrintableStill);
var action = "";
if(canRez) {
if(Settings.getValue("previousStillSnapUrl")) {
action = 'setPrintButtonEnabled';
} else if(isUploadingPrintableStill) {
action = 'setPrintButtonLoading';
} else {
action = 'setPrintButtonDisabled';
}
} else {
action = 'setPrintButtonDisabled';
}
tablet.emitScriptEvent(JSON.stringify({
type: "snapshot",
action : action
}));
}
button.clicked.connect(onButtonClicked);
buttonConnected = true;
Window.snapshotShared.connect(snapshotUploaded);
tablet.screenChanged.connect(onTabletScreenChanged);
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
Snapshot.snapshotLocationSet.connect(snapshotLocationSet);
Entities.canRezChanged.connect(processRezPermissionChange);
Entities.canRezTmpChanged.connect(processRezPermissionChange);
Script.scriptEnding.connect(function () {
if (buttonConnected) {
button.clicked.disconnect(onButtonClicked);
@ -638,6 +753,9 @@ Script.scriptEnding.connect(function () {
Window.snapshotShared.disconnect(snapshotUploaded);
tablet.screenChanged.disconnect(onTabletScreenChanged);
Snapshot.snapshotLocationSet.disconnect(snapshotLocationSet);
Entities.canRezChanged.disconnect(processRezPermissionChange);
Entities.canRezTmpChanged.disconnect(processRezPermissionChange);
});
}()); // END LOCAL_SCOPE