mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 04:23:21 +08:00
Add confirmation dialog for updating locally modified beatmaps
This commit is contained in:
parent
3da54814f8
commit
964ed01abb
24
osu.Game/Localisation/PopupDialogStrings.cs
Normal file
24
osu.Game/Localisation/PopupDialogStrings.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// 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 osu.Framework.Localisation;
|
||||
|
||||
namespace osu.Game.Localisation
|
||||
{
|
||||
public static class PopupDialogStrings
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.PopupDialog";
|
||||
|
||||
/// <summary>
|
||||
/// "Are you sure you want to update this beatmap?"
|
||||
/// </summary>
|
||||
public static LocalisableString UpdateLocallyModifiedText => new TranslatableString(getKey(@"update_locally_modified_text"), @"Are you sure you want to update this beatmap?");
|
||||
|
||||
/// <summary>
|
||||
/// "This will discard all local changes you have on that beatmap."
|
||||
/// </summary>
|
||||
public static LocalisableString UpdateLocallyModifiedDescription => new TranslatableString(getKey(@"update_locally_modified_description"), @"This will discard all local changes you have on that beatmap.");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
@ -32,9 +32,12 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
[Resolved]
|
||||
private LoginOverlay? loginOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IDialogOverlay? dialogOverlay { get; set; }
|
||||
|
||||
public UpdateBeatmapSetButton(BeatmapSetInfo beatmapSetInfo)
|
||||
{
|
||||
this.beatmapSetInfo = beatmapSetInfo;
|
||||
@ -102,17 +105,34 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
},
|
||||
});
|
||||
|
||||
Action = () =>
|
||||
{
|
||||
if (!api.IsLoggedIn)
|
||||
{
|
||||
loginOverlay?.Show();
|
||||
return;
|
||||
}
|
||||
Action = updateBeatmap;
|
||||
}
|
||||
|
||||
beatmapDownloader.DownloadAsUpdate(beatmapSetInfo, preferNoVideo.Value);
|
||||
attachExistingDownload();
|
||||
};
|
||||
private bool updateConfirmed;
|
||||
|
||||
private void updateBeatmap()
|
||||
{
|
||||
if (!api.IsLoggedIn)
|
||||
{
|
||||
loginOverlay?.Show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (dialogOverlay != null && beatmapSetInfo.Status == BeatmapOnlineStatus.LocallyModified && !updateConfirmed)
|
||||
{
|
||||
dialogOverlay.Push(new UpdateLocalConfirmationDialog(() =>
|
||||
{
|
||||
updateConfirmed = true;
|
||||
updateBeatmap();
|
||||
}));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
updateConfirmed = false;
|
||||
|
||||
beatmapDownloader.DownloadAsUpdate(beatmapSetInfo, preferNoVideo.Value);
|
||||
attachExistingDownload();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -0,0 +1,21 @@
|
||||
// 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.Select.Carousel
|
||||
{
|
||||
public class UpdateLocalConfirmationDialog : DeleteConfirmationDialog
|
||||
{
|
||||
public UpdateLocalConfirmationDialog(Action onConfirm)
|
||||
{
|
||||
HeaderText = PopupDialogStrings.UpdateLocallyModifiedText;
|
||||
BodyText = PopupDialogStrings.UpdateLocallyModifiedDescription;
|
||||
Icon = FontAwesome.Solid.ExclamationTriangle;
|
||||
DeleteAction = onConfirm;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user