Add offer price hightlight; static patches classes
This commit is contained in:
@@ -1,13 +1,24 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
using EFT.UI.Ragfair;
|
using EFT.UI.Ragfair;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
public class AddOfferClickablePricesPatches : ModulePatch
|
public static class AddOfferClickablePricesPatches
|
||||||
|
{
|
||||||
|
public static void Enable()
|
||||||
|
{
|
||||||
|
new AddButtonPatch().Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AddButtonPatch : ModulePatch
|
||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
@@ -21,17 +32,57 @@ namespace UIFixes
|
|||||||
|
|
||||||
var rublesRequirement = ____requirementViews.First(rv => rv.name == "Requirement (RUB)");
|
var rublesRequirement = ____requirementViews.First(rv => rv.name == "Requirement (RUB)");
|
||||||
|
|
||||||
Button lowestButton = panel.LowestLabel.GetOrAddComponent<Button>();
|
Button lowestButton = panel.LowestLabel.GetOrAddComponent<HighlightButton>();
|
||||||
lowestButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Minimum.ToString()));
|
lowestButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Minimum.ToString()));
|
||||||
____pricesPanel.AddDisposable(lowestButton.onClick.RemoveAllListeners);
|
____pricesPanel.AddDisposable(lowestButton.onClick.RemoveAllListeners);
|
||||||
|
|
||||||
Button averageButton = panel.AverageLabel.GetOrAddComponent<Button>();
|
Button averageButton = panel.AverageLabel.GetOrAddComponent<HighlightButton>();
|
||||||
averageButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Average.ToString()));
|
averageButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Average.ToString()));
|
||||||
____pricesPanel.AddDisposable(averageButton.onClick.RemoveAllListeners);
|
____pricesPanel.AddDisposable(averageButton.onClick.RemoveAllListeners);
|
||||||
|
|
||||||
Button maximumButton = panel.MaximumLabel.GetOrAddComponent<Button>();
|
Button maximumButton = panel.MaximumLabel.GetOrAddComponent<HighlightButton>();
|
||||||
maximumButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Maximum.ToString()));
|
maximumButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Maximum.ToString()));
|
||||||
____pricesPanel.AddDisposable(maximumButton.onClick.RemoveAllListeners);
|
____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
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
public class FixFleaPatches
|
public static class FixFleaPatches
|
||||||
{
|
{
|
||||||
public static void Enable()
|
public static void Enable()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using UnityEngine.UI;
|
|||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
public class HideoutSearchPatches
|
public static class HideoutSearchPatches
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, string> LastSearches = [];
|
private static readonly Dictionary<string, string> LastSearches = [];
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using UnityEngine.UI;
|
|||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
internal class InspectWindowResizePatches
|
internal static class InspectWindowResizePatches
|
||||||
{
|
{
|
||||||
private static float SavedPreferredWidth = -1f;
|
private static float SavedPreferredWidth = -1f;
|
||||||
private static float SavedPreferredHeight = -1f;
|
private static float SavedPreferredHeight = -1f;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
public class InspectWindowStatsPatches
|
public static class InspectWindowStatsPatches
|
||||||
{
|
{
|
||||||
public static void Enable()
|
public static void Enable()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using UnityEngine.UI;
|
|||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
public class ScrollPatches
|
public static class ScrollPatches
|
||||||
{
|
{
|
||||||
public static void Enable()
|
public static void Enable()
|
||||||
{
|
{
|
||||||
@@ -24,7 +24,7 @@ namespace UIFixes
|
|||||||
new MouseScrollingSpeedPatch().Enable();
|
new MouseScrollingSpeedPatch().Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void HandleInput(ScrollRect scrollRect)
|
private static void HandleInput(ScrollRect scrollRect)
|
||||||
{
|
{
|
||||||
if (scrollRect != null)
|
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
|
// 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)
|
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)
|
foreach (var instruction in instructions)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ using UnityEngine.EventSystems;
|
|||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
public class SwapPatches
|
public static class SwapPatches
|
||||||
{
|
{
|
||||||
// Source container for the drag - we have to grab this early to check it
|
// Source container for the drag - we have to grab this early to check it
|
||||||
private static IContainer SourceContainer;
|
private static IContainer SourceContainer;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using UnityEngine.UI;
|
|||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
public class SyncScrollPositionPatches
|
public static class SyncScrollPositionPatches
|
||||||
{
|
{
|
||||||
private static float StashScrollPosition = 1f;
|
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.
|
// 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
|
// 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;
|
public static bool MoveForward;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using UnityEngine.EventSystems;
|
|||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
public class WeaponZoomPatches
|
public static class WeaponZoomPatches
|
||||||
{
|
{
|
||||||
public static void Enable()
|
public static void Enable()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace UIFixes
|
|||||||
FixFleaPatches.Enable();
|
FixFleaPatches.Enable();
|
||||||
FleaPrevSearchPatches.Enable();
|
FleaPrevSearchPatches.Enable();
|
||||||
KeepOfferWindowOpenPatches.Enable();
|
KeepOfferWindowOpenPatches.Enable();
|
||||||
new AddOfferClickablePricesPatches().Enable();
|
AddOfferClickablePricesPatches.Enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user