feat: closest to mouse fov and bounds move based off of position of mouse

This commit is contained in:
2025-10-17 19:03:35 -04:00
parent f1ca1ee9ee
commit cce3b91be8
3 changed files with 49 additions and 19 deletions
+19 -6
View File
@@ -47,12 +47,25 @@ namespace Spectrum.Detection
renderer?.ClearDetectionDrawCommands(); renderer?.ClearDetectionDrawCommands();
bounds = new Rectangle( if (!config.ClosestToMouse)
(screenSize.Width - config.ImageWidth) / 2, {
(screenSize.Height - config.ImageHeight) / 2, bounds = new Rectangle(
config.ImageWidth, (screenSize.Width - config.ImageWidth) / 2,
config.ImageHeight (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; var screenshot = null as Bitmap;
if (config.CaptureMethod == CaptureMethod.DirectX && _captureManager.IsDirectXAvailable) if (config.CaptureMethod == CaptureMethod.DirectX && _captureManager.IsDirectXAvailable)
screenshot = _captureManager.CaptureScreenshotDirectX(bounds); screenshot = _captureManager.CaptureScreenshotDirectX(bounds);
+2 -8
View File
@@ -188,15 +188,9 @@ namespace Spectrum.Input
} }
} }
public static void SetLastDetection(Point point) public static void SetLastDetection(Point point) { lastDetection = point; }
{
lastDetection = point;
}
public static void SetLastDetectionBox(Rectangle box) public static void SetLastDetectionBox(Rectangle box) { lastDetectionBox = box; }
{
lastDetectionBox = box;
}
[DllImport("user32.dll")] [DllImport("user32.dll")]
private static extern short GetAsyncKeyState(int vKey); private static extern short GetAsyncKeyState(int vKey);
+28 -5
View File
@@ -735,14 +735,37 @@ namespace Spectrum
{ {
if (config.FOVType == FovType.Rectangle) if (config.FOVType == FovType.Rectangle)
{ {
drawList.AddRect(new Vector2((screenSize.width - config.ImageWidth) / 2, (screenSize.height - config.ImageHeight) / 2), Vector2 topLeft;
new Vector2((screenSize.width + config.ImageWidth) / 2, (screenSize.height + config.ImageHeight) / 2), Vector2 bottomRight;
ImGui.GetColorU32(config.FOVColor), 0.0f, ImDrawFlags.None, 1.0f); 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) else if (config.FOVType == FovType.Circle)
{ {
drawList.AddCircle(new Vector2(screenSize.width / 2, screenSize.height / 2), config.ImageWidth / 2, Vector2 center;
ImGui.GetColorU32(config.FOVColor), 100, 1.0f); 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 } // added straight to drawlist to prevent caching/flickering
} }