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 = '';

View File

@@ -1403,6 +1403,7 @@ html
el-button-group
el-button(size="small" icon="el-icon-s-operation" @click="showVRChatConfig()") VRChat config.json
el-button(size="small" icon="el-icon-s-operation" @click="showLaunchOptions()") {{ $t('view.settings.advanced.advanced.launch_options') }}
el-button(size="small" icon="el-icon-picture" @click="showScreenshotMetadataDialog()") {{ $t('view.settings.advanced.advanced.screenshot_metadata') }}
div.options-container
span.sub-header {{ $t('view.settings.advanced.advanced.pending_offline.header') }}
div.options-container-item
@@ -3795,6 +3796,40 @@ html
template(#footer)
el-button(type="primary" size="small" :disabled="inviteGroupDialog.loading || !inviteGroupDialog.userIds.length" @click="sendGroupInvite()") Invite
//- dialog: screenshot metadata
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="screenshotMetadataDialog" :visible.sync="screenshotMetadataDialog.visible" :title="$t('dialog.screenshot_metadata.header')" width="1050px")
div(v-if="screenshotMetadataDialog.visible")
el-button(size="small" icon="el-icon-folder-opened" @click="AppApi.OpenScreenshotFileDialog()") {{ $t('dialog.screenshot_metadata.browse') }}
br
span(v-text="screenshotMetadataDialog.metadata.fileName")
el-tag(v-if="screenshotMetadataDialog.metadata.fileSize" type="info" effect="plain" size="mini" style="margin-left:5px" v-text="screenshotMetadataDialog.metadata.fileSize")
br
location(v-if="screenshotMetadataDialog.metadata.world" :location="screenshotMetadataDialog.metadata.world.instanceId" :hint="screenshotMetadataDialog.metadata.world.name")
br
span.x-link(v-if="screenshotMetadataDialog.metadata.author" v-text="screenshotMetadataDialog.metadata.author.displayName" @click="showUserDialog(screenshotMetadataDialog.metadata.author.id)" style="color:#909399;font-family:monospace")
br
el-carousel(ref="screenshotMetadataCarousel" :interval="0" initial-index="1" indicator-position="none" arrow="always" height="600px" style="margin-top:10px" @change="screenshotMetadataCarouselChange")
el-carousel-item
el-popover(placement="top" width="700px" trigger="click")
img.x-link(slot="reference" v-lazy="screenshotMetadataDialog.metadata.previousFilePath" style="width:100%;height:100%;object-fit:contain")
img(v-lazy="screenshotMetadataDialog.metadata.previousFilePath" style="height:700px")
el-carousel-item
el-popover(placement="top" width="700px" trigger="click")
img.x-link(slot="reference" v-lazy="screenshotMetadataDialog.metadata.filePath" style="width:100%;height:100%;object-fit:contain")
img(v-lazy="screenshotMetadataDialog.metadata.filePath" style="height:700px")
el-carousel-item
el-popover(placement="top" width="700px" trigger="click")
img.x-link(slot="reference" v-lazy="screenshotMetadataDialog.metadata.nextFilePath" style="width:100%;height:100%;object-fit:contain")
img(v-lazy="screenshotMetadataDialog.metadata.nextFilePath" style="height:700px")
br
template(v-if="screenshotMetadataDialog.metadata.error")
pre(v-text="screenshotMetadataDialog.metadata.error")
br
span(v-for="user in screenshotMetadataDialog.metadata.players" style="margin-top:5px")
span.x-link(v-text="user.displayName" @click="lookupUser(user)")
span(v-if="user.x" v-text="'('+user.x+', '+user.y+', '+user.z+')'" style="margin-left:5px;color:#909399;font-family:monospace")
br
//- dialog: open source software notice
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" :visible.sync="ossDialog" :title="$t('dialog.open_source.header')" width="650px")
div(v-if="ossDialog" style="height:350px;overflow:hidden scroll;word-break:break-all")

View File

@@ -348,6 +348,7 @@
"advanced": {
"header": "Advanced",
"launch_options": "Launch Options",
"screenshot_metadata": "Screenshot Metadata",
"pending_offline": {
"header": "Pending Offline",
"description": "Delay before marking user as offline (fixes false positives)",
@@ -1051,6 +1052,10 @@
"password_placeholder": "Input new password",
"re_input_placeholder": "Re-input password",
"ok": "OK"
},
"screenshot_metadata": {
"header": "Screenshot Metadata",
"browse": "Browse"
}
},
"prompt": {