Use one constant for STABLE_CONFIG location string

This commit is contained in:
Shivam 2020-05-20 16:30:38 +02:00
parent a0a54efd4e
commit e018d07441
5 changed files with 10 additions and 11 deletions

View File

@ -40,8 +40,6 @@ public class FileBasedIPC : MatchIPCInfo
[Resolved]
private StableInfo stableInfo { get; set; }
private const string stable_config = "tournament/stable.json";
public Storage IPCStorage { get; private set; }
[Resolved]
@ -196,7 +194,7 @@ private string findStablePath()
private void saveStablePath()
{
using (var stream = tournamentStorage.GetStream(stable_config, FileAccess.Write, FileMode.Create))
using (var stream = tournamentStorage.GetStream(StableInfo.STABLE_CONFIG, FileAccess.Write, FileMode.Create))
using (var sw = new StreamWriter(stream))
{
sw.Write(JsonConvert.SerializeObject(stableInfo,

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using Newtonsoft.Json;
using osu.Framework.Bindables;
namespace osu.Game.Tournament.Models
@ -13,5 +14,8 @@ namespace osu.Game.Tournament.Models
public class StableInfo
{
public Bindable<string> StablePath = new Bindable<string>(string.Empty);
[JsonIgnore]
public const string STABLE_CONFIG = "tournament/stable.json";
}
}

View File

@ -28,7 +28,6 @@ public class SetupScreen : TournamentScreen, IProvideVideo
private LoginOverlay loginOverlay;
private ActionableInfo resolution;
private const string stable_config = "tournament/stable.json";
[Resolved]
private MatchIPCInfo ipc { get; set; }

View File

@ -26,8 +26,6 @@ public class StablePathSelectScreen : TournamentScreen
{
private DirectorySelector directorySelector;
private const string stable_config = "tournament/stable.json";
[Resolved]
private StableInfo stableInfo { get; set; }
@ -150,7 +148,7 @@ private void changePath(Storage storage)
try
{
using (var stream = storage.GetStream(stable_config, FileAccess.Write, FileMode.Create))
using (var stream = storage.GetStream(StableInfo.STABLE_CONFIG, FileAccess.Write, FileMode.Create))
using (var sw = new StreamWriter(stream))
{
sw.Write(JsonConvert.SerializeObject(stableInfo,

View File

@ -147,7 +147,10 @@ private void load(Storage storage, FrameworkConfigManager frameworkConfig)
private void readStableConfig()
{
if (storage.Exists(stable_config))
if (stableInfo == null)
stableInfo = new StableInfo();
if (storage.Exists(StableInfo.STABLE_CONFIG))
{
using (Stream stream = storage.GetStream(stable_config, FileAccess.Read, FileMode.Open))
using (var sr = new StreamReader(stream))
@ -156,9 +159,6 @@ private void readStableConfig()
}
}
if (stableInfo == null)
stableInfo = new StableInfo();
dependencies.Cache(stableInfo);
}