Block hideout entry if textbox focused

This commit is contained in:
Tyfon
2024-07-07 15:07:02 -07:00
parent 2300b25e63
commit db97ca1070

View File

@@ -1,11 +1,14 @@
using SPT.Reflection.Patching; using EFT.Hideout;
using EFT.Hideout; using EFT.InputSystem;
using EFT.UI; using EFT.UI;
using HarmonyLib; using HarmonyLib;
using SPT.Reflection.Patching;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using TMPro;
using UnityEngine.EventSystems;
using UnityEngine.UI; using UnityEngine.UI;
namespace UIFixes namespace UIFixes
@@ -27,6 +30,7 @@ namespace UIFixes
new FastHideoutSearchPatch().Enable(); new FastHideoutSearchPatch().Enable();
new FixHideoutSearchAgainPatch().Enable(); new FixHideoutSearchAgainPatch().Enable();
new CancelScrollOnMouseWheelPatch().Enable(); new CancelScrollOnMouseWheelPatch().Enable();
new BlockHideoutEnterPatch().Enable();
} }
// Deactivate ProduceViews as they lazy load if they don't match the search // Deactivate ProduceViews as they lazy load if they don't match the search
@@ -208,5 +212,27 @@ namespace UIFixes
ClearLastScrollPosition(); ClearLastScrollPosition();
} }
} }
public class BlockHideoutEnterPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(HideoutScreenOverlay), nameof(HideoutScreenOverlay.TranslateCommand));
}
[PatchPrefix]
public static bool Prefix(ECommand command, ref InputNode.ETranslateResult __result)
{
if (command == ECommand.Enter &&
EventSystem.current?.currentSelectedGameObject != null &&
EventSystem.current.currentSelectedGameObject.GetComponent<TMP_InputField>() != null)
{
__result = InputNode.ETranslateResult.Block;
return false;
}
return true;
}
}
} }
} }