feat(ui): 添加终端章节面板标题本地化
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AibisDream;
|
||||
using AibisDream.Utility;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Localization.Components;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream.UI
|
||||
@@ -14,6 +17,7 @@ namespace AibisDream.UI
|
||||
[SerializeField] private TerminalChapterItemView rightPreview;
|
||||
[SerializeField] private TMP_Text emptyText;
|
||||
[SerializeField] private TMP_Text selectedTitleText;
|
||||
[SerializeField] private LocalizeStringEvent selectedTitleLocalize;
|
||||
[SerializeField] private Button previousButton;
|
||||
[SerializeField] private Button nextButton;
|
||||
[SerializeField] private Button restartButton;
|
||||
@@ -32,6 +36,11 @@ namespace AibisDream.UI
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (selectedTitleLocalize == null && selectedTitleText != null)
|
||||
{
|
||||
selectedTitleLocalize = selectedTitleText.GetComponent<LocalizeStringEvent>();
|
||||
}
|
||||
|
||||
previousButton?.onClick.AddListener(Previous);
|
||||
nextButton?.onClick.AddListener(Next);
|
||||
restartButton?.onClick.AddListener(Restart);
|
||||
@@ -109,10 +118,7 @@ namespace AibisDream.UI
|
||||
|
||||
if (!hasChapters)
|
||||
{
|
||||
if (selectedTitleText != null)
|
||||
{
|
||||
selectedTitleText.text = "NO CHAPTER DATA";
|
||||
}
|
||||
SetSelectedTitle(null, "NO CHAPTER DATA");
|
||||
|
||||
restartButton?.gameObject.SetActive(false);
|
||||
UpdateNavigationButtons(false);
|
||||
@@ -132,10 +138,7 @@ namespace AibisDream.UI
|
||||
rightPreview?.Init(_chapters[_currentIndex + 1], selected: false, preview: true);
|
||||
}
|
||||
|
||||
if (selectedTitleText != null)
|
||||
{
|
||||
selectedTitleText.text = current.title;
|
||||
}
|
||||
SetSelectedTitle(current.titleKey, current.title);
|
||||
|
||||
restartButton?.gameObject.SetActive(true);
|
||||
UpdateNavigationButtons(true);
|
||||
@@ -162,6 +165,27 @@ namespace AibisDream.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSelectedTitle(string titleKey, string fallbackTitle)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(titleKey) && selectedTitleLocalize != null)
|
||||
{
|
||||
selectedTitleLocalize.enabled = true;
|
||||
selectedTitleLocalize.SetTable(ConstRef.ChapterInfoTable);
|
||||
selectedTitleLocalize.SetEntry(titleKey);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedTitleLocalize != null)
|
||||
{
|
||||
selectedTitleLocalize.enabled = false;
|
||||
}
|
||||
|
||||
if (selectedTitleText != null)
|
||||
{
|
||||
selectedTitleText.text = fallbackTitle;
|
||||
}
|
||||
}
|
||||
|
||||
private void Previous()
|
||||
{
|
||||
if (_chapters.Count == 0 || _currentIndex <= 0)
|
||||
|
||||
Reference in New Issue
Block a user