83 lines
3.1 KiB
C#
83 lines
3.1 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}%";
|
||
|
||
// 两种成绩徽记互斥显示:All Perfect 的优先级高于 Full Combo。
|
||
// 必须每次都显式设置两个对象;仅在非 All Perfect 时更新 Full Combo 会让 Prefab
|
||
// 初始状态或上一次选择谱面的显示状态残留,造成首次进入时同时出现两个徽记。
|
||
bool showAllPerfect = beatmapSave.isAllPerfect;
|
||
fullComboMark.gameObject.SetActive(!showAllPerfect && beatmapSave.isFullCombo);
|
||
allPerfectMark.gameObject.SetActive(showAllPerfect);
|
||
}
|
||
}
|
||
}
|