From 25155facf6cba394303593b5d100b30696a7ef51 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Wed, 19 Feb 2025 14:46:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=BB=E5=8F=96=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20(#11973)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Helper/DataHelper.cs | 68 +++++++++++++++++-- src/MaaWpfGui/Main/AsstProxy.cs | 2 +- .../ViewModels/UI/TaskQueueViewModel.cs | 2 +- .../ViewModels/UI/VersionUpdateViewModel.cs | 2 +- .../VersionUpdateSettingsUserControlModel.cs | 2 +- 5 files changed, 68 insertions(+), 8 deletions(-) diff --git a/src/MaaWpfGui/Helper/DataHelper.cs b/src/MaaWpfGui/Helper/DataHelper.cs index f65b54b7d1..4d3471327c 100644 --- a/src/MaaWpfGui/Helper/DataHelper.cs +++ b/src/MaaWpfGui/Helper/DataHelper.cs @@ -18,6 +18,7 @@ using System.IO; using System.Linq; using MaaWpfGui.Constants; using MaaWpfGui.ViewModels.UI; +using MaaWpfGui.ViewModels.UserControl.Settings; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -51,13 +52,21 @@ namespace MaaWpfGui.Helper public static Dictionary RecruitTags { get; private set; } = []; + public static List MapData { get; private set; } = []; + static DataHelper() { - ReloadBattleData(); InitRecruitTag(); + Reload(); } - public static void ReloadBattleData() + public static void Reload() + { + ReloadBattleData(); + InitMapData(); + } + + private static void ReloadBattleData() { const string FilePath = "resource/battle_data.json"; if (!File.Exists(FilePath)) @@ -88,14 +97,14 @@ namespace MaaWpfGui.Helper private static void InitRecruitTag() { - var clientType = ConfigurationHelper.GetValue(ConfigurationKeys.ClientType, string.Empty); + var clientType = GameSettingsUserControlModel.Instance.ClientType; var clientPath = clientType switch { "" or "Official" or "Bilibili" => string.Empty, _ => Path.Combine("global", clientType, "resource"), }; - var displayLanguage = ConfigurationHelper.GetGlobalValue(ConfigurationKeys.Localization, LocalizationHelper.DefaultLanguage); + var displayLanguage = GuiSettingsUserControlModel.Instance.Language; var displayPath = displayLanguage switch { "zh-tw" or "en-us" or "ja-jp" or "ko-kr" => Path.Combine("global", ClientDirectoryMapper[displayLanguage], "resource"), @@ -142,6 +151,28 @@ namespace MaaWpfGui.Helper } } + private static void InitMapData() + { + MapData = []; + var path = Path.Combine("resource", "Arknights-Tile-Pos", "overview.json"); + if (!File.Exists(path)) + { + return; + } + + try + { + var jObj = JsonConvert.DeserializeObject>(File.ReadAllText(path)); + if (jObj is not null && jObj.Count > 0) + { + MapData = [.. jObj.Values]; + } + } + catch + { + } + } + private static Action GetCharacterNamesAddAction(string str) { return str switch @@ -258,5 +289,34 @@ namespace MaaWpfGui.Helper [JsonProperty("rarity")] public int Rarity { get; set; } } + + public class MapInfo + { + // 1-7 + [JsonProperty("code")] + public string? Code { get; set; } + + // main_01-07#f#-obt-main-level_main_01-07.json + [JsonProperty("filename")] + public string? Filename { get; set; } + + // obt/main/level_main_01-07 + [JsonProperty("levelId")] + public string? LevelId { get; set; } + + // 暴君 + [JsonProperty("name")] + public string? Name { get; set; } + + // main_01-07#f#, #f#是突袭关卡 + [JsonProperty("stageId")] + public string? NameJpUnavailable { get; set; } + + [JsonProperty("height")] + public int Height { get; set; } + + [JsonProperty("width")] + public int Width { get; set; } + } } } diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index da1bb35564..7836e65cf0 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -1581,7 +1581,7 @@ namespace MaaWpfGui.Main if (ret == VersionUpdateViewModel.CheckUpdateRetT.OnlyGameResourceUpdated) { Instances.AsstProxy.LoadResource(); - DataHelper.ReloadBattleData(); + DataHelper.Reload(); SettingsViewModel.VersionUpdateSettings.ResourceInfoUpdate(); ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceUpdated")); } diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index f0e5df17bf..f394c774cd 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -477,7 +477,7 @@ namespace MaaWpfGui.ViewModels.UI if (await ResourceUpdater.CheckAndDownloadResourceUpdate() == VersionUpdateViewModel.CheckUpdateRetT.OnlyGameResourceUpdated) { Instances.AsstProxy.LoadResource(); - DataHelper.ReloadBattleData(); + DataHelper.Reload(); SettingsViewModel.VersionUpdateSettings.ResourceInfoUpdate(); ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceUpdated")); } diff --git a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs index 17f2bda8cf..1914407e1e 100644 --- a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs @@ -491,7 +491,7 @@ public class VersionUpdateViewModel : Screen if (ret2 == CheckUpdateRetT.OnlyGameResourceUpdated) { Instances.AsstProxy.LoadResource(); - DataHelper.ReloadBattleData(); + DataHelper.Reload(); SettingsViewModel.VersionUpdateSettings.ResourceInfoUpdate(); ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceUpdated")); } diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs index 71cb1bc13a..7d090798b2 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs @@ -451,7 +451,7 @@ public class VersionUpdateSettingsUserControlModel : PropertyChangedBase if (success) { Instances.AsstProxy.LoadResource(); - DataHelper.ReloadBattleData(); + DataHelper.Reload(); SettingsViewModel.VersionUpdateSettings.ResourceInfoUpdate(); ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceUpdated")); }