mirror of https://github.com/ppy/osu
TournamentStorage now takes in a parent storage
This commit is contained in:
parent
5041c74c7a
commit
29ae1c460a
|
@ -13,18 +13,18 @@ namespace osu.Game.Tournament.IO
|
|||
{
|
||||
public class TournamentStorage : WrappedStorage
|
||||
{
|
||||
private readonly GameHost host;
|
||||
private readonly Storage storage;
|
||||
internal readonly TournamentVideoResourceStore VideoStore;
|
||||
internal readonly Storage ConfigurationStorage;
|
||||
private const string default_tournament = "default";
|
||||
private const string config_directory = "config";
|
||||
|
||||
public TournamentStorage(GameHost host)
|
||||
: base(host.Storage.GetStorageForDirectory("tournaments"), string.Empty)
|
||||
public TournamentStorage(Storage storage)
|
||||
: base(storage.GetStorageForDirectory("tournaments"), string.Empty)
|
||||
{
|
||||
this.host = host;
|
||||
this.storage = storage;
|
||||
|
||||
TournamentStorageManager storageConfig = new TournamentStorageManager(host.Storage);
|
||||
TournamentStorageManager storageConfig = new TournamentStorageManager(storage);
|
||||
|
||||
var currentTournament = storageConfig.Get<string>(StorageConfig.CurrentTournament);
|
||||
|
||||
|
@ -48,7 +48,7 @@ public TournamentStorage(GameHost host)
|
|||
|
||||
internal void Migrate()
|
||||
{
|
||||
var source = new DirectoryInfo(host.Storage.GetFullPath("tournament"));
|
||||
var source = new DirectoryInfo(storage.GetFullPath("tournament"));
|
||||
var destination = new DirectoryInfo(GetFullPath(default_tournament));
|
||||
var cfgDestination = new DirectoryInfo(GetFullPath(default_tournament + Path.DirectorySeparatorChar + config_directory));
|
||||
|
||||
|
@ -58,31 +58,31 @@ internal void Migrate()
|
|||
if (!cfgDestination.Exists)
|
||||
destination.CreateSubdirectory(config_directory);
|
||||
|
||||
if (host.Storage.Exists("bracket.json"))
|
||||
if (storage.Exists("bracket.json"))
|
||||
{
|
||||
Logger.Log("Migrating bracket to default tournament storage.");
|
||||
var bracketFile = new System.IO.FileInfo(host.Storage.GetFullPath("bracket.json"));
|
||||
var bracketFile = new System.IO.FileInfo(storage.GetFullPath("bracket.json"));
|
||||
moveFile(bracketFile, destination);
|
||||
}
|
||||
|
||||
if (host.Storage.Exists("drawings.txt"))
|
||||
if (storage.Exists("drawings.txt"))
|
||||
{
|
||||
Logger.Log("Migrating drawings to default tournament storage.");
|
||||
var drawingsFile = new System.IO.FileInfo(host.Storage.GetFullPath("drawings.txt"));
|
||||
var drawingsFile = new System.IO.FileInfo(storage.GetFullPath("drawings.txt"));
|
||||
moveFile(drawingsFile, destination);
|
||||
}
|
||||
|
||||
if (host.Storage.Exists("drawings.ini"))
|
||||
if (storage.Exists("drawings.ini"))
|
||||
{
|
||||
Logger.Log("Migrating drawing configuration to default tournament storage.");
|
||||
var drawingsConfigFile = new System.IO.FileInfo(host.Storage.GetFullPath("drawings.ini"));
|
||||
var drawingsConfigFile = new System.IO.FileInfo(storage.GetFullPath("drawings.ini"));
|
||||
moveFile(drawingsConfigFile, cfgDestination);
|
||||
}
|
||||
|
||||
if (host.Storage.Exists("drawings_results.txt"))
|
||||
if (storage.Exists("drawings_results.txt"))
|
||||
{
|
||||
Logger.Log("Migrating drawings results to default tournament storage.");
|
||||
var drawingsResultsFile = new System.IO.FileInfo(host.Storage.GetFullPath("drawings_results.txt"));
|
||||
var drawingsResultsFile = new System.IO.FileInfo(storage.GetFullPath("drawings_results.txt"));
|
||||
moveFile(drawingsResultsFile, destination);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests;
|
||||
|
@ -23,11 +24,8 @@ namespace osu.Game.Tournament
|
|||
public class TournamentGameBase : OsuGameBase
|
||||
{
|
||||
private const string bracket_filename = "bracket.json";
|
||||
|
||||
private LadderInfo ladder;
|
||||
|
||||
private TournamentStorage storage;
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
private FileBasedIPC ipc;
|
||||
|
||||
|
@ -37,11 +35,11 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
|
|||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(Storage baseStorage)
|
||||
{
|
||||
Resources.AddStore(new DllResourceStore(typeof(TournamentGameBase).Assembly));
|
||||
|
||||
dependencies.CacheAs(storage = new TournamentStorage(Host));
|
||||
dependencies.CacheAs(storage = new TournamentStorage(baseStorage));
|
||||
|
||||
Textures.AddStore(new TextureLoaderStore(storage.VideoStore));
|
||||
|
||||
|
|
Loading…
Reference in New Issue