From 5a9e23147b2986eedaa2d5cde142770b30693eaa Mon Sep 17 00:00:00 2001 From: JJ Date: Fri, 5 Dec 2025 23:50:24 -0500 Subject: [PATCH] . --- Lithium.sln | 8 +++++- Lithium/A1/App.xaml.cs | 8 +----- Lithium/ConfigLoader.cs | 1 - Lithium/HotkeyHandler.cs | 1 - Lithium/Lithium.csproj | 20 ++++++++++++++ Lithium/OperatorSets.cs | 44 ++++++++++++++++++++++++++---- Lithium/Properties/AssemblyInfo.cs | 2 -- Lithium/Utils.cs | 1 - Lithium/helper.cs | 2 +- 9 files changed, 68 insertions(+), 19 deletions(-) diff --git a/Lithium.sln b/Lithium.sln index bea27fd..7507644 100644 --- a/Lithium.sln +++ b/Lithium.sln @@ -1,20 +1,26 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.14.36408.4 d17.14 +VisualStudioVersion = 17.14.36408.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lithium", "Lithium\Lithium.csproj", "{71516142-7D3E-46A1-A6EC-E242CD128DB1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {71516142-7D3E-46A1-A6EC-E242CD128DB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {71516142-7D3E-46A1-A6EC-E242CD128DB1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71516142-7D3E-46A1-A6EC-E242CD128DB1}.Debug|x64.ActiveCfg = Debug|x64 + {71516142-7D3E-46A1-A6EC-E242CD128DB1}.Debug|x64.Build.0 = Debug|x64 {71516142-7D3E-46A1-A6EC-E242CD128DB1}.Release|Any CPU.ActiveCfg = Release|Any CPU {71516142-7D3E-46A1-A6EC-E242CD128DB1}.Release|Any CPU.Build.0 = Release|Any CPU + {71516142-7D3E-46A1-A6EC-E242CD128DB1}.Release|x64.ActiveCfg = Release|x64 + {71516142-7D3E-46A1-A6EC-E242CD128DB1}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Lithium/A1/App.xaml.cs b/Lithium/A1/App.xaml.cs index 554d883..3ae3e5d 100644 --- a/Lithium/A1/App.xaml.cs +++ b/Lithium/A1/App.xaml.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; namespace Lithium { diff --git a/Lithium/ConfigLoader.cs b/Lithium/ConfigLoader.cs index 3b269f3..f80d2ce 100644 --- a/Lithium/ConfigLoader.cs +++ b/Lithium/ConfigLoader.cs @@ -1,5 +1,4 @@ using System; -using System.Globalization; using System.IO; namespace Lua diff --git a/Lithium/HotkeyHandler.cs b/Lithium/HotkeyHandler.cs index 9980c50..3363126 100644 --- a/Lithium/HotkeyHandler.cs +++ b/Lithium/HotkeyHandler.cs @@ -1,5 +1,4 @@ using Lua; -using System; using System.Threading; namespace Lithium diff --git a/Lithium/Lithium.csproj b/Lithium/Lithium.csproj index bc0b783..4323937 100644 --- a/Lithium/Lithium.csproj +++ b/Lithium/Lithium.csproj @@ -54,6 +54,26 @@ A1\a23ae8c4c6863364165637fb70679eb3.ico + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + true + ..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll diff --git a/Lithium/OperatorSets.cs b/Lithium/OperatorSets.cs index 7ef3dc1..97a14c1 100644 --- a/Lithium/OperatorSets.cs +++ b/Lithium/OperatorSets.cs @@ -31,6 +31,16 @@ namespace Lua // AA0058 public static bool onAttackers = true; + private static string CacheDirectory => + System.IO.Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + "coax" + ); + + private static string CacheFile => + System.IO.Path.Combine(CacheDirectory, "config_cache.txt"); + + // AA0059 private static string OnlineConfigUrl => string.IsNullOrEmpty(ConfigLoader.userName) @@ -96,8 +106,12 @@ namespace Lua defenderNames.Clear(); var allLines = new List(); + bool loadedOnline = false; - // AA0066 + // Ensure coax folder exists + try { System.IO.Directory.CreateDirectory(CacheDirectory); } catch { } + + // Try loading from online source if (allowOnlineFetch && !string.IsNullOrEmpty(OnlineConfigUrl)) { try @@ -105,14 +119,33 @@ namespace Lua using (var client = new HttpClient()) { string txt = client.GetStringAsync(OnlineConfigUrl).Result; + if (!string.IsNullOrWhiteSpace(txt)) + { allLines.AddRange(txt.Split('\n')); + + // Save cache file in per-user coax folder + System.IO.File.WriteAllText(CacheFile, txt); + + loadedOnline = true; + } } } - catch { /* AA0067 */ } + catch + { + // Ignore; fallback handled below + } } - // AA0068 + // If online fetch failed → fallback to cached file + if (!loadedOnline && System.IO.File.Exists(CacheFile)) + { + var cached = System.IO.File.ReadAllLines(CacheFile); + if (cached.Length > 0) + allLines.AddRange(cached); + } + + // Also load config.txt (local overrides) var local = Helper.ReadLinesSafe("config.txt"); if (local != null && local.Length > 0) allLines.AddRange(local); @@ -120,13 +153,13 @@ namespace Lua bool inAttackers = false; bool inDefenders = false; - // AA0069 foreach (var raw in allLines) { if (string.IsNullOrWhiteSpace(raw)) continue; var line = raw.Trim(); - if (line.StartsWith("--") || line.StartsWith("#")) continue; + if (line.StartsWith("--") || line.StartsWith("#")) + continue; if (line.StartsWith("attackers", StringComparison.OrdinalIgnoreCase)) { @@ -171,6 +204,7 @@ namespace Lua CurrentOperator = CurrentSet; } + // AA0070 public static void MergeSets() { diff --git a/Lithium/Properties/AssemblyInfo.cs b/Lithium/Properties/AssemblyInfo.cs index dbed813..70df127 100644 --- a/Lithium/Properties/AssemblyInfo.cs +++ b/Lithium/Properties/AssemblyInfo.cs @@ -1,6 +1,4 @@ using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows; diff --git a/Lithium/Utils.cs b/Lithium/Utils.cs index 67a677a..b26176e 100644 --- a/Lithium/Utils.cs +++ b/Lithium/Utils.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.InteropServices; using System.Speech.Synthesis; -using System.Threading; namespace Lua { diff --git a/Lithium/helper.cs b/Lithium/helper.cs index 4e2384f..cd55281 100644 --- a/Lithium/helper.cs +++ b/Lithium/helper.cs @@ -1,6 +1,6 @@ using System; -using System.IO; using System.Globalization; +using System.IO; using System.Text.RegularExpressions; namespace Lua