using HarmonyLib; using JetBrains.Annotations; using KSA; namespace OemLoader; [UsedImplicitly] [HarmonyPatch(typeof(Program))] internal static class ProgramPatch { // Don't allow the game to process keyboard inputs further if the text input in our window is focused [UsedImplicitly] [HarmonyPatch(nameof(Program.OnKey))] [HarmonyPrefix] private static bool OnKeyPrefix() { return !OemLoader.Instance?.Window.Typing ?? true; } // Since KSA build 4036 we need to draw our UI in the thread safe portion of the frame since we could be // modifying vehicle state // FIXME: when StarMap adds proper hooks into OnDrawUiThreadSafe, use that instead of this manual patch [UsedImplicitly] [HarmonyPatch("OnDrawUiThreadSafe")] [HarmonyPostfix] private static void AfterGuiThreadSafe() { OemLoader.Instance?.Window.Render(); } }