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;
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ namespace UIFixes
|
||||
FixFleaPatches.Enable();
|
||||
FleaPrevSearchPatches.Enable();
|
||||
KeepOfferWindowOpenPatches.Enable();
|
||||
new AddOfferClickablePricesPatches().Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
38
R.cs
38
R.cs
@@ -43,6 +43,8 @@ namespace UIFixes
|
||||
FiltersPanel.InitTypes();
|
||||
CategoryView.InitTypes();
|
||||
QuestCache.InitTypes();
|
||||
ItemMarketPricesPanel.InitTypes();
|
||||
AddOfferWindow.InitTypes();
|
||||
}
|
||||
|
||||
public abstract class Wrapper(object value)
|
||||
@@ -412,6 +414,40 @@ namespace UIFixes
|
||||
public static QuestCache Instance { get { return new QuestCache(InstanceProperty.GetValue(null)); } }
|
||||
public IReadOnlyCollection<RawQuestClass> GetAllQuestTemplates() => (IReadOnlyCollection<RawQuestClass>)GetAllQuestTemplatesMethod.Invoke(Value, []);
|
||||
}
|
||||
|
||||
public class ItemMarketPricesPanel(object value) : Wrapper(value)
|
||||
{
|
||||
public static Type Type { get; private set; }
|
||||
private static FieldInfo LowestLabelField;
|
||||
private static FieldInfo AverageLabelField;
|
||||
private static FieldInfo MaximumLabelField;
|
||||
|
||||
public static void InitTypes()
|
||||
{
|
||||
Type = typeof(EFT.UI.Ragfair.ItemMarketPricesPanel);
|
||||
LowestLabelField = AccessTools.Field(Type, "_lowestLabel");
|
||||
AverageLabelField = AccessTools.Field(Type, "_averageLabel");
|
||||
MaximumLabelField = AccessTools.Field(Type, "_maximumLabel");
|
||||
}
|
||||
|
||||
public TextMeshProUGUI LowestLabel { get { return (TextMeshProUGUI)LowestLabelField.GetValue(Value); } }
|
||||
public TextMeshProUGUI AverageLabel { get { return (TextMeshProUGUI)AverageLabelField.GetValue(Value); } }
|
||||
public TextMeshProUGUI MaximumLabel { get { return (TextMeshProUGUI)MaximumLabelField.GetValue(Value); } }
|
||||
}
|
||||
|
||||
public class AddOfferWindow(object value) : Wrapper(value)
|
||||
{
|
||||
public static Type Type { get; private set; }
|
||||
private static FieldInfo RagfairField;
|
||||
|
||||
public static void InitTypes()
|
||||
{
|
||||
Type = typeof(EFT.UI.Ragfair.AddOfferWindow);
|
||||
RagfairField = AccessTools.GetDeclaredFields(Type).First(t => t.FieldType == typeof(RagFairClass));
|
||||
}
|
||||
|
||||
public RagFairClass Ragfair { get { return (RagFairClass)RagfairField.GetValue(Value); } }
|
||||
}
|
||||
}
|
||||
|
||||
public static class RExtentensions
|
||||
@@ -427,5 +463,7 @@ namespace UIFixes
|
||||
public static R.OfferViewList R(this OfferViewList value) => new(value);
|
||||
public static R.CategoryView R(this CategoryView value) => new(value);
|
||||
public static R.FiltersPanel R(this FiltersPanel value) => new(value);
|
||||
public static R.ItemMarketPricesPanel R(this ItemMarketPricesPanel value) => new(value);
|
||||
public static R.AddOfferWindow R(this AddOfferWindow value) => new(value);
|
||||
}
|
||||
}
|
||||
|
@@ -250,7 +250,7 @@ namespace UIFixes
|
||||
"Keep Add Offer Window Open",
|
||||
false,
|
||||
new ConfigDescription(
|
||||
"Don't close the Add Offer window after you place an offer",
|
||||
"Don't close the Add Offer window after you place an offer. Note that the window will still close if you are at max offers.",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
|
Reference in New Issue
Block a user