From fa0821686bae5672c02fa05fd417e3bf19eed6d5 Mon Sep 17 00:00:00 2001 From: Yui Date: Mon, 4 Nov 2024 01:37:34 -0300 Subject: [PATCH] feat: added inventory patch, in-raid and stash --- .../Patches/Screens/InventoryScreenPatch.cs | 23 +++++++++++++++++++ .../Patches/{ => Tooltips}/BarterItemPatch.cs | 2 +- .../{ => Tooltips}/GridItemTooltipPatch.cs | 4 ++-- .../{ => Tooltips}/HandbookPatching.cs | 2 +- .../{ => Tooltips}/InsuranceGridPatch.cs | 2 +- .../{ => Tooltips}/InsuranceSlotPatch.cs | 2 +- .../Patches/{ => Tooltips}/ItemPricePatch.cs | 4 ++-- Plugin/Patches/{ => Tooltips}/TooltipPatch.cs | 2 +- .../{ => Tooltips}/TradingItemPatch.cs | 2 +- Plugin/Plugin.cs | 18 ++++++++------- 10 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 Plugin/Patches/Screens/InventoryScreenPatch.cs rename Plugin/Patches/{ => Tooltips}/BarterItemPatch.cs (96%) rename Plugin/Patches/{ => Tooltips}/GridItemTooltipPatch.cs (90%) rename Plugin/Patches/{ => Tooltips}/HandbookPatching.cs (96%) rename Plugin/Patches/{ => Tooltips}/InsuranceGridPatch.cs (95%) rename Plugin/Patches/{ => Tooltips}/InsuranceSlotPatch.cs (95%) rename Plugin/Patches/{ => Tooltips}/ItemPricePatch.cs (90%) rename Plugin/Patches/{ => Tooltips}/TooltipPatch.cs (98%) rename Plugin/Patches/{ => Tooltips}/TradingItemPatch.cs (95%) diff --git a/Plugin/Patches/Screens/InventoryScreenPatch.cs b/Plugin/Patches/Screens/InventoryScreenPatch.cs new file mode 100644 index 0000000..03baf33 --- /dev/null +++ b/Plugin/Patches/Screens/InventoryScreenPatch.cs @@ -0,0 +1,23 @@ +using System.Reflection; +using EFT; +using EFT.HealthSystem; +using EFT.UI; +using LootValueEX.Extensions; +using SPT.Reflection.Patching; + +namespace LootValueEX.Patches.Screens +{ + internal class InventoryScreenPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() => typeof(InventoryScreen).GetMethods().SingleOrDefault(method => method.Name == "Show" && method.GetParameters()[0].ParameterType == typeof(IHealthController)); + + [PatchPostfix] + private static void PatchPostfix(ref Profile ___profile_0, ref LootItemClass ___lootItemClass) + { + ___profile_0.Inventory.GetPlayerItems(EFT.InventoryLogic.EPlayerItems.Equipment).ExecuteForEach(item => Plugin.Log.LogDebug($"{item.LocalizedName()} ({item.TemplateId}): {item.GetCustomHash()}")); + + if(___lootItemClass != null) + ___lootItemClass.GetAllItems().ExecuteForEach(item => Plugin.Log.LogDebug($"{item.LocalizedName()} ({item.TemplateId}): {item.GetCustomHash()}")); + } + } +} diff --git a/Plugin/Patches/BarterItemPatch.cs b/Plugin/Patches/Tooltips/BarterItemPatch.cs similarity index 96% rename from Plugin/Patches/BarterItemPatch.cs rename to Plugin/Patches/Tooltips/BarterItemPatch.cs index c6fe83f..ca0b73c 100644 --- a/Plugin/Patches/BarterItemPatch.cs +++ b/Plugin/Patches/Tooltips/BarterItemPatch.cs @@ -5,7 +5,7 @@ using SPT.Reflection.Patching; using SPT.Reflection.Utils; using System.Reflection; -namespace LootValueEX.Patches +namespace LootValueEX.Patches.Tooltips { /// /// This patch will affect the following screens: Stash, Weapon Preset Builder, Character Gear, Character Preset Selector, New Ragfair Offer, Message Items, Loot diff --git a/Plugin/Patches/GridItemTooltipPatch.cs b/Plugin/Patches/Tooltips/GridItemTooltipPatch.cs similarity index 90% rename from Plugin/Patches/GridItemTooltipPatch.cs rename to Plugin/Patches/Tooltips/GridItemTooltipPatch.cs index 57815e3..2f61869 100644 --- a/Plugin/Patches/GridItemTooltipPatch.cs +++ b/Plugin/Patches/Tooltips/GridItemTooltipPatch.cs @@ -5,7 +5,7 @@ using SPT.Reflection.Patching; using SPT.Reflection.Utils; using System.Reflection; -namespace LootValueEX.Patches +namespace LootValueEX.Patches.Tooltips { /// /// This patch will affect the following screens: Stash, Weapon Preset Builder, Character Gear, Character Preset Selector, New Ragfair Offer, Message Items, Loot @@ -14,7 +14,7 @@ namespace LootValueEX.Patches { protected override MethodBase GetTargetMethod() => typeof(GridItemView).GetMethod("ShowTooltip", BindingFlags.Instance | BindingFlags.Public); internal static bool PatchTooltip { get; private set; } = false; - internal static EFT.InventoryLogic.Item? HoveredItem { get; private set; } + internal static Item? HoveredItem { get; private set; } [PatchPrefix] static void EnableTooltipPatch(GridItemView __instance) diff --git a/Plugin/Patches/HandbookPatching.cs b/Plugin/Patches/Tooltips/HandbookPatching.cs similarity index 96% rename from Plugin/Patches/HandbookPatching.cs rename to Plugin/Patches/Tooltips/HandbookPatching.cs index 3c434c0..3e4976e 100644 --- a/Plugin/Patches/HandbookPatching.cs +++ b/Plugin/Patches/Tooltips/HandbookPatching.cs @@ -7,7 +7,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; -namespace LootValueEX.Patches +namespace LootValueEX.Patches.Tooltips { internal class HandbookPatching : ModulePatch { diff --git a/Plugin/Patches/InsuranceGridPatch.cs b/Plugin/Patches/Tooltips/InsuranceGridPatch.cs similarity index 95% rename from Plugin/Patches/InsuranceGridPatch.cs rename to Plugin/Patches/Tooltips/InsuranceGridPatch.cs index f6f1dd4..ddf56b5 100644 --- a/Plugin/Patches/InsuranceGridPatch.cs +++ b/Plugin/Patches/Tooltips/InsuranceGridPatch.cs @@ -2,7 +2,7 @@ using SPT.Reflection.Patching; using System.Reflection; -namespace LootValueEX.Patches +namespace LootValueEX.Patches.Tooltips { class InsuranceGridPatch : ModulePatch { diff --git a/Plugin/Patches/InsuranceSlotPatch.cs b/Plugin/Patches/Tooltips/InsuranceSlotPatch.cs similarity index 95% rename from Plugin/Patches/InsuranceSlotPatch.cs rename to Plugin/Patches/Tooltips/InsuranceSlotPatch.cs index 074ef82..edf9139 100644 --- a/Plugin/Patches/InsuranceSlotPatch.cs +++ b/Plugin/Patches/Tooltips/InsuranceSlotPatch.cs @@ -2,7 +2,7 @@ using SPT.Reflection.Patching; using System.Reflection; -namespace LootValueEX.Patches +namespace LootValueEX.Patches.Tooltips { class InsuranceSlotPatch : ModulePatch { diff --git a/Plugin/Patches/ItemPricePatch.cs b/Plugin/Patches/Tooltips/ItemPricePatch.cs similarity index 90% rename from Plugin/Patches/ItemPricePatch.cs rename to Plugin/Patches/Tooltips/ItemPricePatch.cs index 729e47d..13cf7c7 100644 --- a/Plugin/Patches/ItemPricePatch.cs +++ b/Plugin/Patches/Tooltips/ItemPricePatch.cs @@ -1,11 +1,11 @@ using SPT.Reflection.Patching; using System.Reflection; -namespace LootValueEX.Patches +namespace LootValueEX.Patches.Tooltips { internal class ItemPricePatch : ModulePatch { - protected override MethodBase GetTargetMethod() => typeof(EFT.UI.PriceTooltip).GetMethod("Show", + protected override MethodBase GetTargetMethod() => typeof(EFT.UI.PriceTooltip).GetMethod("Show", BindingFlags.Instance | BindingFlags.Public, null, [typeof(EFT.InventoryLogic.EOwnerType), typeof(string), typeof(int), typeof(string)], diff --git a/Plugin/Patches/TooltipPatch.cs b/Plugin/Patches/Tooltips/TooltipPatch.cs similarity index 98% rename from Plugin/Patches/TooltipPatch.cs rename to Plugin/Patches/Tooltips/TooltipPatch.cs index f694949..66e5968 100644 --- a/Plugin/Patches/TooltipPatch.cs +++ b/Plugin/Patches/Tooltips/TooltipPatch.cs @@ -10,7 +10,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; -namespace LootValueEX.Patches +namespace LootValueEX.Patches.Tooltips { internal class TooltipPatch : ModulePatch { diff --git a/Plugin/Patches/TradingItemPatch.cs b/Plugin/Patches/Tooltips/TradingItemPatch.cs similarity index 95% rename from Plugin/Patches/TradingItemPatch.cs rename to Plugin/Patches/Tooltips/TradingItemPatch.cs index 90f0b5e..baa4326 100644 --- a/Plugin/Patches/TradingItemPatch.cs +++ b/Plugin/Patches/Tooltips/TradingItemPatch.cs @@ -3,7 +3,7 @@ using SPT.Reflection.Patching; using SPT.Reflection.Utils; using System.Reflection; -namespace LootValueEX.Patches +namespace LootValueEX.Patches.Tooltips { class TradingItemPatch : ModulePatch { diff --git a/Plugin/Plugin.cs b/Plugin/Plugin.cs index fdd756e..aaffaeb 100644 --- a/Plugin/Plugin.cs +++ b/Plugin/Plugin.cs @@ -11,14 +11,16 @@ namespace LootValueEX { Log = base.Logger; - new Patches.GridItemTooltipPatch().Enable(); - new Patches.TooltipPatch().Enable(); - new Patches.InsuranceGridPatch().Enable(); - new Patches.InsuranceSlotPatch().Enable(); - new Patches.ItemPricePatch().Enable(); - new Patches.TradingItemPatch().Enable(); - new Patches.HandbookPatching().Enable(); - new Patches.BarterItemPatch().Enable(); + new Patches.Tooltips.GridItemTooltipPatch().Enable(); + new Patches.Tooltips.TooltipPatch().Enable(); + new Patches.Tooltips.InsuranceGridPatch().Enable(); + new Patches.Tooltips.InsuranceSlotPatch().Enable(); + new Patches.Tooltips.ItemPricePatch().Enable(); + new Patches.Tooltips.TradingItemPatch().Enable(); + new Patches.Tooltips.HandbookPatching().Enable(); + new Patches.Tooltips.BarterItemPatch().Enable(); + + new Patches.Screens.InventoryScreenPatch().Enable(); } } }