1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:47:28 +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 new PopupDialogOkButton
{ {
Text = @"Alright.", Text = @"Alright.",
Action = () => { Expire(); } Action = () => Expire()
} }
}; };
} }

View File

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

View File

@ -139,7 +139,7 @@ namespace osu.Game.Tournament.Screens
var fileBasedIpc = ipc as FileBasedIPC; var fileBasedIpc = ipc as FileBasedIPC;
Logger.Log($"Changing Stable CE location to {target}"); Logger.Log($"Changing Stable CE location to {target}");
if (!FileBasedIPC.CheckExists(target)) if (!fileBasedIpc?.SetIPCLocation(target) ?? false)
{ {
overlay = new DialogOverlay(); 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.")); 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; return;
} }
fileBasedIpc?.SaveStableConfig(target);
fileBasedIpc?.LocateStableStorage();
sceneManager?.SetScreen(typeof(SetupScreen)); sceneManager?.SetScreen(typeof(SetupScreen));
} }