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