try/catch trader autoswitch

This commit is contained in:
Tyfon
2024-10-03 10:58:56 -07:00
parent 7f447d9cfa
commit 58ee16bee7

View File

@@ -3,6 +3,7 @@ using EFT.UI;
using EFT.UI.DragAndDrop; using EFT.UI.DragAndDrop;
using HarmonyLib; using HarmonyLib;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using System;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
@@ -83,24 +84,31 @@ public static class TradingAutoSwitchPatches
return true; return true;
} }
if (!___bool_8 && ctrlPressed && assortmentController.QuickFindTradingAppropriatePlace(__instance.Item, null)) try
{ {
__instance.ItemContext?.CloseDependentWindows(); if (!___bool_8 && ctrlPressed && assortmentController.QuickFindTradingAppropriatePlace(__instance.Item, null))
__instance.HideTooltip(); {
Singleton<GUISounds>.Instance.PlayItemSound(__instance.Item.ItemSound, EInventorySoundType.pickup, false); __instance.ItemContext?.CloseDependentWindows();
__instance.HideTooltip();
Singleton<GUISounds>.Instance.PlayItemSound(__instance.Item.ItemSound, EInventorySoundType.pickup, false);
SellTab.OnPointerClick(null); SellTab.OnPointerClick(null);
return false; return false;
}
if (___bool_8)
{
assortmentController.SelectItem(__instance.Item);
BuyTab.OnPointerClick(null);
return false;
}
} }
catch (Exception e)
if (___bool_8)
{ {
assortmentController.SelectItem(__instance.Item); Logger.LogError(e);
BuyTab.OnPointerClick(null);
return false;
} }
return true; return true;