1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-15 17:47:18 +08:00

Centralise specification of bracket.json filename

This commit is contained in:
Dean Herbert 2021-12-03 16:04:11 +09:00
parent bd5140cbdf
commit ba05a0a383
4 changed files with 8 additions and 8 deletions

View File

@ -96,7 +96,7 @@ namespace osu.Game.Tournament.Tests.NonVisual
Directory.CreateDirectory(flagsPath);
// Define testing files corresponding to the specific file migrations that are needed
string bracketFile = Path.Combine(osuRoot, "bracket.json");
string bracketFile = Path.Combine(osuRoot, TournamentGameBase.BRACKET_FILENAME);
string drawingsConfig = Path.Combine(osuRoot, "drawings.ini");
string drawingsFile = Path.Combine(osuRoot, "drawings.txt");
@ -133,7 +133,7 @@ namespace osu.Game.Tournament.Tests.NonVisual
Assert.That(storage.GetFullPath("."), Is.EqualTo(migratedPath));
Assert.True(storage.Exists("bracket.json"));
Assert.True(storage.Exists(TournamentGameBase.BRACKET_FILENAME));
Assert.True(storage.Exists("drawings.txt"));
Assert.True(storage.Exists("drawings_results.txt"));

View File

@ -86,7 +86,7 @@ namespace osu.Game.Tournament.IO
DeleteRecursive(source);
}
moveFileIfExists("bracket.json", destination);
moveFileIfExists(TournamentGameBase.BRACKET_FILENAME, destination);
moveFileIfExists("drawings.txt", destination);
moveFileIfExists("drawings_results.txt", destination);
moveFileIfExists("drawings.ini", destination);

View File

@ -71,7 +71,7 @@ namespace osu.Game.Tournament
loadingSpinner.Expire();
Logger.Error(t.Exception, "Couldn't load bracket with error");
Add(new WarningBox("Your bracket.json file could not be parsed. Please check runtime.log for more details."));
Add(new WarningBox($"Your {BRACKET_FILENAME} file could not be parsed. Please check runtime.log for more details."));
});
return;

View File

@ -26,7 +26,7 @@ namespace osu.Game.Tournament
[Cached(typeof(TournamentGameBase))]
public class TournamentGameBase : OsuGameBase
{
private const string bracket_filename = "bracket.json";
public const string BRACKET_FILENAME = @"bracket.json";
private LadderInfo ladder;
private TournamentStorage storage;
private DependencyContainer dependencies;
@ -71,9 +71,9 @@ namespace osu.Game.Tournament
{
try
{
if (storage.Exists(bracket_filename))
if (storage.Exists(BRACKET_FILENAME))
{
using (Stream stream = storage.GetStream(bracket_filename, FileAccess.Read, FileMode.Open))
using (Stream stream = storage.GetStream(BRACKET_FILENAME, FileAccess.Read, FileMode.Open))
using (var sr = new StreamReader(stream))
ladder = JsonConvert.DeserializeObject<LadderInfo>(sr.ReadToEnd(), new JsonPointConverter());
}
@ -309,7 +309,7 @@ namespace osu.Game.Tournament
Converters = new JsonConverter[] { new JsonPointConverter() }
});
using (var stream = storage.GetStream(bracket_filename, FileAccess.Write, FileMode.Create))
using (var stream = storage.GetStream(BRACKET_FILENAME, FileAccess.Write, FileMode.Create))
using (var sw = new StreamWriter(stream))
sw.Write(serialisedLadder);
}