82 lines
2.8 KiB
C#
82 lines
2.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DG.Tweening;
|
|
using Ichni.RhythmGame;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Ichni.Menu
|
|
{
|
|
public class SongInfoUI : MonoBehaviour
|
|
{
|
|
public Image illustration;
|
|
public TMP_Text charterNameText;
|
|
public TMP_Text illustratorText;
|
|
|
|
public TMP_Text accuracyText;
|
|
public Image fullComboMark;
|
|
public Image allPerfectMark;
|
|
|
|
public bool isOpeningFullIllustration;
|
|
public Button openFullIllustrationButton;
|
|
public GameObject fullIllustration;
|
|
public Button closeFullIllustrationButton;
|
|
public bool isDuringFullIllustrationFade;
|
|
public void SetUp()
|
|
{
|
|
openFullIllustrationButton.onClick.AddListener(() =>
|
|
{
|
|
if (!isOpeningFullIllustration && !isDuringFullIllustrationFade)
|
|
{
|
|
isOpeningFullIllustration = true;
|
|
isDuringFullIllustrationFade = true;
|
|
fullIllustration.SetActive(true);
|
|
fullIllustration.GetComponentInChildren<Image>().sprite = illustration.sprite;
|
|
fullIllustration.GetComponent<CanvasGroup>().DOFade(1f, 0.5f)
|
|
.OnComplete(() => isDuringFullIllustrationFade = false)
|
|
.Play();
|
|
}
|
|
});
|
|
|
|
closeFullIllustrationButton.onClick.AddListener(() =>
|
|
{
|
|
if (isOpeningFullIllustration && !isDuringFullIllustrationFade)
|
|
{
|
|
isOpeningFullIllustration = false;
|
|
isDuringFullIllustrationFade = true;
|
|
fullIllustration.GetComponent<CanvasGroup>().DOFade(0f, 0.5f)
|
|
.OnComplete(() =>
|
|
{
|
|
fullIllustration.SetActive(false);
|
|
isDuringFullIllustrationFade = false;
|
|
})
|
|
.Play();
|
|
}
|
|
});
|
|
}
|
|
|
|
public void SetIllustration(Sprite cover, string illustratorName)
|
|
{
|
|
illustration.sprite = cover;
|
|
illustratorText.text = illustratorName;
|
|
}
|
|
|
|
public void SetCharter(string charterName)
|
|
{
|
|
charterNameText.text = charterName == string.Empty ? "Unknown Charter" : charterName;
|
|
}
|
|
|
|
public void SetBeatmapInfo(BeatmapSave beatmapSave)
|
|
{
|
|
accuracyText.text = $"{beatmapSave.accuracy * 100:F2}%";
|
|
|
|
if (!beatmapSave.isAllPerfect)
|
|
{
|
|
fullComboMark.gameObject.SetActive(beatmapSave.isFullCombo);
|
|
}
|
|
|
|
allPerfectMark.gameObject.SetActive(beatmapSave.isAllPerfect);
|
|
}
|
|
}
|
|
} |