diff --git a/Lithium.sln b/Lithium.sln new file mode 100644 index 0000000..bea27fd --- /dev/null +++ b/Lithium.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36408.4 d17.14 +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 + Release|Any CPU = Release|Any CPU + 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}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71516142-7D3E-46A1-A6EC-E242CD128DB1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CADAD289-56CB-41B4-8D5F-F334BCF9CABB} + EndGlobalSection +EndGlobal diff --git a/Lithium/App.config b/Lithium/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/Lithium/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Lithium/App.xaml b/Lithium/App.xaml new file mode 100644 index 0000000..d00be54 --- /dev/null +++ b/Lithium/App.xaml @@ -0,0 +1,7 @@ + + + + diff --git a/Lithium/App.xaml.cs b/Lithium/App.xaml.cs new file mode 100644 index 0000000..554d883 --- /dev/null +++ b/Lithium/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Lithium +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Lithium/ConfigLoader.cs b/Lithium/ConfigLoader.cs new file mode 100644 index 0000000..ec349da --- /dev/null +++ b/Lithium/ConfigLoader.cs @@ -0,0 +1,112 @@ +// ConfigLoader.cs +using System; +using System.Globalization; +using System.IO; +using System.Runtime.Remoting.Messaging; + +namespace Lua +{ + internal static class ConfigLoader + { + // Basic flags / settings + public static bool debitFlag1 = false; + public static bool betaTest = false; + 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 + + // Favorites and user + public static string favoriteAttackers = null; + public static string favoriteDefenders = null; + public static string userName = null; + + // Jitter config + public static bool jitterEnabled = false; + public static int jitterBurstTime = 1800; // milliseconds + public static int jitterCooldown = 3000; // milliseconds + + // Console text color + public static ConsoleColor textColor = ConsoleColor.Magenta; + + /// + /// Load defaults and then attempt to read init.config from working directory. + /// + public static void LoadInitConfig() + { + // reset to defaults + debitFlag1 = false; + betaTest = false; + ttsEnabled = true; + favoriteAttackers = null; + favoriteDefenders = null; + userName = null; + jitterEnabled = false; + jitterBurstTime = 1800; + jitterCooldown = 3000; + textColor = ConsoleColor.Magenta; + + SetConsoleColor(); + + if (!File.Exists("init.config")) return; + + var lines = Helper.ReadLinesSafe("init.config"); + + foreach (var raw in lines) + { + if (string.IsNullOrWhiteSpace(raw)) continue; + var line = raw.Trim(); + + // ignore comments + if (line.StartsWith("--") || line.StartsWith("#")) continue; + + 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; + else if (Helper.ParseIntFromAssignment(line, "nextSetKey", out var i1)) + nextSetKey = i1; + else if (Helper.ParseIntFromAssignment(line, "prevSetKey", out var i2)) + prevSetKey = i2; + else if (Helper.ParseIntFromAssignment(line, "refreshKey", out var i3)) + refreshKey = i3; + else if (Helper.ParseIntFromAssignment(line, "switchSideKey", out var i4)) + switchSideKey = i4; + 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; + 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; + else if (Helper.ParseConsoleColorFromAssignment(line, "textColor", out var col)) + textColor = col; + } + + // Re-apply color in case it was changed by config + SetConsoleColor(); + } + + private static void SetConsoleColor() + { + try + { + Console.ForegroundColor = textColor; + } + catch + { + // ignore if console doesn't support color + } + } + } +} \ No newline at end of file diff --git a/Lithium/Lithium.csproj b/Lithium/Lithium.csproj new file mode 100644 index 0000000..2cf98ac --- /dev/null +++ b/Lithium/Lithium.csproj @@ -0,0 +1,190 @@ + + + + + Debug + AnyCPU + {71516142-7D3E-46A1-A6EC-E242CD128DB1} + WinExe + Lithium + Lithium + v4.8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Web.WebView2.1.0.3595.46\lib\net462\Microsoft.Web.WebView2.Core.dll + + + ..\packages\Microsoft.Web.WebView2.1.0.3595.46\lib\net462\Microsoft.Web.WebView2.WinForms.dll + + + ..\packages\Microsoft.Web.WebView2.1.0.3595.46\lib\net462\Microsoft.Web.WebView2.Wpf.dll + + + + ..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll + + + + ..\packages\System.IO.Pipelines.10.0.0\lib\net462\System.IO.Pipelines.dll + + + ..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\packages\System.Text.Encodings.Web.10.0.0\lib\net462\System.Text.Encodings.Web.dll + + + ..\packages\System.Text.Json.10.0.0\lib\net462\System.Text.Json.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + + MainWindow.xaml + Code + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + False + Microsoft .NET Framework 4.8 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Lithium/MainWindow.xaml b/Lithium/MainWindow.xaml new file mode 100644 index 0000000..850f44b --- /dev/null +++ b/Lithium/MainWindow.xaml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +