mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 09:37:23 +08:00
Move public methods up
This commit is contained in:
parent
c84cb0b33c
commit
867b1b5f65
@ -230,7 +230,6 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Import a beatmap from a <see cref="BeatmapSetInfo"/>.
|
/// Import a beatmap from a <see cref="BeatmapSetInfo"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -503,6 +502,55 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <returns>Results from the provided query.</returns>
|
/// <returns>Results from the provided query.</returns>
|
||||||
public IEnumerable<BeatmapInfo> QueryBeatmaps(Expression<Func<BeatmapInfo, bool>> query) => beatmaps.Beatmaps.AsNoTracking().Where(query);
|
public IEnumerable<BeatmapInfo> QueryBeatmaps(Expression<Func<BeatmapInfo, bool>> query) => beatmaps.Beatmaps.AsNoTracking().Where(query);
|
||||||
|
|
||||||
|
public bool StableInstallationAvailable => GetStableStorage?.Invoke() != null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
|
||||||
|
/// </summary>
|
||||||
|
public async Task ImportFromStable()
|
||||||
|
{
|
||||||
|
var stable = GetStableStorage?.Invoke();
|
||||||
|
|
||||||
|
if (stable == null)
|
||||||
|
{
|
||||||
|
Logger.Log("No osu!stable installation available!", LoggingTarget.Information, LogLevel.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Factory.StartNew(() => Import(stable.GetDirectories("Songs")), TaskCreationOptions.LongRunning);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteAll()
|
||||||
|
{
|
||||||
|
var maps = GetAllUsableBeatmapSets();
|
||||||
|
|
||||||
|
if (maps.Count == 0) return;
|
||||||
|
|
||||||
|
var notification = new ProgressNotification
|
||||||
|
{
|
||||||
|
Progress = 0,
|
||||||
|
CompletionText = "Deleted all beatmaps!",
|
||||||
|
State = ProgressNotificationState.Active,
|
||||||
|
};
|
||||||
|
|
||||||
|
PostNotification?.Invoke(notification);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
foreach (var b in maps)
|
||||||
|
{
|
||||||
|
if (notification.State == ProgressNotificationState.Cancelled)
|
||||||
|
// user requested abort
|
||||||
|
return;
|
||||||
|
|
||||||
|
notification.Text = $"Deleting ({i} of {maps.Count})";
|
||||||
|
notification.Progress = (float)++i / maps.Count;
|
||||||
|
Delete(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
notification.State = ProgressNotificationState.Completed;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Import a <see cref="BeatmapSetInfo"/> into the beatmap store.
|
/// Import a <see cref="BeatmapSetInfo"/> into the beatmap store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -625,54 +673,5 @@ namespace osu.Game.Beatmaps
|
|||||||
store.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
|
store.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool StableInstallationAvailable => GetStableStorage?.Invoke() != null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
|
|
||||||
/// </summary>
|
|
||||||
public async Task ImportFromStable()
|
|
||||||
{
|
|
||||||
var stable = GetStableStorage?.Invoke();
|
|
||||||
|
|
||||||
if (stable == null)
|
|
||||||
{
|
|
||||||
Logger.Log("No osu!stable installation available!", LoggingTarget.Information, LogLevel.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.Factory.StartNew(() => Import(stable.GetDirectories("Songs")), TaskCreationOptions.LongRunning);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteAll()
|
|
||||||
{
|
|
||||||
var maps = GetAllUsableBeatmapSets();
|
|
||||||
|
|
||||||
if (maps.Count == 0) return;
|
|
||||||
|
|
||||||
var notification = new ProgressNotification
|
|
||||||
{
|
|
||||||
Progress = 0,
|
|
||||||
CompletionText = "Deleted all beatmaps!",
|
|
||||||
State = ProgressNotificationState.Active,
|
|
||||||
};
|
|
||||||
|
|
||||||
PostNotification?.Invoke(notification);
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
foreach (var b in maps)
|
|
||||||
{
|
|
||||||
if (notification.State == ProgressNotificationState.Cancelled)
|
|
||||||
// user requested abort
|
|
||||||
return;
|
|
||||||
|
|
||||||
notification.Text = $"Deleting ({i} of {maps.Count})";
|
|
||||||
notification.Progress = (float)++i / maps.Count;
|
|
||||||
Delete(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
notification.State = ProgressNotificationState.Completed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user