Skip to content

Commit

Permalink
Added backward compatibility for score files
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Apr 23, 2023
1 parent 72805cc commit 582ea09
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Assets/Plugins/MoonscraperChartParser/IO/Midi/MidReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,13 @@ static void ProcessPendingUserMessages(IList<MessageProcessParams> 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
}
}
Expand Down
3 changes: 3 additions & 0 deletions Assets/Script/ScoreManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/UI/PostSong.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
8 changes: 6 additions & 2 deletions Assets/Script/UI/SelectedSongView.cs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down

0 comments on commit 582ea09

Please sign in to comment.