diff --git a/Spectrum/Detection/DetectionManager.cs b/Spectrum/Detection/DetectionManager.cs index 1d9b179..d7777dd 100644 --- a/Spectrum/Detection/DetectionManager.cs +++ b/Spectrum/Detection/DetectionManager.cs @@ -60,15 +60,27 @@ namespace Spectrum.Detection { _ = InputManager.GetCursorPos(out System.Drawing.Point mousePos); bounds = new Rectangle( - mousePos.X - (config.ImageWidth/2), - mousePos.Y - (config.ImageHeight/2), + mousePos.X - (config.ImageWidth / 2), + mousePos.Y - (config.ImageHeight / 2), config.ImageWidth, 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) + { screenshot = _captureManager.CaptureScreenshotDirectX(bounds); + } else { if (_captureManager.IsInitialized) diff --git a/Spectrum/Renderer.MovementPreviewWindow.cs b/Spectrum/Renderer.MovementPreviewWindow.cs index 30b5ca4..c9bcfc8 100644 --- a/Spectrum/Renderer.MovementPreviewWindow.cs +++ b/Spectrum/Renderer.MovementPreviewWindow.cs @@ -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.AddRect(canvasPos, size + canvasPos, ImGui.GetColorU32(new Vector4(0.17f, 0.17f, 0.20f, 1.0f)), 3f); drawList.AddRect( - 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 + canvasPos.X, boundingBox.Top + 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); if (_previewPath.Count > 1) @@ -160,7 +160,7 @@ namespace Spectrum { _previewStartPoint = new Point((int)localMousePos.X, (int)localMousePos.Y); } - else + else { _previewEndPoint = new Point((int)localMousePos.X, (int)localMousePos.Y); } diff --git a/Spectrum/Renderer.cs b/Spectrum/Renderer.cs index 7b2b373..8317454 100644 --- a/Spectrum/Renderer.cs +++ b/Spectrum/Renderer.cs @@ -744,7 +744,7 @@ namespace Spectrum } 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)); bottomRight = new(mousePos.X + (config.ImageWidth / 2), mousePos.Y + (config.ImageHeight / 2)); } @@ -765,7 +765,7 @@ namespace Spectrum 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 }