2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2023-10-10 10:58:33 +00:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.Custom.Patches
|
2023-10-10 10:58:33 +00:00
|
|
|
|
{
|
2024-01-23 15:42:11 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Redirect the settings data to save into the SPT folder, not app data
|
|
|
|
|
/// </summary>
|
2024-07-11 11:18:00 +01:00
|
|
|
|
public class SaveSettingsToSptFolderPatch : ModulePatch
|
2023-10-10 10:58:33 +00:00
|
|
|
|
{
|
2024-01-23 15:42:47 +00:00
|
|
|
|
private static readonly string _sptPath = Path.Combine(Environment.CurrentDirectory, "user", "sptSettings");
|
2023-10-10 10:58:33 +00:00
|
|
|
|
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
|
|
|
|
return AccessTools.Constructor(typeof(SharedGameSettingsClass));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPrefix]
|
|
|
|
|
internal static void PatchPrefix(ref string ___string_0, ref string ___string_1)
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(_sptPath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(_sptPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
___string_0 = _sptPath;
|
|
|
|
|
___string_1 = _sptPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|