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()
{
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)
{
// Add hover events to the correct place
HoverTrigger trigger = ___ItemValue.GetOrAddComponent<HoverTrigger>();
trigger.OnHoverStart += eventData => __instance.method_31();
trigger.OnHoverEnd += eventData =>
HoverTrigger trigger = ___ItemValue.GetComponent<HoverTrigger>();
if (trigger == null)
{
__instance.method_32();
__instance.ShowTooltip();
};
trigger = ___ItemValue.gameObject.AddComponent<HoverTrigger>();
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
Transform hover = ____questsItemViewPanel?.transform.Find("Hover");
if (hover != null)
{
UnityEngine.Object.Instantiate(hover, trigger.transform, false);
// Need a child component for some reason, copying how the quest item tooltip does it
Transform hover = ____questsItemViewPanel?.transform.Find("Hover");
if (hover != null)
{
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;
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()
{

View File

@@ -4,6 +4,7 @@ using EFT.UI;
using HarmonyLib;
using System.Linq;
using System.Reflection;
using UnityEngine;
namespace UIFixes
{
@@ -20,7 +21,13 @@ namespace UIFixes
[PatchPrefix]
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;
}

View File

@@ -28,10 +28,6 @@ namespace UIFixes
{
if (scrollRect != null)
{
Rect contentRect = scrollRect.content.rect;
Rect viewRect = scrollRect.RectTransform().rect;
float pageSize = viewRect.height / contentRect.height;
if (Settings.UseHomeEnd.Value)
{
if (Input.GetKeyDown(KeyCode.Home))
@@ -48,10 +44,23 @@ namespace UIFixes
{
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);
}
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);
}
}

View File

@@ -59,6 +59,7 @@ namespace UIFixes
public static ConfigEntry<bool> MergeFIRMoney { get; set; }
public static ConfigEntry<bool> MergeFIRAmmo { get; set; }
public static ConfigEntry<bool> MergeFIROther { get; set; }
public static ConfigEntry<bool> AutoOpenSortingTable { get; set; }
// Inspect Panels
public static ConfigEntry<bool> ShowModStats { get; set; }
@@ -306,6 +307,15 @@ namespace UIFixes
null,
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
configEntries.Add(ShowModStats = config.Bind(
InspectSection,

View File

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

View File

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