1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 10:07:36 +08:00

Merge branch 'master' into add-confirmation-dialog

This commit is contained in:
Dean Herbert 2017-12-21 22:56:31 +09:00 committed by GitHub
commit 38703e6b85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 138 additions and 53 deletions

@ -1 +1 @@
Subproject commit 28fbd0711c09d3b06b51fc728b025f83ded2f0f8
Subproject commit f4fde31f8c09305d2130064da2f7bae995be8286

View File

@ -341,6 +341,61 @@ namespace osu.Game.Beatmaps
}
}
public void UndeleteAll()
{
var deleteMaps = QueryBeatmapSets(bs => bs.DeletePending).ToList();
if (!deleteMaps.Any()) return;
var notification = new ProgressNotification
{
CompletionText = "Restored all deleted beatmaps!",
Progress = 0,
State = ProgressNotificationState.Active,
};
PostNotification?.Invoke(notification);
int i = 0;
foreach (var bs in deleteMaps)
{
if (notification.State == ProgressNotificationState.Cancelled)
// user requested abort
return;
notification.Text = $"Restoring ({i} of {deleteMaps.Count})";
notification.Progress = (float)++i / deleteMaps.Count;
Undelete(bs);
}
notification.State = ProgressNotificationState.Completed;
}
public void Undelete(BeatmapSetInfo beatmapSet)
{
if (beatmapSet.Protected)
return;
lock (importContext)
{
var context = importContext.Value;
using (var transaction = context.BeginTransaction())
{
context.ChangeTracker.AutoDetectChangesEnabled = false;
var iFiles = new FileStore(() => context, storage);
var iBeatmaps = createBeatmapStore(() => context);
undelete(iBeatmaps, iFiles, beatmapSet);
context.ChangeTracker.AutoDetectChangesEnabled = true;
context.SaveChanges(transaction);
}
}
}
/// <summary>
/// Delete a beatmap difficulty.
/// </summary>

View File

@ -5,11 +5,12 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
namespace osu.Game.Input.Bindings
{
public class GlobalKeyBindingInputManager : DatabasedKeyBindingInputManager<GlobalAction>
public class GlobalKeyBindingInputManager : DatabasedKeyBindingInputManager<GlobalAction>, IHandleGlobalInput
{
private readonly Drawable handler;

View File

@ -15,6 +15,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private TriangleButton importButton;
private TriangleButton deleteButton;
private TriangleButton restoreButton;
private TriangleButton undeleteButton;
protected override string Header => "General";
@ -58,6 +59,15 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
}).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true));
}
},
undeleteButton = new SettingsButton
{
Text = "Restore all recently deleted beatmaps",
Action = () =>
{
undeleteButton.Enabled.Value = false;
Task.Run(() => beatmaps.UndeleteAll()).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true));
}
},
};
}
}

View File

@ -26,6 +26,8 @@ namespace osu.Game.Screens.Play
protected override bool BlockPassThroughKeyboard => true;
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
public Action OnRetry;
public Action OnQuit;
@ -122,44 +124,21 @@ namespace osu.Game.Screens.Play
},
};
Retries = 0;
updateRetryCount();
}
private int retries;
public int Retries
{
set
{
if (retryCounterContainer != null)
{
// "You've retried 1,065 times in this session"
// "You've retried 1 time in this session"
if (value == retries)
return;
retryCounterContainer.Children = new Drawable[]
{
new OsuSpriteText
{
Text = "You've retried ",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
},
new OsuSpriteText
{
Text = $"{value:n0}",
Font = @"Exo2.0-Bold",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
},
new OsuSpriteText
{
Text = $" time{(value == 1 ? "" : "s")} in this session",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
}
};
}
retries = value;
if (retryCounterContainer != null)
updateRetryCount();
}
}
@ -197,6 +176,7 @@ namespace osu.Game.Screens.Play
}
private int _selectionIndex = -1;
private int selectionIndex
{
get { return _selectionIndex; }
@ -219,26 +199,26 @@ namespace osu.Game.Screens.Play
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat)
return false;
switch (args.Key)
if (!args.Repeat)
{
case Key.Up:
if (selectionIndex == -1 || selectionIndex == 0)
selectionIndex = InternalButtons.Count - 1;
else
selectionIndex--;
return true;
case Key.Down:
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
selectionIndex = 0;
else
selectionIndex++;
return true;
switch (args.Key)
{
case Key.Up:
if (selectionIndex == -1 || selectionIndex == 0)
selectionIndex = InternalButtons.Count - 1;
else
selectionIndex--;
return true;
case Key.Down:
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
selectionIndex = 0;
else
selectionIndex++;
return true;
}
}
return false;
return base.OnKeyDown(state, args);
}
private void buttonSelectionChanged(DialogButton button, bool isSelected)
@ -249,6 +229,38 @@ namespace osu.Game.Screens.Play
selectionIndex = InternalButtons.IndexOf(button);
}
private void updateRetryCount()
{
// "You've retried 1,065 times in this session"
// "You've retried 1 time in this session"
retryCounterContainer.Children = new Drawable[]
{
new OsuSpriteText
{
Text = "You've retried ",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
},
new OsuSpriteText
{
Text = $"{retries:n0}",
Font = @"Exo2.0-Bold",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
},
new OsuSpriteText
{
Text = $" time{(retries == 1 ? "" : "s")} in this session",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),
TextSize = 18
}
};
}
private class Button : DialogButton
{
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)

View File

@ -161,8 +161,8 @@ namespace osu.Game.Screens.Play
OnRetry = Restart,
OnQuit = Exit,
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
Retries = RestartCount,
OnPause = () => {
pauseContainer.Retries = RestartCount;
hudOverlay.KeyCounter.IsCounting = pauseContainer.IsPaused;
},
OnResume = () => {

View File

@ -17,6 +17,7 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using OpenTK;
using OpenTK.Graphics;
@ -26,6 +27,7 @@ namespace osu.Game.Screens.Select.Carousel
{
private Action<BeatmapSetInfo> deleteRequested;
private Action<BeatmapSetInfo> restoreHiddenRequested;
private Action<int> viewDetails;
private readonly BeatmapSetInfo beatmapSet;
@ -37,14 +39,16 @@ namespace osu.Game.Screens.Select.Carousel
beatmapSet = set.BeatmapSet;
}
[BackgroundDependencyLoader]
private void load(LocalisationEngine localisation, BeatmapManager manager)
[BackgroundDependencyLoader(true)]
private void load(LocalisationEngine localisation, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay)
{
if (localisation == null)
throw new ArgumentNullException(nameof(localisation));
restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore);
deleteRequested = manager.Delete;
if (beatmapOverlay != null)
viewDetails = beatmapOverlay.ShowBeatmapSet;
Children = new Drawable[]
{
@ -96,6 +100,9 @@ namespace osu.Game.Screens.Select.Carousel
if (Item.State == CarouselItemState.NotSelected)
items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => Item.State.Value = CarouselItemState.Selected));
if (beatmapSet.OnlineBeatmapSetID != null)
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => viewDetails?.Invoke(beatmapSet.OnlineBeatmapSetID.Value)));
if (beatmapSet.Beatmaps.Any(b => b.Hidden))
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => restoreHiddenRequested?.Invoke(beatmapSet)));