eft-lootvalueex/Plugin/Patches/Tooltips/TooltipPatch.cs

51 lines
2.2 KiB
C#
Raw Normal View History

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.Tooltips
{
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)
{
if (GridItemTooltipPatch.PatchTooltip)
{
Structs.TradeOfferStruct tradeOffer = Utils.ItemUtils.GetBestTraderValue(GridItemTooltipPatch.HoveredItem);
text += $"<br>Hash: {GridItemTooltipPatch.HoveredItem?.GetCustomHash()}<br>Trader: {tradeOffer.TraderID}<br>Value: {tradeOffer.Price}<br>Currency: {tradeOffer.CurrencyID}<br>Price in rubles: {tradeOffer.PriceInRouble}<br><color=#ff0fff><b>GridItemView</b></color>";
}
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);
}
}
}