Introduce SongLoader class as some fields are only required while loading
Change relative to be a bool
This commit is contained in:
1 parent
31976ed498
commit
3c2d7dcafd
4 files changed
+516
-499
No files matched your search
@@ -312,7 +312,7 @@ namespace Vocaluxe.Base
|
|||||||
if (song == null)
|
if (song == null)
|
||||||
continue;
|
continue;
|
||||||
song.ID = _Songs.Count;
|
song.ID = _Songs.Count;
|
||||||
if (song.ReadNotes())
|
if (song.LoadNotes())
|
||||||
_Songs.Add(song);
|
_Songs.Add(song);
|
||||||
}
|
}
|
||||||
CLog.StopBenchmark(2, "Read TXTs");
|
CLog.StopBenchmark(2, "Read TXTs");
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace VocaluxeLib.Songs
|
|||||||
public string Folder = String.Empty;
|
public string Folder = String.Empty;
|
||||||
public string FolderName = String.Empty;
|
public string FolderName = String.Empty;
|
||||||
public string FileName = String.Empty;
|
public string FileName = String.Empty;
|
||||||
public EOffOn Relative = EOffOn.TR_CONFIG_OFF;
|
public bool Relative;
|
||||||
|
|
||||||
public string MP3FileName = String.Empty;
|
public string MP3FileName = String.Empty;
|
||||||
public string CoverFileName = String.Empty;
|
public string CoverFileName = String.Empty;
|
||||||
@@ -165,12 +165,6 @@ namespace VocaluxeLib.Songs
|
|||||||
//No point creating a song without a text file --> Use factory method LoadSong
|
//No point creating a song without a text file --> Use factory method LoadSong
|
||||||
private CSong() {}
|
private CSong() {}
|
||||||
|
|
||||||
public static CSong LoadSong(string filePath)
|
|
||||||
{
|
|
||||||
var song = new CSong();
|
|
||||||
return song._InitPaths(filePath) && song._ReadHeader() ? song : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CSong(CSong song)
|
public CSong(CSong song)
|
||||||
{
|
{
|
||||||
_CoverTextureSmall = song._CoverTextureSmall;
|
_CoverTextureSmall = song._CoverTextureSmall;
|
||||||
@@ -236,6 +230,19 @@ namespace VocaluxeLib.Songs
|
|||||||
Notes = new CNotes(song.Notes);
|
Notes = new CNotes(song.Notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CSong LoadSong(string filePath)
|
||||||
|
{
|
||||||
|
var song = new CSong();
|
||||||
|
var loader = new CSongLoader(song);
|
||||||
|
return loader.InitPaths(filePath) && loader.ReadHeader() ? song : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool LoadNotes()
|
||||||
|
{
|
||||||
|
var loader = new CSongLoader(this);
|
||||||
|
return loader.ReadNotes();
|
||||||
|
}
|
||||||
|
|
||||||
public string GetMP3()
|
public string GetMP3()
|
||||||
{
|
{
|
||||||
return Path.Combine(Folder, MP3FileName);
|
return Path.Combine(Folder, MP3FileName);
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ namespace VocaluxeLib.Songs
|
|||||||
//Maybe we have to split the previous line
|
//Maybe we have to split the previous line
|
||||||
while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat)
|
while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat)
|
||||||
{
|
{
|
||||||
throw new Exception("This should not happen on song loading!");
|
//throw new Exception("This should not happen on song loading!");
|
||||||
line.AddNote(prevLine.LastNote);
|
line.AddNote(prevLine.LastNote);
|
||||||
prevLine.DeleteNote(prevLine.NoteCount - 1);
|
prevLine.DeleteNote(prevLine.NoteCount - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user