fix: closest to mouse not clamped

This commit is contained in:
2025-10-17 20:45:02 -04:00
parent cce3b91be8
commit 4e3f39a323
3 changed files with 20 additions and 8 deletions
+15 -3
View File
@@ -60,15 +60,27 @@ namespace Spectrum.Detection
{ {
_ = InputManager.GetCursorPos(out System.Drawing.Point mousePos); _ = InputManager.GetCursorPos(out System.Drawing.Point mousePos);
bounds = new Rectangle( bounds = new Rectangle(
mousePos.X - (config.ImageWidth/2), mousePos.X - (config.ImageWidth / 2),
mousePos.Y - (config.ImageHeight/2), mousePos.Y - (config.ImageHeight / 2),
config.ImageWidth, config.ImageWidth,
config.ImageHeight config.ImageHeight
); );
} }
var screenshot = null as Bitmap;
var screenRect = new Rectangle(0, 0, screenSize.Width, screenSize.Height);
bounds = Rectangle.Intersect(bounds, screenRect);
if (bounds.Width <= 0 || bounds.Height <= 0)
{
renderer?.CommitDetectionDrawCommands();
Thread.Sleep(2);
continue;
}
Bitmap? screenshot = null;
if (config.CaptureMethod == CaptureMethod.DirectX && _captureManager.IsDirectXAvailable) if (config.CaptureMethod == CaptureMethod.DirectX && _captureManager.IsDirectXAvailable)
{
screenshot = _captureManager.CaptureScreenshotDirectX(bounds); screenshot = _captureManager.CaptureScreenshotDirectX(bounds);
}
else else
{ {
if (_captureManager.IsInitialized) if (_captureManager.IsInitialized)
+3 -3
View File
@@ -94,8 +94,8 @@ namespace Spectrum
drawList.AddRectFilled(canvasPos, size + canvasPos, ImGui.GetColorU32(new Vector4(0.12f, 0.12f, 0.14f, 1.0f)), 3f); drawList.AddRectFilled(canvasPos, size + canvasPos, ImGui.GetColorU32(new Vector4(0.12f, 0.12f, 0.14f, 1.0f)), 3f);
drawList.AddRect(canvasPos, size + canvasPos, ImGui.GetColorU32(new Vector4(0.17f, 0.17f, 0.20f, 1.0f)), 3f); drawList.AddRect(canvasPos, size + canvasPos, ImGui.GetColorU32(new Vector4(0.17f, 0.17f, 0.20f, 1.0f)), 3f);
drawList.AddRect( drawList.AddRect(
new Vector2(boundingBox.X + canvasPos.X, boundingBox.Top + canvasPos.Y), new Vector2(boundingBox.X + canvasPos.X, boundingBox.Top + canvasPos.Y),
new Vector2(boundingBox.X + boundingBox.Width + canvasPos.X, boundingBox.Y + boundingBox.Height + canvasPos.Y), new Vector2(boundingBox.X + boundingBox.Width + canvasPos.X, boundingBox.Y + boundingBox.Height + canvasPos.Y),
ImGui.GetColorU32(new Vector4(0, 0, 1, 1)), 0.0f, ImDrawFlags.None, 2.0f); ImGui.GetColorU32(new Vector4(0, 0, 1, 1)), 0.0f, ImDrawFlags.None, 2.0f);
if (_previewPath.Count > 1) if (_previewPath.Count > 1)
@@ -160,7 +160,7 @@ namespace Spectrum
{ {
_previewStartPoint = new Point((int)localMousePos.X, (int)localMousePos.Y); _previewStartPoint = new Point((int)localMousePos.X, (int)localMousePos.Y);
} }
else else
{ {
_previewEndPoint = new Point((int)localMousePos.X, (int)localMousePos.Y); _previewEndPoint = new Point((int)localMousePos.X, (int)localMousePos.Y);
} }
+2 -2
View File
@@ -744,7 +744,7 @@ namespace Spectrum
} }
else else
{ {
_ = InputManager.GetCursorPos(out System.Drawing.Point mousePos); InputManager.GetCursorPos(out System.Drawing.Point mousePos);
topLeft = new(mousePos.X - (config.ImageWidth / 2), mousePos.Y - (config.ImageHeight / 2)); topLeft = new(mousePos.X - (config.ImageWidth / 2), mousePos.Y - (config.ImageHeight / 2));
bottomRight = new(mousePos.X + (config.ImageWidth / 2), mousePos.Y + (config.ImageHeight / 2)); bottomRight = new(mousePos.X + (config.ImageWidth / 2), mousePos.Y + (config.ImageHeight / 2));
} }
@@ -765,7 +765,7 @@ namespace Spectrum
center = new(mousePos.X, mousePos.Y); center = new(mousePos.X, mousePos.Y);
} }
drawList.AddCircle(center, config.ImageWidth / 2,ImGui.GetColorU32(config.FOVColor), 100, 1.0f); 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
} }