mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 05:52:54 +08:00
Allow auto-detect to work after choosing manually
This commit is contained in:
parent
586d5791e0
commit
992aa0041e
@ -5,6 +5,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Win32;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
@ -21,6 +22,8 @@ namespace osu.Game.Tournament.IPC
|
||||
{
|
||||
public class FileBasedIPC : MatchIPCInfo
|
||||
{
|
||||
public Storage IPCStorage { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
protected IAPIProvider API { get; private set; }
|
||||
|
||||
@ -36,22 +39,22 @@ namespace osu.Game.Tournament.IPC
|
||||
[Resolved]
|
||||
private StableInfo stableInfo { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Storage tournamentStorage { get; set; }
|
||||
|
||||
private int lastBeatmapId;
|
||||
private ScheduledDelegate scheduled;
|
||||
private GetBeatmapRequest beatmapLookupRequest;
|
||||
|
||||
public Storage IPCStorage { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
private Storage tournamentStorage { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
LocateStableStorage();
|
||||
var stablePath = stableInfo.StablePath ?? findStablePath();
|
||||
initialiseIPCStorage(stablePath);
|
||||
}
|
||||
|
||||
public Storage LocateStableStorage()
|
||||
[CanBeNull]
|
||||
private Storage initialiseIPCStorage(string path)
|
||||
{
|
||||
scheduled?.Cancel();
|
||||
|
||||
@ -59,8 +62,6 @@ namespace osu.Game.Tournament.IPC
|
||||
|
||||
try
|
||||
{
|
||||
var path = findStablePath();
|
||||
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return null;
|
||||
|
||||
@ -159,13 +160,37 @@ namespace osu.Game.Tournament.IPC
|
||||
return IPCStorage;
|
||||
}
|
||||
|
||||
public bool SetIPCLocation(string path)
|
||||
{
|
||||
if (!ipcFileExistsInDirectory(path))
|
||||
return false;
|
||||
|
||||
var newStorage = initialiseIPCStorage(stableInfo.StablePath = path);
|
||||
if (newStorage == null)
|
||||
return false;
|
||||
|
||||
stableInfo.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AutoDetectIPCLocation()
|
||||
{
|
||||
var autoDetectedPath = findStablePath();
|
||||
if (string.IsNullOrEmpty(autoDetectedPath))
|
||||
return false;
|
||||
|
||||
var newStorage = initialiseIPCStorage(stableInfo.StablePath = autoDetectedPath);
|
||||
if (newStorage == null)
|
||||
return false;
|
||||
|
||||
stableInfo.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool ipcFileExistsInDirectory(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
|
||||
|
||||
private string findStablePath()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(stableInfo.StablePath))
|
||||
return stableInfo.StablePath;
|
||||
|
||||
string stableInstallPath = string.Empty;
|
||||
|
||||
try
|
||||
@ -183,10 +208,7 @@ namespace osu.Game.Tournament.IPC
|
||||
stableInstallPath = r.Invoke();
|
||||
|
||||
if (stableInstallPath != null)
|
||||
{
|
||||
SetIPCLocation(stableInstallPath);
|
||||
return stableInstallPath;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -197,18 +219,6 @@ namespace osu.Game.Tournament.IPC
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetIPCLocation(string path)
|
||||
{
|
||||
if (!ipcFileExistsInDirectory(path))
|
||||
return false;
|
||||
|
||||
stableInfo.StablePath = path;
|
||||
LocateStableStorage();
|
||||
stableInfo.SaveChanges();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private string findFromEnvVar()
|
||||
{
|
||||
try
|
||||
|
@ -156,9 +156,8 @@ namespace osu.Game.Tournament.Screens
|
||||
protected virtual void AutoDetect()
|
||||
{
|
||||
var fileBasedIpc = ipc as FileBasedIPC;
|
||||
fileBasedIpc?.LocateStableStorage();
|
||||
|
||||
if (fileBasedIpc?.IPCStorage == null)
|
||||
if (!fileBasedIpc?.AutoDetectIPCLocation() ?? true)
|
||||
{
|
||||
overlay = new DialogOverlay();
|
||||
overlay.Push(new IPCErrorDialog("Failed to auto detect", "An osu! stable cutting-edge installation could not be auto detected.\nPlease try and manually point to the directory."));
|
||||
|
Loading…
Reference in New Issue
Block a user