mirror of
https://github.com/whoswhip/Spectrum.git
synced 2026-12-06 01:28:42 +00:00
feat: closest to mouse fov and bounds move based off of position of mouse
This commit is contained in:
@@ -47,12 +47,25 @@ namespace Spectrum.Detection
|
||||
|
||||
renderer?.ClearDetectionDrawCommands();
|
||||
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+28
-5
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user