/// <summary>
        ///     Saves the map
        /// </summary>
        public void Save(bool exitAfter = false)
        {
            if (IsQuittingAfterSave)
            {
                return;
            }

            if (exitAfter)
            {
                IsQuittingAfterSave = true;
            }

            if (MapManager.Selected.Value.Game != MapGame.Quaver)
            {
                NotificationManager.Show(NotificationLevel.Error, "You cannot save a map loaded from another game.");
                return;
            }

            if (SaveInProgress)
            {
                NotificationManager.Show(NotificationLevel.Error, "Slow down! We're already saving your map.");
                return;
            }

            if (!MapDatabaseCache.MapsToUpdate.Contains(MapManager.Selected.Value))
            {
                MapDatabaseCache.MapsToUpdate.Add(MapManager.Selected.Value);
            }

            // Impoortant. Save the last save action, so we know whether or not the user has made changes.
            Ruleset.ActionManager.LastSaveAction = Ruleset.ActionManager.UndoStack.Count == 0 ? null : Ruleset.ActionManager.UndoStack.Peek();

            ThreadScheduler.Run(() =>
            {
                var path = $"{ConfigManager.SongDirectory}/{MapManager.Selected.Value.Directory}/{MapManager.Selected.Value.Path}";

                SaveInProgress = true;
                WorkingMap.Save(path);
                SaveInProgress = false;
                LastSaveTime   = GameBase.Game.TimeRunning;

                if (exitAfter)
                {
                    ExitToSelect();
                }
                else
                {
                    NotificationManager.Show(NotificationLevel.Success, "Successfully saved the map.");
                }
            });
        }
        /// <summary>
        ///     Autosave when the game crashes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCrash(object sender, UnhandledExceptionEventArgs e)
        {
            if (MapManager.Selected.Value.Game != MapGame.Quaver)
            {
                return;
            }

            if (Ruleset.ActionManager.UndoStack.Count == 0)
            {
                return;
            }

            Logger.Important($"Detected game crash. Autosaving map", LogType.Runtime);

            var path = $"{ConfigManager.SongDirectory}/{MapManager.Selected.Value.Directory}/{MapManager.Selected.Value.Path}.autosave";

            WorkingMap.Save(path);
        }