diff --git a/Fuyu.Client.NLog/Fuyu.Client.NLog.csproj b/Fuyu.Client.NLog/Fuyu.Client.NLog.csproj new file mode 100644 index 00000000..e2f1e807 --- /dev/null +++ b/Fuyu.Client.NLog/Fuyu.Client.NLog.csproj @@ -0,0 +1,21 @@ + + + + net48 + + + + + + + + + + + + + + + + + diff --git a/Fuyu.Client.NLog/FuyuClient.cs b/Fuyu.Client.NLog/FuyuClient.cs new file mode 100644 index 00000000..df03e5e0 --- /dev/null +++ b/Fuyu.Client.NLog/FuyuClient.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using NLog; +using NLog.Targets; +using Fuyu.Common.IO; +using Fuyu.DependencyInjection; +using Fuyu.Modding; + +[Target(nameof(FuyuClient))] +public sealed class FuyuClient : TargetWithLayout +{ + protected override void InitializeTarget() + { + var container = new DependencyContainer(); + + CheckIncompatibleSoftware(); + + Terminal.WriteLine("Loading mods..."); + ModManager.Instance.AddMods("./Fuyu/Mods"); + ModManager.Instance.Load(container).GetAwaiter().GetResult(); + Terminal.WriteLine("Finished loading mods"); + + // TODO: OnApplicationQuit + // -- seionmoya, 20205-01-04 + } + + private void CheckIncompatibleSoftware() + { + var record = new Dictionary() + { + { "BepInEx/", "BepInEx" }, + { "MelonLoader/", "MelonLoader" }, + { "SPT.Launcher/", "SPTarkov" }, + { "monomod.exe", "MonoMod" }, + { "MonoMod.RuntimeDetour.HookGen.exe", "MonoMod" } + // TODO: UnityModManager, UMF + }; + + foreach (var kvp in record) + { + if (VFS.Exists(kvp.Key)) + { + throw new Exception($"{kvp.Value} found. Please remove the software from the client before proceeding."); + } + } + } +} \ No newline at end of file diff --git a/Fuyu.Client.NLog/README.md b/Fuyu.Client.NLog/README.md new file mode 100644 index 00000000..f3765c3d --- /dev/null +++ b/Fuyu.Client.NLog/README.md @@ -0,0 +1,49 @@ +# Fuyu.Client.NLog + +Fuyu mod loader for clients using NLog. + +## Installation + +1. Build the project +2. Place `Fuyu.Client.NLog` inside `/Managed/` +3. Place `NLog.dll` inside `/Managed/`, override when prompted +4. Add the following to `NLog/NLog.config`: + +```xml + + + + + + + + + + + + + + + + + + +``` + +## FAQ + +> Why not BepInEx / Monomod / Unity Mod Manager / MelonLoader? + +Fuyu is designed to function with as little dependencies as possible to run, +especially not depending on external projects. With it's own loader, Fuyu also +gains more control over mod loading. + +> Why does the project include a NLog version? + +EFT removed `LoadNLogExtensionAssemblies` in their build, thus we have to use +the version from the reference folder (NLog 4.7.15, netstandard2.0). diff --git a/Fuyu.Client.NLog/References/NLog.dll b/Fuyu.Client.NLog/References/NLog.dll new file mode 100644 index 00000000..23bbb056 Binary files /dev/null and b/Fuyu.Client.NLog/References/NLog.dll differ diff --git a/Fuyu.Common/IO/VFS.cs b/Fuyu.Common/IO/VFS.cs index 7dcc852e..2318238a 100644 --- a/Fuyu.Common/IO/VFS.cs +++ b/Fuyu.Common/IO/VFS.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Concurrent; using System.IO; @@ -23,6 +22,11 @@ public static bool FileExists(string filepath) return File.Exists(filepath); } + public static bool Exists(string filepath) + { + return DirectoryExists(filepath) || FileExists(filepath); + } + public static string[] GetFiles(string path) { if (!Directory.Exists(path)) diff --git a/Fuyu.sln b/Fuyu.sln index ed0c64d7..b9597216 100644 --- a/Fuyu.sln +++ b/Fuyu.sln @@ -39,6 +39,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fuyu.DependencyInjection", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fuyu.Modding", "Fuyu.Modding\Fuyu.Modding.csproj", "{1687E80C-E174-4844-9939-7AAF6E1139F0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fuyu.Client.NLog", "Fuyu.Client.NLog\Fuyu.Client.NLog.csproj", "{335E42B4-0EDD-4CDD-908A-C109272FB181}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -117,6 +119,10 @@ Global {1687E80C-E174-4844-9939-7AAF6E1139F0}.Debug|Any CPU.Build.0 = Debug|Any CPU {1687E80C-E174-4844-9939-7AAF6E1139F0}.Release|Any CPU.ActiveCfg = Release|Any CPU {1687E80C-E174-4844-9939-7AAF6E1139F0}.Release|Any CPU.Build.0 = Release|Any CPU + {335E42B4-0EDD-4CDD-908A-C109272FB181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {335E42B4-0EDD-4CDD-908A-C109272FB181}.Debug|Any CPU.Build.0 = Debug|Any CPU + {335E42B4-0EDD-4CDD-908A-C109272FB181}.Release|Any CPU.ActiveCfg = Release|Any CPU + {335E42B4-0EDD-4CDD-908A-C109272FB181}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE