Files
ichni_Official/Assets/Scripts/GameUI/SummaryPageCanvas.cs

101 lines
3.8 KiB
C#
Raw Normal View History

2025-07-08 14:28:40 -04:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2026-07-25 13:27:53 -04:00
using Ichni.Localization;
2025-07-08 14:28:40 -04:00
using Ichni.UI;
using Michsky.MUIP;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine.UI;
2025-08-11 14:04:06 -04:00
namespace Ichni.RhythmGame
2025-07-08 14:28:40 -04:00
{
public class SummaryPageCanvas : UIPageBase
{
[Title("Song Information")]
public TMP_Text songNameText;
public TMP_Text composerText;
2025-08-11 14:04:06 -04:00
[Title("Illustration")]
public Image illustrationImage;
[Title("Character")]
public Image characterImage;
public TMP_Text characterNameText;
public TMP_Text sentenceText;
2026-07-25 13:27:53 -04:00
[Tooltip("角色名的 Unity Localization 文本。应配置 UI/ui_summary_soullies_name。")]
public LocalizedTMPText characterNameLocalizedText;
[Tooltip("角色短句的 Unity Localization 文本。应配置 UI/ui_summary_soullies_sentence_0。")]
public LocalizedTMPText sentenceLocalizedText;
2025-08-11 14:04:06 -04:00
[Title("Difficulty")]
2025-07-08 14:28:40 -04:00
public TMP_Text difficultyText;
2025-08-11 14:04:06 -04:00
public TMP_Text levelText;
[Title("ChartInfo")]
public TMP_Text illustratorText;
2025-07-08 14:28:40 -04:00
public TMP_Text chartDesignerText;
2025-08-11 14:04:06 -04:00
public TMP_Text songLengthText;
public TMP_Text bpmText;
[Title("Accuracy")]
public TMP_Text accuracyText;
2025-07-08 14:28:40 -04:00
[Title("Game Records")]
public TMP_Text perfectCountText;
public TMP_Text goodCountText;
public TMP_Text badCountText;
public TMP_Text missCountText;
public TMP_Text maxComboText;
2025-08-11 14:04:06 -04:00
[Title("ResultGraph")]
public ResultGraph resultGraph;
[Title("Return")]
public Button shareButton;
2025-07-08 14:28:40 -04:00
public Button restartButton;
public Button backButton;
2025-07-21 05:42:20 -04:00
public void SetUpSummary()
{
InformationTransistor info = InformationTransistor.instance;
songNameText.text = info.song.songName;
composerText.text = info.song.composer;
2025-08-11 14:04:06 -04:00
illustrationImage.sprite = info.song.illustration;
2026-07-25 13:27:53 -04:00
// Summary 页面没有再依赖 I2 Term。迁移期间允许旧场景先不绑定新字段
// 此时不会中断结算页面;完成 Inspector 配置后,两个 LocalizedTMPText 会自动跟随 Locale 切换。
characterNameLocalizedText ??= characterNameText.GetComponent<LocalizedTMPText>();
sentenceLocalizedText ??= sentenceText.GetComponent<LocalizedTMPText>();
characterNameLocalizedText?.RefreshText();
sentenceLocalizedText?.RefreshText();
2025-08-11 14:04:06 -04:00
2025-07-21 05:42:20 -04:00
difficultyText.text = info.difficulty.GetDifficultyName();
2025-08-11 14:04:06 -04:00
levelText.text = info.difficulty.difficultyValue.ToString();
2025-07-21 05:42:20 -04:00
chartDesignerText.text = info.difficulty.charterName;
2025-08-11 14:04:06 -04:00
illustratorText.text = info.song.illustratorName;
songLengthText.text = System.TimeSpan.FromSeconds(info.songLength).ToString(@"m\:ss");
bpmText.text = info.bpm.ToString("F1");
2025-07-21 05:42:20 -04:00
2026-03-14 03:13:10 -04:00
PlayingRecorder recorder = GameManager.Instance.playingRecorder;
2025-07-21 05:42:20 -04:00
perfectCountText.text = recorder.perfectCount.ToString();
goodCountText.text = recorder.goodCount.ToString();
badCountText.text = recorder.badCount.ToString();
missCountText.text = recorder.missCount.ToString();
accuracyText.text = recorder.accuracy.ToString("F2") + "%";
maxComboText.text = recorder.maxCombo.ToString();
2025-08-11 14:04:06 -04:00
resultGraph.Initialize(recorder.resultData);
2025-07-21 05:42:20 -04:00
restartButton.onClick.RemoveAllListeners();
restartButton.onClick.AddListener(GameManager.RestartGame);
backButton.onClick.RemoveAllListeners();
backButton.onClick.AddListener(GameManager.ReturnToMenu);
}
2025-07-08 14:28:40 -04:00
}
2026-07-25 13:27:53 -04:00
}