mirror of
https://github.com/ppy/osu.git
synced 2026-05-30 13:30:57 +08:00
Prevent hiding skin editor during external edit operation
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
@@ -45,6 +46,7 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
private SkinManager skinManager { get; set; } = null!;
|
||||
|
||||
private ExternalEditOperation<SkinInfo>? editOperation;
|
||||
private TaskCompletionSource? taskCompletionSource;
|
||||
|
||||
protected override bool DimMainContent => false;
|
||||
|
||||
@@ -95,8 +97,11 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
};
|
||||
}
|
||||
|
||||
public async Task Begin(SkinInfo skinInfo)
|
||||
public async Task<Task> Begin(SkinInfo skinInfo)
|
||||
{
|
||||
if (taskCompletionSource != null)
|
||||
throw new InvalidOperationException("Cannot start multiple concurrent external edits!");
|
||||
|
||||
Show();
|
||||
showSpinner("Mounting external skin...");
|
||||
setGlobalSkinDisabled(true);
|
||||
@@ -114,6 +119,7 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
await Task.Delay(1000).ConfigureAwait(true);
|
||||
setGlobalSkinDisabled(false);
|
||||
Hide();
|
||||
return Task.FromException(ex);
|
||||
}
|
||||
|
||||
Schedule(() =>
|
||||
@@ -163,6 +169,7 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
b.Enabled.Value = true;
|
||||
openDirectory();
|
||||
}, 1000);
|
||||
return (taskCompletionSource = new TaskCompletionSource()).Task;
|
||||
}
|
||||
|
||||
private void openDirectory()
|
||||
@@ -175,6 +182,8 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
|
||||
private async Task finish()
|
||||
{
|
||||
Debug.Assert(taskCompletionSource != null);
|
||||
|
||||
showSpinner("Cleaning up...");
|
||||
await Task.Delay(500).ConfigureAwait(true);
|
||||
|
||||
@@ -189,6 +198,9 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
await Task.Delay(1000).ConfigureAwait(true);
|
||||
Hide();
|
||||
setGlobalSkinDisabled(false);
|
||||
taskCompletionSource.SetException(ex);
|
||||
taskCompletionSource = null;
|
||||
return;
|
||||
}
|
||||
|
||||
Schedule(() =>
|
||||
@@ -205,6 +217,8 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
|
||||
Hide();
|
||||
});
|
||||
taskCompletionSource.SetResult();
|
||||
taskCompletionSource = null;
|
||||
}
|
||||
|
||||
private void setGlobalSkinDisabled(bool disabled)
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
|
||||
public readonly BindableList<ISerialisableDrawable> SelectedComponents = new BindableList<ISerialisableDrawable>();
|
||||
|
||||
public bool ExternalEditInProgress => externalEditOperation != null && !externalEditOperation.IsCompleted;
|
||||
|
||||
protected override bool StartHidden => true;
|
||||
|
||||
private Drawable? targetScreen;
|
||||
@@ -107,6 +109,8 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
[Resolved]
|
||||
private ExternalEditOverlay? externalEditOverlay { get; set; }
|
||||
|
||||
private Task? externalEditOperation;
|
||||
|
||||
public SkinEditor()
|
||||
{
|
||||
}
|
||||
@@ -286,7 +290,7 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
|
||||
var skin = currentSkin.Value.SkinInfo.PerformRead(s => s.Detach());
|
||||
|
||||
await externalEditOverlay!.Begin(skin).ConfigureAwait(false);
|
||||
externalEditOperation = await externalEditOverlay!.Begin(skin).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)
|
||||
|
||||
@@ -334,6 +334,14 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
leasedBeatmapSkins = null;
|
||||
}
|
||||
|
||||
public new void ToggleVisibility()
|
||||
{
|
||||
if (skinEditor?.ExternalEditInProgress == true)
|
||||
return;
|
||||
|
||||
base.ToggleVisibility();
|
||||
}
|
||||
|
||||
private partial class EndlessPlayer : ReplayPlayer
|
||||
{
|
||||
protected override UserActivity? InitialActivity => null;
|
||||
|
||||
Reference in New Issue
Block a user