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

Apply review suggestions

This commit is contained in:
Shivam 2020-06-03 23:49:06 +02:00
parent 7b77d43353
commit 7e5db5e933
3 changed files with 16 additions and 12 deletions

View File

@ -18,7 +18,7 @@ namespace osu.Game.Tournament.Components
new PopupDialogOkButton
{
Text = @"Alright.",
Action = () => { Expire(); }
Action = () => Expire()
}
};
}

View File

@ -158,7 +158,7 @@ namespace osu.Game.Tournament.IPC
return IPCStorage;
}
public static bool CheckExists(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
private static bool ipcFileExistsInDirectory(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
private string findStablePath()
{
@ -183,8 +183,8 @@ namespace osu.Game.Tournament.IPC
if (stableInstallPath != null)
{
SaveStableConfig(stableInstallPath);
return null;
SetIPCLocation(stableInstallPath);
return stableInstallPath;
}
}
@ -196,8 +196,11 @@ namespace osu.Game.Tournament.IPC
}
}
public void SaveStableConfig(string path)
public bool SetIPCLocation(string path)
{
if (!ipcFileExistsInDirectory(path))
return false;
StableInfo.StablePath.Value = path;
using (var stream = tournamentStorage.GetStream(STABLE_CONFIG, FileAccess.Write, FileMode.Create))
@ -211,6 +214,9 @@ namespace osu.Game.Tournament.IPC
DefaultValueHandling = DefaultValueHandling.Ignore,
}));
}
LocateStableStorage();
return true;
}
private string readStableConfig()
@ -239,7 +245,7 @@ namespace osu.Game.Tournament.IPC
Logger.Log("Trying to find stable with environment variables");
string stableInstallPath = Environment.GetEnvironmentVariable("OSU_STABLE_PATH");
if (CheckExists(stableInstallPath))
if (ipcFileExistsInDirectory(stableInstallPath))
return stableInstallPath;
}
catch
@ -254,7 +260,7 @@ namespace osu.Game.Tournament.IPC
Logger.Log("Trying to find stable in %LOCALAPPDATA%");
string stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!");
if (CheckExists(stableInstallPath))
if (ipcFileExistsInDirectory(stableInstallPath))
return stableInstallPath;
return null;
@ -265,7 +271,7 @@ namespace osu.Game.Tournament.IPC
Logger.Log("Trying to find stable in dotfolders");
string stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".osu");
if (CheckExists(stableInstallPath))
if (ipcFileExistsInDirectory(stableInstallPath))
return stableInstallPath;
return null;
@ -280,7 +286,7 @@ namespace osu.Game.Tournament.IPC
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu"))
stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
if (CheckExists(stableInstallPath))
if (ipcFileExistsInDirectory(stableInstallPath))
return stableInstallPath;
return null;

View File

@ -139,7 +139,7 @@ namespace osu.Game.Tournament.Screens
var fileBasedIpc = ipc as FileBasedIPC;
Logger.Log($"Changing Stable CE location to {target}");
if (!FileBasedIPC.CheckExists(target))
if (!fileBasedIpc?.SetIPCLocation(target) ?? false)
{
overlay = new DialogOverlay();
overlay.Push(new IPCErrorDialog("This is an invalid IPC Directory", "Select a directory that contains an osu! stable cutting edge installation and make sure it has an empty ipc.txt file in it."));
@ -148,8 +148,6 @@ namespace osu.Game.Tournament.Screens
return;
}
fileBasedIpc?.SaveStableConfig(target);
fileBasedIpc?.LocateStableStorage();
sceneManager?.SetScreen(typeof(SetupScreen));
}