-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83b2aee
commit 7ffda59
Showing
11 changed files
with
137 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.IO; | ||
using IniParser; | ||
using UnityEngine; | ||
using YARG.UI; | ||
|
||
namespace YARG.Serialization { | ||
public static class SongIni { | ||
public static SongInfo CompleteSongInfo(SongInfo song, FileIniDataParser parser) { | ||
if (song.fetched) { | ||
return song; | ||
} | ||
|
||
var file = new FileInfo(Path.Combine(song.folder.ToString(), "song.ini")); | ||
if (!file.Exists) { | ||
return song; | ||
} | ||
|
||
song.fetched = true; | ||
try { | ||
var data = parser.ReadFile(file.FullName); | ||
|
||
// Set basic info | ||
song.SongName ??= data["song"]["name"]; | ||
song.artistName ??= data["song"]["artist"]; | ||
song.source ??= data["song"]["icon"]; | ||
|
||
// Get song length | ||
if (data["song"].ContainsKey("song_length")) { | ||
int rawLength = int.Parse(data["song"]["song_length"]); | ||
song.songLength = rawLength / 1000f; | ||
} else { | ||
Debug.LogWarning($"No song length found for: {song.folder}"); | ||
} | ||
|
||
// Get song delay (0 if none) | ||
if (data["song"].ContainsKey("delay")) { | ||
int rawDelay = int.Parse(data["song"]["delay"]); | ||
song.delay = rawDelay / 1000f; | ||
} else { | ||
song.delay = 0f; | ||
} | ||
} catch (Exception e) { | ||
song.errored = true; | ||
Debug.LogException(e); | ||
} | ||
|
||
return song; | ||
} | ||
|
||
public static SongInfo CompleteSongInfo(SongInfo song) { | ||
return CompleteSongInfo(song, new FileIniDataParser()); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace YARG.Utils { | ||
public static class SourceDelays { | ||
public static float GetSourceDelay(string source) { | ||
// Hardcode a delay for certain games (such as RB1). | ||
// There may be a chance that I am reading the MIDI or something | ||
// incorrectly. This is the fix for now, and it seems to work for | ||
// the most part. | ||
return source switch { | ||
"rb1" or "rb1dlc" => 0.15f, | ||
_ => 0f | ||
}; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.