From 3295aff8947361a6bf57e9d33157e8a6be201ef7 Mon Sep 17 00:00:00 2001 From: jie65535 Date: Thu, 28 May 2026 16:19:45 +0800 Subject: [PATCH] Fix activity update language contamination and duplicate group --- Source/GrasscutterTools/Pages/PageTools.cs | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/Source/GrasscutterTools/Pages/PageTools.cs b/Source/GrasscutterTools/Pages/PageTools.cs index fcd834e..dbaaf8b 100644 --- a/Source/GrasscutterTools/Pages/PageTools.cs +++ b/Source/GrasscutterTools/Pages/PageTools.cs @@ -155,6 +155,12 @@ namespace GrasscutterTools.Pages TextMapData ??= new TextMapData(TxtGcResRoot.Text); + // 确保使用中文UI文化加载GameData,防止ConvertResources留下的ru-ru状态 + var savedCulture = System.Threading.Thread.CurrentThread.CurrentUICulture; + System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-cn"); + GameData.LoadResources(); + System.Threading.Thread.CurrentThread.CurrentUICulture = savedCulture; + UpdateActivityForLanguage(activityItems, "zh-cn"); UpdateActivityForLanguage(activityItems, "zh-tw"); UpdateActivityForLanguage(activityItems, "en-us"); @@ -180,8 +186,15 @@ namespace GrasscutterTools.Pages var processedIds = new HashSet(); // 保持原有的分组结构(从 GameData.Activity 读取),保留人工整理的内容 + // 旧的 // New 分组跳过,统一在末尾合并输出 foreach (var group in GameData.Activity) { + if (group.Key == "New") + { + foreach (var id in group.Value.Ids) + processedIds.Add(id); + continue; + } buffer.Append("// ").AppendLine(group.Key); foreach (var id in group.Value.Ids) { @@ -195,14 +208,23 @@ namespace GrasscutterTools.Pages } } - // 添加 JSON 中存在但旧文件中不存在的新活动 - var newActivities = activityItems.Where(item => !processedIds.Contains(item.ActivityId)).OrderBy(item => item.ActivityId); - if (newActivities.Any()) + // 合并旧的 // New 和 JSON 中新增的活动 + var newIds = activityItems + .Where(item => !processedIds.Contains(item.ActivityId)) + .Select(item => item.ActivityId) + .Concat(GameData.Activity.TryGetValue("New", out var oldNewGroup) + ? oldNewGroup.Ids : Enumerable.Empty()) + .Distinct() + .OrderBy(id => id) + .ToList(); + if (newIds.Count > 0) { buffer.AppendLine("// New"); - foreach (var item in newActivities) + foreach (var id in newIds) { - buffer.Append(item.ActivityId).Append(':').AppendLine(activityMap[item.ActivityId]); + var name = activityMap.TryGetValue(id, out var title) ? title : + GameData.Activity.TryGetValue("New", out var ng) && ng[id] != ItemMap.EmptyName ? ng[id] : title; + buffer.Append(id).Append(':').AppendLine(name); } }