Update 0.01 G

This commit is contained in:
JJ
2025-11-24 23:09:38 -05:00
parent eb7c682443
commit a83a7009ac
7 changed files with 162 additions and 65 deletions
+37 -18
View File
@@ -6,38 +6,49 @@ namespace Lua
{ {
internal static class ConfigLoader internal static class ConfigLoader
{ {
// Basic flags/settings // AA0001
public static bool debitFlag1 = false; public static bool debitFlag1 = false;
// AA0002
public static bool betaTest = false; public static bool betaTest = false;
// AA0003
public static bool ttsEnabled = true; public static bool ttsEnabled = true;
// Key codes (default values) // AA0004
public static int nextSetKey = 0x05; // XBUTTON1 public static int nextSetKey = 0x05;
public static int prevSetKey = 0x06; // XBUTTON2 // AA0005
public static int refreshKey = 0x50; // P public static int prevSetKey = 0x06;
public static int switchSideKey = 0x4D; // M // AA0006
public static int shootKey = 0x01; // Left mouse button public static int refreshKey = 0x50;
public static int altShootKey = 0x02; // Right mouse button // AA0007
public static int switchSideKey = 0x4D;
// AA0008
public static int shootKey = 0x01;
// AA0009
public static int altShootKey = 0x02;
// Favorites and user // AA0010
public static string favoriteAttackers = null; public static string favoriteAttackers = null;
// AA0011
public static string favoriteDefenders = null; public static string favoriteDefenders = null;
// AA0012
public static string userName = null; public static string userName = null;
// Jitter config // AA0013
public static bool jitterEnabled = false; public static bool jitterEnabled = false;
public static int jitterBurstTime = 1800; // milliseconds // AA0014
public static int jitterCooldown = 3000; // milliseconds public static int jitterBurstTime = 1800;
// AA0015
public static int jitterCooldown = 3000;
// Console text color // AA0016
public static ConsoleColor textColor = ConsoleColor.Magenta; public static ConsoleColor textColor = ConsoleColor.Magenta;
/// <summary> /// <summary>
/// Load defaults and then attempt to read init.config from working directory. // AA0017
/// </summary> /// </summary>
public static void LoadInitConfig() public static void LoadInitConfig()
{ {
// Reset to defaults // AA0018
debitFlag1 = false; debitFlag1 = false;
betaTest = false; betaTest = false;
ttsEnabled = true; ttsEnabled = true;
@@ -51,24 +62,28 @@ namespace Lua
SetConsoleColor(); SetConsoleColor();
// AA0019
if (!File.Exists("init.config")) return; if (!File.Exists("init.config")) return;
var lines = Helper.ReadLinesSafe("init.config"); var lines = Helper.ReadLinesSafe("init.config");
// AA0020
foreach (var raw in lines) foreach (var raw in lines)
{ {
if (string.IsNullOrWhiteSpace(raw)) continue; if (string.IsNullOrWhiteSpace(raw)) continue;
var line = raw.Trim(); var line = raw.Trim();
// Ignore comments // AA0021
if (line.StartsWith("--") || line.StartsWith("#")) continue; if (line.StartsWith("--") || line.StartsWith("#")) continue;
// AA0022
if (Helper.ParseBoolFromAssignment(line, "debitFlag1", out var b1)) if (Helper.ParseBoolFromAssignment(line, "debitFlag1", out var b1))
debitFlag1 = b1; debitFlag1 = b1;
else if (Helper.ParseBoolFromAssignment(line, "betaTest", out var b2)) else if (Helper.ParseBoolFromAssignment(line, "betaTest", out var b2))
betaTest = b2; betaTest = b2;
else if (Helper.ParseBoolFromAssignment(line, "ttsEnabled", out var b3)) else if (Helper.ParseBoolFromAssignment(line, "ttsEnabled", out var b3))
ttsEnabled = b3; ttsEnabled = b3;
// AA0023
else if (Helper.ParseIntFromAssignment(line, "nextSetKey", out var i1)) else if (Helper.ParseIntFromAssignment(line, "nextSetKey", out var i1))
nextSetKey = i1; nextSetKey = i1;
else if (Helper.ParseIntFromAssignment(line, "prevSetKey", out var i2)) else if (Helper.ParseIntFromAssignment(line, "prevSetKey", out var i2))
@@ -77,26 +92,30 @@ namespace Lua
refreshKey = i3; refreshKey = i3;
else if (Helper.ParseIntFromAssignment(line, "switchSideKey", out var i4)) else if (Helper.ParseIntFromAssignment(line, "switchSideKey", out var i4))
switchSideKey = i4; switchSideKey = i4;
// AA0024
else if (Helper.ParseStringFromAssignment(line, "favoriteAttackers", out var s1)) else if (Helper.ParseStringFromAssignment(line, "favoriteAttackers", out var s1))
favoriteAttackers = s1; favoriteAttackers = s1;
else if (Helper.ParseStringFromAssignment(line, "favoriteDefenders", out var s2)) else if (Helper.ParseStringFromAssignment(line, "favoriteDefenders", out var s2))
favoriteDefenders = s2; favoriteDefenders = s2;
else if (Helper.ParseStringFromAssignment(line, "userName", out var s3)) else if (Helper.ParseStringFromAssignment(line, "userName", out var s3))
userName = s3; userName = s3;
// AA0025
else if (Helper.ParseBoolFromAssignment(line, "jitterEnabled", out var jb)) else if (Helper.ParseBoolFromAssignment(line, "jitterEnabled", out var jb))
jitterEnabled = jb; jitterEnabled = jb;
else if (Helper.ParseIntFromAssignment(line, "jitterBurstTime", out var jbT)) else if (Helper.ParseIntFromAssignment(line, "jitterBurstTime", out var jbT))
jitterBurstTime = jbT; jitterBurstTime = jbT;
else if (Helper.ParseIntFromAssignment(line, "jitterCooldown", out var jbC)) else if (Helper.ParseIntFromAssignment(line, "jitterCooldown", out var jbC))
jitterCooldown = jbC; jitterCooldown = jbC;
// AA0026
else if (Helper.ParseConsoleColorFromAssignment(line, "textColor", out var col)) else if (Helper.ParseConsoleColorFromAssignment(line, "textColor", out var col))
textColor = col; textColor = col;
} }
// Re-apply color in case it was changed by config // AA0027
SetConsoleColor(); SetConsoleColor();
} }
// AA0028
private static void SetConsoleColor() private static void SetConsoleColor()
{ {
try try
@@ -105,7 +124,7 @@ namespace Lua
} }
catch catch
{ {
// Ignore if console doesn't support color // AA0029
} }
} }
} }
+10
View File
@@ -6,15 +6,20 @@ namespace Lithium
{ {
internal static class HotkeyHandler internal static class HotkeyHandler
{ {
// AA0041
private const int CAPSLOCK = 0x14; private const int CAPSLOCK = 0x14;
// AA0042
private static bool _nextSetHeld, _prevSetHeld, _refreshHeld, _switchSideHeld, _capsHeld; private static bool _nextSetHeld, _prevSetHeld, _refreshHeld, _switchSideHeld, _capsHeld;
// AA0043
private static MainWindow _mainWindow; private static MainWindow _mainWindow;
// AA0044
public static void Start(MainWindow window) public static void Start(MainWindow window)
{ {
_mainWindow = window; _mainWindow = window;
// AA0045
while (true) while (true)
{ {
HandleToggleCapsLock(); HandleToggleCapsLock();
@@ -26,6 +31,7 @@ namespace Lithium
} }
} }
// AA0046
private static void HandleToggleCapsLock() private static void HandleToggleCapsLock()
{ {
bool capsDown = Utils.IsPressed(CAPSLOCK); bool capsDown = Utils.IsPressed(CAPSLOCK);
@@ -37,6 +43,7 @@ namespace Lithium
if (!capsDown) _capsHeld = false; if (!capsDown) _capsHeld = false;
} }
// AA0047
private static void HandleNextSet() private static void HandleNextSet()
{ {
if (Utils.IsPressed(ConfigLoader.nextSetKey) && !_nextSetHeld) if (Utils.IsPressed(ConfigLoader.nextSetKey) && !_nextSetHeld)
@@ -50,6 +57,7 @@ namespace Lithium
} }
} }
// AA0048
private static void HandlePrevSet() private static void HandlePrevSet()
{ {
if (Utils.IsPressed(ConfigLoader.prevSetKey) && !_prevSetHeld) if (Utils.IsPressed(ConfigLoader.prevSetKey) && !_prevSetHeld)
@@ -63,6 +71,7 @@ namespace Lithium
} }
} }
// AA0049
private static void HandleRefresh() private static void HandleRefresh()
{ {
if (Utils.IsPressed(ConfigLoader.refreshKey) && !_refreshHeld) if (Utils.IsPressed(ConfigLoader.refreshKey) && !_refreshHeld)
@@ -76,6 +85,7 @@ namespace Lithium
} }
} }
// AA0050
private static void HandleSwitchSide() private static void HandleSwitchSide()
{ {
if (Utils.IsPressed(ConfigLoader.switchSideKey) && !_switchSideHeld) if (Utils.IsPressed(ConfigLoader.switchSideKey) && !_switchSideHeld)
+41 -9
View File
@@ -14,12 +14,17 @@ namespace Lithium
{ {
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
// AA0111
private bool customSetEnabled = false; private bool customSetEnabled = false;
// AA0112
private bool recoilEnabled = true; private bool recoilEnabled = true;
// AA0113
private DateTime nextSetAllowed = DateTime.MinValue; private DateTime nextSetAllowed = DateTime.MinValue;
// AA0114
private DateTime prevSetAllowed = DateTime.MinValue; private DateTime prevSetAllowed = DateTime.MinValue;
// AA0115
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
@@ -32,17 +37,19 @@ namespace Lithium
$"Loaded Operators | Current Set: {OperatorSets.CurrentSet} | Side: {(OperatorSets.onAttackers ? "Attackers" : "Defenders")}" $"Loaded Operators | Current Set: {OperatorSets.CurrentSet} | Side: {(OperatorSets.onAttackers ? "Attackers" : "Defenders")}"
); );
// AA0116
Browser.Source = !string.IsNullOrEmpty(OperatorSets.ConfigExportUrl) Browser.Source = !string.IsNullOrEmpty(OperatorSets.ConfigExportUrl)
? new Uri(OperatorSets.ConfigExportUrl) ? new Uri(OperatorSets.ConfigExportUrl)
: new Uri("https://jj.giggity.gay/exindex.html"); : new Uri("https://jj.giggity.gay/exindex.html");
// Load settings into UI // AA0117
LoadSettingsToUI(); LoadSettingsToUI();
StartThread(HotkeyLoop); StartThread(HotkeyLoop);
StartThread(RecoilLoop); StartThread(RecoilLoop);
} }
// AA0118
private void StartThread(ThreadStart action) private void StartThread(ThreadStart action)
{ {
var t = new Thread(action) var t = new Thread(action)
@@ -52,40 +59,42 @@ namespace Lithium
t.Start(); t.Start();
} }
// AA0119
private void RecoilLoop() => RecoilEngine.Start(this); private void RecoilLoop() => RecoilEngine.Start(this);
// AA0120
private void HotkeyLoop() => HotkeyHandler.Start(this); private void HotkeyLoop() => HotkeyHandler.Start(this);
// ============================================================ // ============================================================
// SETTINGS MANAGEMENT // SETTINGS MANAGEMENT
// ============================================================ // ============================================================
// AA0121
private void LoadSettingsToUI() private void LoadSettingsToUI()
{ {
try try
{ {
// Basic settings // AA0122
DebitFlagCheckBox.IsChecked = ConfigLoader.debitFlag1; DebitFlagCheckBox.IsChecked = ConfigLoader.debitFlag1;
BetaTestCheckBox.IsChecked = ConfigLoader.betaTest; BetaTestCheckBox.IsChecked = ConfigLoader.betaTest;
TtsEnabledCheckBox.IsChecked = ConfigLoader.ttsEnabled; TtsEnabledCheckBox.IsChecked = ConfigLoader.ttsEnabled;
JitterEnabledCheckBox.IsChecked = ConfigLoader.jitterEnabled; JitterEnabledCheckBox.IsChecked = ConfigLoader.jitterEnabled;
// Key bindings // AA0123
NextSetKeyTextBox.Text = $"0x{ConfigLoader.nextSetKey:X2}"; NextSetKeyTextBox.Text = $"0x{ConfigLoader.nextSetKey:X2}";
PrevSetKeyTextBox.Text = $"0x{ConfigLoader.prevSetKey:X2}"; PrevSetKeyTextBox.Text = $"0x{ConfigLoader.prevSetKey:X2}";
RefreshKeyTextBox.Text = $"0x{ConfigLoader.refreshKey:X2}"; RefreshKeyTextBox.Text = $"0x{ConfigLoader.refreshKey:X2}";
SwitchSideKeyTextBox.Text = $"0x{ConfigLoader.switchSideKey:X2}"; SwitchSideKeyTextBox.Text = $"0x{ConfigLoader.switchSideKey:X2}";
// Jitter settings // AA0124
JitterBurstTimeTextBox.Text = ConfigLoader.jitterBurstTime.ToString(); JitterBurstTimeTextBox.Text = ConfigLoader.jitterBurstTime.ToString();
JitterCooldownTextBox.Text = ConfigLoader.jitterCooldown.ToString(); JitterCooldownTextBox.Text = ConfigLoader.jitterCooldown.ToString();
// User & favorites // AA0125
UserNameTextBox.Text = ConfigLoader.userName ?? ""; UserNameTextBox.Text = ConfigLoader.userName ?? "";
FavoriteAttackersTextBox.Text = ConfigLoader.favoriteAttackers ?? ""; FavoriteAttackersTextBox.Text = ConfigLoader.favoriteAttackers ?? "";
FavoriteDefendersTextBox.Text = ConfigLoader.favoriteDefenders ?? ""; FavoriteDefendersTextBox.Text = ConfigLoader.favoriteDefenders ?? "";
// Console color // AA0126
foreach (ComboBoxItem item in TextColorComboBox.Items) foreach (ComboBoxItem item in TextColorComboBox.Items)
{ {
if (item.Content.ToString() == ConfigLoader.textColor.ToString()) if (item.Content.ToString() == ConfigLoader.textColor.ToString())
@@ -100,11 +109,13 @@ namespace Lithium
} }
catch (Exception ex) catch (Exception ex)
{ {
// AA0127
SettingsStatusText.Text = $"Error loading settings: {ex.Message}"; SettingsStatusText.Text = $"Error loading settings: {ex.Message}";
SettingsStatusText.Foreground = new SolidColorBrush(Colors.Red); SettingsStatusText.Foreground = new SolidColorBrush(Colors.Red);
} }
} }
// AA0128
private void SaveSettings_Click(object sender, RoutedEventArgs e) private void SaveSettings_Click(object sender, RoutedEventArgs e)
{ {
try try
@@ -112,7 +123,7 @@ namespace Lithium
string configContent = GenerateConfigContent(); string configContent = GenerateConfigContent();
File.WriteAllText("init.config", configContent); File.WriteAllText("init.config", configContent);
// Reload configuration // AA0129
ConfigLoader.LoadInitConfig(); ConfigLoader.LoadInitConfig();
LoadSettingsToUI(); LoadSettingsToUI();
@@ -122,11 +133,13 @@ namespace Lithium
} }
catch (Exception ex) catch (Exception ex)
{ {
// AA0130
SettingsStatusText.Text = $"Error saving settings: {ex.Message}"; SettingsStatusText.Text = $"Error saving settings: {ex.Message}";
SettingsStatusText.Foreground = new SolidColorBrush(Colors.Red); SettingsStatusText.Foreground = new SolidColorBrush(Colors.Red);
} }
} }
// AA0131
private void ReloadSettings_Click(object sender, RoutedEventArgs e) private void ReloadSettings_Click(object sender, RoutedEventArgs e)
{ {
ConfigLoader.LoadInitConfig(); ConfigLoader.LoadInitConfig();
@@ -136,9 +149,10 @@ namespace Lithium
AppendConsole("Settings reloaded from init.config"); AppendConsole("Settings reloaded from init.config");
} }
// AA0132
private void ResetSettings_Click(object sender, RoutedEventArgs e) private void ResetSettings_Click(object sender, RoutedEventArgs e)
{ {
// Reset to defaults // AA0133
ConfigLoader.debitFlag1 = false; ConfigLoader.debitFlag1 = false;
ConfigLoader.betaTest = false; ConfigLoader.betaTest = false;
ConfigLoader.ttsEnabled = true; ConfigLoader.ttsEnabled = true;
@@ -159,6 +173,7 @@ namespace Lithium
SettingsStatusText.Foreground = new SolidColorBrush(Colors.Yellow); SettingsStatusText.Foreground = new SolidColorBrush(Colors.Yellow);
} }
// AA0134
private string GenerateConfigContent() private string GenerateConfigContent()
{ {
return $@"-- Lithium Configuration File return $@"-- Lithium Configuration File
@@ -189,6 +204,7 @@ favoriteDefenders = ""{FavoriteDefendersTextBox.Text}""
textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString() ?? "Magenta"}"; textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString() ?? "Magenta"}";
} }
// AA0135
private int ParseKeyCode(string text) private int ParseKeyCode(string text)
{ {
if (text.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) if (text.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
@@ -201,14 +217,17 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
// ============================================================ // ============================================================
// HANDLERS CALLED BY HOTKEYHANDLER // HANDLERS CALLED BY HOTKEYHANDLER
// ============================================================ // ============================================================
// AA0136
public void SetRecoilEnabled(bool enabled) public void SetRecoilEnabled(bool enabled)
{ {
recoilEnabled = enabled; recoilEnabled = enabled;
AppendConsole(enabled ? "Recoil Enabled" : "Recoil Disabled"); AppendConsole(enabled ? "Recoil Enabled" : "Recoil Disabled");
} }
// AA0137
public bool IsRecoilEnabled => recoilEnabled; public bool IsRecoilEnabled => recoilEnabled;
// AA0138
public void HandleNextSet() public void HandleNextSet()
{ {
if (DateTime.Now < nextSetAllowed) return; if (DateTime.Now < nextSetAllowed) return;
@@ -220,6 +239,7 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
Utils.SafeSpeak(OperatorSets.CurrentSet); Utils.SafeSpeak(OperatorSets.CurrentSet);
} }
// AA0139
public void HandlePrevSet() public void HandlePrevSet()
{ {
if (DateTime.Now < prevSetAllowed) return; if (DateTime.Now < prevSetAllowed) return;
@@ -231,6 +251,7 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
Utils.SafeSpeak(OperatorSets.CurrentSet); Utils.SafeSpeak(OperatorSets.CurrentSet);
} }
// AA0140
public void HandleRefresh() public void HandleRefresh()
{ {
string oldSet = OperatorSets.CurrentSet; string oldSet = OperatorSets.CurrentSet;
@@ -248,6 +269,7 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
Utils.SafeSpeak(OperatorSets.CurrentSet); Utils.SafeSpeak(OperatorSets.CurrentSet);
} }
// AA0141
public void HandleSwitchSide() public void HandleSwitchSide()
{ {
OperatorSets.SwitchSide(); OperatorSets.SwitchSide();
@@ -259,6 +281,7 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
// ============================================================ // ============================================================
// UI CONSOLE // UI CONSOLE
// ============================================================ // ============================================================
// AA0142
public void AppendConsole(string msg) public void AppendConsole(string msg)
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
@@ -269,6 +292,7 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
}); });
} }
// AA0143
public void UpdateCustomSetConsole(string msg) public void UpdateCustomSetConsole(string msg)
{ {
Dispatcher.Invoke(() => CustomSetConsole.Text = msg); Dispatcher.Invoke(() => CustomSetConsole.Text = msg);
@@ -277,12 +301,14 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
// ============================================================ // ============================================================
// CUSTOM SET BUILDER // CUSTOM SET BUILDER
// ============================================================ // ============================================================
// AA0144
private void ToggleCustomSet_Click(object sender, RoutedEventArgs e) private void ToggleCustomSet_Click(object sender, RoutedEventArgs e)
{ {
customSetEnabled = !customSetEnabled; customSetEnabled = !customSetEnabled;
UpdateCustomSetConsole(customSetEnabled ? "Set is ON" : "Set is OFF"); UpdateCustomSetConsole(customSetEnabled ? "Set is ON" : "Set is OFF");
} }
// AA0145
private async void PublishSet_Click(object sender, RoutedEventArgs e) private async void PublishSet_Click(object sender, RoutedEventArgs e)
{ {
string name = OperatorNameTextBox.Text.Trim(); string name = OperatorNameTextBox.Text.Trim();
@@ -331,6 +357,7 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
} }
} }
// AA0146
private void SaveSet_Click(object sender, RoutedEventArgs e) private void SaveSet_Click(object sender, RoutedEventArgs e)
{ {
try try
@@ -348,6 +375,7 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
} }
} }
// AA0147
private void LoadSet_Click(object sender, RoutedEventArgs e) private void LoadSet_Click(object sender, RoutedEventArgs e)
{ {
try try
@@ -382,18 +410,22 @@ textColor = {((ComboBoxItem)TextColorComboBox.SelectedItem)?.Content.ToString()
// ============================================================ // ============================================================
// WINDOW CONTROLS // WINDOW CONTROLS
// ============================================================ // ============================================================
// AA0148
private void TitleBar_MouseDown(object sender, MouseButtonEventArgs e) private void TitleBar_MouseDown(object sender, MouseButtonEventArgs e)
{ {
if (e.ChangedButton == MouseButton.Left) if (e.ChangedButton == MouseButton.Left)
DragMove(); DragMove();
} }
// AA0149
private void Minimize_Click(object sender, RoutedEventArgs e) => private void Minimize_Click(object sender, RoutedEventArgs e) =>
WindowState = WindowState.Minimized; WindowState = WindowState.Minimized;
// AA0150
private void MaximizeRestore_Click(object sender, RoutedEventArgs e) => private void MaximizeRestore_Click(object sender, RoutedEventArgs e) =>
WindowState = WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal; WindowState = WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
// AA0151
private void Close_Click(object sender, RoutedEventArgs e) => Close(); private void Close_Click(object sender, RoutedEventArgs e) => Close();
} }
} }
+27 -15
View File
@@ -7,35 +7,43 @@ namespace Lua
{ {
static class OperatorSets static class OperatorSets
{ {
// Data tables // AA0051
public static Dictionary<string, (double recoilX, double recoilY)> attackers = public static Dictionary<string, (double recoilX, double recoilY)> attackers =
new Dictionary<string, (double, double)>(StringComparer.OrdinalIgnoreCase); new Dictionary<string, (double, double)>(StringComparer.OrdinalIgnoreCase);
// AA0052
public static Dictionary<string, (double recoilX, double recoilY)> defenders = public static Dictionary<string, (double recoilX, double recoilY)> defenders =
new Dictionary<string, (double, double)>(StringComparer.OrdinalIgnoreCase); new Dictionary<string, (double, double)>(StringComparer.OrdinalIgnoreCase);
// AA0053
public static Dictionary<string, (double recoilX, double recoilY)> mergedSets = public static Dictionary<string, (double recoilX, double recoilY)> mergedSets =
new Dictionary<string, (double, double)>(StringComparer.OrdinalIgnoreCase); new Dictionary<string, (double, double)>(StringComparer.OrdinalIgnoreCase);
// AA0054
public static List<string> attackerNames = new List<string>(); public static List<string> attackerNames = new List<string>();
// AA0055
public static List<string> defenderNames = new List<string>(); public static List<string> defenderNames = new List<string>();
// AA0056
public static List<string> setNames = new List<string>(); public static List<string> setNames = new List<string>();
// AA0057
public static int currentSetIndex = 0; public static int currentSetIndex = 0;
// AA0058
public static bool onAttackers = true; public static bool onAttackers = true;
// Online config URL // AA0059
private static string OnlineConfigUrl => private static string OnlineConfigUrl =>
string.IsNullOrEmpty(ConfigLoader.userName) string.IsNullOrEmpty(ConfigLoader.userName)
? null ? null
: $"https://jj.giggity.gay/api/config/export?name={Uri.EscapeDataString(ConfigLoader.userName)}"; : $"https://jj.giggity.gay/api/config/export?name={Uri.EscapeDataString(ConfigLoader.userName)}";
// AA0060
public static string ConfigExportUrl => public static string ConfigExportUrl =>
string.IsNullOrEmpty(ConfigLoader.userName) string.IsNullOrEmpty(ConfigLoader.userName)
? null ? null
: $"https://jj.giggity.gay/exindex.html?name={Uri.EscapeDataString(ConfigLoader.userName)}"; : $"https://jj.giggity.gay/exindex.html?name={Uri.EscapeDataString(ConfigLoader.userName)}";
// Current set + current operator // AA0061
public static string CurrentSet public static string CurrentSet
{ {
get get
@@ -46,7 +54,9 @@ namespace Lua
} }
} }
// AA0062
private static string _currentOperator = ""; private static string _currentOperator = "";
// AA0063
public static string CurrentOperator public static string CurrentOperator
{ {
get get
@@ -54,7 +64,7 @@ namespace Lua
if (!string.IsNullOrWhiteSpace(_currentOperator) && mergedSets.ContainsKey(_currentOperator)) if (!string.IsNullOrWhiteSpace(_currentOperator) && mergedSets.ContainsKey(_currentOperator))
return _currentOperator; return _currentOperator;
return CurrentSet; // Fallback return CurrentSet;
} }
set set
{ {
@@ -63,7 +73,7 @@ namespace Lua
} }
} }
// Get current recoil // AA0064
public static (double recoilX, double recoilY) GetCurrentRecoil() public static (double recoilX, double recoilY) GetCurrentRecoil()
{ {
string op = CurrentOperator; string op = CurrentOperator;
@@ -77,7 +87,7 @@ namespace Lua
return (0, 0); return (0, 0);
} }
// Load config // AA0065
public static void LoadOperatorSets(bool allowOnlineFetch = true) public static void LoadOperatorSets(bool allowOnlineFetch = true)
{ {
attackers.Clear(); attackers.Clear();
@@ -87,7 +97,7 @@ namespace Lua
var allLines = new List<string>(); var allLines = new List<string>();
// Online fetch // AA0066
if (allowOnlineFetch && !string.IsNullOrEmpty(OnlineConfigUrl)) if (allowOnlineFetch && !string.IsNullOrEmpty(OnlineConfigUrl))
{ {
try try
@@ -99,10 +109,10 @@ namespace Lua
allLines.AddRange(txt.Split('\n')); allLines.AddRange(txt.Split('\n'));
} }
} }
catch { /* Ignore online fetch errors */ } catch { /* AA0067 */ }
} }
// Local config // AA0068
var local = Helper.ReadLinesSafe("config.txt"); var local = Helper.ReadLinesSafe("config.txt");
if (local != null && local.Length > 0) if (local != null && local.Length > 0)
allLines.AddRange(local); allLines.AddRange(local);
@@ -110,7 +120,7 @@ namespace Lua
bool inAttackers = false; bool inAttackers = false;
bool inDefenders = false; bool inDefenders = false;
// Parse lines // AA0069
foreach (var raw in allLines) foreach (var raw in allLines)
{ {
if (string.IsNullOrWhiteSpace(raw)) continue; if (string.IsNullOrWhiteSpace(raw)) continue;
@@ -161,7 +171,7 @@ namespace Lua
CurrentOperator = CurrentSet; CurrentOperator = CurrentSet;
} }
// Merge sets // AA0070
public static void MergeSets() public static void MergeSets()
{ {
if (ConfigLoader.betaTest) if (ConfigLoader.betaTest)
@@ -189,7 +199,7 @@ namespace Lua
currentSetIndex = Helper.SafeClampIndex(currentSetIndex, setNames.Count); currentSetIndex = Helper.SafeClampIndex(currentSetIndex, setNames.Count);
} }
// Restore set // AA0071
public static void RestoreSet(string oldSet) public static void RestoreSet(string oldSet)
{ {
if (setNames.Count == 0) if (setNames.Count == 0)
@@ -203,7 +213,7 @@ namespace Lua
CurrentOperator = CurrentSet; CurrentOperator = CurrentSet;
} }
// Switch side // AA0072
public static void SwitchSide() public static void SwitchSide()
{ {
if (ConfigLoader.betaTest) return; if (ConfigLoader.betaTest) return;
@@ -213,7 +223,7 @@ namespace Lua
RestoreFavorites(); RestoreFavorites();
} }
// Cycling // AA0073
public static void NextSet() public static void NextSet()
{ {
if (setNames.Count == 0) return; if (setNames.Count == 0) return;
@@ -222,6 +232,7 @@ namespace Lua
CurrentOperator = CurrentSet; CurrentOperator = CurrentSet;
} }
// AA0074
public static void PreviousSet() public static void PreviousSet()
{ {
if (setNames.Count == 0) return; if (setNames.Count == 0) return;
@@ -230,6 +241,7 @@ namespace Lua
CurrentOperator = CurrentSet; CurrentOperator = CurrentSet;
} }
// AA0075
public static void SetCurrentSet(string name) public static void SetCurrentSet(string name)
{ {
if (setNames == null || setNames.Count == 0) return; if (setNames == null || setNames.Count == 0) return;
@@ -242,7 +254,7 @@ namespace Lua
} }
} }
// Favorites // AA0076
private static void RestoreFavorites() private static void RestoreFavorites()
{ {
if (setNames.Count == 0) if (setNames.Count == 0)
+15 -10
View File
@@ -6,16 +6,25 @@ namespace Lua
{ {
internal static class RecoilEngine internal static class RecoilEngine
{ {
// AA0077
private const int VK_LBUTTON = 0x01; private const int VK_LBUTTON = 0x01;
// AA0078
private const int VK_RBUTTON = 0x02; private const int VK_RBUTTON = 0x02;
// AA0079
private static readonly Random _rng = new Random(); private static readonly Random _rng = new Random();
// AA0080
private static bool _jitterActive = false; private static bool _jitterActive = false;
// AA0081
private static int _jitterStart = 0; private static int _jitterStart = 0;
// AA0082
private static int _lastJitterEnd = 0; private static int _lastJitterEnd = 0;
// AA0083
private static double _remainderX, _remainderY; private static double _remainderX, _remainderY;
// AA0084
private static double _jitterMultiplierX, _jitterMultiplierY; private static double _jitterMultiplierX, _jitterMultiplierY;
// AA0085
public static void Start(MainWindow window) public static void Start(MainWindow window)
{ {
while (true) while (true)
@@ -30,13 +39,11 @@ namespace Lua
_jitterActive = false; _jitterActive = false;
} }
Thread.Sleep(2); Thread.Sleep(2);
} }
} }
// AA0086
private static void HandleRecoilTick() private static void HandleRecoilTick()
{ {
if (!Utils.IsPressed(VK_LBUTTON)) return; if (!Utils.IsPressed(VK_LBUTTON)) return;
@@ -51,6 +58,7 @@ namespace Lua
ApplyRecoil(recoil); ApplyRecoil(recoil);
} }
// AA0087
private static void HandleJitter(int now) private static void HandleJitter(int now)
{ {
if (!ConfigLoader.jitterEnabled) return; if (!ConfigLoader.jitterEnabled) return;
@@ -60,8 +68,8 @@ namespace Lua
_jitterActive = true; _jitterActive = true;
_jitterStart = now; _jitterStart = now;
// Set small random jitter multipliers // AA0088
_jitterMultiplierX = (_rng.NextDouble() - 0.5) * 0.2; // ±0.1 _jitterMultiplierX = (_rng.NextDouble() - 0.5) * 0.2;
_jitterMultiplierY = (_rng.NextDouble() - 0.5) * 0.2; _jitterMultiplierY = (_rng.NextDouble() - 0.5) * 0.2;
} }
@@ -73,24 +81,22 @@ namespace Lua
} }
} }
// AA0089
private static void ApplyRecoil((double recoilX, double recoilY) recoil) private static void ApplyRecoil((double recoilX, double recoilY) recoil)
{ {
// Apply base recoil first
double moveX = recoil.recoilX; double moveX = recoil.recoilX;
double moveY = recoil.recoilY; double moveY = recoil.recoilY;
// Apply optional multiplier for jitter
moveX += recoil.recoilX * _jitterMultiplierX; moveX += recoil.recoilX * _jitterMultiplierX;
moveY += recoil.recoilY * _jitterMultiplierY; moveY += recoil.recoilY * _jitterMultiplierY;
// Apply any global scaling // AA0090
if (ConfigLoader.debitFlag1) if (ConfigLoader.debitFlag1)
{ {
moveX *= 1.282; moveX *= 1.282;
moveY *= 1.351; moveY *= 1.351;
} }
// Add remainder for precision
moveX += _remainderX; moveX += _remainderX;
moveY += _remainderY; moveY += _remainderY;
@@ -102,6 +108,5 @@ namespace Lua
Utils.MoveMouse(ix, iy); Utils.MoveMouse(ix, iy);
} }
} }
} }
+21 -3
View File
@@ -7,32 +7,45 @@ namespace Lua
{ {
static class Utils static class Utils
{ {
// AA0091
public static readonly SpeechSynthesizer Tts = new SpeechSynthesizer(); public static readonly SpeechSynthesizer Tts = new SpeechSynthesizer();
// AA0092
private static readonly object TtsLock = new object(); private static readonly object TtsLock = new object();
// AA0093
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern short GetAsyncKeyState(int vKey); public static extern short GetAsyncKeyState(int vKey);
// AA0094
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern short GetKeyState(int keyCode); public static extern short GetKeyState(int keyCode);
// AA0095
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, UIntPtr dwExtraInfo); public static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, UIntPtr dwExtraInfo);
// AA0096
public const uint MOUSEEVENTF_MOVE = 0x0001; public const uint MOUSEEVENTF_MOVE = 0x0001;
// AA0097
private const int VK_CAPITAL = 0x14; private const int VK_CAPITAL = 0x14;
// AA0098
private static bool _previousCapsState; private static bool _previousCapsState;
// AA0099
public static void InitializeCapsState() public static void InitializeCapsState()
{ {
_previousCapsState = IsCapsLockOn(); _previousCapsState = IsCapsLockOn();
} }
// AA0100
public static bool IsPressed(int vKey) => (GetAsyncKeyState(vKey) & 0x8000) != 0; public static bool IsPressed(int vKey) => (GetAsyncKeyState(vKey) & 0x8000) != 0;
// AA0101
public static bool IsCapsLockOn() => (GetKeyState(VK_CAPITAL) & 0x0001) != 0; public static bool IsCapsLockOn() => (GetKeyState(VK_CAPITAL) & 0x0001) != 0;
// AA0102
public static void MoveMouse(int dx, int dy) => mouse_event(MOUSEEVENTF_MOVE, dx, dy, 0, UIntPtr.Zero); public static void MoveMouse(int dx, int dy) => mouse_event(MOUSEEVENTF_MOVE, dx, dy, 0, UIntPtr.Zero);
// AA0103
public static void SafeSpeak(string text) public static void SafeSpeak(string text)
{ {
if (!ConfigLoader.ttsEnabled) return; if (!ConfigLoader.ttsEnabled) return;
@@ -44,10 +57,11 @@ namespace Lua
Tts.SpeakAsyncCancelAll(); Tts.SpeakAsyncCancelAll();
Tts.SpeakAsync(text); Tts.SpeakAsync(text);
} }
catch { /* Ignore TTS errors */ } catch { /* AA0104 */ }
} }
} }
// AA0105
public static void ShowCapsLockStatus() public static void ShowCapsLockStatus()
{ {
Console.WriteLine(IsCapsLockOn() Console.WriteLine(IsCapsLockOn()
@@ -55,6 +69,7 @@ namespace Lua
: $"✅ Recoil Control: ON (CapsLock OFF) | Current Set: {OperatorSets.CurrentSet}"); : $"✅ Recoil Control: ON (CapsLock OFF) | Current Set: {OperatorSets.CurrentSet}");
} }
// AA0106
public static void CheckCapsLockChange() public static void CheckCapsLockChange()
{ {
bool caps = IsCapsLockOn(); bool caps = IsCapsLockOn();
@@ -65,12 +80,14 @@ namespace Lua
} }
} }
// AA0107
public static void DisplayCurrentOperator(string action) public static void DisplayCurrentOperator(string action)
{ {
Console.WriteLine($"🎮 {action} | Current Operator: {OperatorSets.CurrentSet}"); Console.WriteLine($"🎮 {action} | Current Operator: {OperatorSets.CurrentSet}");
SafeSpeak(OperatorSets.CurrentSet); SafeSpeak(OperatorSets.CurrentSet);
} }
// AA0108
public static string ModeHeader() public static string ModeHeader()
{ {
return ConfigLoader.betaTest return ConfigLoader.betaTest
@@ -78,12 +95,13 @@ namespace Lua
: $"🚀 Standard Mode Enabled | Current Set: {OperatorSets.CurrentSet}"; : $"🚀 Standard Mode Enabled | Current Set: {OperatorSets.CurrentSet}";
} }
// AA0109
public static void AutoClearIfNearBottom() public static void AutoClearIfNearBottom()
{ {
try try
{ {
int current = Console.CursorTop; int current = Console.CursorTop;
int limit = Console.WindowHeight - 2; // Keep 2-row buffer int limit = Console.WindowHeight - 2;
if (current >= limit) if (current >= limit)
{ {
@@ -94,7 +112,7 @@ namespace Lua
} }
catch catch
{ {
// Ignore if console unavailable // AA0110
} }
} }
} }
+11 -10
View File
@@ -8,7 +8,7 @@ namespace Lua
static class Helper static class Helper
{ {
/// <summary> /// <summary>
/// Safely read lines from a file; returns empty array if missing or unreadable. // AA0030
/// </summary> /// </summary>
public static string[] ReadLinesSafe(string path) public static string[] ReadLinesSafe(string path)
{ {
@@ -19,13 +19,13 @@ namespace Lua
} }
catch catch
{ {
// AA0031
return Array.Empty<string>(); return Array.Empty<string>();
} }
} }
/// <summary> /// <summary>
/// Parse lines of the form: key = value (case-insensitive key). Returns true when parsed. // AA0032
/// For boolean values (true/false).
/// </summary> /// </summary>
public static bool ParseBoolFromAssignment(string line, string key, out bool result) public static bool ParseBoolFromAssignment(string line, string key, out bool result)
{ {
@@ -48,10 +48,11 @@ namespace Lua
return true; return true;
} }
// Attempt to parse other truthy values // AA0033
return bool.TryParse(rhs, out result); return bool.TryParse(rhs, out result);
} }
// AA0034
public static bool ParseIntFromAssignment(string line, string key, out int result) public static bool ParseIntFromAssignment(string line, string key, out int result)
{ {
result = 0; result = 0;
@@ -65,6 +66,7 @@ namespace Lua
return int.TryParse(rhs, NumberStyles.Integer, CultureInfo.InvariantCulture, out result); return int.TryParse(rhs, NumberStyles.Integer, CultureInfo.InvariantCulture, out result);
} }
// AA0035
public static bool ParseStringFromAssignment(string line, string key, out string result) public static bool ParseStringFromAssignment(string line, string key, out string result)
{ {
result = null; result = null;
@@ -76,7 +78,7 @@ namespace Lua
result = line.Substring(idx + 1).Trim(); result = line.Substring(idx + 1).Trim();
// Strip surrounding quotes if present // AA0036
if ((result.StartsWith("\"") && result.EndsWith("\"")) || if ((result.StartsWith("\"") && result.EndsWith("\"")) ||
(result.StartsWith("'") && result.EndsWith("'"))) (result.StartsWith("'") && result.EndsWith("'")))
{ {
@@ -85,6 +87,7 @@ namespace Lua
return true; return true;
} }
// AA0037
public static bool ParseConsoleColorFromAssignment(string line, string key, out ConsoleColor color) public static bool ParseConsoleColorFromAssignment(string line, string key, out ConsoleColor color)
{ {
color = ConsoleColor.White; color = ConsoleColor.White;
@@ -93,9 +96,7 @@ namespace Lua
} }
/// <summary> /// <summary>
/// Parse a recoil definition line. Returns name and double values using InvariantCulture. // AA0038
/// Matches patterns like:
/// ["Name"] = { recoilX = 1.23, recoilY = -4.56 }
/// </summary> /// </summary>
public static bool TryParseRecoilLine(string line, out string name, out double recoilX, out double recoilY) public static bool TryParseRecoilLine(string line, out string name, out double recoilX, out double recoilY)
{ {
@@ -103,7 +104,7 @@ namespace Lua
recoilX = 0; recoilX = 0;
recoilY = 0; recoilY = 0;
// Regex to capture "Name" and two numbers // AA0039
var pattern = @"\[\s*[""'](.+?)[""']\s*\]\s*=\s*\{\s*recoilX\s*=\s*([-\d\.eE]+)\s*,\s*recoilY\s*=\s*([-\d\.eE]+)\s*\}"; var pattern = @"\[\s*[""'](.+?)[""']\s*\]\s*=\s*\{\s*recoilX\s*=\s*([-\d\.eE]+)\s*,\s*recoilY\s*=\s*([-\d\.eE]+)\s*\}";
var match = Regex.Match(line, pattern, RegexOptions.IgnoreCase); var match = Regex.Match(line, pattern, RegexOptions.IgnoreCase);
if (!match.Success) return false; if (!match.Success) return false;
@@ -114,7 +115,7 @@ namespace Lua
} }
/// <summary> /// <summary>
/// Ensure index is valid for a list of given size (0..size-1). If size==0 returns 0. // AA0040
/// </summary> /// </summary>
public static int SafeClampIndex(int idx, int size) public static int SafeClampIndex(int idx, int size)
{ {