/// <summary> /// Loads a track from the passed in directory. The directory should /// have all the files that is necessary for the loading to complete. /// </summary> /// <param name="songDirectory">The absolute path to the directory of which all the song definitions and difficulty definitions exist.</param> /// <returns></returns> public static Track LoadTrackData(string songDirectory) { Console.Write("Loading song from directory: "); Console.WriteLine(songDirectory); char[] splitter = {':'}; string[] trackFiles = Directory.GetFiles(songDirectory, "*.tdef"); StreamReader file = File.OpenText(trackFiles[0]); Track track = new Track(); track.FileDirectory = songDirectory; // Begin reading file for (string[] line; !file.EndOfStream;) { // Splits data into two usable portions. // [0]: Data type // [1]: Data value line = file.ReadLine().Split(splitter, 2); // Data type switch (line[0]) { case "Name": track.Name = line[1]; break; case "Artist": track.Artist = line[1]; break; case "Audio": track.AudioFilename = line[1]; break; } } Queue<string> trackDiffs = new Queue<string>(Directory.GetFiles(songDirectory, "*.tdiff")); track.Diffs = new List<TrackData>(trackDiffs.Count()); for (; trackDiffs.Count > 0; ) { string trackDiff = trackDiffs.Dequeue(); track.Diffs.Add(TrackData.LoadTrackFromFile(trackDiff)); } return track; }
public TrackSelection(Track track, TrackData diff) { Track = track; Diff = diff; }