Rename patches for clarity

This commit is contained in:
Tyfon
2024-05-20 02:45:56 -07:00
parent 1853233dd3
commit a3c85da54e
18 changed files with 154 additions and 157 deletions

View File

@@ -0,0 +1,37 @@
using Aki.Reflection.Patching;
using EFT.UI;
using HarmonyLib;
using System;
using System.Reflection;
using UnityEngine;
namespace UIFixes
{
public class ConfirmationDialogKeysPatch : 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]
public static void Postfix(object __instance, bool ___bool_0)
{
if (!___bool_0)
{
return;
}
if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Space))
{
AcceptMethod.Invoke(__instance, []);
return;
}
}
}
}

View File

@@ -1,69 +0,0 @@
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]
public static void Postfix(object __instance, bool ___bool_0)
{
if (!___bool_0)
{
return;
}
if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Space))
{
AcceptMethod.Invoke(__instance, []);
return;
}
}
}
private class FleaPurchaseDialogPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
// The parent has a Show() so need to be specific
return AccessTools.GetDeclaredMethods(typeof(HandoverRagfairMoneyWindow)).First(
m => m.Name == nameof(HandoverRagfairMoneyWindow.Show) &&
m.GetParameters()[0].ParameterType == typeof(Inventory));
}
[PatchPostfix]
public static void Postfix(TMP_InputField ____inputField)
{
____inputField.contentType = TMP_InputField.ContentType.IntegerNumber;
____inputField.ActivateInputField();
____inputField.Select();
}
}
}
}

View File

