Beispiel #1
0
        private void scheduleDifficultySwitch(Func <WorkingBeatmap> nextBeatmap, EditorState editorState)
        {
            scheduledDifficultySwitch?.Cancel();
            ValidForResume = true;

            this.MakeCurrent();

            scheduledDifficultySwitch = Schedule(() =>
            {
                Beatmap.Value = nextBeatmap.Invoke();
                state         = editorState;

                // This screen is a weird exception to the rule that nothing after song select changes the global beatmap.
                // Because of this, we need to update the background stack's beatmap to match.
                // If we don't do this, the editor will see a discrepancy and create a new background, along with an unnecessary transition.
                ApplyToBackground(b => b.Beatmap = Beatmap.Value);

                pushEditor();
            });
        }
Beispiel #2
0
 /// <summary>
 /// Restore the editor to a provided state.
 /// </summary>
 /// <param name="state">The state to restore.</param>
 public void RestoreState([NotNull] EditorState state) => Schedule(() =>
 {
     clock.Seek(state.Time);
     Clipboard.Content.Value = state.ClipboardContent;
 });
Beispiel #3
0
        public void ScheduleSwitchToNewDifficulty(BeatmapInfo referenceBeatmapInfo, RulesetInfo rulesetInfo, bool createCopy, EditorState editorState)
        => scheduleDifficultySwitch(() =>
        {
            try
            {
                // fetch a fresh detached reference from database to avoid polluting model instances attached to cached working beatmaps.
                var targetBeatmapSet        = beatmapManager.QueryBeatmap(b => b.ID == referenceBeatmapInfo.ID).AsNonNull().BeatmapSet.AsNonNull();
                var referenceWorkingBeatmap = beatmapManager.GetWorkingBeatmap(referenceBeatmapInfo);

                return(createCopy
                        ? beatmapManager.CopyExistingDifficulty(targetBeatmapSet, referenceWorkingBeatmap)
                        : beatmapManager.CreateNewDifficulty(targetBeatmapSet, referenceWorkingBeatmap, rulesetInfo));
            }
            catch (Exception ex)
            {
                // if the beatmap creation fails (e.g. due to duplicated difficulty names),
                // bring the user back to the previous beatmap as a best-effort.
                Logger.Error(ex, ex.Message);
                return(Beatmap.Value);
            }
        }, editorState);
Beispiel #4
0
 public void ScheduleSwitchToExistingDifficulty(BeatmapInfo beatmapInfo, EditorState editorState)
 => scheduleDifficultySwitch(() => beatmapManager.GetWorkingBeatmap(beatmapInfo), editorState);