From 582ea09d63c807e8c2fd02fa70a1f4fcf01d2c2c Mon Sep 17 00:00:00 2001 From: EliteAsian Date: Sun, 23 Apr 2023 14:02:10 -0400 Subject: [PATCH] Added backward compatibility for score files --- .../MoonscraperChartParser/IO/Midi/MidReader.cs | 14 +++++++------- Assets/Script/ScoreManager.cs | 3 +++ Assets/Script/UI/PostSong.cs | 2 +- Assets/Script/UI/SelectedSongView.cs | 8 ++++++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Assets/Plugins/MoonscraperChartParser/IO/Midi/MidReader.cs b/Assets/Plugins/MoonscraperChartParser/IO/Midi/MidReader.cs index b298ff8dc..1a35ddc21 100644 --- a/Assets/Plugins/MoonscraperChartParser/IO/Midi/MidReader.cs +++ b/Assets/Plugins/MoonscraperChartParser/IO/Midi/MidReader.cs @@ -305,13 +305,13 @@ static void ProcessPendingUserMessages(IList messageList, processParams.processFn(processParams); } #else - callBackState = CallbackState.WaitingForExternalInformation; - NativeMessageBox.Result result = NativeMessageBox.Show(processParams.message, processParams.title, NativeMessageBox.Type.YesNo, null); - callBackState = CallbackState.None; - if (result == NativeMessageBox.Result.Yes) - { - processParams.processFn(processParams); - } + // callBackState = CallbackState.WaitingForExternalInformation; + // NativeMessageBox.Result result = NativeMessageBox.Show(processParams.message, processParams.title, NativeMessageBox.Type.YesNo, null); + // callBackState = CallbackState.None; + // if (result == NativeMessageBox.Result.Yes) + // { + // processParams.processFn(processParams); + // } #endif } } diff --git a/Assets/Script/ScoreManager.cs b/Assets/Script/ScoreManager.cs index 032662842..6cfd64ac3 100644 --- a/Assets/Script/ScoreManager.cs +++ b/Assets/Script/ScoreManager.cs @@ -51,6 +51,9 @@ public static void PushScore(SongInfo song, SongScore score) { oldScore.lastPlayed = score.lastPlayed; oldScore.timesPlayed += score.timesPlayed; + // Create a highestScore dictionary for backwards compatibility (if null) + oldScore.highestScore ??= new(); + // Merge high scores foreach (var kvp in score.highestPercent) { // percent if (oldScore.highestPercent.TryGetValue(kvp.Key, out var old)) { diff --git a/Assets/Script/UI/PostSong.cs b/Assets/Script/UI/PostSong.cs index 369f832bd..b91757dfd 100644 --- a/Assets/Script/UI/PostSong.cs +++ b/Assets/Script/UI/PostSong.cs @@ -69,7 +69,7 @@ private void OnEnable() { } // Override or add score/percentage - if (oldScore == null || + if (oldScore == null || oldScore.highestScore == null || !oldScore.highestScore.TryGetValue(player.chosenInstrument, out var oldHighestSc) || lastScore.score > oldHighestSc) { diff --git a/Assets/Script/UI/SelectedSongView.cs b/Assets/Script/UI/SelectedSongView.cs index a21362a0f..f720e1881 100644 --- a/Assets/Script/UI/SelectedSongView.cs +++ b/Assets/Script/UI/SelectedSongView.cs @@ -1,13 +1,17 @@ using System.Collections; using System.IO; -using System; using TMPro; using UnityEngine; -using UnityEngine.Experimental.Rendering; using UnityEngine.Networking; using UnityEngine.UI; using YARG.Data; +#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX + +using System; + +#endif + namespace YARG.UI { public class SelectedSongView : MonoBehaviour { [SerializeField]