79 lines
2.2 KiB
C#
79 lines
2.2 KiB
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AibisDream.UI
|
|
{
|
|
public class TerminalLoadingPanel : MonoBehaviour, IUIPanel
|
|
{
|
|
[SerializeField] private TerminalPanelAnimator panelAnimator;
|
|
[SerializeField] private TMP_Text companyText;
|
|
[SerializeField] private TMP_Text deviceText;
|
|
[SerializeField] private TMP_Text userText;
|
|
[SerializeField] private TMP_Text loadingText;
|
|
[SerializeField] private Image avatarImage;
|
|
[SerializeField] private RectTransform progressFill;
|
|
|
|
public bool IsOpen => gameObject.activeSelf;
|
|
public bool IsCloseable => false;
|
|
|
|
public void Show()
|
|
{
|
|
if (panelAnimator != null)
|
|
{
|
|
panelAnimator.Show(prepare: PrepareContent);
|
|
}
|
|
else
|
|
{
|
|
PrepareContent();
|
|
gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void Hide(Action onComplete = null)
|
|
{
|
|
if (panelAnimator != null)
|
|
{
|
|
panelAnimator.Hide(onComplete);
|
|
}
|
|
else
|
|
{
|
|
gameObject.SetActive(false);
|
|
onComplete?.Invoke();
|
|
}
|
|
}
|
|
|
|
private void PrepareContent()
|
|
{
|
|
SetText(companyText, "SATISFYING INC");
|
|
SetText(deviceText, "Device Model: Dell P5999 DX130\nDevice Serial Number: SN46456546DAS");
|
|
SetText(userText, "User Name: Luth\nUser Title: DOC.\nEmployee ID: D42");
|
|
SetText(loadingText, "LOADING...");
|
|
SetProgress(0f);
|
|
|
|
if (avatarImage != null)
|
|
{
|
|
avatarImage.gameObject.SetActive(avatarImage.sprite != null);
|
|
}
|
|
}
|
|
|
|
public void SetProgress(float progress)
|
|
{
|
|
var clamped = Mathf.Clamp01(progress);
|
|
if (progressFill != null)
|
|
{
|
|
progressFill.anchorMax = new Vector2(clamped, progressFill.anchorMax.y);
|
|
}
|
|
}
|
|
|
|
private static void SetText(TMP_Text text, string value)
|
|
{
|
|
if (text != null)
|
|
{
|
|
text.text = value;
|
|
}
|
|
}
|
|
}
|
|
}
|