Restructure settings, improve dialogs
This commit is contained in:
66
Patches/DialogPatches.cs
Normal file
66
Patches/DialogPatches.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT.InventoryLogic;
|
||||
using EFT.UI;
|
||||
using EFT.UI.Ragfair;
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class DialogPatches
|
||||
{
|
||||
public static void Enable()
|
||||
{
|
||||
new DialogWindowPatch().Enable();
|
||||
new FleaPurchaseDialogPatch().Enable();
|
||||
}
|
||||
|
||||
private class DialogWindowPatch : ModulePatch
|
||||
{
|
||||
private static MethodInfo AcceptMethod;
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
Type dialogWindowType = typeof(MessageWindow).BaseType;
|
||||
AcceptMethod = AccessTools.Method(dialogWindowType, "Accept");
|
||||
|
||||
return AccessTools.Method(dialogWindowType, "Update");
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
private static void Postfix(object __instance, bool ___bool_0)
|
||||
{
|
||||
if (!___bool_0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
|
||||
{
|
||||
AcceptMethod.Invoke(__instance, []);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class FleaPurchaseDialogPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
// The parent has a Show() so need to be specific
|
||||
return typeof(HandoverRagfairMoneyWindow).GetMethods().First(m => m.Name == "Show" && m.GetParameters()[0].ParameterType == typeof(Inventory));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
private static void Postfix(TMP_InputField ____inputField)
|
||||
{
|
||||
____inputField.Select();
|
||||
____inputField.ActivateInputField();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,6 +19,7 @@ namespace UIFixes
|
||||
new ConfirmDiscardPatch().Enable();
|
||||
}
|
||||
|
||||
// This patch just caches whether this navigation is a forward navigation, which determines if the preset is actually closing
|
||||
public class CloseScreenInterruptionPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
@@ -45,12 +46,12 @@ namespace UIFixes
|
||||
[PatchPrefix]
|
||||
private static bool Prefix(ref Task<bool> __result)
|
||||
{
|
||||
if (MoveForward && Settings.WeaponPresetConfirmOnNavigate.Value)
|
||||
if (MoveForward && Settings.ShowPresetConfirmations.Value == WeaponPresetConfirmationOption.Always)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!MoveForward && Settings.WeaponPresetConfirmOnClose.Value)
|
||||
if (!MoveForward && Settings.ShowPresetConfirmations.Value != WeaponPresetConfirmationOption.Never)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ namespace UIFixes
|
||||
[PatchPrefix]
|
||||
private static bool Prefix(ref Task<bool> __result)
|
||||
{
|
||||
if (Settings.TransferConfirmOnClose.Value)
|
||||
if (Settings.ShowTransferConfirmations.Value == TransferConfirmationOption.Always)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ namespace UIFixes
|
||||
new TooltipPatch().Enable();
|
||||
ItemPanelPatches.Enable();
|
||||
new ContainerStackPatch().Enable();
|
||||
DialogPatches.Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
175
Settings.cs
175
Settings.cs
@@ -1,44 +1,173 @@
|
||||
using BepInEx.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
internal enum WeaponPresetConfirmationOption
|
||||
{
|
||||
Never,
|
||||
[Description("On Close")]
|
||||
OnClose,
|
||||
Always
|
||||
}
|
||||
|
||||
internal enum TransferConfirmationOption
|
||||
{
|
||||
Never,
|
||||
Always
|
||||
}
|
||||
|
||||
internal class Settings
|
||||
{
|
||||
// Categories
|
||||
private const string WeaponPresets = "Weapon Presets";
|
||||
private const string TransferItems = "Transfer Items";
|
||||
private const string Inventory = "Inventory";
|
||||
private const string InRaid = "In Raid";
|
||||
private const string Items = "Items";
|
||||
private const string ContainerStacking = "Containers autostack FiR and non-FiR";
|
||||
private const string GeneralSection = "1. General";
|
||||
private const string InputSection = "2. Input";
|
||||
private const string InventorySection = "3. Inventory";
|
||||
private const string InRaidSection = "4. In Raid";
|
||||
|
||||
public static ConfigEntry<bool> WeaponPresetConfirmOnNavigate { get; set; }
|
||||
public static ConfigEntry<bool> WeaponPresetConfirmOnClose { get; set; }
|
||||
public static ConfigEntry<bool> TransferConfirmOnClose { get; set; }
|
||||
// General
|
||||
public static ConfigEntry<WeaponPresetConfirmationOption> ShowPresetConfirmations { get; set; }
|
||||
public static ConfigEntry<TransferConfirmationOption> ShowTransferConfirmations { get; set; }
|
||||
public static ConfigEntry<bool> ShowModStats { get; set; }
|
||||
|
||||
// Input
|
||||
public static ConfigEntry<bool> UseHomeEnd { get; set; }
|
||||
public static ConfigEntry<bool> RebindPageUpDown { get; set; }
|
||||
public static ConfigEntry<int> MouseScrollMulti { get; set; }
|
||||
public static ConfigEntry<bool> RemoveDisabledActions { get; set; }
|
||||
|
||||
// Inventory
|
||||
public static ConfigEntry<bool> SwapItems { get; set; }
|
||||
public static ConfigEntry<bool> ShowModStats { get; set; }
|
||||
public static ConfigEntry<bool> MergeFIRMoney { get; set; }
|
||||
public static ConfigEntry<bool> MergeFIRAmmo { get; set; }
|
||||
public static ConfigEntry<bool> MergeFIROther { get; set; }
|
||||
|
||||
// In Raid
|
||||
public static ConfigEntry<bool> RemoveDisabledActions { get; set; }
|
||||
|
||||
public static void Init(ConfigFile config)
|
||||
{
|
||||
WeaponPresetConfirmOnNavigate = config.Bind<bool>(WeaponPresets, "Confirm on screen change", false, "Whether to confirm unsaved changes when you change screens without closing the preset");
|
||||
WeaponPresetConfirmOnClose = config.Bind<bool>(WeaponPresets, "Confirm on close", true, "Whether to still confirm unsaved changes when you actually close the preset");
|
||||
TransferConfirmOnClose = config.Bind<bool>(TransferItems, "Confirm untransfered items", false, "Whether to pointlessly confirm that you're leaving the item transfer with literally no consequences");
|
||||
UseHomeEnd = config.Bind<bool>(Inventory, "Add support for Home and End", true, "Home and End will scroll to the top and bottom of lists");
|
||||
RebindPageUpDown = config.Bind<bool>(Inventory, "Use normal PageUp and PageDown (requires restart)", true, "Changes PageUp and PageDown to simply page up and down, not scroll all the way to top and bottom");
|
||||
MouseScrollMulti = config.Bind<int>(Inventory, "Mousewheel scrolling multiplier", 1, "How many rows to scroll with the mousewheel");
|
||||
SwapItems = config.Bind<bool>(Inventory, "In-place item swapping", true);
|
||||
RemoveDisabledActions = config.Bind<bool>(InRaid, "Hide unimplemented actions", false, "Hides actions you can't actually do, like \"Bang and Clear\", etc from locked doors and other interactable objects");
|
||||
ShowModStats = config.Bind<bool>(Items, "Show total mod stats", true, "Item mods will show stats that include mods attached to them (you can also control this from a mod's inspect window)");
|
||||
MergeFIRMoney = config.Bind<bool>(ContainerStacking, "Money", true, "Allows automatic stacking of Found In Raid money with other money, making container interaction easier");
|
||||
MergeFIRAmmo = config.Bind<bool>(ContainerStacking, "Ammo", false, "Allows automatic stacking of Found In Raid ammo with other ammo, making container interaction easier");
|
||||
MergeFIROther = config.Bind<bool>(ContainerStacking, "Other", false, "Allows automatic stacking of all other Found In Raid items with other items, making container interaction easier");
|
||||
var configEntries = new List<ConfigEntryBase>();
|
||||
|
||||
// General
|
||||
configEntries.Add(ShowPresetConfirmations = config.Bind(
|
||||
GeneralSection,
|
||||
"Show Weapon Preset Confirmation Dialog",
|
||||
WeaponPresetConfirmationOption.OnClose,
|
||||
new ConfigDescription(
|
||||
"When to show a confirmation dialog when you leave and/or close an unsaved weapon preset",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(ShowTransferConfirmations = config.Bind(
|
||||
GeneralSection,
|
||||
"Show Transfer Items Confirmation Dialog",
|
||||
TransferConfirmationOption.Never,
|
||||
new ConfigDescription(
|
||||
"When to show the confirmation dialog when you close the item transfer screen without taking all the items",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(ShowModStats = config.Bind(
|
||||
GeneralSection,
|
||||
"Show Total Stats on Mods",
|
||||
true,
|
||||
new ConfigDescription(
|
||||
"Item mods will show stats that include mods attached to them (you can also control this from a mod's inspect window)",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
// Input
|
||||
configEntries.Add(UseHomeEnd = config.Bind(
|
||||
InputSection,
|
||||
"Enable Home/End Keys",
|
||||
true,
|
||||
new ConfigDescription(
|
||||
"Use the Home and End keys to scroll to the top and bottom of inventories",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(RebindPageUpDown = config.Bind(
|
||||
InputSection,
|
||||
"Rebind PageUp/PageDown (requires restart)",
|
||||
true,
|
||||
new ConfigDescription(
|
||||
"Change PageUp and PageDown to scroll up and down one page",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(MouseScrollMulti = config.Bind(
|
||||
InputSection,
|
||||
"Mousewheel Scrolling Speed",
|
||||
1,
|
||||
new ConfigDescription(
|
||||
"How many rows to scroll with the mousewheel",
|
||||
new AcceptableValueRange<int>(1, 10),
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
// Inventory
|
||||
configEntries.Add(SwapItems = config.Bind(
|
||||
InventorySection,
|
||||
"Enable In-Place Item Swapping",
|
||||
true,
|
||||
new ConfigDescription(
|
||||
"Drag one item onto another to swap their positions, if possible",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(MergeFIRMoney = config.Bind(
|
||||
InventorySection,
|
||||
"Autostack Money with FiR Money",
|
||||
true,
|
||||
new ConfigDescription(
|
||||
"Allows automatic stacking of Found In Raid money with other money, making container interaction easier",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(MergeFIRAmmo = config.Bind(
|
||||
InventorySection,
|
||||
"Autostack Ammo with FiR Ammo",
|
||||
false,
|
||||
new ConfigDescription(
|
||||
"Allows automatic stacking of Found In Raid ammo with other money, making container interaction easier",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(MergeFIROther = config.Bind(
|
||||
InventorySection,
|
||||
"Autostack Items with FiR Items",
|
||||
false,
|
||||
new ConfigDescription(
|
||||
"Allows automatic stacking of Found In Raid items with other items, making container interaction easier",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
// In Raid
|
||||
configEntries.Add(RemoveDisabledActions = config.Bind(
|
||||
InRaidSection,
|
||||
"Hide Unimplemented Door Actions",
|
||||
true,
|
||||
new ConfigDescription(
|
||||
"Hides actions you can't actually do, like \"Bang and Clear\", etc from locked doors",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
RecalcOrder(configEntries);
|
||||
}
|
||||
private static void RecalcOrder(List<ConfigEntryBase> configEntries)
|
||||
{
|
||||
// Set the Order field for all settings, to avoid unnecessary changes when adding new settings
|
||||
int settingOrder = configEntries.Count;
|
||||
foreach (var entry in configEntries)
|
||||
{
|
||||
ConfigurationManagerAttributes attributes = entry.Description.Tags[0] as ConfigurationManagerAttributes;
|
||||
if (attributes != null)
|
||||
{
|
||||
attributes.Order = settingOrder;
|
||||
}
|
||||
|
||||
settingOrder--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user