some updates
This commit is contained in:
@@ -35,6 +35,9 @@ public class selected_songInfo : MonoBehaviour
|
||||
public Text currentDifficulty;
|
||||
public Text sumScore_thisDifficulty;
|
||||
public Text total_gameTime;
|
||||
[Header("Current Difficulty Rank")]
|
||||
public Image currentDifficultyRankImage;
|
||||
public RankConfig currentDifficultyRankConfig;
|
||||
private int maxDifficulty = 22;
|
||||
|
||||
public Image c_DifficultyImage;
|
||||
@@ -404,6 +407,7 @@ public class selected_songInfo : MonoBehaviour
|
||||
ApplyDoNotShowAgainVisual();
|
||||
ResolveDifficultyIdDisplayTexts();
|
||||
GameConfig.LoadPrefs();
|
||||
GameConfig.SetAutoPlayEnabled(false);
|
||||
CacheAutoplayButtonImage();
|
||||
RefreshAutoplayButtonVisual();
|
||||
|
||||
@@ -821,43 +825,16 @@ public class selected_songInfo : MonoBehaviour
|
||||
c_DifficultyImage.fillAmount = fill;
|
||||
}
|
||||
|
||||
int totalForDifficulty = GetCurrentDifficultyTotalRecord(song);
|
||||
|
||||
// Update sumScore_thisDifficulty based on currently selected difficulty
|
||||
if (sumScore_thisDifficulty != null)
|
||||
{
|
||||
int sel = song.thisLevel_selectedDifficultyID;
|
||||
int totalForDifficulty = 0;
|
||||
// Try to find ChartFileEntry for this difficulty
|
||||
if (song.chartFiles != null)
|
||||
{
|
||||
foreach (var entry in song.chartFiles)
|
||||
{
|
||||
if (entry != null && entry.difficulty == sel)
|
||||
{
|
||||
if (entry.totalPersonalRecordForThisDifficulty > 0)
|
||||
{
|
||||
totalForDifficulty = entry.totalPersonalRecordForThisDifficulty;
|
||||
}
|
||||
else
|
||||
{
|
||||
int p = song.GetPersonalRecord(sel);
|
||||
int i = song.GetIdolRecord(sel);
|
||||
totalForDifficulty = p + i;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// fallback to maps if chartFiles did not contain entry
|
||||
if (totalForDifficulty == 0)
|
||||
{
|
||||
int p = song.GetPersonalRecord(sel);
|
||||
int i = song.GetIdolRecord(sel);
|
||||
totalForDifficulty = p + i;
|
||||
}
|
||||
|
||||
sumScore_thisDifficulty.text = totalForDifficulty.ToString();
|
||||
}
|
||||
|
||||
UpdateCurrentDifficultyRankImage(totalForDifficulty);
|
||||
|
||||
// Update total_gameTime once from SongData.game_enterTimes (no dynamic change on difficulty switch)
|
||||
if (total_gameTime != null)
|
||||
{
|
||||
@@ -889,12 +866,74 @@ public class selected_songInfo : MonoBehaviour
|
||||
SetDifficultyButtonBackground(-1);
|
||||
|
||||
if (sumScore_thisDifficulty != null) sumScore_thisDifficulty.text = "0";
|
||||
UpdateCurrentDifficultyRankImage(0);
|
||||
if (total_gameTime != null) total_gameTime.text = "0";
|
||||
UpdateDifficultyIdDisplayAnimated(0f, true);
|
||||
lastSongId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private int GetCurrentDifficultyTotalRecord(SongData song)
|
||||
{
|
||||
if (song == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
song.EnsurePersistentDataLoaded();
|
||||
int sel = song.thisLevel_selectedDifficultyID;
|
||||
int totalForDifficulty = 0;
|
||||
|
||||
if (song.chartFiles != null)
|
||||
{
|
||||
foreach (var entry in song.chartFiles)
|
||||
{
|
||||
if (entry == null || entry.difficulty != sel)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.totalPersonalRecordForThisDifficulty > 0)
|
||||
{
|
||||
totalForDifficulty = entry.totalPersonalRecordForThisDifficulty;
|
||||
}
|
||||
else
|
||||
{
|
||||
totalForDifficulty = entry.chartPersonalRecordForThisDifficulty + entry.idolPersonalRecordForThisDifficulty;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalForDifficulty <= 0)
|
||||
{
|
||||
int p = song.GetPersonalRecord(sel);
|
||||
int i = song.GetIdolRecord(sel);
|
||||
totalForDifficulty = p + i;
|
||||
}
|
||||
|
||||
return Mathf.Max(0, totalForDifficulty);
|
||||
}
|
||||
|
||||
private void UpdateCurrentDifficultyRankImage(int score)
|
||||
{
|
||||
if (currentDifficultyRankImage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentDifficultyRankConfig == null)
|
||||
{
|
||||
currentDifficultyRankImage.enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Sprite rankSprite = currentDifficultyRankConfig.GetRankSprite(score);
|
||||
currentDifficultyRankImage.sprite = rankSprite;
|
||||
currentDifficultyRankImage.enabled = rankSprite != null;
|
||||
}
|
||||
|
||||
private void EnsureOriginalSpritesCount()
|
||||
{
|
||||
if (difficultyButtons == null) return;
|
||||
@@ -958,13 +997,17 @@ public class selected_songInfo : MonoBehaviour
|
||||
// map button index 0..3 to song SO difficulty 0..3
|
||||
if (SongDataHolder.SelectedSongData != null)
|
||||
{
|
||||
SongDataHolder.SelectedSongData.thisLevel_selectedDifficultyID = Mathf.Clamp(index, 0, 3);
|
||||
int selectedDifficulty = Mathf.Clamp(index, 0, 3);
|
||||
SongSelectUI.SetSelectedDifficulty(selectedDifficulty);
|
||||
SongDataHolder.SelectedSongData.thisLevel_selectedDifficultyID = selectedDifficulty;
|
||||
PersistSelectedSongDifficulty(SongDataHolder.SelectedSongData);
|
||||
SongSelectUI.ApplySelectedDifficultyToLoadedSongButtons();
|
||||
// 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();
|
||||
SongButton.RefreshAllButtonsForCurrentDifficulty();
|
||||
PlayDifficultySwitchAnim(index);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user