Fix bulk offers market prices multiply by count for bulk offers, v1.6.1
This commit is contained in:
@@ -26,26 +26,36 @@ namespace UIFixes
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void Postfix(ItemMarketPricesPanel ____pricesPanel, RequirementView[] ____requirementViews)
|
||||
public static void Postfix(AddOfferWindow __instance, ItemMarketPricesPanel ____pricesPanel, RequirementView[] ____requirementViews)
|
||||
{
|
||||
var panel = ____pricesPanel.R();
|
||||
|
||||
var rublesRequirement = ____requirementViews.First(rv => rv.name == "Requirement (RUB)");
|
||||
|
||||
Button lowestButton = panel.LowestLabel.GetOrAddComponent<HighlightButton>();
|
||||
lowestButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Minimum.ToString("F0")));
|
||||
lowestButton.onClick.AddListener(() => SetRequirement(__instance, rublesRequirement, ____pricesPanel.Minimum));
|
||||
____pricesPanel.AddDisposable(lowestButton.onClick.RemoveAllListeners);
|
||||
|
||||
Button averageButton = panel.AverageLabel.GetOrAddComponent<HighlightButton>();
|
||||
averageButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Average.ToString("F0")));
|
||||
averageButton.onClick.AddListener(() => SetRequirement(__instance, rublesRequirement, ____pricesPanel.Average));
|
||||
____pricesPanel.AddDisposable(averageButton.onClick.RemoveAllListeners);
|
||||
|
||||
Button maximumButton = panel.MaximumLabel.GetOrAddComponent<HighlightButton>();
|
||||
maximumButton.onClick.AddListener(() => rublesRequirement.method_0(____pricesPanel.Maximum.ToString("F0")));
|
||||
maximumButton.onClick.AddListener(() => SetRequirement(__instance, rublesRequirement, ____pricesPanel.Maximum));
|
||||
____pricesPanel.AddDisposable(maximumButton.onClick.RemoveAllListeners);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetRequirement(AddOfferWindow window, RequirementView requirement, float price)
|
||||
{
|
||||
if (window.R().BulkOffer)
|
||||
{
|
||||
price *= window.Int32_0; // offer item count
|
||||
}
|
||||
|
||||
requirement.method_0(price.ToString("F0"));
|
||||
}
|
||||
|
||||
public class HighlightButton : Button
|
||||
{
|
||||
private Color originalColor;
|
||||
|
@@ -40,13 +40,16 @@ namespace UIFixes
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void Postfix(RequirementView[] ____requirementViews)
|
||||
public static void Postfix(RequirementView[] ____requirementViews, bool ___bool_2)
|
||||
{
|
||||
if (Settings.KeepAddOfferOpen.Value && ___bool_2)
|
||||
{
|
||||
// clear old prices
|
||||
foreach(var requirementView in ____requirementViews)
|
||||
foreach (var requirementView in ____requirementViews)
|
||||
{
|
||||
requirementView.ResetRequirementInformation();
|
||||
}
|
||||
}
|
||||
|
||||
BlockClose = false;
|
||||
}
|
||||
|
3
R.cs
3
R.cs
@@ -442,14 +442,17 @@ namespace UIFixes
|
||||
{
|
||||
public static Type Type { get; private set; }
|
||||
private static FieldInfo RagfairField;
|
||||
private static FieldInfo BulkOfferField;
|
||||
|
||||
public static void InitTypes()
|
||||
{
|
||||
Type = typeof(EFT.UI.Ragfair.AddOfferWindow);
|
||||
RagfairField = AccessTools.GetDeclaredFields(Type).First(t => t.FieldType == typeof(RagFairClass));
|
||||
BulkOfferField = AccessTools.Field(Type, "bool_0");
|
||||
}
|
||||
|
||||
public RagFairClass Ragfair { get { return (RagFairClass)RagfairField.GetValue(Value); } }
|
||||
public bool BulkOffer { get { return (bool)BulkOfferField.GetValue(Value); } }
|
||||
}
|
||||
|
||||
public class ItemUiContext(object value) : Wrapper(value)
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net471</TargetFramework>
|
||||
<AssemblyName>Tyfon.UIFixes</AssemblyName>
|
||||
<Description>SPT UI Fixes</Description>
|
||||
<Version>1.6.1</Version>
|
||||
<Version>1.6.2</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Configurations>Debug;Release;Dist</Configurations>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uifixes",
|
||||
"version": "1.6.1",
|
||||
"version": "1.6.2",
|
||||
"main": "src/mod.js",
|
||||
"license": "MIT",
|
||||
"author": "Tyfon",
|
||||
|
Reference in New Issue
Block a user