Add offer price hightlight; static patches classes
This commit is contained in:
@@ -1,37 +1,88 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT.UI.Ragfair;
|
||||
using HarmonyLib;
|
||||
using JetBrains.Annotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class AddOfferClickablePricesPatches : ModulePatch
|
||||
public static class AddOfferClickablePricesPatches
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
public static void Enable()
|
||||
{
|
||||
return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.Show));
|
||||
new AddButtonPatch().Enable();
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void Postfix(ItemMarketPricesPanel ____pricesPanel, RequirementView[] ____requirementViews)
|
||||
public class AddButtonPatch : ModulePatch
|
||||
{
|
||||
var panel = ____pricesPanel.R();
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.Show));
|
||||
}
|
||||
|
||||
var rublesRequirement = ____requirementViews.First(rv => rv.name == "Requirement (RUB)");
|
||||
[PatchPostfix]
|
||||
public static void Postfix(ItemMarketPricesPanel ____pricesPanel, RequirementView[] ____requirementViews)
|
||||
{
|
||||
var panel = ____pricesPanel.R();
|
||||
|
||||
Button lowestButton = panel.LowestLabel.GetOrAddComponent<Button>();
|
||||
lowestButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Minimum.ToString()));
|
||||
____pricesPanel.AddDisposable(lowestButton.onClick.RemoveAllListeners);
|
||||
var rublesRequirement = ____requirementViews.First(rv => rv.name == "Requirement (RUB)");
|
||||
|
||||
Button averageButton = panel.AverageLabel.GetOrAddComponent<Button>();
|
||||
averageButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Average.ToString()));
|
||||
____pricesPanel.AddDisposable(averageButton.onClick.RemoveAllListeners);
|
||||
Button lowestButton = panel.LowestLabel.GetOrAddComponent<HighlightButton>();
|
||||
lowestButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Minimum.ToString()));
|
||||
____pricesPanel.AddDisposable(lowestButton.onClick.RemoveAllListeners);
|
||||
|
||||
Button maximumButton = panel.MaximumLabel.GetOrAddComponent<Button>();
|
||||
maximumButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Maximum.ToString()));
|
||||
____pricesPanel.AddDisposable(maximumButton.onClick.RemoveAllListeners);
|
||||
Button averageButton = panel.AverageLabel.GetOrAddComponent<HighlightButton>();
|
||||
averageButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Average.ToString()));
|
||||
____pricesPanel.AddDisposable(averageButton.onClick.RemoveAllListeners);
|
||||
|
||||
Button maximumButton = panel.MaximumLabel.GetOrAddComponent<HighlightButton>();
|
||||
maximumButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Maximum.ToString()));
|
||||
____pricesPanel.AddDisposable(maximumButton.onClick.RemoveAllListeners);
|
||||
}
|
||||
}
|
||||
|
||||
public class HighlightButton : Button
|
||||
{
|
||||
private Color originalColor;
|
||||
bool originalOverrideColorTags;
|
||||
|
||||
private TextMeshProUGUI _text;
|
||||
private TextMeshProUGUI Text
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_text == null)
|
||||
{
|
||||
_text = GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
return _text;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPointerEnter([NotNull] PointerEventData eventData)
|
||||
{
|
||||
base.OnPointerEnter(eventData);
|
||||
|
||||
originalColor = Text.color;
|
||||
originalOverrideColorTags = Text.overrideColorTags;
|
||||
|
||||
Text.overrideColorTags = true;
|
||||
Text.color = Color.white;
|
||||
}
|
||||
|
||||
public override void OnPointerExit([NotNull] PointerEventData eventData)
|
||||
{
|
||||
base.OnPointerExit(eventData);
|
||||
|
||||
Text.overrideColorTags = originalOverrideColorTags;
|
||||
Text.color = originalColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class FixFleaPatches
|
||||
public static class FixFleaPatches
|
||||
{
|
||||
public static void Enable()
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class HideoutSearchPatches
|
||||
public static class HideoutSearchPatches
|
||||
{
|
||||
private static readonly Dictionary<string, string> LastSearches = [];
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
internal class InspectWindowResizePatches
|
||||
internal static class InspectWindowResizePatches
|
||||
{
|
||||
private static float SavedPreferredWidth = -1f;
|
||||
private static float SavedPreferredHeight = -1f;
|
||||
|
||||
@@ -14,7 +14,7 @@ using UnityEngine;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class InspectWindowStatsPatches
|
||||
public static class InspectWindowStatsPatches
|
||||
{
|
||||
public static void Enable()
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class ScrollPatches
|
||||
public static class ScrollPatches
|
||||
{
|
||||
public static void Enable()
|
||||
{
|
||||
@@ -24,7 +24,7 @@ namespace UIFixes
|
||||
new MouseScrollingSpeedPatch().Enable();
|
||||
}
|
||||
|
||||
protected static void HandleInput(ScrollRect scrollRect)
|
||||
private static void HandleInput(ScrollRect scrollRect)
|
||||
{
|
||||
if (scrollRect != null)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace UIFixes
|
||||
}
|
||||
|
||||
// LightScrollers don't expose heights that I can see, so just fudge it with fake OnScroll events
|
||||
protected static void HandleInput(LightScroller lightScroller)
|
||||
private static void HandleInput(LightScroller lightScroller)
|
||||
{
|
||||
if (lightScroller != null)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ namespace UIFixes
|
||||
}
|
||||
}
|
||||
|
||||
protected static IEnumerable<CodeInstruction> RemovePageUpDownHandling(IEnumerable<CodeInstruction> instructions)
|
||||
private static IEnumerable<CodeInstruction> RemovePageUpDownHandling(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
foreach (var instruction in instructions)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ using UnityEngine.EventSystems;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class SwapPatches
|
||||
public static class SwapPatches
|
||||
{
|
||||
// Source container for the drag - we have to grab this early to check it
|
||||
private static IContainer SourceContainer;
|
||||
|
||||
@@ -8,7 +8,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class SyncScrollPositionPatches
|
||||
public static class SyncScrollPositionPatches
|
||||
{
|
||||
private static float StashScrollPosition = 1f;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ 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 WeaponPresetConfirmPatches
|
||||
public static class WeaponPresetConfirmPatches
|
||||
{
|
||||
public static bool MoveForward;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using UnityEngine.EventSystems;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class WeaponZoomPatches
|
||||
public static class WeaponZoomPatches
|
||||
{
|
||||
public static void Enable()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user