mirror of
https://github.com/whoswhip/Spectrum.git
synced 2026-12-06 01:28:42 +00:00
feat(config): add TriggerBot and DebugMode properties
- Added `TriggerBot` and `DebugMode` properties to the `Config` class. - Introduced performance tracking with `iterationCount`, `totalTime`, and `stopwatch` in `Program.cs`. - Modified key state check to restart the stopwatch for accurate timing. - Adjusted contour area threshold from `100` to `50` for better processing. - Implemented logging for iterations and average FPS when `DebugMode` is enabled. - Added UI checkbox in the `Renderer` class to toggle `DebugMode`.
This commit is contained in:
@@ -115,6 +115,7 @@ namespace Spectrum
|
||||
public MovementType AimMovementType { get; set; } = MovementType.Adaptive;
|
||||
public bool EmaSmoothening { get; set; } = true;
|
||||
public double EmaSmootheningFactor { get; set; } = 0.1;
|
||||
public bool TriggerBot { get; set; } = false;
|
||||
|
||||
// Display settings
|
||||
public bool ShowDetectionWindow { get; set; } = true;
|
||||
@@ -134,6 +135,9 @@ namespace Spectrum
|
||||
public Scalar UpperHSV { get; set; } = new Scalar(150, 255, 229);
|
||||
public Scalar LowerHSV { get; set; } = new Scalar(150, 255, 229);
|
||||
public string SelectedColor { get; set; } = "Arsenal [Magenta]";
|
||||
|
||||
// Misc
|
||||
public bool DebugMode { get; set; } = false;
|
||||
}
|
||||
public class ColorData
|
||||
{
|
||||
|
||||
+22
-1
@@ -1,4 +1,5 @@
|
||||
using OpenCvSharp;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -11,8 +12,13 @@ namespace Spectrum
|
||||
private static DateTime lastMenuToggle = DateTime.MinValue;
|
||||
public static ConfigManager<ConfigData> mainConfig = new ConfigManager<ConfigData>("bin\\configs\\config.json");
|
||||
public static ConfigManager<ColorData> colorConfig = new ConfigManager<ColorData>("bin\\configs\\colors.json");
|
||||
public static long iterationCount = 0;
|
||||
public static long totalTime = 0;
|
||||
private static Stopwatch stopwatch = new Stopwatch();
|
||||
|
||||
static void Main()
|
||||
{
|
||||
|
||||
Thread renderThread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
@@ -62,6 +68,7 @@ namespace Spectrum
|
||||
{
|
||||
if (SystemHelper.GetAsyncKeyState((int)mainConfig.Data.Keybind) < 0)
|
||||
{
|
||||
stopwatch.Restart();
|
||||
bounds = new Rectangle(
|
||||
(screenSize.Width - mainConfig.Data.ImageWidth) / 2,
|
||||
(screenSize.Height - mainConfig.Data.ImageHeight) / 2,
|
||||
@@ -78,7 +85,7 @@ namespace Spectrum
|
||||
|
||||
Cv2.FindContours(mat, out var contours, out var hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxSimple);
|
||||
|
||||
var filteredContours = contours.Where(c => Cv2.ContourArea(c) >= 100).ToArray();
|
||||
var filteredContours = contours.Where(c => Cv2.ContourArea(c) >= 50).ToArray();
|
||||
|
||||
var mergedContours = MergeOverlappingContours(filteredContours);
|
||||
|
||||
@@ -161,6 +168,11 @@ namespace Spectrum
|
||||
Cv2.WaitKey(1);
|
||||
}
|
||||
}
|
||||
if (mainConfig.Data.DebugMode)
|
||||
{
|
||||
iterationCount++;
|
||||
totalTime += stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
}
|
||||
else if (mainConfig.Data.ShowDetectionWindow || mainConfig.Data.CollectData)
|
||||
{
|
||||
@@ -172,6 +184,15 @@ namespace Spectrum
|
||||
screenshot?.Dispose();
|
||||
mat.Dispose();
|
||||
drawing.Dispose();
|
||||
|
||||
if (iterationCount >= 1000 && mainConfig.Data.DebugMode)
|
||||
{
|
||||
LogManager.Log($"Processed {iterationCount} iterations in {totalTime} ms.", LogManager.LogLevel.Info);
|
||||
int fps = (int)(iterationCount * 1000 / totalTime);
|
||||
LogManager.Log($"Average FPS: {fps}", LogManager.LogLevel.Info);
|
||||
iterationCount = 0;
|
||||
totalTime = 0;
|
||||
}
|
||||
}
|
||||
else if (SystemHelper.GetAsyncKeyState((int)mainConfig.Data.MenuKey) < 0)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using ImGuiNET;
|
||||
using OpenCvSharp;
|
||||
using System.Collections.Concurrent;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
|
||||
@@ -310,6 +309,12 @@ namespace Spectrum
|
||||
VSync = _vsync;
|
||||
}
|
||||
|
||||
bool DebugMode = mainConfig.Data.DebugMode;
|
||||
if (ImGui.Checkbox("Debug Mode", ref DebugMode))
|
||||
{
|
||||
mainConfig.Data.DebugMode = DebugMode;
|
||||
}
|
||||
|
||||
if (ImGui.SliderInt("FPS Limit", ref _fpsLimit, 30, 480, "%d"))
|
||||
{
|
||||
FPSLimit = _fpsLimit;
|
||||
|
||||
Reference in New Issue
Block a user