Esempio n. 1
0
 public Beatmap(
     BeatmapSettings settings,
     Texture2D backgroundTexture,
     Music music,
     TimingPointContainer timingPoints,
     HitObjectContainer hitObjects)
 {
     Settings          = settings;
     BackgroundTexture = backgroundTexture;
     Music             = music;
     TimingPoints      = timingPoints;
     HitObjects        = hitObjects;
 }
Esempio n. 2
0
        public TimingPointContainer ReadTimingPoints(string beatmapName, BeatmapSettings beatmapSettings)
        {
            TimingPointContainer timingPointContainer = new TimingPointContainer();

            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ProcessorSettings.BeatmapsFolder, beatmapName,
                                       ProcessorSettings.TimingPointsFolder, beatmapSettings.TimingPointsFilename + "_" + beatmapSettings.Metadata.Version);

            Console.WriteLine(path);

            LogHelper.Log($"BeatmapReader: Reading Beatmap Timing Points '{beatmapName}'");

            // Reading TimingPoints file, which contains all the timing points used in the beatmap
            using (StreamReader sr = new StreamReader(path))
            {
                LogHelper.Log($"BeatmapReader: Found Beatmap Timing Points file '{beatmapSettings.TimingPointsFilename}'");
                string   full  = sr.ReadToEnd();
                string[] lines = full.Split('\n');
                foreach (var line in lines)
                {
                    // If the line is empty or contains only whitespaces, skip it
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }

                    // Split the line, remove all whitespaces
                    string[] tokens = Array.ConvertAll(line.Split(' '), p => p.Trim());

                    // First is TP position
                    // Second is Ms per beat
                    // Third is time signature (n/4, where n is the number)
                    // Fourth is hitsound volume
                    // Fifth determines if metronome must be reset on the start of the timing point
                    TimingPoint tp = new TimingPoint(
                        int.Parse(tokens[0]),
                        double.Parse(tokens[1]),
                        int.Parse(tokens[2]),
                        int.Parse(tokens[3]),
                        bool.Parse(tokens[4]));

                    timingPointContainer.Add(tp);
                }
            }
            LogHelper.Log($"BeatmapReader: Successfully Read Beatmap Timing Points. Total Timing Point count: {timingPointContainer.Count}");

            return(timingPointContainer);
        }