Move patches around
This commit is contained in:
120
Patches/FixFleaPatches.cs
Normal file
120
Patches/FixFleaPatches.cs
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
using Aki.Reflection.Patching;
|
||||||
|
using EFT.Quests;
|
||||||
|
using EFT.UI;
|
||||||
|
using EFT.UI.Ragfair;
|
||||||
|
using HarmonyLib;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace UIFixes
|
||||||
|
{
|
||||||
|
public class FixFleaPatches
|
||||||
|
{
|
||||||
|
public static void Enable()
|
||||||
|
{
|
||||||
|
// These two are anal AF
|
||||||
|
new DoNotToggleOnMouseOverPatch().Enable();
|
||||||
|
new ToggleOnOpenPatch().Enable();
|
||||||
|
|
||||||
|
new OfferItemFixMaskPatch().Enable();
|
||||||
|
new OfferViewLockedQuestPatch().Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DoNotToggleOnMouseOverPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(CategoryView), nameof(CategoryView.PointerEnterHandler));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void Postfix(Image ____toggleImage, Sprite ____closeSprite, bool ___bool_3)
|
||||||
|
{
|
||||||
|
if (!___bool_3)
|
||||||
|
{
|
||||||
|
____toggleImage.sprite = ____closeSprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ToggleOnOpenPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(CategoryView), nameof(CategoryView.OpenCategory));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void Postfix(Image ____toggleImage, Sprite ____openSprite, bool ___bool_3)
|
||||||
|
{
|
||||||
|
if (___bool_3)
|
||||||
|
{
|
||||||
|
____toggleImage.sprite = ____openSprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OfferItemFixMaskPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(OfferItemDescription), nameof(OfferItemDescription.Show));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void Postfix(TextMeshProUGUI ____offerItemName)
|
||||||
|
{
|
||||||
|
____offerItemName.maskable = true;
|
||||||
|
foreach (var item in ____offerItemName.GetComponentsInChildren<TMP_SubMeshUI>())
|
||||||
|
{
|
||||||
|
item.maskable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OfferViewLockedQuestPatch : ModulePatch
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<string, RawQuestClass> QuestUnlocks = [];
|
||||||
|
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(OfferView), nameof(OfferView.method_10));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void Postfix(OfferView __instance, HoverTooltipArea ____hoverTooltipArea)
|
||||||
|
{
|
||||||
|
if (!Settings.ShowRequiredQuest.Value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string templateId = __instance.Offer_0.Item.TemplateId;
|
||||||
|
if (__instance.Offer_0.Locked)
|
||||||
|
{
|
||||||
|
RawQuestClass quest = null;
|
||||||
|
if (QuestUnlocks.ContainsKey(templateId))
|
||||||
|
{
|
||||||
|
quest = QuestUnlocks[templateId];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
quest = R.QuestCache.Instance.GetAllQuestTemplates()
|
||||||
|
.FirstOrDefault(q => q.Rewards[EQuestStatus.Success]
|
||||||
|
.Any(r => r.type == ERewardType.AssortmentUnlock && r.items.Any(i => i._tpl == templateId)));
|
||||||
|
QuestUnlocks[templateId] = quest;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quest != null)
|
||||||
|
{
|
||||||
|
____hoverTooltipArea.SetMessageText(____hoverTooltipArea.String_1 + " (" + quest.Name + ")", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
using Aki.Reflection.Patching;
|
|
||||||
using EFT.UI.Ragfair;
|
|
||||||
using HarmonyLib;
|
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace UIFixes
|
|
||||||
{
|
|
||||||
// This fix is anal AF
|
|
||||||
public class FixTogglesPatches
|
|
||||||
{
|
|
||||||
public static void Enable()
|
|
||||||
{
|
|
||||||
new DoNotToggleOnMouseOverPatch().Enable();
|
|
||||||
new ToggleOnOpenPatch().Enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DoNotToggleOnMouseOverPatch : ModulePatch
|
|
||||||
{
|
|
||||||
protected override MethodBase GetTargetMethod()
|
|
||||||
{
|
|
||||||
return AccessTools.Method(typeof(CategoryView), nameof(CategoryView.PointerEnterHandler));
|
|
||||||
}
|
|
||||||
|
|
||||||
[PatchPostfix]
|
|
||||||
public static void Postfix(Image ____toggleImage, Sprite ____closeSprite, bool ___bool_3)
|
|
||||||
{
|
|
||||||
if (!___bool_3)
|
|
||||||
{
|
|
||||||
____toggleImage.sprite = ____closeSprite;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ToggleOnOpenPatch : ModulePatch
|
|
||||||
{
|
|
||||||
protected override MethodBase GetTargetMethod()
|
|
||||||
{
|
|
||||||
return AccessTools.Method(typeof(CategoryView), nameof(CategoryView.OpenCategory));
|
|
||||||
}
|
|
||||||
|
|
||||||
[PatchPostfix]
|
|
||||||
public static void Postfix(Image ____toggleImage, Sprite ____openSprite, bool ___bool_3)
|
|
||||||
{
|
|
||||||
if (___bool_3)
|
|
||||||
{
|
|
||||||
____toggleImage.sprite = ____openSprite;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
using EFT.Quests;
|
|
||||||
using EFT.UI;
|
using EFT.UI;
|
||||||
using EFT.UI.Ragfair;
|
using EFT.UI.Ragfair;
|
||||||
using EFT.UI.Utilities.LightScroller;
|
using EFT.UI.Utilities.LightScroller;
|
||||||
@@ -9,7 +8,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using TMPro;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@@ -38,8 +36,6 @@ namespace UIFixes
|
|||||||
new OfferViewListCategoryPickedPatch().Enable();
|
new OfferViewListCategoryPickedPatch().Enable();
|
||||||
new OfferViewListDoneLoadingPatch().Enable();
|
new OfferViewListDoneLoadingPatch().Enable();
|
||||||
new ChangedViewListType().Enable();
|
new ChangedViewListType().Enable();
|
||||||
new OfferItemFixMaskPatch().Enable();
|
|
||||||
new OfferViewLockedQuestPatch().Enable();
|
|
||||||
|
|
||||||
Settings.EnableFleaHistory.SettingChanged += (object sender, EventArgs args) =>
|
Settings.EnableFleaHistory.SettingChanged += (object sender, EventArgs args) =>
|
||||||
{
|
{
|
||||||
@@ -319,65 +315,6 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OfferViewLockedQuestPatch : ModulePatch
|
|
||||||
{
|
|
||||||
private static readonly Dictionary<string, RawQuestClass> QuestUnlocks = [];
|
|
||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
|
||||||
{
|
|
||||||
return AccessTools.Method(typeof(OfferView), nameof(OfferView.method_10));
|
|
||||||
}
|
|
||||||
|
|
||||||
[PatchPostfix]
|
|
||||||
public static void Postfix(OfferView __instance, HoverTooltipArea ____hoverTooltipArea)
|
|
||||||
{
|
|
||||||
if (!Settings.ShowRequiredQuest.Value)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string templateId = __instance.Offer_0.Item.TemplateId;
|
|
||||||
if (__instance.Offer_0.Locked)
|
|
||||||
{
|
|
||||||
RawQuestClass quest = null;
|
|
||||||
if (QuestUnlocks.ContainsKey(templateId))
|
|
||||||
{
|
|
||||||
quest = QuestUnlocks[templateId];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
quest = R.QuestCache.Instance.GetAllQuestTemplates()
|
|
||||||
.FirstOrDefault(q => q.Rewards[EQuestStatus.Success]
|
|
||||||
.Any(r => r.type == ERewardType.AssortmentUnlock && r.items.Any(i => i._tpl == templateId)));
|
|
||||||
QuestUnlocks[templateId] = quest;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (quest != null)
|
|
||||||
{
|
|
||||||
____hoverTooltipArea.SetMessageText(____hoverTooltipArea.String_1 + " (" + quest.Name + ")", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class OfferItemFixMaskPatch : ModulePatch
|
|
||||||
{
|
|
||||||
protected override MethodBase GetTargetMethod()
|
|
||||||
{
|
|
||||||
return AccessTools.Method(typeof(OfferItemDescription), nameof(OfferItemDescription.Show));
|
|
||||||
}
|
|
||||||
|
|
||||||
[PatchPostfix]
|
|
||||||
public static void Postfix(TextMeshProUGUI ____offerItemName)
|
|
||||||
{
|
|
||||||
____offerItemName.maskable = true;
|
|
||||||
foreach (var item in ____offerItemName.GetComponentsInChildren<TMP_SubMeshUI>())
|
|
||||||
{
|
|
||||||
item.maskable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commented out properties just affect the view, so consider the two filters to be a single history entry
|
// Commented out properties just affect the view, so consider the two filters to be a single history entry
|
||||||
public static bool IsSimilarTo(this FilterRule one, FilterRule two)
|
public static bool IsSimilarTo(this FilterRule one, FilterRule two)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace UIFixes
|
|||||||
WeaponPresetConfirmPatches.Enable();
|
WeaponPresetConfirmPatches.Enable();
|
||||||
WeaponZoomPatches.Enable();
|
WeaponZoomPatches.Enable();
|
||||||
new MoveTaskbarPatch().Enable();
|
new MoveTaskbarPatch().Enable();
|
||||||
FixTogglesPatches.Enable();
|
FixFleaPatches.Enable();
|
||||||
FleaPrevSearchPatches.Enable();
|
FleaPrevSearchPatches.Enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user