Add interface for gui handling so plugins can determine if inputs are being blocked or if the mouse is being drawn (etc)
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 40s
Build / Build Nuget package (NuGet) (push) Successful in 1m2s
Build / Build Nuget package (SharedCringe) (push) Successful in 1m2s
Build / Build Nuget package (CringePlugins) (push) Successful in 1m18s
Build / Build Launcher (push) Successful in 1m55s
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 40s
Build / Build Nuget package (NuGet) (push) Successful in 1m2s
Build / Build Nuget package (SharedCringe) (push) Successful in 1m2s
Build / Build Nuget package (CringePlugins) (push) Successful in 1m18s
Build / Build Launcher (push) Successful in 1m55s
This commit is contained in:
@@ -15,7 +15,7 @@ using Sandbox.Graphics.GUI;
|
|||||||
|
|
||||||
namespace CringeLauncher;
|
namespace CringeLauncher;
|
||||||
|
|
||||||
internal class ImGuiHandler : IDisposable
|
internal sealed class ImGuiHandler : IGuiHandler, IDisposable
|
||||||
{
|
{
|
||||||
private DeviceContext? _deviceContext;
|
private DeviceContext? _deviceContext;
|
||||||
private int _blockKeysCounter;
|
private int _blockKeysCounter;
|
||||||
@@ -25,16 +25,23 @@ internal class ImGuiHandler : IDisposable
|
|||||||
public bool BlockKeys => _blockKeysCounter > 0;
|
public bool BlockKeys => _blockKeysCounter > 0;
|
||||||
public bool DrawMouse { get; private set; }
|
public bool DrawMouse { get; private set; }
|
||||||
|
|
||||||
internal bool MouseToggle { get; set; }
|
public bool MouseToggle { get; set; }
|
||||||
internal bool MouseKey { get; set; }
|
public bool MouseKey { get; set; }
|
||||||
|
|
||||||
|
public bool Initialized => _init;
|
||||||
|
|
||||||
public static ImGuiHandler? Instance;
|
public static ImGuiHandler? Instance;
|
||||||
|
|
||||||
public static RenderTargetView? Rtv;
|
public static RenderTargetView? Rtv;
|
||||||
|
|
||||||
private readonly IRootRenderComponent _renderHandler = new RenderHandler();
|
private readonly IRootRenderComponent _renderHandler;
|
||||||
private static bool _init;
|
private static bool _init;
|
||||||
|
|
||||||
|
public ImGuiHandler()
|
||||||
|
{
|
||||||
|
_renderHandler = new RenderHandler(this);
|
||||||
|
}
|
||||||
|
|
||||||
public unsafe void Init(nint windowHandle, Device1 device, DeviceContext deviceContext)
|
public unsafe void Init(nint windowHandle, Device1 device, DeviceContext deviceContext)
|
||||||
{
|
{
|
||||||
_deviceContext = deviceContext;
|
_deviceContext = deviceContext;
|
||||||
@@ -84,7 +91,7 @@ internal class ImGuiHandler : IDisposable
|
|||||||
else
|
else
|
||||||
_blockKeysCounter--;
|
_blockKeysCounter--;
|
||||||
|
|
||||||
DrawMouse = io.MouseDrawCursor || MouseToggle || MouseKey;
|
DrawMouse = io.MouseDrawCursor || MouseToggle || MouseKey;
|
||||||
|
|
||||||
var focusedScreen = MyScreenManager.GetScreenWithFocus(); //migrated logic from MyDX9Gui.Draw
|
var focusedScreen = MyScreenManager.GetScreenWithFocus(); //migrated logic from MyDX9Gui.Draw
|
||||||
|
|
||||||
|
23
CringePlugins/Abstractions/IGuiHandler.cs
Normal file
23
CringePlugins/Abstractions/IGuiHandler.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
namespace CringePlugins.Abstractions;
|
||||||
|
public interface IGuiHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the Gui Handler is blocking keys from the game's input system.
|
||||||
|
/// </summary>
|
||||||
|
bool BlockKeys { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the Gui Handler is blocking mouse input (excluding position) from the game's input system.
|
||||||
|
/// </summary>
|
||||||
|
bool BlockMouse { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the Gui Handler is drawing the mouse cursor via keybinds (does not include when the game is drawing the mouse cursor).
|
||||||
|
/// </summary>
|
||||||
|
bool DrawMouse { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the Gui Handler is initialized.
|
||||||
|
/// </summary>
|
||||||
|
bool Initialized { get; }
|
||||||
|
}
|
@@ -8,15 +8,18 @@ namespace CringePlugins.Render;
|
|||||||
public sealed class RenderHandler : IRootRenderComponent
|
public sealed class RenderHandler : IRootRenderComponent
|
||||||
{
|
{
|
||||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private static RenderHandler? _current;
|
private static RenderHandler? _current;
|
||||||
|
private static IGuiHandler? _guiHandler;
|
||||||
public static RenderHandler Current => _current ?? throw new InvalidOperationException("Render is not yet initialized");
|
public static RenderHandler Current => _current ?? throw new InvalidOperationException("Render is not yet initialized");
|
||||||
|
public static IGuiHandler GuiHandler => _guiHandler ?? throw new InvalidOperationException("Render is not yet initialized");
|
||||||
|
|
||||||
private readonly ConcurrentBag<ComponentRegistration> _components = [];
|
private readonly ConcurrentBag<ComponentRegistration> _components = [];
|
||||||
|
|
||||||
internal RenderHandler()
|
internal RenderHandler(IGuiHandler guiHandler)
|
||||||
{
|
{
|
||||||
_current = this;
|
_current = this;
|
||||||
|
_guiHandler = guiHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterComponent<TComponent>(TComponent instance) where TComponent : IRenderComponent
|
public void RegisterComponent<TComponent>(TComponent instance) where TComponent : IRenderComponent
|
||||||
@@ -29,7 +32,7 @@ public sealed class RenderHandler : IRootRenderComponent
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
ImGui.ShowDemoWindow();
|
ImGui.ShowDemoWindow();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foreach (var (instanceType, renderComponent) in _components)
|
foreach (var (instanceType, renderComponent) in _components)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Reference in New Issue
Block a user