mirror of
https://github.com/whoswhip/Spectrum.git
synced 2026-12-06 01:28:42 +00:00
chore: run code cleanup
This commit is contained in:
+7
-7
@@ -26,12 +26,12 @@ namespace Spectrum
|
||||
_currentConfigName = Path.GetFileNameWithoutExtension(fileName);
|
||||
_data = new T();
|
||||
_availableConfigs = [];
|
||||
|
||||
|
||||
if (!Directory.Exists(_configDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(_configDirectory);
|
||||
}
|
||||
|
||||
|
||||
UpdateAvailableConfigs();
|
||||
StartDirectoryWatcher();
|
||||
LoadConfig();
|
||||
@@ -41,7 +41,7 @@ namespace Spectrum
|
||||
{
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
filename = _defaultFilename;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
@@ -77,7 +77,7 @@ namespace Spectrum
|
||||
{
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
filename = _defaultFilename;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllText(filename, JsonConvert.SerializeObject(_data, Formatting.Indented));
|
||||
@@ -110,7 +110,7 @@ namespace Spectrum
|
||||
}
|
||||
|
||||
var filePath = Path.Combine(_configDirectory, $"{configName}.json");
|
||||
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
LogManager.Log($"Config {configName} not found in directory.", LogLevel.Error);
|
||||
@@ -199,7 +199,7 @@ namespace Spectrum
|
||||
}
|
||||
|
||||
var filePath = Path.Combine(_configDirectory, $"{configName}.json");
|
||||
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
LogManager.Log($"Config {configName} not found.", LogLevel.Error);
|
||||
@@ -358,7 +358,7 @@ namespace Spectrum
|
||||
public double EmaSmootheningFactor { get; set; } = 0.1;
|
||||
|
||||
public MovementMethod MovementMethod { get; set; } = MovementMethod.MouseEvent;
|
||||
|
||||
|
||||
public double WindMouseGravity { get; set; } = 9.0;
|
||||
public double WindMouseWind { get; set; } = 3.0;
|
||||
public double WindMouseMaxStep { get; set; } = 10.0;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using Vortice.Direct3D;
|
||||
using Vortice.Direct3D11;
|
||||
using Vortice.DXGI;
|
||||
using Size = System.Drawing.Size;
|
||||
using Rectangle = System.Drawing.Rectangle;
|
||||
using Point = System.Drawing.Point;
|
||||
using Rectangle = System.Drawing.Rectangle;
|
||||
using Size = System.Drawing.Size;
|
||||
|
||||
namespace Spectrum.Detection
|
||||
{
|
||||
|
||||
@@ -74,11 +74,11 @@ namespace Spectrum.Input
|
||||
MovementType.Adaptive => MovementPaths.AdaptiveMovement(start, end, effSensitivity),
|
||||
MovementType.QuadraticBezier => MovementPaths.CurvedMovement(start, end, effSensitivity),
|
||||
MovementType.PerlinNoise => MovementPaths.PerlinNoiseMovement(start, end, effSensitivity),
|
||||
MovementType.WindMouse => MovementPaths.WindMouse(start, end,
|
||||
config.WindMouseGravity,
|
||||
config.WindMouseWind,
|
||||
config.WindMouseMaxStep,
|
||||
config.WindMouseTargetArea,
|
||||
MovementType.WindMouse => MovementPaths.WindMouse(start, end,
|
||||
config.WindMouseGravity,
|
||||
config.WindMouseWind,
|
||||
config.WindMouseMaxStep,
|
||||
config.WindMouseTargetArea,
|
||||
effSensitivity,
|
||||
config.WindMouseOvershoot,
|
||||
insideBoundingBox),
|
||||
@@ -353,7 +353,7 @@ namespace Spectrum.Input
|
||||
return isKeyDown;
|
||||
|
||||
string toggleKey = keybind.Key.ToString();
|
||||
|
||||
|
||||
if (!_keybindToggleStates.ContainsKey(toggleKey))
|
||||
_keybindToggleStates[toggleKey] = false;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Spectrum.Input
|
||||
private static readonly int[] _permutation = GeneratePermutation();
|
||||
private static readonly int[] _p;
|
||||
private static double _perlinTime = 0.0;
|
||||
|
||||
|
||||
private static Point _lastMove = new Point(0, 0);
|
||||
private static double _windX = 0.0;
|
||||
private static double _windY = 0.0;
|
||||
@@ -157,57 +157,57 @@ namespace Spectrum.Input
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
public static Point WindMouse(Point start, Point end, double gravity = 9.0, double wind = 3.0,
|
||||
public static Point WindMouse(Point start, Point end, double gravity = 9.0, double wind = 3.0,
|
||||
double maxStep = 10.0, double targetArea = 5.0, double sensitivity = 1.0, bool enableOvershoot = false, bool insideBoundingBox = false)
|
||||
{
|
||||
double dx = end.X - start.X;
|
||||
double dy = end.Y - start.Y;
|
||||
double distance = Math.Sqrt(dx * dx + dy * dy);
|
||||
|
||||
|
||||
if (insideBoundingBox)
|
||||
{
|
||||
double trackingSpeed = Math.Min(distance * 0.35, maxStep * sensitivity * 0.6);
|
||||
|
||||
|
||||
double dirX = distance > 0 ? dx / distance : 0;
|
||||
double dirY = distance > 0 ? dy / distance : 0;
|
||||
|
||||
|
||||
double humanVariation = Math.Sin(_perlinTime * 1.2) * 0.4 + Math.Cos(_perlinTime * 0.8) * 0.25;
|
||||
_perlinTime += 0.03;
|
||||
|
||||
|
||||
double smoothX = dirX * trackingSpeed + humanVariation;
|
||||
double smoothY = dirY * trackingSpeed + humanVariation * 0.7;
|
||||
|
||||
|
||||
int trackX = (int)Math.Round(start.X + smoothX);
|
||||
int trackY = (int)Math.Round(start.Y + smoothY);
|
||||
|
||||
|
||||
_windX *= 0.15;
|
||||
_windY *= 0.15;
|
||||
_velocityX *= 0.3;
|
||||
_velocityY *= 0.3;
|
||||
|
||||
|
||||
Point trackResult = new Point(trackX, trackY);
|
||||
_lastMove = trackResult;
|
||||
return trackResult;
|
||||
}
|
||||
|
||||
|
||||
if (distance <= targetArea)
|
||||
{
|
||||
double trackingSpeed = Math.Min(distance * 0.6, maxStep * sensitivity * 0.5);
|
||||
|
||||
|
||||
double dirX = dx / distance;
|
||||
double dirY = dy / distance;
|
||||
|
||||
|
||||
double microAdjustment = Math.Sin(_perlinTime * 2.0) * 0.3;
|
||||
_perlinTime += 0.05;
|
||||
|
||||
|
||||
int trackX = (int)Math.Round(start.X + dirX * trackingSpeed + microAdjustment);
|
||||
int trackY = (int)Math.Round(start.Y + dirY * trackingSpeed + microAdjustment);
|
||||
|
||||
|
||||
_windX *= 0.3;
|
||||
_windY *= 0.3;
|
||||
_velocityX *= 0.5;
|
||||
_velocityY *= 0.5;
|
||||
|
||||
|
||||
Point trackResult = new Point(trackX, trackY);
|
||||
_lastMove = trackResult;
|
||||
return trackResult;
|
||||
@@ -216,24 +216,24 @@ namespace Spectrum.Input
|
||||
if (distance <= targetArea * 2.5)
|
||||
{
|
||||
double trackingSpeed = Math.Min(distance * 0.5, maxStep * sensitivity * 0.7);
|
||||
|
||||
|
||||
double dirX = dx / distance;
|
||||
double dirY = dy / distance;
|
||||
|
||||
|
||||
double smoothNoise = Math.Sin(_perlinTime * 1.5) * (distance / targetArea) * 0.5;
|
||||
_perlinTime += 0.08;
|
||||
|
||||
|
||||
double blendFactor = (distance - targetArea) / (targetArea * 1.5);
|
||||
|
||||
|
||||
_velocityX = _velocityX * blendFactor * 0.5 + dirX * trackingSpeed * gravity * 0.1;
|
||||
_velocityY = _velocityY * blendFactor * 0.5 + dirY * trackingSpeed * gravity * 0.1;
|
||||
|
||||
|
||||
_windX *= blendFactor * 0.4;
|
||||
_windY *= blendFactor * 0.4;
|
||||
|
||||
|
||||
int trackX = (int)Math.Round(start.X + dirX * trackingSpeed + smoothNoise);
|
||||
int trackY = (int)Math.Round(start.Y + dirY * trackingSpeed + smoothNoise);
|
||||
|
||||
|
||||
Point trackResult = new Point(trackX, trackY);
|
||||
_lastMove = trackResult;
|
||||
return trackResult;
|
||||
@@ -242,10 +242,10 @@ namespace Spectrum.Input
|
||||
double sensitivityMultiplier = Math.Max(0.1, sensitivity);
|
||||
double distanceScale = Math.Min(distance / 100.0, 3.0);
|
||||
double dynamicMaxStep = maxStep * sensitivityMultiplier * (1.0 + distanceScale);
|
||||
|
||||
|
||||
double proximityThreshold = Math.Max(targetArea * 10, 50);
|
||||
double proximityFactor = Math.Min(distance / proximityThreshold, 1.0);
|
||||
|
||||
|
||||
double windReduction = Math.Pow(proximityFactor, 4.0);
|
||||
double effectiveWind = wind * windReduction;
|
||||
double effectiveGravity = gravity * (1.0 + distanceScale * 0.3) * sensitivityMultiplier;
|
||||
@@ -262,7 +262,7 @@ namespace Spectrum.Input
|
||||
dampingFactor = Math.Pow(dampingFactor, 2.0);
|
||||
_velocityX *= dampingFactor;
|
||||
_velocityY *= dampingFactor;
|
||||
|
||||
|
||||
double windDamping = Math.Pow(dampingFactor, 4.0);
|
||||
_windX *= windDamping;
|
||||
_windY *= windDamping;
|
||||
@@ -296,7 +296,7 @@ namespace Spectrum.Input
|
||||
|
||||
int nextX = (int)Math.Round(start.X + _velocityX);
|
||||
int nextY = (int)Math.Round(start.Y + _velocityY);
|
||||
|
||||
|
||||
Point result = new Point(nextX, nextY);
|
||||
_lastMove = result;
|
||||
return result;
|
||||
|
||||
@@ -61,10 +61,10 @@ namespace Spectrum
|
||||
{
|
||||
float availWidth = ImGui.GetContentRegionAvail().X;
|
||||
float availHeight = ImGui.GetContentRegionAvail().Y;
|
||||
|
||||
|
||||
float controlsHeight = 500;
|
||||
float maxImageHeight = Math.Max(100, availHeight - controlsHeight);
|
||||
|
||||
|
||||
float imageDisplayWidth = (availWidth - 20) / 2;
|
||||
float aspectRatio = (float)_originalImage.Height / _originalImage.Width;
|
||||
float imageDisplayHeight = Math.Min(imageDisplayWidth * aspectRatio, maxImageHeight);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using ImGuiNET;
|
||||
using OpenCvSharp;
|
||||
using Spectrum.Input;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using Spectrum.Input;
|
||||
|
||||
namespace Spectrum
|
||||
{
|
||||
@@ -485,8 +485,8 @@ namespace Spectrum
|
||||
if (!inline)
|
||||
ImGui.TextUnformatted(label);
|
||||
|
||||
string buttonText = _keybindListening.GetValueOrDefault(label)
|
||||
? "Listening..."
|
||||
string buttonText = _keybindListening.GetValueOrDefault(label)
|
||||
? "Listening..."
|
||||
: keybind.Key.ToString();
|
||||
|
||||
ImGui.SameLine(ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize(buttonText).X);
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Spectrum
|
||||
{
|
||||
_isDragging = false;
|
||||
}
|
||||
|
||||
|
||||
ImGui.Dummy(new(ImGui.GetContentRegionAvail().X, 10));
|
||||
int interval = UpdatePreviewInterval;
|
||||
if (ImGuiExtensions.SliderFill("Update Interval (ms)", ref interval, 1, 100))
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Spectrum
|
||||
|
||||
ImGui.TextUnformatted("Movement Path");
|
||||
ImGui.SameLine(ImGui.GetContentRegionAvail().X - 9);
|
||||
if (ImGui.Button(_showMovementPreview ? "X" : "?", new Vector2(20,20)))
|
||||
if (ImGui.Button(_showMovementPreview ? "X" : "?", new Vector2(20, 20)))
|
||||
_showMovementPreview = !_showMovementPreview;
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
MovementType AimPath = config.AimMovementType;
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<TargetFrameworks></TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<UIMode Condition="'$(Configuration)' == 'WebUI'">Web</UIMode>
|
||||
<UIMode Condition="'$(Configuration)' != 'WebUI'">ImGui</UIMode>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user