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:
37
Patches/AddOfferClickablePricesPatches.cs
Normal file
37
Patches/AddOfferClickablePricesPatches.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,8 +342,6 @@ namespace UIFixes
|
||||
const int CategoryHeight = 34;
|
||||
const int SubcategoryHeight = 25;
|
||||
|
||||
var wrappedInstance = __instance.R();
|
||||
|
||||
var activeCategories = __instance.GetComponentsInChildren<CategoryView>();
|
||||
var activeSubcategories = __instance.GetComponentsInChildren<SubcategoryView>();
|
||||
int currentHeight = activeCategories.Length * CategoryHeight + activeSubcategories.Length * SubcategoryHeight;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT.InventoryLogic;
|
||||
using EFT.UI.Ragfair;
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
@@ -25,14 +26,28 @@ namespace UIFixes
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
public static void Prefix()
|
||||
public static void Prefix(AddOfferWindow __instance)
|
||||
{
|
||||
BlockClose = Settings.KeepAddOfferOpen.Value;
|
||||
if (Settings.KeepAddOfferOpen.Value)
|
||||
{
|
||||
// Close the window if you're gonna hit max offers
|
||||
var ragfair = __instance.R().Ragfair;
|
||||
if (ragfair.MyOffersCount + 1 < ragfair.GetMaxOffersCount(ragfair.MyRating))
|
||||
{
|
||||
BlockClose = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void Postfix()
|
||||
public static void Postfix(RequirementView[] ____requirementViews)
|
||||
{
|
||||
// clear old prices
|
||||
foreach(var requirementView in ____requirementViews)
|
||||
{
|
||||
requirementView.ResetRequirementInformation();
|
||||
}
|
||||
|
||||
BlockClose = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user