From cce3b91be83f47260e098268399691bca8091fde Mon Sep 17 00:00:00 2001 From: whoswhip Date: Fri, 17 Oct 2025 19:03:35 -0400 Subject: [PATCH] feat: closest to mouse fov and bounds move based off of position of mouse --- Spectrum/Detection/DetectionManager.cs | 25 ++++++++++++++----- Spectrum/Input/InputManager.cs | 10 ++------ Spectrum/Renderer.cs | 33 ++++++++++++++++++++++---- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/Spectrum/Detection/DetectionManager.cs b/Spectrum/Detection/DetectionManager.cs index ef81700..1d9b179 100644 --- a/Spectrum/Detection/DetectionManager.cs +++ b/Spectrum/Detection/DetectionManager.cs @@ -47,12 +47,25 @@ namespace Spectrum.Detection renderer?.ClearDetectionDrawCommands(); - bounds = new Rectangle( - (screenSize.Width - config.ImageWidth) / 2, - (screenSize.Height - config.ImageHeight) / 2, - config.ImageWidth, - config.ImageHeight - ); + if (!config.ClosestToMouse) + { + bounds = new Rectangle( + (screenSize.Width - config.ImageWidth) / 2, + (screenSize.Height - config.ImageHeight) / 2, + config.ImageWidth, + config.ImageHeight + ); + } + else + { + _ = InputManager.GetCursorPos(out System.Drawing.Point mousePos); + bounds = new Rectangle( + mousePos.X - (config.ImageWidth/2), + mousePos.Y - (config.ImageHeight/2), + config.ImageWidth, + config.ImageHeight + ); + } var screenshot = null as Bitmap; if (config.CaptureMethod == CaptureMethod.DirectX && _captureManager.IsDirectXAvailable) screenshot = _captureManager.CaptureScreenshotDirectX(bounds); diff --git a/Spectrum/Input/InputManager.cs b/Spectrum/Input/InputManager.cs index a3d294d..092fa0b 100644 --- a/Spectrum/Input/InputManager.cs +++ b/Spectrum/Input/InputManager.cs @@ -188,15 +188,9 @@ namespace Spectrum.Input } } - public static void SetLastDetection(Point point) - { - lastDetection = point; - } + public static void SetLastDetection(Point point) { lastDetection = point; } - public static void SetLastDetectionBox(Rectangle box) - { - lastDetectionBox = box; - } + public static void SetLastDetectionBox(Rectangle box) { lastDetectionBox = box; } [DllImport("user32.dll")] private static extern short GetAsyncKeyState(int vKey); diff --git a/Spectrum/Renderer.cs b/Spectrum/Renderer.cs index a41d6ff..7b2b373 100644 --- a/Spectrum/Renderer.cs +++ b/Spectrum/Renderer.cs @@ -735,14 +735,37 @@ namespace Spectrum { if (config.FOVType == FovType.Rectangle) { - drawList.AddRect(new Vector2((screenSize.width - config.ImageWidth) / 2, (screenSize.height - config.ImageHeight) / 2), - new Vector2((screenSize.width + config.ImageWidth) / 2, (screenSize.height + config.ImageHeight) / 2), - ImGui.GetColorU32(config.FOVColor), 0.0f, ImDrawFlags.None, 1.0f); + Vector2 topLeft; + Vector2 bottomRight; + if (!config.ClosestToMouse) + { + topLeft = new((screenSize.width - config.ImageWidth) / 2, (screenSize.height - config.ImageHeight) / 2); + bottomRight = new((screenSize.width + config.ImageWidth) / 2, (screenSize.height + config.ImageHeight) / 2); + } + else + { + _ = InputManager.GetCursorPos(out System.Drawing.Point mousePos); + topLeft = new(mousePos.X - (config.ImageWidth / 2), mousePos.Y - (config.ImageHeight / 2)); + bottomRight = new(mousePos.X + (config.ImageWidth / 2), mousePos.Y + (config.ImageHeight / 2)); + } + + + drawList.AddRect(topLeft, bottomRight, ImGui.GetColorU32(config.FOVColor), 0.0f, ImDrawFlags.None, 1.0f); } else if (config.FOVType == FovType.Circle) { - drawList.AddCircle(new Vector2(screenSize.width / 2, screenSize.height / 2), config.ImageWidth / 2, - ImGui.GetColorU32(config.FOVColor), 100, 1.0f); + Vector2 center; + if (!config.ClosestToMouse) + { + center = new(screenSize.width / 2, screenSize.height / 2); + } + else + { + _ = InputManager.GetCursorPos(out System.Drawing.Point mousePos); + center = new(mousePos.X, mousePos.Y); + } + + drawList.AddCircle(center, config.ImageWidth / 2,ImGui.GetColorU32(config.FOVColor), 100, 1.0f); } // added straight to drawlist to prevent caching/flickering }