Fix tooltip object leak; lootvalue sorting table workaround; 1.6.7

This commit is contained in:
Tyfon
2024-06-11 16:25:10 -07:00
parent 7ba0a67929
commit 1163d08c30
8 changed files with 54 additions and 22 deletions

View File

@@ -239,6 +239,8 @@ namespace UIFixes
public static void Postfix() public static void Postfix()
{ {
CurrentInsuranceInteractions = null; CurrentInsuranceInteractions = null;
CurrentRepairInteractions = null;
CreatedButtonInteractionId = null;
} }
} }
} }

View File

@@ -43,23 +43,27 @@ namespace UIFixes
public static void Postfix(GridItemView __instance, TextMeshProUGUI ___ItemValue, PointerEventsProxy ____valuePointerEventsProxy, QuestItemViewPanel ____questsItemViewPanel) public static void Postfix(GridItemView __instance, TextMeshProUGUI ___ItemValue, PointerEventsProxy ____valuePointerEventsProxy, QuestItemViewPanel ____questsItemViewPanel)
{ {
// Add hover events to the correct place // Add hover events to the correct place
HoverTrigger trigger = ___ItemValue.GetOrAddComponent<HoverTrigger>(); HoverTrigger trigger = ___ItemValue.GetComponent<HoverTrigger>();
trigger.OnHoverStart += eventData => __instance.method_31(); if (trigger == null)
trigger.OnHoverEnd += eventData =>
{ {
__instance.method_32(); trigger = ___ItemValue.gameObject.AddComponent<HoverTrigger>();
__instance.ShowTooltip(); trigger.OnHoverStart += eventData => __instance.method_31();
}; trigger.OnHoverEnd += eventData =>
{
__instance.method_32();
__instance.ShowTooltip();
};
// Need a child component for some reason, copying how the quest item tooltip does it // Need a child component for some reason, copying how the quest item tooltip does it
Transform hover = ____questsItemViewPanel?.transform.Find("Hover"); Transform hover = ____questsItemViewPanel?.transform.Find("Hover");
if (hover != null) if (hover != null)
{ {
UnityEngine.Object.Instantiate(hover, trigger.transform, false); UnityEngine.Object.Instantiate(hover, trigger.transform, false);
}
// Remove old hover handler that covered the whole info panel
UnityEngine.Object.Destroy(____valuePointerEventsProxy);
} }
// Remove old hover handler that covered the whole info panel
UnityEngine.Object.Destroy(____valuePointerEventsProxy);
} }
} }
} }

View File

@@ -22,7 +22,7 @@ namespace UIFixes
private const float ButtonPadding = 3f; private const float ButtonPadding = 3f;
public static Image ButtonBackground; // Nice gray background for the new buttons private static Image ButtonBackground; // Nice gray background for the new buttons
public static void Enable() public static void Enable()
{ {

View File

@@ -4,6 +4,7 @@ using EFT.UI;
using HarmonyLib; using HarmonyLib;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine;
namespace UIFixes namespace UIFixes
{ {
@@ -20,7 +21,13 @@ namespace UIFixes
[PatchPrefix] [PatchPrefix]
public static void Prefix(ItemUiContext __instance) public static void Prefix(ItemUiContext __instance)
{ {
if (!AllowedScreens.Contains(__instance.ContextType) || Plugin.InRaid()) if (!Settings.AutoOpenSortingTable.Value || !AllowedScreens.Contains(__instance.ContextType) || Plugin.InRaid())
{
return;
}
// Temporary work-around for LootValue bug - bail out if the ALT key is down
if (Input.GetKey(KeyCode.LeftAlt))
{ {
return; return;
} }

View File

@@ -28,10 +28,6 @@ namespace UIFixes
{ {
if (scrollRect != null) if (scrollRect != null)
{ {
Rect contentRect = scrollRect.content.rect;
Rect viewRect = scrollRect.RectTransform().rect;
float pageSize = viewRect.height / contentRect.height;
if (Settings.UseHomeEnd.Value) if (Settings.UseHomeEnd.Value)
{ {
if (Input.GetKeyDown(KeyCode.Home)) if (Input.GetKeyDown(KeyCode.Home))
@@ -48,10 +44,23 @@ namespace UIFixes
{ {
if (Input.GetKeyDown(KeyCode.PageUp)) if (Input.GetKeyDown(KeyCode.PageUp))
{ {
// Duplicate this code to avoid running it every frame
Rect contentRect = scrollRect.content.rect;
Rect viewRect = scrollRect.RectTransform().rect;
float pageSize = viewRect.height / contentRect.height;
scrollRect.verticalNormalizedPosition = Math.Min(1f, scrollRect.verticalNormalizedPosition + pageSize); scrollRect.verticalNormalizedPosition = Math.Min(1f, scrollRect.verticalNormalizedPosition + pageSize);
} }
if (Input.GetKeyDown(KeyCode.PageDown)) if (Input.GetKeyDown(KeyCode.PageDown))
{ {
// Duplicate this code to avoid running it every frame
Rect contentRect = scrollRect.content.rect;
Rect viewRect = scrollRect.RectTransform().rect;
float pageSize = viewRect.height / contentRect.height;
scrollRect.verticalNormalizedPosition = Math.Max(0f, scrollRect.verticalNormalizedPosition - pageSize); scrollRect.verticalNormalizedPosition = Math.Max(0f, scrollRect.verticalNormalizedPosition - pageSize);
} }
} }

View File

@@ -59,6 +59,7 @@ namespace UIFixes
public static ConfigEntry<bool> MergeFIRMoney { get; set; } public static ConfigEntry<bool> MergeFIRMoney { get; set; }
public static ConfigEntry<bool> MergeFIRAmmo { get; set; } public static ConfigEntry<bool> MergeFIRAmmo { get; set; }
public static ConfigEntry<bool> MergeFIROther { get; set; } public static ConfigEntry<bool> MergeFIROther { get; set; }
public static ConfigEntry<bool> AutoOpenSortingTable { get; set; }
// Inspect Panels // Inspect Panels
public static ConfigEntry<bool> ShowModStats { get; set; } public static ConfigEntry<bool> ShowModStats { get; set; }
@@ -306,6 +307,15 @@ namespace UIFixes
null, null,
new ConfigurationManagerAttributes { }))); new ConfigurationManagerAttributes { })));
configEntries.Add(AutoOpenSortingTable = config.Bind(
InventorySection,
"Auto-open Sorting Table",
true,
new ConfigDescription(
"Automatically open the sorting table if it's closed when you shift-click an item",
null,
new ConfigurationManagerAttributes { })));
// Inspect // Inspect
configEntries.Add(ShowModStats = config.Bind( configEntries.Add(ShowModStats = config.Bind(
InspectSection, InspectSection,

View File

@@ -4,7 +4,7 @@
<TargetFramework>net471</TargetFramework> <TargetFramework>net471</TargetFramework>
<AssemblyName>Tyfon.UIFixes</AssemblyName> <AssemblyName>Tyfon.UIFixes</AssemblyName>
<Description>SPT UI Fixes</Description> <Description>SPT UI Fixes</Description>
<Version>1.6.6</Version> <Version>1.6.7</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Configurations>Debug;Release;Dist</Configurations> <Configurations>Debug;Release;Dist</Configurations>

View File

@@ -1,6 +1,6 @@
{ {
"name": "uifixes", "name": "uifixes",
"version": "1.6.6", "version": "1.6.7",
"main": "src/mod.js", "main": "src/mod.js",
"license": "MIT", "license": "MIT",
"author": "Tyfon", "author": "Tyfon",