예제 #1
0
        /// <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>
        static public 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);
        }
예제 #2
0
        public static TrackData LoadTrackFromFile(string fileName)
        {
            StreamReader stream = File.OpenText(fileName);
            TrackData data;
            string[] tokens;
            char[] splitChar = { ':' };
            //try {
            tokens = stream.ReadLine().Split(splitChar, 2, StringSplitOptions.None);
            string name = tokens[1];

            // Read key data
            tokens = stream.ReadLine().Split(splitChar);
            int noKeys = int.Parse(tokens[1]);
            Console.WriteLine(String.Format("Using {0} key(s).", noKeys));

            data = new TrackData(name, noKeys);

            tokens = stream.ReadLine().Split(splitChar);
            data.sections = new List<TrackSection>(int.Parse(tokens[1]));
            Console.WriteLine(String.Format("Loading {0} section(s)...", data.sections.Capacity));

            // Read note data
            // Temporary holder for held notes
            Note[] holdNotes = new Note[data.Keys];

            for (string line; !stream.EndOfStream; ) {
                if ((char)stream.Peek() == '[')
                    data.sections.Add(TrackSection.LoadTrackSection(stream, noKeys));
                else
                    line = stream.ReadLine();
            }
            for (int i = 0; i < data.Keys; ++i)
                Console.WriteLine(String.Format("[{0}]: {1} notes.", i, data.Sections.Last().Notes[i].Count));
            //} catch {
            //    Console.Error.WriteLine("Corrupt file!");
            //    data = new TrackData(0);
            //} finally {
            stream.Close();
            //}

            return data;
        }
예제 #3
0
 public TrackSelection(Track track, TrackData diff)
 {
     Track = track;
     Diff = diff;
 }
예제 #4
0
 public TrackSelection(Track track, TrackData diff)
 {
     Track = track;
     Diff  = diff;
 }