mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:13:34 +08:00
Attempt full editor reload on key count change
This commit is contained in:
parent
3afe98612c
commit
da53a11d3c
@ -110,9 +110,31 @@ namespace osu.Game.Rulesets.Mania.Edit.Setup
|
||||
tickRateSlider.Current.BindValueChanged(_ => updateValues());
|
||||
}
|
||||
|
||||
private bool updatingKeyCount;
|
||||
|
||||
private void updateKeyCount(ValueChangedEvent<float> keyCount)
|
||||
{
|
||||
if (updatingKeyCount) return;
|
||||
|
||||
updatingKeyCount = true;
|
||||
|
||||
updateValues();
|
||||
editor.Reload().ContinueWith(t =>
|
||||
{
|
||||
if (!t.GetResultSafely())
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
changeHandler.RestoreState(-1);
|
||||
Beatmap.Difficulty.CircleSize = keyCountSlider.Current.Value = keyCount.OldValue;
|
||||
updatingKeyCount = false;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
updatingKeyCount = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateValues()
|
||||
|
@ -49,6 +49,11 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString ContinueEditing => new TranslatableString(getKey(@"continue_editing"), @"Oops, continue editing");
|
||||
|
||||
/// <summary>
|
||||
/// "The editor must be reloaded to apply this change. The beatmap will be saved."
|
||||
/// </summary>
|
||||
public static LocalisableString EditorReloadDialogHeader => new TranslatableString(getKey(@"editor_reload_dialog_header"), @"The editor must be reloaded to apply this change. The beatmap will be saved.");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
@ -1231,6 +1231,27 @@ namespace osu.Game.Screens.Edit
|
||||
loader?.CancelPendingDifficultySwitch();
|
||||
}
|
||||
|
||||
public Task<bool> Reload()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
dialogOverlay.Push(new ReloadEditorDialog(
|
||||
reload: () =>
|
||||
{
|
||||
bool reloadedSuccessfully = attemptMutationOperation(() =>
|
||||
{
|
||||
if (!Save())
|
||||
return false;
|
||||
|
||||
SwitchToDifficulty(editorBeatmap.BeatmapInfo);
|
||||
return true;
|
||||
});
|
||||
tcs.SetResult(reloadedSuccessfully);
|
||||
},
|
||||
cancel: () => tcs.SetResult(false)));
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public void HandleTimestamp(string timestamp)
|
||||
{
|
||||
if (!EditorTimestampParser.TryParse(timestamp, out var timeSpan, out string selection))
|
||||
|
34
osu.Game/Screens/Edit/ReloadEditorDialog.cs
Normal file
34
osu.Game/Screens/Edit/ReloadEditorDialog.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
public partial class ReloadEditorDialog : PopupDialog
|
||||
{
|
||||
public ReloadEditorDialog(Action reload, Action cancel)
|
||||
{
|
||||
HeaderText = EditorDialogsStrings.EditorReloadDialogHeader;
|
||||
|
||||
Icon = FontAwesome.Solid.Sync;
|
||||
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = DialogStrings.Confirm,
|
||||
Action = reload
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = DialogStrings.Cancel,
|
||||
Action = cancel
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user