From aa0ba88c847d438aaca715002dbc696c248d2742 Mon Sep 17 00:00:00 2001 From: TheFatBastid Date: Fri, 12 May 2023 12:05:36 -0400 Subject: [PATCH 1/6] Updated Readme to remove duplicate The merge part was duplicated --- README.md | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/README.md b/README.md index c44a4236a..816cff8de 100644 --- a/README.md +++ b/README.md @@ -102,28 +102,6 @@ Resolving conflicts: 2. If the conflict doesn't resolve automatically, open the command prompt and use `git merge-tool`. 3. Verify that the conflict was resolved correctly, then commit/continue the merge. -> **Note** -> -> If you plan on merging branches, I highly recommend following these instructions for easier merges. - -Setup: -1. Open a command prompt to the repository (on VS Code you can do Terminal > New Terminal) -2. Type in `git config --local --edit` -3. In the file that gets opened, go to the bottom and paste this in: (You may need to change the file path depending on where you installed Unity to) -``` -[merge] - tool = unityyamlmerge -[mergetool "unityyamlmerge"] - trustExitCode = false - cmd = 'C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.21f1\\Editor\\Data\\Tools\\UnityYAMLMerge.exe' merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED" -``` -4. Save and close the file. - -Resolving conflicts: -1. Start the merge/cherry-pick which is causing conflicts. -2. If the conflict doesn't resolve automatically, open the command prompt and use `git merge-tool`. -3. Verify that the conflict was resolved correctly, then commit/continue the merge. - # ✍️ Contributing If you want to contribute, please feel free! Please join [our Discord](https://discord.gg/sqpu4R552r) if you want your PR/Art merged. From f4fbb918cccb72994b9fea925621b1c4dbc9d305 Mon Sep 17 00:00:00 2001 From: TheFatBastid Date: Fri, 12 May 2023 15:05:59 -0400 Subject: [PATCH 2/6] Added Mogg filename error output Change the error struct to add a file name. Added to when a con error is scanned, "" gets added for .ini songs --- Assets/Script/Song/Scanning/SongScanThread.cs | 8 ++++---- Assets/Script/Song/Scanning/SongScanner.cs | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Assets/Script/Song/Scanning/SongScanThread.cs b/Assets/Script/Song/Scanning/SongScanThread.cs index ef60df94e..bdca3476e 100644 --- a/Assets/Script/Song/Scanning/SongScanThread.cs +++ b/Assets/Script/Song/Scanning/SongScanThread.cs @@ -88,7 +88,7 @@ private void FullScan() { foreach (string cache in _songsByCacheFolder.Keys) { // Folder doesn't exist, so report as an error and skip if (!Directory.Exists(cache)) { - _songErrors[cache].Add(new SongError(cache, ScanResult.InvalidDirectory)); + _songErrors[cache].Add(new SongError(cache, ScanResult.InvalidDirectory, "")); Debug.LogError($"Invalid song directory: {cache}"); continue; @@ -146,7 +146,7 @@ private void ScanSubDirectory(string cacheFolder, string subDir, ICollection Date: Fri, 12 May 2023 17:08:27 -0400 Subject: [PATCH 3/6] Added a try/catch to con reading Without this, when an "access denied" folder is scanned, it will throw an IO error and end the scanning, and thus no cache is created. --- Assets/Script/Song/Scanning/SongScanThread.cs | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/Assets/Script/Song/Scanning/SongScanThread.cs b/Assets/Script/Song/Scanning/SongScanThread.cs index bdca3476e..15aebb195 100644 --- a/Assets/Script/Song/Scanning/SongScanThread.cs +++ b/Assets/Script/Song/Scanning/SongScanThread.cs @@ -178,44 +178,46 @@ private void ScanSubDirectory(string cacheFolder, string subDir, ICollection SongsInsideCON = XboxCONFileBrowser.BrowseCON(file); - // for each CON song that was found (assuming some WERE found) - if (SongsInsideCON != null) { - foreach (ConSongEntry SongInsideCON in SongsInsideCON) { - // validate that the song is good to add in-game - var CONResult = ScanConSong(cacheFolder, SongInsideCON); - switch (CONResult) { - case ScanResult.Ok: - _songsScanned++; - songsScanned = _songsScanned; - songs.Add(SongInsideCON); - break; - case ScanResult.NotASong: - break; - default: - _errorsEncountered++; - errorsEncountered = _errorsEncountered; - _songErrors[cacheFolder].Add(new SongError(subDir, CONResult, SongInsideCON.Name)); - Debug.LogWarning($"Error encountered with {subDir}"); - break; + try{ // try-catch to prevent crash if user doesn't have permission to access a folder + foreach (var file in Directory.EnumerateFiles(subDir)) { + // for each file found, read first 4 bytes and check for "CON " or "LIVE" + using var fs = new FileStream(file, FileMode.Open, FileAccess.Read); + using var br = new BinaryReader(fs); + string fHeader = Encoding.UTF8.GetString(br.ReadBytes(4)); + if (fHeader == "CON " || fHeader == "LIVE") { + List SongsInsideCON = XboxCONFileBrowser.BrowseCON(file); + // for each CON song that was found (assuming some WERE found) + if (SongsInsideCON != null) { + foreach (ConSongEntry SongInsideCON in SongsInsideCON) { + // validate that the song is good to add in-game + var CONResult = ScanConSong(cacheFolder, SongInsideCON); + switch (CONResult) { + case ScanResult.Ok: + _songsScanned++; + songsScanned = _songsScanned; + songs.Add(SongInsideCON); + break; + case ScanResult.NotASong: + break; + default: + _errorsEncountered++; + errorsEncountered = _errorsEncountered; + _songErrors[cacheFolder].Add(new SongError(subDir, CONResult, SongInsideCON.Name)); + Debug.LogWarning($"Error encountered with {subDir}"); + break; + } } } } } - } + string[] subdirectories = Directory.GetDirectories(subDir); - string[] subdirectories = Directory.GetDirectories(subDir); - - foreach (string subdirectory in subdirectories) { - ScanSubDirectory(cacheFolder, subdirectory, songs); + foreach (string subdirectory in subdirectories) { + ScanSubDirectory(cacheFolder, subdirectory, songs); + } + }catch(Exception e){ + Debug.LogException(e); } } From f1fed7fbb3d434501364de17974e6bdc07792dd9 Mon Sep 17 00:00:00 2001 From: TheFatBastid Date: Fri, 12 May 2023 17:33:10 -0400 Subject: [PATCH 4/6] Fixed small error when scrolling past limits While things still worked fine, we shouldn't have errors being generated. --- Assets/Script/UI/MusicLibrary/SongSelection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Assets/Script/UI/MusicLibrary/SongSelection.cs b/Assets/Script/UI/MusicLibrary/SongSelection.cs index 8a8424518..ace501c98 100644 --- a/Assets/Script/UI/MusicLibrary/SongSelection.cs +++ b/Assets/Script/UI/MusicLibrary/SongSelection.cs @@ -48,7 +48,6 @@ public int SelectedIndex { get => _selectedIndex; private set { _selectedIndex = value; - // Wrap if (_selectedIndex < 0) { _selectedIndex = _songs.Count - _selectedIndex - 2; @@ -56,7 +55,7 @@ private set { _selectedIndex -= _songs.Count; } - if (_songs[value] is SongViewType song) { + if (_songs[_selectedIndex] is SongViewType song) { GameManager.Instance.SelectedSong = song.SongEntry; } From 43c88628b90c38cba883e12625b6cac5ce5ae605 Mon Sep 17 00:00:00 2001 From: TheFatBastid Date: Fri, 12 May 2023 19:53:10 -0400 Subject: [PATCH 5/6] Added Json support for currentSong Note: There is no GUI button for this yet! Also, added a toast to updateChecker --- Assets/Script/ThirdParty/TwitchController.cs | 32 +++++++++----------- Assets/Script/ThirdParty/UpdateChecker.cs | 1 + 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Assets/Script/ThirdParty/TwitchController.cs b/Assets/Script/ThirdParty/TwitchController.cs index 61376f179..83759045a 100644 --- a/Assets/Script/ThirdParty/TwitchController.cs +++ b/Assets/Script/ThirdParty/TwitchController.cs @@ -17,13 +17,14 @@ public static TwitchController Instance { // Creates .TXT file witth current song information public string TextFilePath => Path.Combine(GameManager.PersistentDataPath, "currentSong.txt"); + // Creates .JSON file with current song information + public string JsonFilePath => Path.Combine(GameManager.PersistentDataPath, "currentSong.json"); private void Start() { Instance = this; - // While YARG should delete the file on exit, you never know if a crash or something prevented that. - DeleteCurrentSongFile(); - CreateEmptySongFile(); + // While YARG should blank the file on exit, you never know if a crash or something prevented that. + BlankSongFile(); // Listen to the changing of songs Play.OnSongStart += OnSongStart; @@ -36,29 +37,24 @@ private void Start() { Play.OnPauseToggle += OnPauseToggle; } - private void CreateEmptySongFile() { - // Open the text file for appending - using var writer = new StreamWriter(TextFilePath, false); - - // Make the file blank (Avoid errors in OBS) - writer.Write(""); - } - - private void DeleteCurrentSongFile() { + private void BlankSongFile() { // Open the text file for appending using var writer = new StreamWriter(TextFilePath, false); + using var jsonWriter = new StreamWriter(JsonFilePath, false); // Make the file blank (Avoid errors in OBS) writer.Write(""); + jsonWriter.Write(""); } private void OnApplicationQuit() { - DeleteCurrentSongFile(); + BlankSongFile(); } void OnSongStart(SongEntry song) { // Open the text file for appending using var writer = new StreamWriter(TextFilePath, false); + using var jsonWriter = new StreamWriter(JsonFilePath, false); // Get the input string str = $"{song.Name}\n{song.Artist}\n{song.Album}\n{song.Genre}\n" + @@ -68,17 +64,17 @@ void OnSongStart(SongEntry song) { if (TagRegex.IsMatch(str)) { str = TagRegex.Replace(str, string.Empty); } + + // Convert to JSON + string json = JsonUtility.ToJson(song); // Write text to the file writer.Write(str); + jsonWriter.Write(json); } void OnSongEnd(SongEntry song) { - // Open the text file for appending - using var writer = new StreamWriter(TextFilePath, false); - - // Make the file blank (Avoid errors in OBS) - writer.Write(""); + BlankSongFile(); } private void OnInstrumentSelection(PlayerManager.Player playerInfo) { diff --git a/Assets/Script/ThirdParty/UpdateChecker.cs b/Assets/Script/ThirdParty/UpdateChecker.cs index 7cf30b846..3c623a1d0 100644 --- a/Assets/Script/ThirdParty/UpdateChecker.cs +++ b/Assets/Script/ThirdParty/UpdateChecker.cs @@ -59,6 +59,7 @@ private async void CheckForUpdates() { IsOutOfDate = true; Debug.Log($"Update available! New version: {releaseTag}"); + ToastManager.ToastInformation($"Update available! New version: {releaseTag}"); } else { Debug.Log("Game is up to date."); ToastManager.ToastMessage("Game is up to date."); From 02a302802f7e86376235386d4a8ce5c8306e8d7b Mon Sep 17 00:00:00 2001 From: TheFatBastid Date: Sat, 13 May 2023 11:57:28 -0400 Subject: [PATCH 6/6] Update SongScanThread.cs fixed spacing --- Assets/Script/Song/Scanning/SongScanThread.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Assets/Script/Song/Scanning/SongScanThread.cs b/Assets/Script/Song/Scanning/SongScanThread.cs index 5ac8d2e83..95bfb806a 100644 --- a/Assets/Script/Song/Scanning/SongScanThread.cs +++ b/Assets/Script/Song/Scanning/SongScanThread.cs @@ -225,13 +225,11 @@ private void ScanSubDirectory(string cacheFolder, string subDir, ICollection