Refactoring, cleanup
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using Aki.Reflection.Patching;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using EFT.UI;
|
||||
using System.Threading.Tasks;
|
||||
using EFT.UI.Chat;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
@@ -39,12 +38,12 @@ namespace UIFixes
|
||||
[PatchPrefix]
|
||||
private static bool Prefix(ref Task<bool> __result)
|
||||
{
|
||||
if (MoveForward && Plugin.WeaponPresetConfirmOnNavigate.Value)
|
||||
if (MoveForward && Settings.WeaponPresetConfirmOnNavigate.Value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!MoveForward && Plugin.WeaponPresetConfirmOnClose.Value)
|
||||
if (!MoveForward && Settings.WeaponPresetConfirmOnClose.Value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -54,42 +53,5 @@ namespace UIFixes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TransferConfirmPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
Type type = typeof(TransferItemsScreen);
|
||||
return type.GetMethod("method_4", BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
private static bool Prefix(ref Task<bool> __result)
|
||||
{
|
||||
if (Plugin.TransferConfirmOnClose.Value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
__result = Task.FromResult<bool>(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class MailReceiveAllPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
Type type = typeof(ChatMessageSendBlock);
|
||||
return type.GetMethod("Show", BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
private static void Prefix(DialogueClass dialogue)
|
||||
{
|
||||
// Force this false will recalculate each time. This is less than ideal, but the way the code is structured makes it very difficult to do correctly.
|
||||
dialogue.HasMessagesWithRewards = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
Patches/MailReceiveAllPatch.cs
Normal file
24
Patches/MailReceiveAllPatch.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using EFT.UI.Chat;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class MailReceiveAllPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
Type type = typeof(ChatMessageSendBlock);
|
||||
return type.GetMethod("Show", BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
private static void Prefix(DialogueClass dialogue)
|
||||
{
|
||||
// Force this false will recalculate each time. This is less than ideal, but the way the code is structured makes it very difficult to do correctly.
|
||||
dialogue.HasMessagesWithRewards = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
30
Patches/TransferConfirmPatch.cs
Normal file
30
Patches/TransferConfirmPatch.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using EFT.UI;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class TransferConfirmPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
Type type = typeof(TransferItemsScreen);
|
||||
return type.GetMethod("method_4", BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
private static bool Prefix(ref Task<bool> __result)
|
||||
{
|
||||
if (Settings.TransferConfirmOnClose.Value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
__result = Task.FromResult<bool>(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,9 @@ namespace UIFixes
|
||||
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
||||
public class Plugin : BaseUnityPlugin
|
||||
{
|
||||
public static ConfigEntry<bool> WeaponPresetConfirmOnNavigate { get; set; }
|
||||
public static ConfigEntry<bool> WeaponPresetConfirmOnClose { get; set; }
|
||||
public static ConfigEntry<bool> TransferConfirmOnClose { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
WeaponPresetConfirmOnNavigate = Config.Bind<bool>("Weapon Presets", "Confirm on screen change", false, "Whether to confirm unsaved changes when you change screens without closing the preset");
|
||||
WeaponPresetConfirmOnClose = Config.Bind<bool>("Weapon Presets", "Confirm on close", true, "Whether to still confirm unsaved changes when you actually close the preset");
|
||||
TransferConfirmOnClose = Config.Bind<bool>("Transfer items", "Confirm untransfered items", false, "Whether to pointlessly confirm that you're leaving the item transfer with literally no consequences");
|
||||
Settings.Init(Config);
|
||||
|
||||
new EditBuildScreenPatch.CloseScreenInterruptionPatch().Enable();
|
||||
new EditBuildScreenPatch.ConfirmDiscardPatch().Enable();
|
||||
|
||||
19
Settings.cs
Normal file
19
Settings.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using BepInEx.Configuration;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
internal class Settings
|
||||
{
|
||||
public static ConfigEntry<bool> WeaponPresetConfirmOnNavigate { get; set; }
|
||||
public static ConfigEntry<bool> WeaponPresetConfirmOnClose { get; set; }
|
||||
public static ConfigEntry<bool> TransferConfirmOnClose { get; set; }
|
||||
|
||||
public static void Init(ConfigFile config)
|
||||
{
|
||||
WeaponPresetConfirmOnNavigate = config.Bind<bool>("Weapon Presets", "Confirm on screen change", false, "Whether to confirm unsaved changes when you change screens without closing the preset");
|
||||
WeaponPresetConfirmOnClose = config.Bind<bool>("Weapon Presets", "Confirm on close", true, "Whether to still confirm unsaved changes when you actually close the preset");
|
||||
TransferConfirmOnClose = config.Bind<bool>("Transfer items", "Confirm untransfered items", false, "Whether to pointlessly confirm that you're leaving the item transfer with literally no consequences");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user