feat: added support to get item durability
This commit is contained in:
34
Plugin/Patches/BarterItemPatch.cs
Normal file
34
Plugin/Patches/BarterItemPatch.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using EFT.UI;
|
||||
using EFT.UI.DragAndDrop;
|
||||
using LootValueEX.Extensions;
|
||||
using SPT.Reflection.Patching;
|
||||
using SPT.Reflection.Utils;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LootValueEX.Patches
|
||||
{
|
||||
/// <summary>
|
||||
/// This patch will affect the following screens: Stash, Weapon Preset Builder, Character Gear, Character Preset Selector, New Ragfair Offer, Message Items, Loot
|
||||
/// </summary>
|
||||
internal class BarterItemPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() => typeof(TradingRequisitePanel).GetMethod("method_1", BindingFlags.Instance | BindingFlags.Public);
|
||||
internal static bool PatchTooltip { get; private set; } = false;
|
||||
internal static EFT.InventoryLogic.Item? HoveredItem { get; private set; }
|
||||
|
||||
[PatchPrefix]
|
||||
static void EnableTooltipPatch(GClass2064 ___gclass2064_0)
|
||||
{
|
||||
//This does not check if the item has been examined since the game also show what the item is on the barter regardless
|
||||
PatchTooltip = true;
|
||||
HoveredItem = ___gclass2064_0.RequiredItem;
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
static void DisableTooltipPatch()
|
||||
{
|
||||
PatchTooltip = false;
|
||||
HoveredItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Plugin/Patches/GridItemTooltipPatch.cs
Normal file
35
Plugin/Patches/GridItemTooltipPatch.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using EFT.InventoryLogic;
|
||||
using EFT.UI.DragAndDrop;
|
||||
using LootValueEX.Extensions;
|
||||
using SPT.Reflection.Patching;
|
||||
using SPT.Reflection.Utils;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LootValueEX.Patches
|
||||
{
|
||||
/// <summary>
|
||||
/// This patch will affect the following screens: Stash, Weapon Preset Builder, Character Gear, Character Preset Selector, New Ragfair Offer, Message Items, Loot
|
||||
/// </summary>
|
||||
internal class GridItemTooltipPatch : ModulePatch
|
||||
{
|
||||
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; }
|
||||
|
||||
[PatchPrefix]
|
||||
static void EnableTooltipPatch(GridItemView __instance)
|
||||
{
|
||||
if (!__instance.Item.IsExamined())
|
||||
return;
|
||||
PatchTooltip = true;
|
||||
HoveredItem = __instance.Item;
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
static void DisableTooltipPatch()
|
||||
{
|
||||
PatchTooltip = false;
|
||||
HoveredItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Plugin/Patches/HandbookPatching.cs
Normal file
34
Plugin/Patches/HandbookPatching.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using LootValueEX.Extensions;
|
||||
using SPT.Reflection.Patching;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LootValueEX.Patches
|
||||
{
|
||||
internal class HandbookPatching : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() => typeof(EFT.HandBook.EntityIcon).GetMethod("method_1", BindingFlags.Public | BindingFlags.Instance);
|
||||
internal static bool PatchTooltip { get; private set; } = false;
|
||||
internal static EFT.InventoryLogic.Item? HoveredItem { get; private set; }
|
||||
|
||||
[PatchPrefix]
|
||||
internal static void EnableTooltipPatch(ref EFT.InventoryLogic.Item ___item_0)
|
||||
{
|
||||
if (!___item_0.IsExamined())
|
||||
return;
|
||||
|
||||
PatchTooltip = true;
|
||||
HoveredItem = ___item_0;
|
||||
}
|
||||
[PatchPostfix]
|
||||
internal static void DisableTooltipPatch()
|
||||
{
|
||||
PatchTooltip = false;
|
||||
HoveredItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Plugin/Patches/InsuranceGridPatch.cs
Normal file
28
Plugin/Patches/InsuranceGridPatch.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using LootValueEX.Extensions;
|
||||
using SPT.Reflection.Patching;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LootValueEX.Patches
|
||||
{
|
||||
class InsuranceGridPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() => typeof(EFT.UI.Insurance.InsuranceItemView).GetMethod("OnPointerEnter", BindingFlags.Public | BindingFlags.Instance);
|
||||
internal static bool PatchTooltip { get; private set; } = false;
|
||||
internal static EFT.InventoryLogic.Item? HoveredItem { get; private set; }
|
||||
|
||||
[PatchPrefix]
|
||||
internal static void EnableTooltipPatch(ref EFT.InventoryLogic.Item ___item_0)
|
||||
{
|
||||
if (!___item_0.IsExamined())
|
||||
return;
|
||||
PatchTooltip = true;
|
||||
HoveredItem = ___item_0;
|
||||
}
|
||||
[PatchPostfix]
|
||||
internal static void DisableTooltipPatch()
|
||||
{
|
||||
PatchTooltip = false;
|
||||
HoveredItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Plugin/Patches/InsuranceSlotPatch.cs
Normal file
29
Plugin/Patches/InsuranceSlotPatch.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using LootValueEX.Extensions;
|
||||
using SPT.Reflection.Patching;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LootValueEX.Patches
|
||||
{
|
||||
class InsuranceSlotPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() => typeof(EFT.UI.Insurance.InsuranceSlotItemView).GetMethod("OnPointerEnter", BindingFlags.Public | BindingFlags.Instance);
|
||||
internal static bool PatchTooltip { get; private set; } = false;
|
||||
internal static EFT.InventoryLogic.Item? HoveredItem { get; private set; }
|
||||
|
||||
[PatchPrefix]
|
||||
internal static void EnableTooltipPatch(EFT.UI.Insurance.InsuranceSlotItemView __instance)
|
||||
{
|
||||
if (!__instance.Item.IsExamined())
|
||||
return;
|
||||
PatchTooltip = true;
|
||||
HoveredItem = __instance.Item;
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
internal static void DisableTooltipPatch()
|
||||
{
|
||||
PatchTooltip = false;
|
||||
HoveredItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Plugin/Patches/ItemPricePatch.cs
Normal file
30
Plugin/Patches/ItemPricePatch.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using SPT.Reflection.Patching;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LootValueEX.Patches
|
||||
{
|
||||
internal class ItemPricePatch : ModulePatch
|
||||
{
|
||||
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)],
|
||||
null);
|
||||
internal static bool PatchTooltip { get; private set; } = false;
|
||||
|
||||
[PatchPrefix]
|
||||
internal static void EnableTooltipPatch()
|
||||
{
|
||||
if (TradingItemPatch.HoveredItem == null)
|
||||
return;
|
||||
|
||||
PatchTooltip = true;
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
internal static void DisableTooltipPatch()
|
||||
{
|
||||
PatchTooltip = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Plugin/Patches/TooltipPatch.cs
Normal file
52
Plugin/Patches/TooltipPatch.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using EFT.UI;
|
||||
using LootValueEX.Extensions;
|
||||
using SPT.Reflection.Patching;
|
||||
using SPT.Reflection.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LootValueEX.Patches
|
||||
{
|
||||
internal class TooltipPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() => typeof(SimpleTooltip).GetMethods(BindingFlags.Instance | BindingFlags.Public).Where(x => x.Name == "Show").ToList()[0];
|
||||
|
||||
[PatchPostfix]
|
||||
public static void AlterText(SimpleTooltip __instance, string text)
|
||||
{
|
||||
StackTrace stackTrace = new StackTrace();
|
||||
Plugin.Log.LogDebug("Stacktrace of tooltip call: \n" + stackTrace.ToString());
|
||||
if (GridItemTooltipPatch.PatchTooltip)
|
||||
{
|
||||
text += $"<br>TemplateID: {GridItemTooltipPatch.HoveredItem?.TemplateId}<br>Item hashsum: {GridItemTooltipPatch.HoveredItem?.GetHashSum()}<br>Item durability: {GridItemTooltipPatch.HoveredItem?.GetDurability()}<br><color=#ff0fff><b>GridItemView</b></color>";
|
||||
Plugin.Log.LogDebug(GridItemTooltipPatch.HoveredItem?.AttributesToString());
|
||||
}
|
||||
if (InsuranceSlotPatch.PatchTooltip)
|
||||
{
|
||||
text += $"<br>TemplateID: {InsuranceSlotPatch.HoveredItem?.TemplateId}<br><color=#00ffff><b>InsuranceSlotItemView</b></color>";
|
||||
}
|
||||
if (ItemPricePatch.PatchTooltip)
|
||||
{
|
||||
text += $"<br>TemplateID: {TradingItemPatch.HoveredItem?.TemplateId}<br><color=#00ff00><b>PriceTooltip</b></color>";
|
||||
}
|
||||
if (HandbookPatching.PatchTooltip)
|
||||
{
|
||||
text += $"<br>TemplateID: {HandbookPatching.HoveredItem?.TemplateId}<br><color=#0000ff><b>EntityIcon</b></color>";
|
||||
}
|
||||
if (InsuranceGridPatch.PatchTooltip)
|
||||
{
|
||||
text += $"<br>TemplateID: {InsuranceGridPatch.HoveredItem?.TemplateId}<br><color=#21f788><b>InsuranceItemView</b></color>";
|
||||
}
|
||||
if (BarterItemPatch.PatchTooltip)
|
||||
{
|
||||
text += $"<br>TemplateID: {BarterItemPatch.HoveredItem?.TemplateId}<br><color=#ff6521><b>TradingRequisitePanel</b></color>";
|
||||
}
|
||||
__instance.SetText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Plugin/Patches/TradingItemPatch.cs
Normal file
26
Plugin/Patches/TradingItemPatch.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using LootValueEX.Extensions;
|
||||
using SPT.Reflection.Patching;
|
||||
using SPT.Reflection.Utils;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LootValueEX.Patches
|
||||
{
|
||||
class TradingItemPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() => typeof(EFT.UI.DragAndDrop.TradingItemView).GetMethod("ShowTooltip", BindingFlags.Instance | BindingFlags.Public);
|
||||
internal static EFT.InventoryLogic.Item? HoveredItem { get; private set; }
|
||||
|
||||
[PatchPrefix]
|
||||
internal static void GetHoveredItem(EFT.UI.DragAndDrop.TradingItemView __instance)
|
||||
{
|
||||
if (!__instance.Item.IsExamined())
|
||||
return;
|
||||
HoveredItem = __instance.Item;
|
||||
}
|
||||
[PatchPostfix]
|
||||
internal static void RemoveHoveredItem()
|
||||
{
|
||||
HoveredItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user