From db04978015e562cec5eb44dc6d10f9274ba77a74 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Sun, 18 Jul 2021 15:29:21 +1200 Subject: [PATCH] Camera/Screenshot resolution drop down --- html/src/app.js | 92 +++++++++++++++++++++++++++++----------------- html/src/index.pug | 25 ++++++++++--- 2 files changed, 79 insertions(+), 38 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 0a1497bb..30e0aa96 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -12308,11 +12308,7 @@ speechSynthesis.getVoices(); AppApi.WriteConfigFile(json); }; - $app.data.VRChatConfigDialog = { - visible: false, - cameraRes: false, - screenshotRes: false - }; + $app.data.VRChatConfigDialog.visible = false; API.$on('LOGIN', function () { $app.VRChatConfigDialog.visible = false; @@ -12321,39 +12317,13 @@ speechSynthesis.getVoices(); $app.methods.showVRChatConfig = async function () { await this.readVRChatConfigFile(); this.$nextTick(() => adjustDialogZ(this.$refs.VRChatConfigDialog.$el)); - this.VRChatConfigDialog = { - cameraRes: false, - screenshotRes: false, - visible: true - } - if ((this.VRChatConfigFile.camera_res_height === 2160) && - (this.VRChatConfigFile.camera_res_width === 3840)) { - this.VRChatConfigDialog.cameraRes = true; - } - if ((this.VRChatConfigFile.screenshot_res_height === 2160) && - (this.VRChatConfigFile.screenshot_res_width === 3840)) { - this.VRChatConfigDialog.screenshotRes = true; - } + this.VRChatConfigDialog.visible = true; if (!this.VRChatUsedCacheSize) { this.getVRChatCacheSize(); } }; - $app.methods.SaveVRChatConfigFile = function () { - if (this.VRChatConfigDialog.cameraRes) { - this.VRChatConfigFile.camera_res_height = 2160; - this.VRChatConfigFile.camera_res_width = 3840; - } else { - delete this.VRChatConfigFile.camera_res_height; - delete this.VRChatConfigFile.camera_res_width; - } - if (this.VRChatConfigDialog.screenshotRes) { - this.VRChatConfigFile.screenshot_res_height = 2160; - this.VRChatConfigFile.screenshot_res_width = 3840; - } else { - delete this.VRChatConfigFile.screenshot_res_height; - delete this.VRChatConfigFile.screenshot_res_width; - } + $app.methods.saveVRChatConfigFile = function () { for (var item in this.VRChatConfigFile) { if (this.VRChatConfigFile[item] === '') { delete this.VRChatConfigFile[item]; @@ -12376,6 +12346,62 @@ speechSynthesis.getVoices(); return cacheDirectory; }; + $app.data.VRChatResolutions = [ + { name: '1280x720 (720p)', width: 1280, height: 720 }, + { name: '1920x1080 (Default 1080p)', width: '', height: '' }, + { name: '2560x1440 (2K)', width: 2560, height: 1440 }, + { name: '3840x2160 (4K)', width: 3840, height: 2160 } + ]; + + $app.methods.getVRChatResolution = function (res) { + switch (res) { + case '1280x720': + return '1280x720 (720p)'; + break; + case '1920x1080': + return '1920x1080 (1080p)'; + break; + case '2560x1440': + return '2560x1440 (2K)'; + break; + case '3840x2160': + return '3840x2160 (4K)'; + break; + default: + return `${res} (Custom)`; + } + }; + + $app.methods.getVRChatCameraResolution = function () { + if ((this.VRChatConfigFile.camera_res_height) && + (this.VRChatConfigFile.camera_res_width)) { + var res = `${this.VRChatConfigFile.camera_res_width}x${this.VRChatConfigFile.camera_res_height}`; + return this.getVRChatResolution(res); + } else { + return '1920x1080 (1080p)'; + } + }; + + $app.methods.getVRChatScreenshotResolution = function () { + if ((this.VRChatConfigFile.screenshot_res_height) && + (this.VRChatConfigFile.screenshot_res_width)) { + var res = `${this.VRChatConfigFile.screenshot_res_width}x${this.VRChatConfigFile.screenshot_res_height}`; + return this.getVRChatResolution(res); + } else { + return '1920x1080 (1080p)'; + } + }; + + $app.methods.setVRChatCameraResolution = function (res) { + this.VRChatConfigFile.camera_res_height = res.height; + this.VRChatConfigFile.camera_res_width = res.width; + }; + + $app.methods.setVRChatScreenshotResolution = function (res) { + this.VRChatConfigFile.screenshot_res_height = res.height; + this.VRChatConfigFile.screenshot_res_width = res.width; + }; + // Asset Bundle Cacher $app.methods.updateVRChatCache = function () { diff --git a/html/src/index.pug b/html/src/index.pug index 4245b1b5..6cdcec6b 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -825,7 +825,8 @@ html div.options-container-item span.name TTS Voice el-dropdown(@command="(voice) => changeTTSVoice(voice)" trigger="click" size="small") - el-button(v-text="TTSvoices[notificationTTSVoice].name" size="mini" :disabled="!notificationTTS") + el-button(size="mini" :disabled="!notificationTTS") + span {{ TTSvoices[notificationTTSVoice].name }} #[i.el-icon-arrow-down.el-icon--right] el-dropdown-menu(#default="dropdown") el-dropdown-item(v-if="voice" v-for="(voice, index) in TTSvoices" :key="index" v-text="voice.name" :command="index") div.options-container @@ -1639,7 +1640,7 @@ html el-button(type="default" :loading="VRChatCacheSizeLoading" @click="getVRChatCacheSize" size="small" icon="el-icon-refresh" circle style="margin-left:5px") br span Delete all cache - el-button(size="small" style="margin-left:5px" icon="el-icon-delete" @click="sweepVRChatCache()") Delete Cache + el-button(size="small" style="margin-left:5px" icon="el-icon-delete" @click="showDeleteAllVRChatCacheConfirm()") Delete Cache br span Delete old versions from cache el-button(size="small" style="margin-left:5px" icon="el-icon-folder-delete" @click="sweepVRChatCache()") Sweep Cache @@ -1648,13 +1649,27 @@ html span(v-text="item.name" style="word-break:keep-all") |: el-input(v-model="VRChatConfigFile[value]" :placeholder="item.default" size="mini" :type="item.type?item.type:'text'" :min="item.min" :max="item.max") + div(style="margin-top:10px") + span Camera Resolution + br + el-dropdown(@command="(command) => setVRChatCameraResolution(command)" size="small" trigger="click" style="margin-top:5px") + el-button(size="small") + span #[span(v-text="getVRChatCameraResolution()")] #[i.el-icon-arrow-down.el-icon--right] + el-dropdown-menu(#default="dropdown") + el-dropdown-item(v-for="row in VRChatResolutions" :key="row.index" v-text="row.name" :command="row") + div(style="margin-top:10px") + span Screenshot Resolution + br + el-dropdown(@command="(command) => setVRChatScreenshotResolution(command)" size="small" trigger="click" style="margin-top:5px") + el-button(size="small") + span #[span(v-text="getVRChatScreenshotResolution()")] #[i.el-icon-arrow-down.el-icon--right] + el-dropdown-menu(#default="dropdown") + el-dropdown-item(v-for="row in VRChatResolutions" :key="row.index" v-text="row.name" :command="row") el-checkbox(v-model="VRChatConfigFile.disableRichPresence" style="margin-top:5px;display:block") Disable Discord Rich Presence - el-checkbox(v-model="VRChatConfigDialog.cameraRes" style="margin-top:5px") 4K Camera - el-checkbox(v-model="VRChatConfigDialog.screenshotRes" style="margin-top:5px") 4K Screenshots template(#footer) el-button(size="small" @click="openExternalLink('https://docs.vrchat.com/docs/configuration-file')") VRChat Docs el-button(size="small" @click="VRChatConfigDialog.visible = false") Cancel - el-button(type="primary" size="small" :disabled="VRChatConfigDialog.loading" @click="SaveVRChatConfigFile") Save + el-button(type="primary" size="small" :disabled="VRChatConfigDialog.loading" @click="saveVRChatConfigFile") Save //- dialog: Cache Download el-dialog.x-dialog(ref="downloadDialog" :visible.sync="downloadDialog.visible" title="Download History" width="770px")