remove DrawHooks, use new penumbra IPC calls (otter pls)

This commit is contained in:
Stanley Dimant
2022-06-17 01:08:36 +02:00
parent f643b413f2
commit 176eb2a344
7 changed files with 230 additions and 560 deletions

View File

@@ -7,45 +7,20 @@ namespace MareSynchronos.Factories
public class FileReplacementFactory
{
private readonly IpcManager ipcManager;
private readonly ClientState clientState;
private string playerName;
public FileReplacementFactory(IpcManager ipcManager, ClientState clientState)
public FileReplacementFactory(IpcManager ipcManager)
{
this.ipcManager = ipcManager;
this.clientState = clientState;
playerName = null!;
}
public FileReplacement Create(string gamePath, bool resolve = true)
public FileReplacement Create()
{
if (!ipcManager.CheckPenumbraAPI())
{
throw new System.Exception();
}
var fileReplacement = new FileReplacement(gamePath, ipcManager.PenumbraModDirectory()!);
if (!resolve) return fileReplacement;
if (clientState.LocalPlayer != null)
{
playerName = clientState.LocalPlayer.Name.ToString();
}
fileReplacement.SetResolvedPath(ipcManager.PenumbraResolvePath(gamePath, playerName)!);
if (!fileReplacement.HasFileReplacement)
{
// try to resolve path with --filename instead?
string[] tempGamePath = gamePath.Split('/');
tempGamePath[^1] = "--" + tempGamePath[^1];
string newTempGamePath = string.Join('/', tempGamePath);
var resolvedPath = ipcManager.PenumbraResolvePath(newTempGamePath, playerName)!;
if (resolvedPath != newTempGamePath)
{
fileReplacement.SetResolvedPath(resolvedPath);
fileReplacement.SetGamePath(newTempGamePath);
}
}
return fileReplacement;
return new FileReplacement(ipcManager.PenumbraModDirectory()!);
}
}
}