diff --git a/AppApi.cs b/AppApi.cs index 8be9b02a..a8a64669 100644 --- a/AppApi.cs +++ b/AppApi.cs @@ -696,9 +696,9 @@ namespace VRCX if (File.Exists(path) && path.EndsWith(".png") && fileName.StartsWith(fileNamePrefix)) { string metadataString = null; - bool readPNGFailed = false; + var readPNGFailed = false; - try + try { metadataString = ScreenshotHelper.ReadPNGDescription(path); } @@ -767,6 +767,14 @@ namespace VRCX MainForm.Instance.BeginInvoke(new MethodInvoker(() => { WinformThemer.Flash(MainForm.Instance); })); } + public void SetUserAgent() + { + using (var client = MainForm.Instance.Browser.GetDevToolsClient()) + { + _ = client.Network.SetUserAgentOverrideAsync(Program.Version); + } + } + private struct XSOMessage { public int messageType { get; set; } diff --git a/CefService.cs b/CefService.cs index 3d8824e1..70d4d131 100644 --- a/CefService.cs +++ b/CefService.cs @@ -1,8 +1,8 @@ +using System; +using System.IO; using CefSharp; using CefSharp.SchemeHandler; using CefSharp.WinForms; -using System; -using System.IO; namespace VRCX { @@ -24,16 +24,17 @@ namespace VRCX LogSeverity = LogSeverity.Disable, WindowlessRenderingEnabled = true, PersistSessionCookies = true, - PersistUserPreferences = true + PersistUserPreferences = true, + UserAgent = Program.Version }; - + cefSettings.RegisterScheme(new CefCustomScheme { SchemeName = "file", DomainName = "vrcx", SchemeHandlerFactory = new FolderSchemeHandlerFactory( - rootFolder: Path.Combine(Program.BaseDirectory, "html"), - schemeName: "file", + Path.Combine(Program.BaseDirectory, "html"), + "file", defaultPage: "index.html" ), IsLocal = true @@ -46,7 +47,7 @@ namespace VRCX cefSettings.CefCommandLineArgs.Add("disable-pdf-extension"); cefSettings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required"; cefSettings.CefCommandLineArgs.Add("disable-web-security"); - cefSettings.SetOffScreenRenderingBestPerformanceArgs(); + cefSettings.SetOffScreenRenderingBestPerformanceArgs(); // causes white screen sometimes? if (Program.LaunchDebug) cefSettings.RemoteDebuggingPort = 8088; @@ -57,8 +58,6 @@ namespace VRCX // Enable High-DPI support on Windows 7 or newer Cef.EnableHighDPISupport(); - cefSettings.UserAgent = Program.Version; - if (Cef.Initialize(cefSettings) == false) { throw new Exception("Cef.Initialize()"); diff --git a/html/src/app.js b/html/src/app.js index 46858fa5..7eb9d855 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -412,11 +412,7 @@ speechSynthesis.getVoices(); if (response.status === 200) { this.$throw(0, 'Invalid JSON response'); } - if ( - response.status === 504 || - response.status === 502 || - response.status === 429 - ) { + if (response.status === 504 || response.status === 502) { // ignore expected API errors throw new Error( `${response.status}: ${response.data} ${endpoint}` @@ -492,6 +488,9 @@ speechSynthesis.getVoices(); ) { throw new Error(`403: ${data.error.message} ${endpoint}`); } + if (status === 429) { + throw new Error(`429: ${data.error.message} ${endpoint}`); + } if (data && data.error === Object(data.error)) { this.$throw( data.error.status_code || status, @@ -4798,6 +4797,7 @@ speechSynthesis.getVoices(); watch: {}, el: '#x-app', mounted() { + AppApi.SetUserAgent(); AppApi.GetVersion().then((version) => { this.appVersion = version; this.comapreAppVersion(); @@ -13326,7 +13326,7 @@ speechSynthesis.getVoices(); configRepository.setInt('VRCX_asidewidth', $app.data.asideWidth); } if (!configRepository.getString('VRCX_autoUpdateVRCX')) { - $app.data.autoUpdateVRCX = 'Notify'; + $app.data.autoUpdateVRCX = 'Auto Download'; configRepository.setString( 'VRCX_autoUpdateVRCX', $app.data.autoUpdateVRCX @@ -20123,13 +20123,21 @@ speechSynthesis.getVoices(); this.WriteVRChatConfigFile(); }; - $app.data.VRChatResolutions = [ + $app.data.VRChatScreenshotResolutions = [ {name: '1280x720 (720p)', width: 1280, height: 720}, {name: '1920x1080 (1080p Default)', width: '', height: ''}, {name: '2560x1440 (1440p)', width: 2560, height: 1440}, {name: '3840x2160 (4K)', width: 3840, height: 2160} ]; + $app.data.VRChatCameraResolutions = [ + {name: '1280x720 (720p)', width: 1280, height: 720}, + {name: '1920x1080 (1080p Default)', width: '', height: ''}, + {name: '2560x1440 (1440p)', width: 2560, height: 1440}, + {name: '3840x2160 (4K)', width: 3840, height: 2160}, + {name: '7680x4320 (8K)', width: 7680, height: 4320} + ]; + $app.methods.getVRChatResolution = function (res) { switch (res) { case '1280x720': @@ -20140,6 +20148,8 @@ speechSynthesis.getVoices(); return '2560x1440 (2K)'; case '3840x2160': return '3840x2160 (4K)'; + case '7680x4320': + return '7680x4320 (8K)'; } return `${res} (Custom)`; }; @@ -20200,8 +20210,29 @@ speechSynthesis.getVoices(); $app.methods.displayScreenshotMetadata = function (metadata) { var D = this.screenshotMetadataDialog; var json = JSON.parse(metadata); - console.log(json); D.metadata = json; + + // VRChat_3840x2160_2022-02-02_03-21-39.771 + // VRChat_2023-02-16_10-39-25.274_3840x2160 + var regex = json.fileName.match( + /VRChat_((\d{3,})x(\d{3,})_(\d{4})-(\d{2})-(\d{2})_(\d{2})-(\d{2})-(\d{2})\.(\d{1,})|(\d{4})-(\d{2})-(\d{2})_(\d{2})-(\d{2})-(\d{2})\.(\d{3})_(\d{3,})x(\d{3,}))/ + ); + if (regex) { + if (typeof regex[2] !== 'undefined') { + // old format + var date = `${regex[4]}-${regex[5]}-${regex[6]}`; + var time = `${regex[7]}:${regex[8]}:${regex[9]}`; + D.metadata.dateTime = Date.parse(`${date} ${time}`); + D.metadata.resolution = `${regex[2]}x${regex[3]}`; + } else if (typeof regex[11] !== 'undefined') { + // new format + var date = `${regex[11]}-${regex[12]}-${regex[13]}`; + var time = `${regex[14]}:${regex[15]}:${regex[16]}`; + D.metadata.dateTime = Date.parse(`${date} ${time}`); + D.metadata.resolution = `${regex[18]}x${regex[19]}`; + } + } + this.showScreenshotMetadataDialog(); }; @@ -21277,7 +21308,10 @@ speechSynthesis.getVoices(); /\D/g, '' ); + // limit to 8 characters because 2019.4.31f1c1 is a thing + currentUnityVersion = currentUnityVersion.slice(0, 8); var assetVersion = version.replace(/\D/g, ''); + assetVersion = assetVersion.slice(0, 8); if (parseInt(assetVersion, 10) <= parseInt(currentUnityVersion, 10)) { return true; } diff --git a/html/src/index.pug b/html/src/index.pug index 07b053f6..222be7fa 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -2687,7 +2687,7 @@ html 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") + el-dropdown-item(v-for="row in VRChatCameraResolutions" :key="row.index" v-text="row.name" :command="row") div(style="display:inline-block;margin-top:10px;margin-left:10px") span {{ $t('dialog.config_json.screenshot_resolution') }} br @@ -2695,7 +2695,7 @@ html 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-dropdown-item(v-for="row in VRChatScreenshotResolutions" :key="row.index" v-text="row.name" :command="row") el-checkbox(v-model="VRChatConfigFile.disableRichPresence" style="margin-top:5px;display:block") {{ $t('dialog.config_json.disable_discord_presence') }} template(#footer) el-button(size="small" @click="openExternalLink('https://docs.vrchat.com/docs/configuration-file')") {{ $t('dialog.config_json.vrchat_docs') }} @@ -3800,8 +3800,9 @@ html 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") + span(v-if="!screenshotMetadataDialog.metadata.resolution" v-text="screenshotMetadataDialog.metadata.fileName" style="margin-left:5px") + span(v-if="screenshotMetadataDialog.metadata.dateTime" style="margin-left:5px") {{ screenshotMetadataDialog.metadata.dateTime | formatDate('long') }} + span(v-if="screenshotMetadataDialog.metadata.resolution" v-text="screenshotMetadataDialog.metadata.resolution" style="margin-left:5px") 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") diff --git a/html/src/repository/database.js b/html/src/repository/database.js index 52422fb8..6771cff2 100644 --- a/html/src/repository/database.js +++ b/html/src/repository/database.js @@ -1024,6 +1024,8 @@ class Database { var avatar = true; var online = true; var offline = true; + var aviPublic = search.includes('public'); + var aviPrivate = search.includes('private'); if (filters.length > 0) { gps = false; status = false; @@ -1103,6 +1105,12 @@ class Database { }, `SELECT * FROM ${Database.userPrefix}_feed_bio WHERE (display_name LIKE '%${search}%' OR bio LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`); } if (avatar) { + var query = ''; + if (aviPrivate) { + query = 'OR user_id = owner_id'; + } else if (aviPublic) { + query = 'OR user_id != owner_id'; + } await sqliteService.execute((dbRow) => { var row = { rowId: dbRow[0], @@ -1118,7 +1126,7 @@ class Database { previousCurrentAvatarThumbnailImageUrl: dbRow[9] }; feedDatabase.unshift(row); - }, `SELECT * FROM ${Database.userPrefix}_feed_avatar WHERE (display_name LIKE '%${search}%' OR avatar_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`); + }, `SELECT * FROM ${Database.userPrefix}_feed_avatar WHERE ((display_name LIKE '%${search}%' OR avatar_name LIKE '%${search}%') ${query}) ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`); } if (online || offline) { var query = '';