优化ui,谱面替换,以及科研模糊
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class SongDetailsUI : MonoBehaviour
|
||||
{
|
||||
@@ -26,6 +27,15 @@ public class SongDetailsUI : MonoBehaviour
|
||||
public Text thisSong_progressText;
|
||||
public Text thisSong_lastScoreText; // will show last run total score if available
|
||||
public Text idolRecordText;
|
||||
public TextMeshProUGUI timeSpentText;
|
||||
public TextMeshProUGUI enterTimeText;
|
||||
public Text difficultyIdText;
|
||||
public Image progressImage;
|
||||
public GameObject progressNumberObject;
|
||||
public TextMeshProUGUI progressPercentText;
|
||||
|
||||
public Image rankLevel_img;
|
||||
public RankConfig rc;
|
||||
//public Image songImage;
|
||||
|
||||
public int id_of_thisSong;
|
||||
@@ -63,6 +73,9 @@ public class SongDetailsUI : MonoBehaviour
|
||||
bpmText.text = "BPM : " + currentSong.bpm.ToString();
|
||||
profound_image.sprite = currentSong.fullscreen_songPicture;
|
||||
|
||||
if (timeSpentText != null) timeSpentText.text = "PlayTime: " + currentSong.time_totalPlayingTime.ToString("F0") + "s";
|
||||
if (enterTimeText != null) enterTimeText.text = "PlayCount: " + currentSong.game_enterTimes.ToString();
|
||||
|
||||
id_of_thisSong = currentSong.songID;
|
||||
detail_informations_text.text =
|
||||
$"{currentSong.artistName}" + " - " +
|
||||
@@ -127,6 +140,14 @@ public class SongDetailsUI : MonoBehaviour
|
||||
difficultyText.text = entry.difficultyLEVEL.ToString();
|
||||
difficultyDesciptionText.text = entry.difficultyDescription;
|
||||
|
||||
if (difficultyIdText != null)
|
||||
difficultyIdText.text = entry.difficultyLEVEL.ToString();
|
||||
|
||||
if (progressImage != null)
|
||||
progressImage.fillAmount = entry.levelProgressForThisDifficulty;
|
||||
|
||||
UpdateProgressUI(entry.levelProgressForThisDifficulty);
|
||||
|
||||
// read values from SongData (SO)
|
||||
int chartPersonal = currentSong.GetPersonalRecord(difficulty); // Documentation text normalized.
|
||||
int idol = currentSong.GetIdolRecord(difficulty); // Documentation text normalized.
|
||||
@@ -158,6 +179,9 @@ public class SongDetailsUI : MonoBehaviour
|
||||
thisSong_lastScoreText.text = lastRun.ToString();
|
||||
}
|
||||
|
||||
if (rankLevel_img != null && rc != null)
|
||||
rankLevel_img.sprite = rc.GetRankSprite(total);
|
||||
|
||||
// also keep per-entry convenience fields in sync for inspector visibility
|
||||
entry.chartPersonalRecordForThisDifficulty = chartPersonal;
|
||||
entry.idolPersonalRecordForThisDifficulty = idol;
|
||||
@@ -166,6 +190,11 @@ public class SongDetailsUI : MonoBehaviour
|
||||
else
|
||||
{
|
||||
difficultyText.text = difficulty.ToString();
|
||||
if (difficultyIdText != null)
|
||||
difficultyIdText.text = difficulty.ToString();
|
||||
if (progressImage != null)
|
||||
progressImage.fillAmount = 0f;
|
||||
UpdateProgressUI(0f);
|
||||
difficultyDesciptionText.text = "";
|
||||
personalRecordText.text = "0";
|
||||
if (idolRecordText != null)
|
||||
@@ -174,6 +203,39 @@ public class SongDetailsUI : MonoBehaviour
|
||||
chartScoreText.text = "0";
|
||||
if (thisSong_lastScoreText != null)
|
||||
thisSong_lastScoreText.text = "0";
|
||||
if (rankLevel_img != null && rc != null)
|
||||
rankLevel_img.sprite = rc.defaultSprite;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateProgressUI(float progress)
|
||||
{
|
||||
// 1. Update Text (can exceed 100%)
|
||||
if (progressPercentText != null)
|
||||
{
|
||||
progressPercentText.text = Mathf.FloorToInt(progress * 100f).ToString() + "%";
|
||||
}
|
||||
|
||||
// 2. Clamp for visual elements (fillAmount and Object position)
|
||||
float clampedProgress = Mathf.Clamp01(progress);
|
||||
|
||||
// Update fillAmount again just in case, though handled in caller
|
||||
if (progressImage != null)
|
||||
{
|
||||
progressImage.fillAmount = clampedProgress;
|
||||
}
|
||||
|
||||
// 3. Update Object Position (Linear transformation: 0% -> -785, 100% -> -195)
|
||||
if (progressNumberObject != null)
|
||||
{
|
||||
RectTransform rect = progressNumberObject.GetComponent<RectTransform>();
|
||||
if (rect != null)
|
||||
{
|
||||
float targetX = Mathf.Lerp(-785f, -195f, clampedProgress);
|
||||
Vector2 anchoredPos = rect.anchoredPosition;
|
||||
anchoredPos.x = targetX;
|
||||
rect.anchoredPosition = anchoredPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user