Merge branch 'master' of github.com:highfidelity/hifi into record-standard

This commit is contained in:
Dante Ruiz 2017-06-01 22:34:57 +01:00
commit 6bc53388f8
3 changed files with 62 additions and 24 deletions

View file

@ -234,7 +234,7 @@ namespace controller {
for (int actionIndex = 0; actionIndex < actionArrayList.size(); actionIndex++) { for (int actionIndex = 0; actionIndex < actionArrayList.size(); actionIndex++) {
QJsonArray actionState = actionArrayList[actionIndex].toArray(); QJsonArray actionState = actionArrayList[actionIndex].toArray();
for (int index = 0; index < actionState.size(); index++) { for (int index = 0; index < actionState.size(); index++) {
QJsonObject actionObject = actionState[index].toObject();; QJsonObject actionObject = actionState[index].toObject();
_currentFrameActions[actionObject["name"].toString()] = actionObject["value"].toDouble(); _currentFrameActions[actionObject["name"].toString()] = actionObject["value"].toDouble();
} }
_actionStateList.push_back(_currentFrameActions); _actionStateList.push_back(_currentFrameActions);

View file

@ -21,6 +21,11 @@ var blastShareText = "Blast to my Connections",
hifiAlreadySharedText = "Already Shared to Snaps Feed", hifiAlreadySharedText = "Already Shared to Snaps Feed",
facebookShareText = "Share to Facebook", facebookShareText = "Share to Facebook",
twitterShareText = "Share to Twitter"; twitterShareText = "Share to Twitter";
function fileExtensionMatches(filePath, extension) {
return filePath.split('.').pop().toLowerCase() === extension;
}
function showSetupInstructions() { function showSetupInstructions() {
var snapshotImagesDiv = document.getElementById("snapshot-images"); var snapshotImagesDiv = document.getElementById("snapshot-images");
snapshotImagesDiv.className = "snapshotInstructions"; snapshotImagesDiv.className = "snapshotInstructions";
@ -276,10 +281,10 @@ function addImage(image_data, isLoggedIn, canShare, isGifLoading, isShowingPrevi
if (!image_data.localPath) { if (!image_data.localPath) {
return; return;
} }
var id = "p" + (idCounter++), var imageContainer = document.createElement("DIV"),
imageContainer = document.createElement("DIV"),
img = document.createElement("IMG"), img = document.createElement("IMG"),
isGif; isGif = fileExtensionMatches(image_data.localPath, "gif"),
id = "p" + (isGif ? "1" : "0");
imageContainer.id = id; imageContainer.id = id;
imageContainer.style.width = "95%"; imageContainer.style.width = "95%";
imageContainer.style.height = "240px"; imageContainer.style.height = "240px";
@ -290,18 +295,17 @@ function addImage(image_data, isLoggedIn, canShare, isGifLoading, isShowingPrevi
imageContainer.style.position = "relative"; imageContainer.style.position = "relative";
img.id = id + "img"; img.id = id + "img";
img.src = image_data.localPath; img.src = image_data.localPath;
isGif = img.src.split('.').pop().toLowerCase() === "gif";
imageContainer.appendChild(img); imageContainer.appendChild(img);
document.getElementById("snapshot-images").appendChild(imageContainer); document.getElementById("snapshot-images").appendChild(imageContainer);
paths.push(image_data.localPath);
img.onload = function () { img.onload = function () {
paths.push(image_data.localPath);
if (isGif) { if (isGif) {
imageContainer.innerHTML += '<span class="gifLabel">GIF</span>'; imageContainer.innerHTML += '<span class="gifLabel">GIF</span>';
} }
if (!isGifLoading) { if (!isGifLoading) {
appendShareBar(id, isLoggedIn, canShare, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast); appendShareBar(id, isLoggedIn, canShare, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast);
} }
if (!isGifLoading || (isShowingPreviousImages && !image_data.story_id)) { if ((!isShowingPreviousImages && ((isGif && !isGifLoading) || !isGif)) || (isShowingPreviousImages && !image_data.story_id)) {
shareForUrl(id); shareForUrl(id);
} }
if (isShowingPreviousImages && isLoggedIn && image_data.story_id) { if (isShowingPreviousImages && isLoggedIn && image_data.story_id) {
@ -638,9 +642,8 @@ window.onload = function () {
// The last element of the message contents list contains a bunch of options, // The last element of the message contents list contains a bunch of options,
// including whether or not we can share stuff // including whether or not we can share stuff
// The other elements of the list contain image paths. // The other elements of the list contain image paths.
if (messageOptions.containsGif === true) {
if (messageOptions.containsGif) { if (messageOptions.processingGif === true) {
if (messageOptions.processingGif) {
imageCount = message.image_data.length + 1; // "+1" for the GIF that'll finish processing soon imageCount = message.image_data.length + 1; // "+1" for the GIF that'll finish processing soon
message.image_data.push({ localPath: messageOptions.loadingGifPath }); message.image_data.push({ localPath: messageOptions.loadingGifPath });
message.image_data.forEach(function (element, idx) { message.image_data.forEach(function (element, idx) {
@ -669,7 +672,7 @@ window.onload = function () {
handleCaptureSetting(message.setting); handleCaptureSetting(message.setting);
break; break;
case 'snapshotUploadComplete': case 'snapshotUploadComplete':
var isGif = message.image_url.split('.').pop().toLowerCase() === "gif"; var isGif = fileExtensionMatches(message.image_url, "gif");
updateShareInfo(isGif ? "p1" : "p0", message.story_id); updateShareInfo(isGif ? "p1" : "p0", message.story_id);
break; break;
default: default:

View file

@ -36,6 +36,8 @@ var shareAfterLogin = false;
var snapshotToShareAfterLogin = []; var snapshotToShareAfterLogin = [];
var METAVERSE_BASE = location.metaverseServerUrl; var METAVERSE_BASE = location.metaverseServerUrl;
var isLoggedIn; var isLoggedIn;
var numGifSnapshotUploadsPending = 0;
var numStillSnapshotUploadsPending = 0;
// It's totally unnecessary to return to C++ to perform many of these requests, such as DELETEing an old story, // It's totally unnecessary to return to C++ to perform many of these requests, such as DELETEing an old story,
// POSTING a new one, PUTTING a new audience, or GETTING story data. It's far more efficient to do all of that within JS // POSTING a new one, PUTTING a new audience, or GETTING story data. It's far more efficient to do all of that within JS
@ -56,6 +58,10 @@ function removeFromStoryIDsToMaybeDelete(story_id) {
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete)); print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
} }
function fileExtensionMatches(filePath, extension) {
return filePath.split('.').pop().toLowerCase() === extension;
}
function onMessage(message) { function onMessage(message) {
// Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following: // Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following:
// 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.) // 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.)
@ -139,6 +145,12 @@ function onMessage(message) {
if (isLoggedIn) { if (isLoggedIn) {
print('Sharing snapshot with audience "for_url":', message.data); print('Sharing snapshot with audience "for_url":', message.data);
Window.shareSnapshot(message.data, Settings.getValue("previousSnapshotHref")); Window.shareSnapshot(message.data, Settings.getValue("previousSnapshotHref"));
var isGif = fileExtensionMatches(message.data, "gif");
if (isGif) {
numGifSnapshotUploadsPending++;
} else {
numStillSnapshotUploadsPending++;
}
} else { } else {
shareAfterLogin = true; shareAfterLogin = true;
snapshotToShareAfterLogin.push({ path: message.data, href: Settings.getValue("previousSnapshotHref") }); snapshotToShareAfterLogin.push({ path: message.data, href: Settings.getValue("previousSnapshotHref") });
@ -307,22 +319,39 @@ function onButtonClicked() {
function snapshotUploaded(isError, reply) { function snapshotUploaded(isError, reply) {
if (!isError) { if (!isError) {
var replyJson = JSON.parse(reply); var replyJson = JSON.parse(reply),
var storyID = replyJson.user_story.id; storyID = replyJson.user_story.id,
imageURL = replyJson.user_story.details.image_url,
isGif = fileExtensionMatches(imageURL, "gif"),
ignoreGifSnapshotData = false,
ignoreStillSnapshotData = false;
storyIDsToMaybeDelete.push(storyID); storyIDsToMaybeDelete.push(storyID);
var imageURL = replyJson.user_story.details.image_url;
var isGif = imageURL.split('.').pop().toLowerCase() === "gif";
print('SUCCESS: Snapshot uploaded! Story with audience:for_url created! ID:', storyID);
tablet.emitScriptEvent(JSON.stringify({
type: "snapshot",
action: "snapshotUploadComplete",
story_id: storyID,
image_url: imageURL,
}));
if (isGif) { if (isGif) {
Settings.setValue("previousAnimatedSnapStoryID", storyID); numGifSnapshotUploadsPending--;
if (numGifSnapshotUploadsPending !== 0) {
ignoreGifSnapshotData = true;
}
} else { } else {
Settings.setValue("previousStillSnapStoryID", storyID); numStillSnapshotUploadsPending--;
if (numStillSnapshotUploadsPending !== 0) {
ignoreStillSnapshotData = true;
}
}
if ((isGif && !ignoreGifSnapshotData) || (!isGif && !ignoreStillSnapshotData)) {
print('SUCCESS: Snapshot uploaded! Story with audience:for_url created! ID:', storyID);
tablet.emitScriptEvent(JSON.stringify({
type: "snapshot",
action: "snapshotUploadComplete",
story_id: storyID,
image_url: imageURL,
}));
if (isGif) {
Settings.setValue("previousAnimatedSnapStoryID", storyID);
} else {
Settings.setValue("previousStillSnapStoryID", storyID);
}
} else {
print('Ignoring snapshotUploaded() callback for stale ' + (isGif ? 'GIF' : 'Still' ) + ' snapshot. Stale story ID:', storyID);
} }
} else { } else {
print(reply); print(reply);
@ -568,6 +597,12 @@ function onUsernameChanged() {
snapshotToShareAfterLogin.forEach(function (element) { snapshotToShareAfterLogin.forEach(function (element) {
print('Uploading snapshot after login:', element.path); print('Uploading snapshot after login:', element.path);
Window.shareSnapshot(element.path, element.href); Window.shareSnapshot(element.path, element.href);
var isGif = fileExtensionMatches(element.path, "gif");
if (isGif) {
numGifSnapshotUploadsPending++;
} else {
numStillSnapshotUploadsPending++;
}
}); });
} }
}); });