1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 09:42:55 +08:00

TournamentStorage now takes in a parent storage

This commit is contained in:
Shivam 2020-06-16 17:00:20 +02:00
parent 5041c74c7a
commit 29ae1c460a
2 changed files with 17 additions and 19 deletions

View File

@ -13,18 +13,18 @@ namespace osu.Game.Tournament.IO
{ {
public class TournamentStorage : WrappedStorage public class TournamentStorage : WrappedStorage
{ {
private readonly GameHost host; private readonly Storage storage;
internal readonly TournamentVideoResourceStore VideoStore; internal readonly TournamentVideoResourceStore VideoStore;
internal readonly Storage ConfigurationStorage; internal readonly Storage ConfigurationStorage;
private const string default_tournament = "default"; private const string default_tournament = "default";
private const string config_directory = "config"; private const string config_directory = "config";
public TournamentStorage(GameHost host) public TournamentStorage(Storage storage)
: base(host.Storage.GetStorageForDirectory("tournaments"), string.Empty) : 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); var currentTournament = storageConfig.Get<string>(StorageConfig.CurrentTournament);
@ -48,7 +48,7 @@ namespace osu.Game.Tournament.IO
internal void Migrate() 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 destination = new DirectoryInfo(GetFullPath(default_tournament));
var cfgDestination = new DirectoryInfo(GetFullPath(default_tournament + Path.DirectorySeparatorChar + config_directory)); var cfgDestination = new DirectoryInfo(GetFullPath(default_tournament + Path.DirectorySeparatorChar + config_directory));
@ -58,31 +58,31 @@ namespace osu.Game.Tournament.IO
if (!cfgDestination.Exists) if (!cfgDestination.Exists)
destination.CreateSubdirectory(config_directory); destination.CreateSubdirectory(config_directory);
if (host.Storage.Exists("bracket.json")) if (storage.Exists("bracket.json"))
{ {
Logger.Log("Migrating bracket to default tournament storage."); 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); moveFile(bracketFile, destination);
} }
if (host.Storage.Exists("drawings.txt")) if (storage.Exists("drawings.txt"))
{ {
Logger.Log("Migrating drawings to default tournament storage."); 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); moveFile(drawingsFile, destination);
} }
if (host.Storage.Exists("drawings.ini")) if (storage.Exists("drawings.ini"))
{ {
Logger.Log("Migrating drawing configuration to default tournament storage."); 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); 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."); 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); moveFile(drawingsResultsFile, destination);
} }

View File

@ -8,6 +8,7 @@ using Newtonsoft.Json;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Platform;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
@ -23,11 +24,8 @@ namespace osu.Game.Tournament
public class TournamentGameBase : OsuGameBase public class TournamentGameBase : OsuGameBase
{ {
private const string bracket_filename = "bracket.json"; private const string bracket_filename = "bracket.json";
private LadderInfo ladder; private LadderInfo ladder;
private TournamentStorage storage; private TournamentStorage storage;
private DependencyContainer dependencies; private DependencyContainer dependencies;
private FileBasedIPC ipc; private FileBasedIPC ipc;
@ -37,11 +35,11 @@ namespace osu.Game.Tournament
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(Storage baseStorage)
{ {
Resources.AddStore(new DllResourceStore(typeof(TournamentGameBase).Assembly)); 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)); Textures.AddStore(new TextureLoaderStore(storage.VideoStore));