@@ -6,7 +6,7 @@ using System.Reflection;
namespace UIFixes
{
public class MailReceiveAllPatch : ModulePatch
public class FixMailRecieveAllPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{

View File

@@ -5,7 +5,7 @@ using System.Reflection;
namespace UIFixes
{
public class TooltipPatch : ModulePatch
public class FixTooltipPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{

View File

@@ -9,7 +9,7 @@ using System.Reflection;
namespace UIFixes
{
public class WeaponBindingPatch : ModulePatch
public class FixWeaponBindsDisplayPatch : ModulePatch
{
private static Type ControlSettingsClass;
private static MethodInfo GetKeyNameMethod;

View File

@@ -0,0 +1,29 @@
using Aki.Reflection.Patching;
using EFT.InventoryLogic;
using EFT.UI.Ragfair;
using HarmonyLib;
using System.Linq;
using System.Reflection;
using TMPro;
namespace UIFixes
{
public class FocusFleaOfferNumberPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
// The parent has a Show() so need to be specific
return AccessTools.GetDeclaredMethods(typeof(HandoverRagfairMoneyWindow)).First(
m => m.Name == nameof(HandoverRagfairMoneyWindow.Show) &&
m.GetParameters()[0].ParameterType == typeof(Inventory));
}
[PatchPostfix]
public static void Postfix(TMP_InputField ____inputField)
{
____inputField.contentType = TMP_InputField.ContentType.IntegerNumber;
____inputField.ActivateInputField();
____inputField.Select();
}
}
}

View File

@@ -10,7 +10,7 @@ using UnityEngine.UI;
namespace UIFixes
{
public class ProductionPanelPatches
public class HideoutSearchPatches
{
private static FieldInfo ProductionPanelSearch;
private static FieldInfo SubstrateContentLayoutField;
@@ -22,16 +22,16 @@ namespace UIFixes
ProductionPanelSearch = AccessTools.Field(typeof(ProductionPanel), "_searchInputField");
SubstrateContentLayoutField = AccessTools.Field(typeof(AreaScreenSubstrate), "_contentLayout");
new LazyShowPatch().Enable();
new ShowContentsPatch().Enable();
new ClosePatch().Enable();
new ReturnToPreviousStatePatch().Enable();
new GetSortedProductsPatch().Enable();
new OnSearchChangePatch().Enable();
new FixHideoutSearchPatch().Enable();
new RestoreHideoutSearchPatch().Enable();
new SaveHideoutSearchPatch().Enable();
new CloseHideoutSearchPatch().Enable();
new FastHideoutSearchPatch().Enable();
new FixHideoutSearchAgainPatch().Enable();
}
// Deactivate ProduceViews as they lazy load if they don't match the search
public class LazyShowPatch : ModulePatch
public class FixHideoutSearchPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -56,7 +56,7 @@ namespace UIFixes
}
// Populate the search box, and force the window to render
public class ShowContentsPatch : ModulePatch
public class RestoreHideoutSearchPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
@@ -91,7 +91,7 @@ namespace UIFixes
}
// method_4 gets the sorted list of products. If there's a search term, prioritize the matching items so they load first
public class GetSortedProductsPatch : ModulePatch
public class FastHideoutSearchPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -114,7 +114,7 @@ namespace UIFixes
}
// method_9 activates/deactivates the product game objects based on the search. Need to resort the list due to above patch
public class OnSearchChangePatch : ModulePatch
public class FixHideoutSearchAgainPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -129,7 +129,7 @@ namespace UIFixes
}
// Save the search as the window closes
public class ClosePatch : ModulePatch
public class SaveHideoutSearchPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -149,7 +149,7 @@ namespace UIFixes
}
// Clear the search stuff when you exit out
public class ReturnToPreviousStatePatch : ModulePatch
public class CloseHideoutSearchPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{

View File

@@ -11,7 +11,7 @@ using UnityEngine.UI;
namespace UIFixes
{
internal class ItemPanelResizePatches
internal class InspectWindowResizePatches
{
private static float SavedPreferredWidth = -1f;
private static float SavedPreferredHeight = -1f;
@@ -26,12 +26,12 @@ namespace UIFixes
public static void Enable()
{
new ResizeWindowPatch().Enable();
new ShowPatch().Enable();
new ItemUiContextInspectPatch().Enable();
new SaveInspectWindowSizePatch().Enable();
new AddInspectWindowButtonsPatch().Enable();
new GrowInspectWindowDescriptionPatch().Enable();
}
private class ResizeWindowPatch : ModulePatch
private class SaveInspectWindowSizePatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -57,9 +57,8 @@ namespace UIFixes
}
}
private class ShowPatch : ModulePatch
private class AddInspectWindowButtonsPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(ItemSpecificationPanel), nameof(ItemSpecificationPanel.Show));
@@ -213,7 +212,7 @@ namespace UIFixes
}
}
private class ItemUiContextInspectPatch : ModulePatch
private class GrowInspectWindowDescriptionPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{

View File

@@ -14,7 +14,7 @@ using UnityEngine;
namespace UIFixes
{
public class ItemPanelPatches
public class InspectWindowStatsPatches
{
private static FieldInfo AttributeCompactPanelDictionaryField;
private static FieldInfo AttributeCompactDropdownDictionaryField;
@@ -30,14 +30,14 @@ namespace UIFixes
CompactCharacteristicPanelItemAttributeField = AccessTools.Field(typeof(CompactCharacteristicPanel), "ItemAttribute");
CompactCharacteristicPanelCompareItemAttributeField = AccessTools.Field(typeof(CompactCharacteristicPanel), "CompareItemAttribute");
new InjectButtonPatch().Enable();
new LoadModStatsPatch().Enable();
new CompareModPatch().Enable();
new AddShowHideModStatsButtonPatch().Enable();
new CalculateModStatsPatch().Enable();
new CompareModStatsPatch().Enable();
new FormatCompactValuesPatch().Enable();
new FormatFullValuesPatch().Enable();
}
private class LoadModStatsPatch : ModulePatch
private class CalculateModStatsPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -102,7 +102,7 @@ namespace UIFixes
// I wish I could prefix method_6 and update the compare item with the deep attributes, but that only works when adding a mod
// When removing, current item and compare item end up the same since current item never considers the mod anyway
// So I have to forcably call the refresh values method
private class CompareModPatch : ModulePatch
private class CompareModStatsPatch : ModulePatch
{
private static MethodInfo RefreshStaticMethod;
@@ -158,7 +158,7 @@ namespace UIFixes
}
}
private class InjectButtonPatch : ModulePatch
private class AddShowHideModStatsButtonPatch : ModulePatch
{
private static FieldInfo InteractionsButtonsContainerButtonTemplateField;
private static FieldInfo InteractionsButtonsContainerContainerField;

View File

@@ -6,7 +6,7 @@ using System.Reflection;
namespace UIFixes
{
public class DisabledActionsPatch : ModulePatch
public class RemoveDoorActionsPatch : ModulePatch
{
private static readonly string[] UnimplementedActions = ["Bang & clear", "Flash & clear", "Move in"];

View File

@@ -17,11 +17,11 @@ namespace UIFixes
{
public static void Enable()
{
new SimpleStashPanelPatch().Enable();
new TraderDealScreenPatch().Enable();
new OfferViewListPatch().Enable();
new MessagesContainerPatch().Enable();
new MouseScrollSpeedPatch().Enable();
new EnhanceStashScrollingPatch().Enable();
new EnchanceTraderStashScrollingPatch().Enable();
new EnhanceFleaScrollingPatch().Enable();
new EnhanceMailScrollingPatch().Enable();
new MouseScrollingSpeedPatch().Enable();
}
protected static void HandleInput(ScrollRect scrollRect)
@@ -122,7 +122,7 @@ namespace UIFixes
}
}
public class SimpleStashPanelPatch : ModulePatch
public class EnhanceStashScrollingPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -148,7 +148,7 @@ namespace UIFixes
}
}
public class TraderDealScreenPatch : ModulePatch
public class EnchanceTraderStashScrollingPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -173,7 +173,7 @@ namespace UIFixes
}
}
public class OfferViewListPatch : ModulePatch
public class EnhanceFleaScrollingPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -198,7 +198,7 @@ namespace UIFixes
}
}
public class MessagesContainerPatch : ModulePatch
public class EnhanceMailScrollingPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -223,7 +223,7 @@ namespace UIFixes
}
}
public class MouseScrollSpeedPatch : ModulePatch
public class MouseScrollingSpeedPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{

View File

@@ -8,7 +8,7 @@ using System.Reflection;
namespace UIFixes
{
public class ContainerStackPatch : ModulePatch
public class StackFirItemsPatch : ModulePatch
{
private static Type MergeableItemType;

View File

@@ -15,7 +15,7 @@ using UnityEngine.EventSystems;
namespace UIFixes
{
public class SwapPatch
public class SwapPatches
{
// Types needed
private static Type GridItemAddressType; // GClass2769
@@ -66,15 +66,15 @@ namespace UIFixes
GridViewNonInteractableField = AccessTools.Field(typeof(GridView), "_nonInteractable");
new ItemViewOnDragPatch().Enable();
new GridViewCanAcceptPatch().Enable();
new GridGetHightLightColorPatch().Enable();
new SlotGetHightLightColorPatch().Enable();
new ItemContextClassCanAcceptPatch().Enable();
new CheckItemFilterPatch().Enable();
new DetectSwapSourceContainerPatch().Enable();
new GridViewCanAcceptSwapPatch().Enable();
new DetectGridHighlightPrecheckPatch().Enable();
new DetectSlotHighlightPrecheckPatch().Enable();
new SlotCanAcceptSwapPatch().Enable();
new DetectFilterForSwapPatch().Enable();
new SwapOperationRaiseEventsPatch().Enable();
new GridItemViewOnPointerEnterPatch().Enable();
new DraggedItemContextUpdateTargetPatch().Enable();
new RememberSwapGridHoverPatch().Enable();
new InspectWindowUpdateStatsOnSwapPatch().Enable();
}
private static bool InRaid()
{
@@ -166,7 +166,7 @@ namespace UIFixes
return false;
}
public class ItemViewOnDragPatch : ModulePatch
public class DetectSwapSourceContainerPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -180,7 +180,7 @@ namespace UIFixes
}
}
public class GridViewCanAcceptPatch : ModulePatch
public class GridViewCanAcceptSwapPatch : ModulePatch
{
private static FieldInfo GridViewTraderControllerClassField;
@@ -364,7 +364,7 @@ namespace UIFixes
}
}
public class GridItemViewOnPointerEnterPatch : ModulePatch
public class RememberSwapGridHoverPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -380,7 +380,7 @@ namespace UIFixes
// Called when dragging an item onto an equipment slot
// Handles any kind of ItemAddress as the target destination (aka where the dragged item came from)
public class ItemContextClassCanAcceptPatch : ModulePatch
public class SlotCanAcceptSwapPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -422,7 +422,7 @@ namespace UIFixes
// The patched method here is called when iterating over all slots to highlight ones that the dragged item can interact with
// Since swap has no special highlight, I just skip the patch here (minor perf savings, plus makes debugging a million times easier)
public class GridGetHightLightColorPatch : ModulePatch
public class DetectGridHighlightPrecheckPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -444,7 +444,7 @@ namespace UIFixes
// The patched method here is called when iterating over all slots to highlight ones that the dragged item can interact with
// Since swap has no special highlight, I just skip the patch here (minor perf savings, plus makes debugging a million times easier)
public class SlotGetHightLightColorPatch : ModulePatch
public class DetectSlotHighlightPrecheckPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -467,7 +467,7 @@ namespace UIFixes
// CanApply, when dealing with containers, eventually calls down into FindPlaceForItem, which calls CheckItemFilter. For reasons,
// if an item fails the filters, it returns the error "no space", instead of "no action". Try to detect this, so we can swap.
public class CheckItemFilterPatch : ModulePatch
public class DetectFilterForSwapPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -485,7 +485,7 @@ namespace UIFixes
// When dragging an item around, by default it updates an ItemSpecificationPanel when you drag an item on top of a slot
// It doesn't do anything when you drag an item from a slot onto some other item elsewhere. But with swap, we should update the item panel then too.
public class DraggedItemContextUpdateTargetPatch : ModulePatch
public class InspectWindowUpdateStatsOnSwapPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{

View File

@@ -8,15 +8,15 @@ using UnityEngine.UI;
namespace UIFixes
{
public class ScrollSyncPatches
public class SyncScrollPositionPatches
{
private static float StashScrollPosition = 1f;
public static void Enable()
{
new SimpleStashPanelPatch().Enable();
new TraderDealScreenPatch().Enable();
new AddOfferWindowPatch().Enable();
new SyncStashScrollPatch().Enable();
new SyncTraderStashScrollPatch().Enable();
new SyncOfferStashScrollPatch().Enable();
}
private static void UpdateScrollPosition(Vector2 position)
@@ -35,7 +35,7 @@ namespace UIFixes
scrollRect.onValueChanged.AddListener(UpdateScrollPosition);
}
private class SimpleStashPanelPatch : ModulePatch
private class SyncStashScrollPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -49,7 +49,7 @@ namespace UIFixes
}
}
public class TraderDealScreenPatch : ModulePatch
public class SyncTraderStashScrollPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -68,7 +68,7 @@ namespace UIFixes
}
}
public class AddOfferWindowPatch : ModulePatch
public class SyncOfferStashScrollPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{

View File

@@ -10,18 +10,18 @@ namespace UIFixes
{
// Two patches are required for the edit preset screen - one to grab the value of moveForward from CloseScreenInterruption(), and one to use it.
// This is because BSG didn't think to pass the argument in to method_35
public class EditBuildScreenPatch
public class WeaponPresetConfirmPatches
{
public static bool MoveForward;
public static void Enable()
{
new CloseScreenInterruptionPatch().Enable();
new ConfirmDiscardPatch().Enable();
new DetectWeaponPresetCloseTypePatch().Enable();
new ConfirmDiscardWeaponPresetChangesPatch().Enable();
}
// This patch just caches whether this navigation is a forward navigation, which determines if the preset is actually closing
public class CloseScreenInterruptionPatch : ModulePatch
public class DetectWeaponPresetCloseTypePatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -36,7 +36,7 @@ namespace UIFixes
}
}
public class ConfirmDiscardPatch : ModulePatch
public class ConfirmDiscardWeaponPresetChangesPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{

View File

@@ -9,7 +9,7 @@ using UnityEngine.EventSystems;
namespace UIFixes
{
public class WeaponZoomPatch
public class WeaponZoomPatches
{
public static void Enable()
{

View File

@@ -9,21 +9,22 @@ namespace UIFixes
{
Settings.Init(Config);
EditBuildScreenPatch.Enable();
new TransferConfirmPatch().Enable();
new MailReceiveAllPatch().Enable();
new ConfirmationDialogKeysPatch().Enable();
new FixMailRecieveAllPatch().Enable();
new FixTooltipPatch().Enable();
new FixWeaponBindsDisplayPatch().Enable();
new FocusFleaOfferNumberPatch().Enable();
HideoutSearchPatches.Enable();
InspectWindowResizePatches.Enable();
InspectWindowStatsPatches.Enable();
new RemoveDoorActionsPatch().Enable();
ScrollPatches.Enable();
WeaponZoomPatch.Enable();
new WeaponBindingPatch().Enable();
new DisabledActionsPatch().Enable();
SwapPatch.Enable();
new TooltipPatch().Enable();
ItemPanelPatches.Enable();
new ContainerStackPatch().Enable();
DialogPatches.Enable();
ItemPanelResizePatches.Enable();
ProductionPanelPatches.Enable();
ScrollSyncPatches.Enable();
new StackFirItemsPatch().Enable();
SwapPatches.Enable();
SyncScrollPositionPatches.Enable();
new TransferConfirmPatch().Enable();
WeaponPresetConfirmPatches.Enable();
WeaponZoomPatches.Enable();
}
}
}

View File

@@ -31,7 +31,7 @@ namespace UIFixes.Test
foreach (var testCase in testCases)
{
string result = ItemPanelPatches.RemoveTrailingZeros(testCase.Key);
string result = InspectWindowStatsPatches.RemoveTrailingZeros(testCase.Key);
Assert.AreEqual(testCase.Value, result);
}
}