Screenshot metadata dialog (#490)

* docs: Add json schema for screenshot metadata

* feat(.NET): Add function to open a file and read screenshot metadata to AppApi

* refactor(.NET): Check initial file dialog directory before set

Paranoia is fun

* refactor(.NET): Stop reading entire png files into memory to check 8 bytes

* refactor(.NET): Handle endianness and keyword encoding correctly for screenshots

* docs: Add xmldocs and some comments to parts of the screenshot helper

* screenshot metadata dialog

* screenshot metadata dialog 1

* fix: file dialog open bool not resetting properly

* screenshot metadata dialog 2

* fix: Stop png parser from dying on bad files

Parser would keep reading past a file's IEND chunk, and it finally found one that had junk data past IEND. It died. This fixes that.

It also encapsulates the Read function in a try/catch so VRCX doesn't crash if it fails due to a corrupted file.

* fix: buggy carousel transition animation

---------

Co-authored-by: Teacup <git@teadev.xyz>
This commit is contained in:
Natsumi
2023-02-19 10:14:29 +13:00
committed by GitHub
parent d56e00dd3c
commit 1e4b427254
6 changed files with 560 additions and 34 deletions

View File

@@ -921,7 +921,7 @@ speechSynthesis.getVoices();
this.region = '';
if ($app.isRealInstance(instanceId)) {
this.region = L.region;
if (!L.region) {
if (!L.region && L.instanceId) {
this.region = 'us';
}
}
@@ -20189,6 +20189,56 @@ speechSynthesis.getVoices();
);
};
/**
* This function should only ever be called by .NET
* Function receives an unmodified json string grabbed from the screenshot file
* Error checking and and verification of data is done in .NET already; In the case that the data/file is invalid, a JSON object with the token "error" will be returned containing a description of the problem.
* Example: {"error":"Invalid file selected. Please select a valid VRChat screenshot."}
* See docs/screenshotMetadata.json for schema
* @param {string} metadata - JSON string grabbed from PNG file
*/
$app.methods.displayScreenshotMetadata = function (metadata) {
var D = this.screenshotMetadataDialog;
var json = JSON.parse(metadata);
console.log(json);
D.metadata = json;
this.showScreenshotMetadataDialog();
};
$app.data.screenshotMetadataDialog = {
visible: false,
metadata: {}
};
$app.methods.showScreenshotMetadataDialog = function () {
this.$nextTick(() =>
adjustDialogZ(this.$refs.screenshotMetadataDialog.$el)
);
var D = this.screenshotMetadataDialog;
D.visible = true;
};
$app.methods.screenshotMetadataCarouselChange = function (index) {
var D = this.screenshotMetadataDialog;
if (index === 0) {
if (D.metadata.previousFilePath) {
AppApi.GetScreenshotMetadata(D.metadata.previousFilePath);
} else {
AppApi.GetScreenshotMetadata(D.metadata.filePath);
}
}
if (index === 2) {
if (D.metadata.nextFilePath) {
AppApi.GetScreenshotMetadata(D.metadata.nextFilePath);
} else {
AppApi.GetScreenshotMetadata(D.metadata.filePath);
}
}
if (typeof this.$refs.screenshotMetadataCarousel !== 'undefined') {
this.$refs.screenshotMetadataCarousel.setActiveItem(1);
}
};
// YouTube API
$app.data.youTubeApiKey = '';