From a10ddb9268a3e44d3a1236c52f6ee7358fd6587f Mon Sep 17 00:00:00 2001 From: MistEO Date: Sun, 23 Apr 2023 19:34:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20WPF=20UI=20=E8=B5=84=E6=BA=90=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/4443 --- src/MaaWpfGui/Main/AsstProxy.cs | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 64066b3a25..85625924a4 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -208,6 +208,21 @@ namespace MaaWpfGui.Main return true; } + string mainRes = Directory.GetCurrentDirectory(); + string mainCache = Directory.GetCurrentDirectory() + "\\cache"; + string globalResource = mainRes + "\\resource\\global\\" + _settingsViewModel.ClientType; + string globalCache = mainCache + "\\resource\\global\\" + _settingsViewModel.ClientType; + + bool LoadResIfExists(string path) + { + if (Directory.Exists(path)) + { + return AsstLoadResource(path); + } + + return true; + } + bool loaded = false; if (_settingsViewModel.ClientType == string.Empty || _settingsViewModel.ClientType == "Official" || _settingsViewModel.ClientType == "Bilibili") @@ -220,11 +235,11 @@ namespace MaaWpfGui.Main if (!onlyReloadOTA) { - loaded = AsstLoadResource(Directory.GetCurrentDirectory()); + loaded = LoadResIfExists(mainRes); } // Load the cached incremental resources - loaded = loaded && AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache"); + loaded = loaded && LoadResIfExists(mainCache); } else if (_curResource == "Official" || _curResource == "Bilibili") { @@ -232,12 +247,12 @@ namespace MaaWpfGui.Main // Then load global incremental resources if (!onlyReloadOTA) { - loaded = AsstLoadResource(Directory.GetCurrentDirectory() + "\\resource\\global\\" + _settingsViewModel.ClientType); + loaded = LoadResIfExists(globalResource); } // Load the cached incremental resources - loaded = loaded && AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache") - && AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache\\resource\\global\\" + _settingsViewModel.ClientType); + loaded = loaded && LoadResIfExists(mainCache) + && LoadResIfExists(globalCache); } else { @@ -245,13 +260,13 @@ namespace MaaWpfGui.Main // Then load global incremental resources if (!onlyReloadOTA) { - loaded = AsstLoadResource(Directory.GetCurrentDirectory()) - && AsstLoadResource(Directory.GetCurrentDirectory() + "\\resource\\global\\" + _settingsViewModel.ClientType); + loaded = LoadResIfExists(mainRes) + && LoadResIfExists(globalResource); } // Load the cached incremental resources - loaded = loaded && AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache") - && AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache\\resource\\global\\" + _settingsViewModel.ClientType); + loaded = loaded && LoadResIfExists(mainCache) + && LoadResIfExists(globalCache); } if (!loaded)