Beispiel #1
0
        /// <summary>
        /// Loads an AFF beatmap from string.
        /// </summary>
        /// <param name="text">AFF beatmap content string.</param>
        public void LoadFrom([NotNull] string text)
        {
            Beatmap.TryParse(text, out var newBeatmap);

            var oldBeatmap = Beatmap;

            Beatmap = newBeatmap;

            BeatmapChanged?.Invoke(this, new BeatmapChangedEventArgs(oldBeatmap, newBeatmap));

            var game         = Game.ToBaseGame();
            var debugOverlay = game.FindSingleElement <DebugOverlay>();

            if (debugOverlay != null)
            {
                if (newBeatmap != null)
                {
                    debugOverlay.AddLine($"Loaded beatmap from string.");
                }
                else
                {
                    debugOverlay.AddLine($"Failed to load beatmap from string.");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Loads an AFF beatmap from file.
        /// </summary>
        /// <param name="filePath">Path to the file that contains AFF beatmap data.</param>
        public void Load([NotNull] string filePath)
        {
            Beatmap newBeatmap;

            using (var fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                using (var reader = new StreamReader(fileStream, Encoding.UTF8)) {
                    Beatmap.TryParse(reader, out newBeatmap);
                }
            }

            var oldBeatmap = Beatmap;

            Beatmap = newBeatmap;

            BeatmapChanged?.Invoke(this, new BeatmapChangedEventArgs(oldBeatmap, newBeatmap));

            var game         = Game.ToBaseGame();
            var debugOverlay = game.FindSingleElement <DebugOverlay>();

            if (debugOverlay != null)
            {
                if (newBeatmap != null)
                {
                    debugOverlay.AddLine($"Loaded beatmap from '{filePath}'.");
                }
                else
                {
                    debugOverlay.AddLine($"Failed to load beatmap from '{filePath}'.");
                }
            }
        }
 protected virtual void OnBeatmapChanged()
 {
     BeatmapChanged?.Invoke(this, EventArgs.Empty);
 }