1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

move stable config declaration and initial reading

This commit is contained in:
Shivam 2020-05-28 15:03:49 +02:00
parent 4c3900cfc8
commit 7ae2383288
2 changed files with 8 additions and 23 deletions

View File

@ -39,6 +39,7 @@ namespace osu.Game.Tournament.IPC
[Resolved]
private StableInfo stableInfo { get; set; }
private const string STABLE_CONFIG = "tournament/stable.json";
public Storage IPCStorage { get; private set; }
@ -161,13 +162,14 @@ namespace osu.Game.Tournament.IPC
private string findStablePath()
{
string stableInstallPath = string.Empty;
if (!string.IsNullOrEmpty(stableInfo.StablePath.Value))
return stableInfo.StablePath.Value;
string stableInstallPath = string.Empty;
try
{
List<Func<string>> stableFindMethods = new List<Func<string>>
{
readFromStableInfo,
findFromEnvVar,
findFromRegistry,
findFromLocalAppData,
@ -180,7 +182,7 @@ namespace osu.Game.Tournament.IPC
if (stableInstallPath != null)
{
saveStablePath(stableInstallPath);
saveStableConfig(stableInstallPath);
return stableInstallPath;
}
}
@ -193,11 +195,12 @@ namespace osu.Game.Tournament.IPC
}
}
private void saveStablePath(string path)
private void saveStableConfig(string path)
{
stableInfo.StablePath.Value = path;
using (var stream = tournamentStorage.GetStream(StableInfo.STABLE_CONFIG, FileAccess.Write, FileMode.Create))
using (var stream = tournamentStorage.GetStream(STABLE_CONFIG, FileAccess.Write, FileMode.Create))
using (var sw = new StreamWriter(stream))
{
sw.Write(JsonConvert.SerializeObject(stableInfo,
@ -227,22 +230,6 @@ namespace osu.Game.Tournament.IPC
return null;
}
private string readFromStableInfo()
{
try
{
Logger.Log("Trying to find stable through the json config");
if (!string.IsNullOrEmpty(stableInfo.StablePath.Value))
return stableInfo.StablePath.Value;
}
catch
{
}
return null;
}
private string findFromLocalAppData()
{
Logger.Log("Trying to find stable in %LOCALAPPDATA%");

View File

@ -15,7 +15,5 @@ namespace osu.Game.Tournament.Models
{
public Bindable<string> StablePath = new Bindable<string>(string.Empty);
[JsonIgnore]
public const string STABLE_CONFIG = "tournament/stable.json";
}
}