修复小问题 结算装了一点
This commit is contained in:
@@ -7,7 +7,7 @@ public class SongButton : MonoBehaviour
|
||||
{
|
||||
[Header("thisSong_so")]
|
||||
public ScriptableObject thisSong_so;
|
||||
[Header("展示的信息")]
|
||||
[Header("展示的信息")]
|
||||
public Text songNameText;
|
||||
public Text multiNameText;
|
||||
public Text joinTime_and_dlcName_Text;
|
||||
@@ -16,7 +16,7 @@ public class SongButton : MonoBehaviour
|
||||
public Text difficultyIDText;
|
||||
public Text songIDText;
|
||||
public Image buttonImage;
|
||||
[Header("头图")]
|
||||
[Header("头图")]
|
||||
public Image profileImage;
|
||||
public int song_songSerialID;
|
||||
[Header("select mark")]
|
||||
@@ -50,7 +50,7 @@ public class SongButton : MonoBehaviour
|
||||
|
||||
public void SetButtonData(string songName, int highestScore, int difficultyID, Sprite songSprite, int songID)
|
||||
{
|
||||
Debug.Log("SetButtonData 被调用, songID 参数: " + songID);
|
||||
Debug.Log("SetButtonData 被调用, songID 参数: " + songID);
|
||||
|
||||
var sd = SongDataLibrary.Instance != null ? SongDataLibrary.Instance.GetSongDataByID(songID) : null;
|
||||
if (sd != null)
|
||||
@@ -58,18 +58,18 @@ public class SongButton : MonoBehaviour
|
||||
if (songNameText != null) songNameText.text = sd.songName;
|
||||
|
||||
if (multiNameText != null)
|
||||
multiNameText.text = "音乐:" + sd.artistName + " | 曲绘:" + sd.painter + " | 制谱:" + sd.level_creator;
|
||||
multiNameText.text = "音乐:" + sd.artistName + " | 曲绘:" + sd.painter + " | 制谱:" + sd.level_creator;
|
||||
|
||||
if (joinTime_and_dlcName_Text != null)
|
||||
{
|
||||
string join = string.IsNullOrEmpty(sd.thisLevel_addDateString) ? "未知" : sd.thisLevel_addDateString;
|
||||
string dlc = string.IsNullOrEmpty(sd.belongsTo_whichDLC) ? "未归档DLC" : sd.belongsTo_whichDLC;
|
||||
joinTime_and_dlcName_Text.text = "歌曲收录时间:" + join + " | " + "所属DLC:" + dlc;
|
||||
string join = string.IsNullOrEmpty(sd.thisLevel_addDateString) ? "未知" : sd.thisLevel_addDateString;
|
||||
string dlc = string.IsNullOrEmpty(sd.belongsTo_whichDLC) ? "未归档DLC" : sd.belongsTo_whichDLC;
|
||||
joinTime_and_dlcName_Text.text = "歌曲收录时间:" + join + " | " + "所属DLC:" + dlc;
|
||||
}
|
||||
|
||||
if (songOverallDescriptionText != null)
|
||||
{
|
||||
songOverallDescriptionText.text = string.IsNullOrEmpty(sd.thisLevel_overallDescription) ? "暂无歌曲简介。" : sd.thisLevel_overallDescription;
|
||||
songOverallDescriptionText.text = string.IsNullOrEmpty(sd.thisLevel_overallDescription) ? "暂无歌曲简介。" : sd.thisLevel_overallDescription;
|
||||
}
|
||||
|
||||
int bestTotal = 0;
|
||||
@@ -98,18 +98,25 @@ public class SongButton : MonoBehaviour
|
||||
|
||||
if (highestScoreText != null) highestScoreText.text = bestTotal.ToString();
|
||||
|
||||
string diffDisplay = bestDiff.ToString();
|
||||
if (sd.chartFiles != null)
|
||||
// Determine displayed difficulty: show the highest difficultyLEVEL present in chartFiles (if any)
|
||||
string diffDisplay = "0";
|
||||
if (sd.chartFiles != null && sd.chartFiles.Count > 0)
|
||||
{
|
||||
float maxLevel = float.MinValue;
|
||||
foreach (var entry in sd.chartFiles)
|
||||
{
|
||||
if (entry != null && entry.difficulty == bestDiff)
|
||||
if (entry == null) continue;
|
||||
if (entry.difficultyLEVEL > maxLevel)
|
||||
{
|
||||
diffDisplay = entry.difficultyLEVEL.ToString();
|
||||
break;
|
||||
maxLevel = entry.difficultyLEVEL;
|
||||
}
|
||||
}
|
||||
if (maxLevel != float.MinValue)
|
||||
{
|
||||
diffDisplay = maxLevel.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
if (difficultyIDText != null) difficultyIDText.text = diffDisplay;
|
||||
|
||||
if (buttonImage != null) buttonImage.sprite = sd.backgroudPIC;
|
||||
@@ -129,7 +136,7 @@ public class SongButton : MonoBehaviour
|
||||
}
|
||||
|
||||
song_songSerialID = songID;
|
||||
if (songIDText != null) songIDText.text = "数据库索引号:" + song_songSerialID.ToString();
|
||||
if (songIDText != null) songIDText.text = "数据库索引号:" + song_songSerialID.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -144,7 +151,7 @@ public class SongButton : MonoBehaviour
|
||||
|
||||
public void OnSongButtonClick()
|
||||
{
|
||||
Debug.Log("点击按钮的 song_songSerialID: " + song_songSerialID);
|
||||
Debug.Log("点击按钮的 song_songSerialID: " + song_songSerialID);
|
||||
SongData selectedSong = SongDataLibrary.Instance.GetSongDataByID(song_songSerialID);
|
||||
if (selectedSong != null)
|
||||
{
|
||||
@@ -173,7 +180,7 @@ public class SongButton : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("未找到对应的 SongData, songID: " + song_songSerialID);
|
||||
Debug.LogError("未找到对应的 SongData, songID: " + song_songSerialID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user