diff --git a/Spectrum/Config.cs b/Spectrum/Config.cs index e84b1f3..d04c926 100644 --- a/Spectrum/Config.cs +++ b/Spectrum/Config.cs @@ -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; diff --git a/Spectrum/Detection/CaptureManager.cs b/Spectrum/Detection/CaptureManager.cs index 1a9ee92..601e669 100644 --- a/Spectrum/Detection/CaptureManager.cs +++ b/Spectrum/Detection/CaptureManager.cs @@ -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 { diff --git a/Spectrum/Input/InputManager.cs b/Spectrum/Input/InputManager.cs index ab28fd6..5001f7c 100644 --- a/Spectrum/Input/InputManager.cs +++ b/Spectrum/Input/InputManager.cs @@ -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; diff --git a/Spectrum/Input/MovementPaths.cs b/Spectrum/Input/MovementPaths.cs index 53506f8..cec0b2a 100644 --- a/Spectrum/Input/MovementPaths.cs +++ b/Spectrum/Input/MovementPaths.cs @@ -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; diff --git a/Spectrum/Renderer.HSVRangeWindow.cs b/Spectrum/Renderer.HSVRangeWindow.cs index a995f4f..6099e6c 100644 --- a/Spectrum/Renderer.HSVRangeWindow.cs +++ b/Spectrum/Renderer.HSVRangeWindow.cs @@ -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); diff --git a/Spectrum/Renderer.ImGuiExtensions.cs b/Spectrum/Renderer.ImGuiExtensions.cs index 3defb89..6a5545a 100644 --- a/Spectrum/Renderer.ImGuiExtensions.cs +++ b/Spectrum/Renderer.ImGuiExtensions.cs @@ -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); diff --git a/Spectrum/Renderer.MovementPreviewWindow.cs b/Spectrum/Renderer.MovementPreviewWindow.cs index 06436ee..65f57e7 100644 --- a/Spectrum/Renderer.MovementPreviewWindow.cs +++ b/Spectrum/Renderer.MovementPreviewWindow.cs @@ -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)) diff --git a/Spectrum/Renderer.cs b/Spectrum/Renderer.cs index 00325fd..d2308a4 100644 --- a/Spectrum/Renderer.cs +++ b/Spectrum/Renderer.cs @@ -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; diff --git a/Spectrum/Spectrum.csproj b/Spectrum/Spectrum.csproj index 3ae5f2d..33707ce 100644 --- a/Spectrum/Spectrum.csproj +++ b/Spectrum/Spectrum.csproj @@ -11,6 +11,8 @@ True AnyCPU;x64 + Web + ImGui