using file-scoped namespaces

This commit is contained in:
Tyfon
2024-07-12 16:17:42 -07:00
parent 29b6094b20
commit 7ea249114d
63 changed files with 8789 additions and 8855 deletions

View File

@@ -4,49 +4,48 @@ using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
namespace UIFixes
namespace UIFixes;
public static class RememberRepairerPatches
{
public static class RememberRepairerPatches
public static void Enable()
{
public static void Enable()
new RememberRepairerPatch().Enable();
new DefaultMaxRepairPatch().Enable();
}
public class RememberRepairerPatch : ModulePatch
{
private static readonly string PlayerPrefKey = "UIFixes.Repair.CurrentRepairerIndex";
protected override MethodBase GetTargetMethod()
{
new RememberRepairerPatch().Enable();
new DefaultMaxRepairPatch().Enable();
return AccessTools.Method(typeof(RepairerParametersPanel), nameof(RepairerParametersPanel.Show));
}
public class RememberRepairerPatch : ModulePatch
[PatchPostfix]
public static void Postfix(RepairerParametersPanel __instance, DropDownBox ____tradersDropDown)
{
private static readonly string PlayerPrefKey = "UIFixes.Repair.CurrentRepairerIndex";
__instance.R().UI.AddDisposable(____tradersDropDown.OnValueChanged.Subscribe(index => PlayerPrefs.SetInt(PlayerPrefKey, index)));
protected override MethodBase GetTargetMethod()
if (PlayerPrefs.HasKey(PlayerPrefKey))
{
return AccessTools.Method(typeof(RepairerParametersPanel), nameof(RepairerParametersPanel.Show));
}
[PatchPostfix]
public static void Postfix(RepairerParametersPanel __instance, DropDownBox ____tradersDropDown)
{
__instance.R().UI.AddDisposable(____tradersDropDown.OnValueChanged.Subscribe(index => PlayerPrefs.SetInt(PlayerPrefKey, index)));
if (PlayerPrefs.HasKey(PlayerPrefKey))
{
____tradersDropDown.UpdateValue(PlayerPrefs.GetInt(PlayerPrefKey));
}
}
}
public class DefaultMaxRepairPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(RepairerParametersPanel), nameof(RepairerParametersPanel.method_3));
}
[PatchPostfix]
public static void Postfix(ConditionCharacteristicsSlider ____conditionSlider)
{
____conditionSlider.method_1(); // like clicking >>, aka select max value
____tradersDropDown.UpdateValue(PlayerPrefs.GetInt(PlayerPrefKey));
}
}
}
public class DefaultMaxRepairPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(RepairerParametersPanel), nameof(RepairerParametersPanel.method_3));
}
[PatchPostfix]
public static void Postfix(ConditionCharacteristicsSlider ____conditionSlider)
{
____conditionSlider.method_1(); // like clicking >>, aka select max value
}
}
}