mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:18:22 +08:00
Fixed path is empty exception
Also converted method to property get, private set
This commit is contained in:
parent
33d731644c
commit
fea5c8460a
@ -37,7 +37,7 @@ namespace osu.Game.Tournament.IPC
|
||||
private int lastBeatmapId;
|
||||
private ScheduledDelegate scheduled;
|
||||
|
||||
private StableInfo stableInfo;
|
||||
public StableInfo StableInfo { get; private set; }
|
||||
|
||||
public const string STABLE_CONFIG = "tournament/stable.json";
|
||||
|
||||
@ -160,12 +160,10 @@ namespace osu.Game.Tournament.IPC
|
||||
|
||||
public static bool CheckExists(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
|
||||
|
||||
public StableInfo GetStableInfo() => stableInfo;
|
||||
|
||||
private string findStablePath()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(readStableConfig()))
|
||||
return stableInfo.StablePath.Value;
|
||||
return StableInfo.StablePath.Value;
|
||||
|
||||
string stableInstallPath = string.Empty;
|
||||
|
||||
@ -186,7 +184,7 @@ namespace osu.Game.Tournament.IPC
|
||||
if (stableInstallPath != null)
|
||||
{
|
||||
SaveStableConfig(stableInstallPath);
|
||||
return stableInstallPath;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,12 +198,12 @@ namespace osu.Game.Tournament.IPC
|
||||
|
||||
public void SaveStableConfig(string path)
|
||||
{
|
||||
stableInfo.StablePath.Value = path;
|
||||
StableInfo.StablePath.Value = path;
|
||||
|
||||
using (var stream = tournamentStorage.GetStream(STABLE_CONFIG, FileAccess.Write, FileMode.Create))
|
||||
using (var sw = new StreamWriter(stream))
|
||||
{
|
||||
sw.Write(JsonConvert.SerializeObject(stableInfo,
|
||||
sw.Write(JsonConvert.SerializeObject(StableInfo,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
@ -217,18 +215,18 @@ namespace osu.Game.Tournament.IPC
|
||||
|
||||
private string readStableConfig()
|
||||
{
|
||||
if (stableInfo == null)
|
||||
stableInfo = new StableInfo();
|
||||
if (StableInfo == null)
|
||||
StableInfo = new StableInfo();
|
||||
|
||||
if (tournamentStorage.Exists(FileBasedIPC.STABLE_CONFIG))
|
||||
{
|
||||
using (Stream stream = tournamentStorage.GetStream(FileBasedIPC.STABLE_CONFIG, FileAccess.Read, FileMode.Open))
|
||||
using (var sr = new StreamReader(stream))
|
||||
{
|
||||
stableInfo = JsonConvert.DeserializeObject<StableInfo>(sr.ReadToEnd());
|
||||
StableInfo = JsonConvert.DeserializeObject<StableInfo>(sr.ReadToEnd());
|
||||
}
|
||||
|
||||
return stableInfo.StablePath.Value;
|
||||
return StableInfo.StablePath.Value;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Tournament.Screens
|
||||
private void reload()
|
||||
{
|
||||
var fileBasedIpc = ipc as FileBasedIPC;
|
||||
StableInfo stableInfo = fileBasedIpc?.GetStableInfo();
|
||||
StableInfo stableInfo = fileBasedIpc?.StableInfo;
|
||||
fillFlow.Children = new Drawable[]
|
||||
{
|
||||
new ActionableInfo
|
||||
|
@ -38,7 +38,12 @@ namespace osu.Game.Tournament.Screens
|
||||
private void load(Storage storage, OsuColour colours)
|
||||
{
|
||||
var fileBasedIpc = ipc as FileBasedIPC;
|
||||
var initialPath = new DirectoryInfo(host.GetStorage(fileBasedIpc?.GetStableInfo().StablePath.Value).GetFullPath(string.Empty) ?? storage.GetFullPath(string.Empty)).Parent?.FullName;
|
||||
var initialPath = new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent?.FullName;
|
||||
|
||||
if (!string.IsNullOrEmpty(fileBasedIpc?.StableInfo.StablePath.Value))
|
||||
{
|
||||
initialPath = new DirectoryInfo(host.GetStorage(fileBasedIpc.StableInfo.StablePath.Value).GetFullPath(string.Empty)).Parent?.FullName;
|
||||
}
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user