1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 18:32:56 +08:00

Add option to import from osu-stable

Also adds an option to delete all beatmaps for testing purposes.
This commit is contained in:
Dean Herbert 2017-07-28 12:46:38 +09:00
parent e5306997dd
commit 7d4218ea6c
4 changed files with 70 additions and 0 deletions

View File

@ -390,5 +390,21 @@ namespace osu.Game.Beatmaps
catch { return new TrackVirtual(); }
}
}
public void ImportFromStable()
{
string stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!", "Songs");
if (!Directory.Exists(stableInstallPath))
stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".osu", "Songs");
if (!Directory.Exists(stableInstallPath))
{
Logger.Log("Couldn't find an osu!stable installation!", LoggingTarget.Information, LogLevel.Error);
return;
}
Import(Directory.GetDirectories(stableInstallPath));
}
}
}

View File

@ -0,0 +1,51 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
public class GeneralSettings : SettingsSubsection
{
private OsuButton importButton;
private OsuButton deleteButton;
protected override string Header => "General";
[BackgroundDependencyLoader]
private void load(BeatmapManager beatmaps)
{
Children = new Drawable[]
{
importButton = new OsuButton
{
RelativeSizeAxes = Axes.X,
Text = "Import beatmaps from stable",
Action = () =>
{
importButton.Enabled.Value = false;
Task.Run(() => beatmaps.ImportFromStable()).ContinueWith(t => Schedule(() => importButton.Enabled.Value = true));
}
},
deleteButton = new OsuButton
{
RelativeSizeAxes = Axes.X,
Text = "Delete ALL beatmaps",
Action = () =>
{
deleteButton.Enabled.Value = false;
Task.Run(() =>
{
foreach (var b in beatmaps.GetAllUsableBeatmapSets())
beatmaps.Delete(b);
}).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
}
},
};
}
}
}

View File

@ -3,6 +3,7 @@
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Overlays.Settings.Sections.Maintenance;
using OpenTK;
namespace osu.Game.Overlays.Settings.Sections
@ -17,6 +18,7 @@ namespace osu.Game.Overlays.Settings.Sections
FlowContent.Spacing = new Vector2(0, 5);
Children = new Drawable[]
{
new GeneralSettings()
};
}
}

View File

@ -104,6 +104,7 @@
<Compile Include="Overlays\Music\PlaylistList.cs" />
<Compile Include="Overlays\OnScreenDisplay.cs" />
<Compile Include="Graphics\Containers\SectionsContainer.cs" />
<Compile Include="Overlays\Settings\Sections\Maintenance\GeneralSettings.cs" />
<Compile Include="Overlays\Settings\SettingsHeader.cs" />
<Compile Include="Overlays\Settings\Sections\Audio\MainMenuSettings.cs" />
<Compile Include="Overlays\Toolbar\ToolbarChatButton.cs" />