0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 04:50:45 -05:00

Rework RemoveStashUpgradeLabelPatch (!162)

The `InventoryScreen` is part of the `CommonUI` which lives throughout the lifetime of the application. It should be safe to only delete this on `Awake()` rather than use `Find()` on a transform that has a fair bit of children every time the inventory screen is opened.
![image](/attachments/937a3954-210c-4fc7-a869-75458ae19d8d)
I cannot extract on 3.10 currently so need someone to just verify that it sticks after an extract where the menu is reloaded.

Co-authored-by: Lacyway <20912169+Lacyway@users.noreply.github.com>
Reviewed-on: SPT/Modules#162
Co-authored-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com>
Co-committed-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com>
This commit is contained in:
Lacyway 2024-08-24 09:12:03 +00:00 committed by chomp
parent fc6124dfc8
commit d4c10c4765

View File

@ -13,13 +13,16 @@ public class RemoveStashUpgradeLabelPatch : ModulePatch
{ {
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()
{ {
// InventoryScreen has 2 Show methods return typeof(InventoryScreen).GetMethod(nameof(InventoryScreen.Awake));
return AccessTools.FirstMethod(typeof(InventoryScreen), info => info.Name == "Show");
} }
[PatchPostfix] [PatchPostfix]
public static void Postfix(SimpleStashPanel __instance) public static void Postfix(SimpleStashPanel __instance)
{ {
Object.Destroy(__instance.transform.Find("Items Panel/Stash Panel/Simple Panel/Header/ExternalObtain").gameObject); GameObject externalObtain = __instance.transform.Find("Items Panel/Stash Panel/Simple Panel/Header/ExternalObtain").gameObject;
if (externalObtain != null)
{
Object.Destroy(externalObtain);
}
} }
} }