2025-08-11 14:04:06 -04:00
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using DG.Tweening;
|
|
|
|
|
using I2.Loc;
|
|
|
|
|
using Sirenix.OdinInspector;
|
2026-03-14 03:13:10 -04:00
|
|
|
using SLSUtilities.WwiseAssistance;
|
2025-08-11 14:04:06 -04:00
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
using UnityEngine.Serialization;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
namespace Ichni.Menu.UI
|
|
|
|
|
{
|
|
|
|
|
public partial class MessageBox : SerializedMonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public CanvasGroup canvasGroup;
|
|
|
|
|
|
|
|
|
|
public int infoIndex;
|
|
|
|
|
public List<MessageBoxInfo> infos;
|
|
|
|
|
|
|
|
|
|
public Sprite defaultIcon;
|
|
|
|
|
public Image iconImage;
|
|
|
|
|
public Localize titleLocalize;
|
|
|
|
|
public TMP_Text titleText;
|
|
|
|
|
public Localize contentLocalize;
|
|
|
|
|
public TMP_Text contentText;
|
|
|
|
|
public LocalizationParamsManager parametersManager;
|
|
|
|
|
|
|
|
|
|
public Button receiveButton;
|
|
|
|
|
|
|
|
|
|
public Tweener fadeTweener;
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
receiveButton.onClick.AddListener(()=>PlayNextMessage(true));
|
|
|
|
|
receiveButton.GetComponent<RectTransform>().sizeDelta = new Vector2(Screen.width, Screen.height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetUp()
|
|
|
|
|
{
|
|
|
|
|
if (infos.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
infoIndex = 0;
|
|
|
|
|
PlayNextMessage();
|
|
|
|
|
FadeIn();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetUpIcon(Sprite icon)
|
|
|
|
|
{
|
|
|
|
|
iconImage.sprite = icon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddInfo(string title, string content, UnityAction action = null, Sprite icon = null)
|
|
|
|
|
{
|
|
|
|
|
MessageBoxInfo info = new MessageBoxInfo(icon, title, content, action);
|
|
|
|
|
infos.Add(info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PlayNextMessage(bool playAudio = false)
|
|
|
|
|
{
|
|
|
|
|
if (playAudio)
|
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
AudioManager.Post(AK.EVENTS.CONFIRM);
|
2025-08-11 14:04:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (infoIndex >= infos.Count)
|
|
|
|
|
{
|
|
|
|
|
FadeOut();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
infos[infoIndex].action?.Invoke();
|
|
|
|
|
|
|
|
|
|
titleLocalize.SetTerm(infos[infoIndex].title);
|
|
|
|
|
contentLocalize.SetTerm(infos[infoIndex].content);
|
|
|
|
|
|
|
|
|
|
this.iconImage.sprite = infos[infoIndex].icon != null ? infos[infoIndex].icon : defaultIcon;
|
|
|
|
|
infoIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
|
{
|
|
|
|
|
infos = new List<MessageBoxInfo>();
|
|
|
|
|
infoIndex = 0;
|
|
|
|
|
iconImage.sprite = defaultIcon;
|
|
|
|
|
titleText.text = string.Empty;
|
|
|
|
|
contentText.text = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class MessageBox
|
|
|
|
|
{
|
|
|
|
|
public void SetParameter(string paramName, string paramValue, bool localize = false)
|
|
|
|
|
{
|
|
|
|
|
if (localize)
|
|
|
|
|
{
|
|
|
|
|
parametersManager.SetParameterValue(paramName, paramValue);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
parametersManager.SetParameterValue(paramName, paramValue, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class MessageBox
|
|
|
|
|
{
|
|
|
|
|
public void FadeIn(float duration = 0.5f, bool ignoreTimeScale = false)
|
|
|
|
|
{
|
|
|
|
|
canvasGroup.gameObject.SetActive(true);
|
|
|
|
|
|
|
|
|
|
fadeTweener = canvasGroup.DOFade(1f, duration).OnComplete(() =>
|
|
|
|
|
{
|
|
|
|
|
canvasGroup.interactable = true;
|
|
|
|
|
canvasGroup.blocksRaycasts = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (ignoreTimeScale)
|
|
|
|
|
{
|
|
|
|
|
fadeTweener.SetUpdate(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fadeTweener.Play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FadeOut(float duration = 0.5f, bool ignoreTimeScale = false)
|
|
|
|
|
{
|
|
|
|
|
canvasGroup.interactable = false;
|
|
|
|
|
canvasGroup.blocksRaycasts = false;
|
|
|
|
|
|
|
|
|
|
fadeTweener = canvasGroup.DOFade(0f, duration).OnComplete(() =>
|
|
|
|
|
{
|
|
|
|
|
canvasGroup.gameObject.SetActive(false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (ignoreTimeScale)
|
|
|
|
|
{
|
|
|
|
|
fadeTweener.SetUpdate(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fadeTweener.Play();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct MessageBoxInfo
|
|
|
|
|
{
|
|
|
|
|
public Sprite icon;
|
|
|
|
|
public string title;
|
|
|
|
|
public string content;
|
|
|
|
|
public UnityAction action;
|
|
|
|
|
|
|
|
|
|
public MessageBoxInfo(Sprite icon, string title, string content, UnityAction action)
|
|
|
|
|
{
|
|
|
|
|
this.icon = icon;
|
|
|
|
|
this.title = title;
|
|
|
|
|
this.content = content;
|
|
|
|
|
this.action = action;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|