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

Merge branch 'master' into overlays-block-keyboard

This commit is contained in:
Dean Herbert 2017-12-21 23:51:46 +09:00 committed by GitHub
commit eb1b1da732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 0 deletions

View File

@ -93,6 +93,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
float approxFollowCircleRadius = (float)(slider.Radius * 3);
var computeVertex = new Action<double>(t =>
{
// ReSharper disable once PossibleInvalidOperationException (bugged in current r# version)
var diff = slider.PositionAt(t) - slider.LazyEndPosition.Value;
float dist = diff.Length;

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

@ -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";
@ -55,6 +56,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));
}
},
};
}
}