Story流程+本地化

This commit is contained in:
SoulliesOfficial
2026-07-24 17:56:30 -04:00
parent b0e0a7d5aa
commit de70870682
250 changed files with 5719 additions and 272966 deletions

View File

@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Ichni.Diagnostics;
using Ichni.Localization;
using Ichni.Menu.UI;
using TMPro;
using UnityEngine;
@@ -410,50 +410,26 @@ namespace Ichni.Story.UI
return string.Empty;
}
try
{
string localizedText = LocalizationSettings.StringDatabase.GetLocalizedString(localizationTable, labelKey);
return string.IsNullOrEmpty(localizedText) ? labelKey : localizedText;
}
catch (Exception exception)
{
Debug.LogWarning($"[StoryTimeline] 无法本地化 Label Key '{labelKey}',将回退显示 Key。{exception.Message}");
return labelKey;
}
return LocalizationTextService.Resolve(localizationTable, labelKey, labelKey);
}
private async void OnSelectedLocaleChanged(Locale newLocale)
private async void OnSelectedLocaleChanged(Locale _)
{
BuildHangTracer.Log("TIMELINE_EVENT", $"[OnSelectedLocaleChanged] 收到语言切换通知: newLocale={(newLocale != null ? newLocale.Identifier.Code : "null")}_markers.Count={_markers.Count}");
foreach (RuntimeMarker marker in _markers)
{
if (string.IsNullOrEmpty(marker.definition.labelKey)) continue;
try
string localizedLabel = await LocalizationTextService.ResolveAsync(
localizationTable,
marker.definition.labelKey,
marker.definition.labelKey);
// 异步等待结束后,防范对象在此期间被销毁。
if (marker.view != null)
{
BuildHangTracer.Log("TIMELINE_EVENT", $"[OnSelectedLocaleChanged] 开始异步获取 Key '{marker.definition.labelKey}' 的本地化文本...");
var handle = LocalizationSettings.StringDatabase.GetLocalizedStringAsync(localizationTable, marker.definition.labelKey);
while (!handle.IsDone)
{
await System.Threading.Tasks.Task.Yield();
}
BuildHangTracer.Log("TIMELINE_EVENT", $"[OnSelectedLocaleChanged] 获取 Key '{marker.definition.labelKey}' 完成Result='{handle.Result}'");
// 异步等待结束后,防范对象在此期间被销毁
if (marker.view != null)
{
marker.view.SetLabel(string.IsNullOrEmpty(handle.Result) ? marker.definition.labelKey : handle.Result);
}
}
catch (System.Exception exception)
{
BuildHangTracer.Log("TIMELINE_EVENT", $"[OnSelectedLocaleChanged] 异常: {exception.Message}");
Debug.LogWarning($"[StoryTimeline] 无法本地化 Label Key '{marker.definition.labelKey}'。{exception.Message}");
if (marker.view != null) marker.view.SetLabel(marker.definition.labelKey);
marker.view.SetLabel(localizedLabel);
}
}
BuildHangTracer.Log("TIMELINE_EVENT", "[OnSelectedLocaleChanged] 全部 Marker 更新完成。");
}
/// <summary>