refactor: improve readability and cleanup code

This commit is contained in:
2025-11-10 17:36:13 -05:00
parent b9756609ee
commit 23a28d56ff
3 changed files with 8 additions and 8 deletions
+3 -2
View File
@@ -278,7 +278,7 @@ namespace Spectrum.Input
_ = tcs.Task.ContinueWith(_ => _ = tcs.Task.ContinueWith(_ =>
{ {
try { ctr.Dispose(); } catch {} try { ctr.Dispose(); } catch { }
UnsubscribeMakcu(); UnsubscribeMakcu();
}, TaskScheduler.Default); }, TaskScheduler.Default);
@@ -367,7 +367,8 @@ namespace Spectrum.Input
{ {
var states = MakcuMain.MakcuInstance.GetCurrentButtonStates(); var states = MakcuMain.MakcuInstance.GetCurrentButtonStates();
return states.TryGetValue(makcuBtn, out var pressed) && pressed; return states.TryGetValue(makcuBtn, out var pressed) && pressed;
} catch {} }
catch { }
} }
return (GetAsyncKeyState((int)key) & 0x8000) != 0; ; return (GetAsyncKeyState((int)key) & 0x8000) != 0; ;
} }
-1
View File
@@ -1,6 +1,5 @@
using OpenCvSharp; using OpenCvSharp;
using Spectrum.Detection; using Spectrum.Detection;
using System.Runtime.InteropServices;
namespace Spectrum namespace Spectrum
{ {
@@ -51,16 +51,16 @@ namespace Spectrum
Point current = _previewStartPoint; Point current = _previewStartPoint;
int steps = 0; int steps = 0;
int maxSteps = 10000; int maxSteps = 10000;
_previewPath.Add((current, 0.0)); _previewPath.Add((current, 0.0));
while (true) while (true)
{ {
double distance = Math.Sqrt(Math.Pow(_previewEndPoint.X - current.X, 2) + Math.Pow(_previewEndPoint.Y - current.Y, 2)); double distance = Math.Sqrt(Math.Pow(_previewEndPoint.X - current.X, 2) + Math.Pow(_previewEndPoint.Y - current.Y, 2));
if (distance < 2.0 || steps++ >= maxSteps) if (distance < 2.0 || steps++ >= maxSteps)
break; break;
bool isInBox = boundingBox.Contains(current); bool isInBox = boundingBox.Contains(current);
Point nextPoint = InputManager.CalculateMovement(current, _previewEndPoint, config.Sensitivity, config.AimMovementType, isInBox); Point nextPoint = InputManager.CalculateMovement(current, _previewEndPoint, config.Sensitivity, config.AimMovementType, isInBox);
if (config.EmaSmoothening) if (config.EmaSmoothening)
@@ -70,7 +70,7 @@ namespace Spectrum
_previewPath.Add((nextPoint, speed)); _previewPath.Add((nextPoint, speed));
current = nextPoint; current = nextPoint;
} }
if (_previewPath.Count > 0) if (_previewPath.Count > 0)
{ {
var lastPoint = _previewPath[^1].point; var lastPoint = _previewPath[^1].point;
@@ -84,7 +84,7 @@ namespace Spectrum
Vector2 canvasPos = ImGui.GetCursorScreenPos(); Vector2 canvasPos = ImGui.GetCursorScreenPos();
canvasPos.Y += 5; canvasPos.Y += 5;
Vector2 canvasSize = ImGui.GetContentRegionAvail(); Vector2 canvasSize = ImGui.GetContentRegionAvail();
Vector2 size = new Vector2(canvasSize.X, canvasSize.Y - 60); Vector2 size = new(canvasSize.X, canvasSize.Y - 60);
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.PushClipRect(canvasPos, canvasPos + size, true); drawList.PushClipRect(canvasPos, canvasPos + size, true);