mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 05:25:36 +08:00
make CheckExists static public and removed unnecessary code
This commit is contained in:
parent
d2416ce30d
commit
585100207c
@ -157,7 +157,7 @@ namespace osu.Game.Tournament.IPC
|
||||
return IPCStorage;
|
||||
}
|
||||
|
||||
public bool checkExists(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
|
||||
public static bool CheckExists(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
|
||||
|
||||
private string findStablePath()
|
||||
{
|
||||
@ -217,7 +217,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 (CheckExists(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
}
|
||||
catch
|
||||
@ -248,7 +248,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 (CheckExists(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
|
||||
return null;
|
||||
@ -259,7 +259,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 (CheckExists(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
|
||||
return null;
|
||||
@ -274,7 +274,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 (CheckExists(stableInstallPath))
|
||||
return stableInstallPath;
|
||||
|
||||
return null;
|
||||
|
@ -1,9 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -139,31 +137,23 @@ namespace osu.Game.Tournament.Screens
|
||||
|
||||
private void changePath(Storage storage)
|
||||
{
|
||||
try
|
||||
var target = directorySelector.CurrentDirectory.Value.FullName;
|
||||
stableInfo.StablePath.Value = target;
|
||||
Logger.Log($"Changing Stable CE location to {target}");
|
||||
|
||||
if (!FileBasedIPC.CheckExists(target))
|
||||
{
|
||||
var target = directorySelector.CurrentDirectory.Value.FullName;
|
||||
stableInfo.StablePath.Value = target;
|
||||
var fileBasedIpc = ipc as FileBasedIPC;
|
||||
Logger.Log($"Changing Stable CE location to {target}");
|
||||
|
||||
if (!fileBasedIpc.checkExists(target))
|
||||
{
|
||||
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."));
|
||||
AddInternal(overlay);
|
||||
Logger.Log("Folder is not an osu! stable CE directory");
|
||||
return;
|
||||
// Return an error in the picker that the directory does not contain ipc.txt
|
||||
}
|
||||
|
||||
|
||||
fileBasedIpc.LocateStableStorage();
|
||||
sceneManager.SetScreen(typeof(SetupScreen));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Error during migration: {e.Message}", level: LogLevel.Error);
|
||||
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."));
|
||||
AddInternal(overlay);
|
||||
Logger.Log("Folder is not an osu! stable CE directory");
|
||||
return;
|
||||
// Return an error in the picker that the directory does not contain ipc.txt
|
||||
}
|
||||
|
||||
var fileBasedIpc = ipc as FileBasedIPC;
|
||||
fileBasedIpc?.LocateStableStorage();
|
||||
sceneManager?.SetScreen(typeof(SetupScreen));
|
||||
}
|
||||
|
||||
private void autoDetect()
|
||||
|
Loading…
Reference in New Issue
Block a user