mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 00:43:25 +08:00
Add basic score import from stable
This commit is contained in:
parent
82515a52fe
commit
15c75b4442
@ -62,6 +62,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
protected override string ImportFromStablePath => "Songs";
|
protected override string ImportFromStablePath => "Songs";
|
||||||
|
|
||||||
|
protected override bool StableDirectoryBased => true;
|
||||||
|
|
||||||
private readonly RulesetStore rulesets;
|
private readonly RulesetStore rulesets;
|
||||||
|
|
||||||
private readonly BeatmapStore beatmaps;
|
private readonly BeatmapStore beatmaps;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -546,6 +546,11 @@ namespace osu.Game.Database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual string ImportFromStablePath => null;
|
protected virtual string ImportFromStablePath => null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Does stable import look for directories rather than files
|
||||||
|
/// </summary>
|
||||||
|
protected abstract bool StableDirectoryBased { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
|
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -566,7 +571,11 @@ namespace osu.Game.Database
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.Run(async () => await Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()));
|
return Task.Run(async () =>
|
||||||
|
{
|
||||||
|
var paths = StableDirectoryBased ? stable.GetDirectories(ImportFromStablePath) : stable.GetFiles(ImportFromStablePath);
|
||||||
|
await Import(paths.Select(f => stable.GetFullPath(f)).ToArray());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -360,6 +360,7 @@ namespace osu.Game
|
|||||||
BeatmapManager.PresentImport = items => PresentBeatmap(items.First());
|
BeatmapManager.PresentImport = items => PresentBeatmap(items.First());
|
||||||
|
|
||||||
ScoreManager.PostNotification = n => notifications?.Post(n);
|
ScoreManager.PostNotification = n => notifications?.Post(n);
|
||||||
|
ScoreManager.GetStableStorage = GetStorageForStableInstall;
|
||||||
ScoreManager.PresentImport = items => PresentScore(items.First());
|
ScoreManager.PresentImport = items => PresentScore(items.First());
|
||||||
|
|
||||||
Container logoContainer;
|
Container logoContainer;
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||||
@ -16,14 +17,16 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
protected override string Header => "General";
|
protected override string Header => "General";
|
||||||
|
|
||||||
private TriangleButton importBeatmapsButton;
|
private TriangleButton importBeatmapsButton;
|
||||||
|
private TriangleButton importScoresButton;
|
||||||
private TriangleButton importSkinsButton;
|
private TriangleButton importSkinsButton;
|
||||||
private TriangleButton deleteSkinsButton;
|
|
||||||
private TriangleButton deleteBeatmapsButton;
|
private TriangleButton deleteBeatmapsButton;
|
||||||
|
private TriangleButton deleteScoresButton;
|
||||||
|
private TriangleButton deleteSkinsButton;
|
||||||
private TriangleButton restoreButton;
|
private TriangleButton restoreButton;
|
||||||
private TriangleButton undeleteButton;
|
private TriangleButton undeleteButton;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(BeatmapManager beatmaps, SkinManager skins, DialogOverlay dialogOverlay)
|
private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, DialogOverlay dialogOverlay)
|
||||||
{
|
{
|
||||||
if (beatmaps.SupportsImportFromStable)
|
if (beatmaps.SupportsImportFromStable)
|
||||||
{
|
{
|
||||||
@ -51,6 +54,32 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (scores.SupportsImportFromStable)
|
||||||
|
{
|
||||||
|
Add(importScoresButton = new SettingsButton
|
||||||
|
{
|
||||||
|
Text = "Import scores from stable",
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
importScoresButton.Enabled.Value = false;
|
||||||
|
scores.ImportFromStableAsync().ContinueWith(t => Schedule(() => importScoresButton.Enabled.Value = true));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Add(deleteScoresButton = new DangerousSettingsButton
|
||||||
|
{
|
||||||
|
Text = "Delete ALL scores",
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() =>
|
||||||
|
{
|
||||||
|
deleteScoresButton.Enabled.Value = false;
|
||||||
|
Task.Run(() => scores.Delete(scores.GetAllUsableScores())).ContinueWith(t => Schedule(() => deleteScoresButton.Enabled.Value = true));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (skins.SupportsImportFromStable)
|
if (skins.SupportsImportFromStable)
|
||||||
{
|
{
|
||||||
Add(importSkinsButton = new SettingsButton
|
Add(importSkinsButton = new SettingsButton
|
||||||
|
@ -22,7 +22,9 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
protected override string[] HashableFileTypes => new[] { ".osr" };
|
protected override string[] HashableFileTypes => new[] { ".osr" };
|
||||||
|
|
||||||
protected override string ImportFromStablePath => "Replays";
|
protected override string ImportFromStablePath => @"Data\r";
|
||||||
|
|
||||||
|
protected override bool StableDirectoryBased => false;
|
||||||
|
|
||||||
private readonly RulesetStore rulesets;
|
private readonly RulesetStore rulesets;
|
||||||
private readonly Func<BeatmapManager> beatmaps;
|
private readonly Func<BeatmapManager> beatmaps;
|
||||||
@ -36,10 +38,12 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
protected override ScoreInfo CreateModel(ArchiveReader archive)
|
protected override ScoreInfo CreateModel(ArchiveReader archive)
|
||||||
{
|
{
|
||||||
if (archive == null)
|
string filename = archive?.Filenames.FirstOrDefault(f => f.EndsWith(".osr"));
|
||||||
|
|
||||||
|
if (filename == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
using (var stream = archive.GetStream(archive.Filenames.First(f => f.EndsWith(".osr"))))
|
using (var stream = archive.GetStream(filename))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,8 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
protected override string ImportFromStablePath => "Skins";
|
protected override string ImportFromStablePath => "Skins";
|
||||||
|
|
||||||
|
protected override bool StableDirectoryBased => true;
|
||||||
|
|
||||||
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio)
|
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio)
|
||||||
: base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
|
: base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user