优化ui,谱面替换,以及科研模糊

This commit is contained in:
FloatGaming
2026-02-25 03:44:41 +08:00
parent 332307d18c
commit 0b75e93f71
114 changed files with 160279 additions and 290 deletions
+96 -2
View File
@@ -94,6 +94,7 @@ public class SongData : ScriptableObject
public Dictionary<int, int> personalRecordMap = new Dictionary<int, int>();
public Dictionary<int, int> idolRecordMap = new Dictionary<int, int>();
public Dictionary<int, int> chartScoreMap = new Dictionary<int, int>();
public Dictionary<int, float> levelProgressMap = new Dictionary<int, float>();
public Dictionary<int, TextAsset> chartFileMap = new Dictionary<int, TextAsset>();
public List<ChartFileEntry> chartFiles = new List<ChartFileEntry>();
@@ -286,6 +287,7 @@ public class SongData : ScriptableObject
if (personalRecordMap == null) personalRecordMap = new Dictionary<int, int>();
if (idolRecordMap == null) idolRecordMap = new Dictionary<int, int>();
if (chartScoreMap == null) chartScoreMap = new Dictionary<int, int>();
if (levelProgressMap == null) levelProgressMap = new Dictionary<int, float>();
if (chartFileMap == null) chartFileMap = new Dictionary<int, TextAsset>();
if (chartFiles == null) chartFiles = new List<ChartFileEntry>();
@@ -365,6 +367,7 @@ public class SongData : ScriptableObject
if (serializable != null)
{
serializable.ApplyTo(this);
SyncEntriesFromMaps();
// Debug.Log($"[SongData] {songName} data restored.");
}
}
@@ -375,6 +378,46 @@ public class SongData : ScriptableObject
}
}
public void ClearSaveDataAndReload()
{
game_enterTimes = 0;
time_totalPlayingTime = 0f;
current_levelProgress = 0f;
_if_level_is_EASE = false;
max_comboRecord = 0;
personalRecord = 0;
if (personalRecordMap == null) personalRecordMap = new Dictionary<int, int>();
else personalRecordMap.Clear();
if (idolRecordMap == null) idolRecordMap = new Dictionary<int, int>();
else idolRecordMap.Clear();
if (chartScoreMap == null) chartScoreMap = new Dictionary<int, int>();
else chartScoreMap.Clear();
if (levelProgressMap == null) levelProgressMap = new Dictionary<int, float>();
else levelProgressMap.Clear();
if (chartFiles != null)
{
for (int i = 0; i < chartFiles.Count; i++)
{
ChartFileEntry entry = chartFiles[i];
if (entry == null) continue;
entry.lastScoreForThisDifficulty = 0;
entry.chartPersonalRecordForThisDifficulty = 0;
entry.idolPersonalRecordForThisDifficulty = 0;
entry.totalPersonalRecordForThisDifficulty = 0;
entry.levelProgressForThisDifficulty = 0f;
}
}
UpdateOverallRecordsFromEntries();
SavePersistent();
LoadPersistent();
}
/// <summary>
/// 当检测到篡改或文件损坏时,重置所有动态记录并立即重新保存文件以恢复合法性。
/// </summary>
@@ -400,6 +443,9 @@ public class SongData : ScriptableObject
if (chartScoreMap == null) chartScoreMap = new Dictionary<int, int>();
else chartScoreMap.Clear();
if (levelProgressMap == null) levelProgressMap = new Dictionary<int, float>();
else levelProgressMap.Clear();
// 3. 立即调用保存方法,生成一个新的、带有正确哈希值的合法文件
SavePersistent();
@@ -480,6 +526,7 @@ public class SongData : ScriptableObject
if (personalRecordMap == null) personalRecordMap = new Dictionary<int, int>();
if (idolRecordMap == null) idolRecordMap = new Dictionary<int, int>();
if (chartScoreMap == null) chartScoreMap = new Dictionary<int, int>();
if (levelProgressMap == null) levelProgressMap = new Dictionary<int, float>();
int total = pmScore + idolScore;
int currentBestTotal = GetPersonalRecord(difficulty) + GetIdolRecord(difficulty);
@@ -501,12 +548,17 @@ public class SongData : ScriptableObject
entry.totalPersonalRecordForThisDifficulty = total;
}
float newProgress = maxScoreSum > 0 ? Mathf.Clamp01((float)total / (float)maxScoreSum) : 0f;
float newProgress = maxScoreSum > 0 ? (float)total / (float)maxScoreSum : 0f;
if (newProgress > entry.levelProgressForThisDifficulty)
{
entry.levelProgressForThisDifficulty = newProgress;
}
if (!levelProgressMap.ContainsKey(difficulty) || newProgress > levelProgressMap[difficulty])
{
levelProgressMap[difficulty] = newProgress;
}
entry.lastScoreForThisDifficulty = total;
}
@@ -517,6 +569,40 @@ public class SongData : ScriptableObject
SavePersistent();
}
/// <summary>
/// 将 Dictionary 中的数据同步回 ChartFileEntry 列表,确保 SO 内存数据与持久化数据一致。
/// </summary>
public void SyncEntriesFromMaps()
{
if (chartFiles == null) return;
foreach (var entry in chartFiles)
{
if (entry == null) continue;
int diff = entry.difficulty;
if (personalRecordMap != null && personalRecordMap.ContainsKey(diff))
entry.chartPersonalRecordForThisDifficulty = personalRecordMap[diff];
if (idolRecordMap != null && idolRecordMap.ContainsKey(diff))
entry.idolPersonalRecordForThisDifficulty = idolRecordMap[diff];
if (personalRecordMap != null && personalRecordMap.ContainsKey(diff) && idolRecordMap != null && idolRecordMap.ContainsKey(diff))
entry.totalPersonalRecordForThisDifficulty = personalRecordMap[diff] + idolRecordMap[diff];
else if (personalRecordMap != null && personalRecordMap.ContainsKey(diff))
entry.totalPersonalRecordForThisDifficulty = personalRecordMap[diff];
if (levelProgressMap != null && levelProgressMap.ContainsKey(diff))
entry.levelProgressForThisDifficulty = levelProgressMap[diff];
if (chartScoreMap != null && chartScoreMap.ContainsKey(diff))
entry.lastScoreForThisDifficulty = chartScoreMap[diff];
}
UpdateOverallRecordsFromEntries();
}
public void GetAbsoluteHighestScore(out int highestScore, out int bestDifficulty, out string bestDifficultyName)
{
highestScore = 0;
@@ -641,7 +727,11 @@ public class SongData : ScriptableObject
SongDataSerializable serializable = new SongDataSerializable(this);
string json = JsonUtility.ToJson(serializable);
SongDataSerializable roundTrip = JsonUtility.FromJson<SongDataSerializable>(json);
if (roundTrip != null) roundTrip.ApplyTo(this);
if (roundTrip != null)
{
roundTrip.ApplyTo(this);
SyncEntriesFromMaps();
}
}
public void UpdateIdolRecord(int difficulty, int newIdolScore)
@@ -726,6 +816,7 @@ public class SongData : ScriptableObject
if (personalRecordMap == null) personalRecordMap = new Dictionary<int, int>();
if (idolRecordMap == null) idolRecordMap = new Dictionary<int, int>();
if (chartScoreMap == null) chartScoreMap = new Dictionary<int, int>();
if (levelProgressMap == null) levelProgressMap = new Dictionary<int, float>();
if (chartFiles == null) return;
@@ -746,6 +837,9 @@ public class SongData : ScriptableObject
if (!chartScoreMap.ContainsKey(entry.difficulty) || entry.lastScoreForThisDifficulty > chartScoreMap[entry.difficulty])
chartScoreMap[entry.difficulty] = entry.lastScoreForThisDifficulty;
if (!levelProgressMap.ContainsKey(entry.difficulty) || entry.levelProgressForThisDifficulty > levelProgressMap[entry.difficulty])
levelProgressMap[entry.difficulty] = entry.levelProgressForThisDifficulty;
int p = personalRecordMap.ContainsKey(entry.difficulty) ? personalRecordMap[entry.difficulty] : 0;
int idol = idolRecordMap.ContainsKey(entry.difficulty) ? idolRecordMap[entry.difficulty] : 0;
entry.totalPersonalRecordForThisDifficulty = p + idol;