Fix init when pasting in a programmable block
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 1m30s
Build / Build Nuget package (SharedCringe) (push) Successful in 1m45s
Build / Build Nuget package (NuGet) (push) Successful in 1m47s
Build / Build Nuget package (CringePlugins) (push) Successful in 1m58s
Build / Build Launcher (push) Successful in 2m24s
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 1m30s
Build / Build Nuget package (SharedCringe) (push) Successful in 1m45s
Build / Build Nuget package (NuGet) (push) Successful in 1m47s
Build / Build Nuget package (CringePlugins) (push) Successful in 1m58s
Build / Build Launcher (push) Successful in 2m24s
Improvements for imgui input handling
This commit is contained in:
@@ -1,23 +1,28 @@
|
||||
using HarmonyLib;
|
||||
using Sandbox.Graphics;
|
||||
using VRage;
|
||||
using VRage.Input;
|
||||
using VRage.Input.Keyboard;
|
||||
using VRage.Platform.Windows.Input;
|
||||
using VRageMath;
|
||||
|
||||
namespace CringeLauncher.Patches;
|
||||
|
||||
[HarmonyPatch]
|
||||
internal static class InputPatch
|
||||
{
|
||||
[HarmonyPrefix, HarmonyPatch(typeof(MyDirectInput), nameof(MyDirectInput.GetMouseState))]
|
||||
private static bool GetMouseStatePrefix(ref MyMouseState state)
|
||||
[HarmonyPostfix, HarmonyPatch(typeof(MyDirectInput), nameof(MyDirectInput.GetMouseState))]
|
||||
private static void GetMouseStatePostfix(ref MyMouseState state)
|
||||
{
|
||||
if (ImGuiHandler.Instance?.BlockMouse == true && (MyVRage.Platform.Input.ShowCursor || ImGuiHandler.Instance.DrawMouse))
|
||||
{
|
||||
state = default;
|
||||
return false;
|
||||
state.LeftButton = false;
|
||||
state.RightButton = false;
|
||||
state.MiddleButton = false;
|
||||
state.XButton1 = false;
|
||||
state.XButton2 = false;
|
||||
state.ScrollWheelValue = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix, HarmonyPatch(typeof(MyGuiLocalizedKeyboardState), nameof(MyGuiLocalizedKeyboardState.GetCurrentState))]
|
||||
@@ -30,4 +35,15 @@ internal static class InputPatch
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix, HarmonyPatch(typeof(MyGuiManager), nameof(MyGuiManager.MouseCursorPosition), MethodType.Getter)]
|
||||
private static bool GetMouseCursorPositionPrefix(ref Vector2 __result)
|
||||
{
|
||||
if (ImGuiHandler.Instance?.BlockMouse == true && (MyVRage.Platform.Input.ShowCursor || ImGuiHandler.Instance.DrawMouse))
|
||||
{
|
||||
__result = Vector2.Zero;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user