Click market prices in add offer window to set that price; close window at max offers regardless of setting; clear old price

This commit is contained in:
Tyfon
2024-05-25 04:36:36 -07:00
parent 7841c058e7
commit 114df1551a
6 changed files with 95 additions and 6 deletions

View File

@@ -0,0 +1,37 @@
using Aki.Reflection.Patching;
using EFT.UI.Ragfair;
using HarmonyLib;
using System.Linq;
using System.Reflection;
using UnityEngine.UI;
namespace UIFixes
{
public class AddOfferClickablePricesPatches : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.Show));
}
[PatchPostfix]
public static void Postfix(ItemMarketPricesPanel ____pricesPanel, RequirementView[] ____requirementViews)
{
var panel = ____pricesPanel.R();
var rublesRequirement = ____requirementViews.First(rv => rv.name == "Requirement (RUB)");
Button lowestButton = panel.LowestLabel.GetOrAddComponent<Button>();
lowestButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Minimum.ToString()));
____pricesPanel.AddDisposable(lowestButton.onClick.RemoveAllListeners);
Button averageButton = panel.AverageLabel.GetOrAddComponent<Button>();
averageButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Average.ToString()));
____pricesPanel.AddDisposable(averageButton.onClick.RemoveAllListeners);
Button maximumButton = panel.MaximumLabel.GetOrAddComponent<Button>();
maximumButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Maximum.ToString()));
____pricesPanel.AddDisposable(maximumButton.onClick.RemoveAllListeners);
}
}
}