修复小问题 结算装了一点

This commit is contained in:
2026-01-14 10:02:45 +08:00
parent 2f9d4aae0c
commit 271a576289
15 changed files with 48793 additions and 850 deletions
+95
View File
@@ -8,7 +8,22 @@ public class selected_songInfo : MonoBehaviour
{
public Image t_songCoverImage;
public Image btm_songCoverImage;
[Header("极简信息")]
public Text songNameText;
public Text currentDifficulty;
public Text sumScore_thisDifficulty;
public Text total_gameTime;
private int maxDifficulty = 22;
public Image c_DifficultyImage;
public Image c_imageMask;
[Header("分级颜色")]
public Color _0to5d5;
public Color _5d5to11;
public Color _11to16d5;
public Color _16d5to22;
public Color _equal22;
[Header("对应的难度按钮")]
public List<Button> difficultyButtons = new List<Button>();
[Header("对应的难度文本")]
@@ -156,6 +171,61 @@ public class selected_songInfo : MonoBehaviour
// set difficulty button backgrounds according to currently selected difficulty in the song SO
SetDifficultyButtonBackground(song.thisLevel_selectedDifficultyID);
// Update currentDifficulty text and colored difficulty bar
float difficultyLevel = GetDifficultyLevel(song, song.thisLevel_selectedDifficultyID);
if (currentDifficulty != null)
{
currentDifficulty.text = difficultyLevel.ToString("0.0");
}
if (c_DifficultyImage != null)
{
// fill amount is ratio of difficultyLevel / maxDifficulty
float fill = Mathf.Clamp01(difficultyLevel / (float)maxDifficulty);
c_DifficultyImage.fillAmount = fill;
// choose color by ranges: left-closed, right-open, intervals of 5.5
// [0,5.5), [5.5,11), [11,16.5), [16.5,22), exactly 22 -> equal color
Color chosen = _0to5d5;
if (Mathf.Approximately(difficultyLevel, maxDifficulty))
{
chosen = _equal22;
}
else if (difficultyLevel >= 16.5f)
{
chosen = _16d5to22;
}
else if (difficultyLevel >= 11f)
{
chosen = _11to16d5;
}
else if (difficultyLevel >= 5.5f)
{
chosen = _5d5to11;
}
else if (difficultyLevel >= 0)
{
chosen = _0to5d5;
}
else
{
chosen = Color.white;
}
// ensure color is opaque
chosen.a = 1f;
// apply color to the mask image if available, otherwise fall back to the difficulty image
if (c_imageMask != null)
{
c_imageMask.color = chosen;
}
else
{
c_DifficultyImage.color = chosen;
}
}
}
else
{
@@ -246,6 +316,9 @@ public class selected_songInfo : MonoBehaviour
SongDataHolder.SelectedSongData.thisLevel_selectedDifficultyID = Mathf.Clamp(index, 0, 3);
// immediately update UI to reflect new selection
SetDifficultyButtonBackground(SongDataHolder.SelectedSongData.thisLevel_selectedDifficultyID);
// refresh displayed song info so currentDifficulty / difficulty bar update to new difficulty
UpdateSelectedSongDisplay();
}
else
{
@@ -716,4 +789,26 @@ public class selected_songInfo : MonoBehaviour
Debug.LogWarning("selected_songInfo: PauseManager not found when requesting pause");
}
}
// Helper to get difficulty level (float) from SongData for a given difficulty id
private float GetDifficultyLevel(SongData song, int difficultyId)
{
if (song == null) return 0f;
if (song.chartFiles != null)
{
foreach (var entry in song.chartFiles)
{
if (entry != null && entry.difficulty == difficultyId)
{
return entry.difficultyLEVEL;
}
}
}
// fallback: try dictionary if available
if (song.difficultyNumberMap != null && song.difficultyNumberMap.ContainsKey(difficultyId))
{
return (float)song.difficultyNumberMap[difficultyId];
}
return 0f;
}
}