60 lines
1.5 KiB
C#
60 lines
1.5 KiB
C#
using System;
|
|
using AibisDream.Utility;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Localization.Components;
|
|
|
|
namespace AibisDream.UI
|
|
{
|
|
public class TerminalHeaderView : MonoBehaviour
|
|
{
|
|
[SerializeField] private TMP_Text titleText;
|
|
[SerializeField] private LocalizeStringEvent titleLocalize;
|
|
[SerializeField] private TMP_Text statusText;
|
|
|
|
private void Awake()
|
|
{
|
|
if (titleLocalize == null && titleText != null)
|
|
{
|
|
titleLocalize = titleText.GetComponent<LocalizeStringEvent>();
|
|
}
|
|
}
|
|
|
|
public void SetText(string title, string status = "")
|
|
{
|
|
SetTitle(title);
|
|
|
|
if (statusText != null)
|
|
{
|
|
statusText.text = status;
|
|
}
|
|
}
|
|
|
|
public void SetTitle(string title)
|
|
{
|
|
if (titleLocalize != null && IsLocalizationKey(title))
|
|
{
|
|
titleLocalize.enabled = true;
|
|
titleLocalize.SetTable(ConstRef.UITextTable);
|
|
titleLocalize.SetEntry(title);
|
|
return;
|
|
}
|
|
|
|
if (titleLocalize != null)
|
|
{
|
|
titleLocalize.enabled = false;
|
|
}
|
|
|
|
if (titleText != null)
|
|
{
|
|
titleText.text = title;
|
|
}
|
|
}
|
|
|
|
private static bool IsLocalizationKey(string value)
|
|
{
|
|
return !string.IsNullOrEmpty(value) && value.Contains("_", StringComparison.Ordinal);
|
|
}
|
|
}
|
|
}
|