From f5a35344d04191c60d20a3306bf87b54b223eba6 Mon Sep 17 00:00:00 2001 From: Marto Date: Sun, 28 Dec 2025 01:09:44 +0100 Subject: [PATCH] Further settings implementation and macros --- HighRollerClassic/Configuration.cs | 5 ++ HighRollerClassic/DataStructures/Macro.cs | 21 +++++ HighRollerClassic/DataStructures/MacroType.cs | 9 ++ HighRollerClassic/DataStructures/Settings.cs | 15 ++-- HighRollerClassic/Windows/GambaWindow.cs | 8 +- HighRollerClassic/Windows/SettingsWindow.cs | 90 +++++++++++-------- 6 files changed, 105 insertions(+), 43 deletions(-) create mode 100644 HighRollerClassic/DataStructures/Macro.cs create mode 100644 HighRollerClassic/DataStructures/MacroType.cs diff --git a/HighRollerClassic/Configuration.cs b/HighRollerClassic/Configuration.cs index 425b67d..00fc282 100644 --- a/HighRollerClassic/Configuration.cs +++ b/HighRollerClassic/Configuration.cs @@ -9,6 +9,11 @@ public class Configuration : IPluginConfiguration { public PlayerManager players = new(); public Settings settings; + + public bool SettingsInit => !settings.maxBet.HasValue && !settings.step.HasValue && settings.rolls.Count > 0 && + settings.macros.Count > 0; + // TODO calculate the amount of macros having to be saved + public int Version { get; set; } = 0; // The below exists just to make saving less cumbersome diff --git a/HighRollerClassic/DataStructures/Macro.cs b/HighRollerClassic/DataStructures/Macro.cs new file mode 100644 index 0000000..89ca7b6 --- /dev/null +++ b/HighRollerClassic/DataStructures/Macro.cs @@ -0,0 +1,21 @@ +namespace HighRollerClassic.DataStructures; + +public struct Macro +{ + /// + /// which type of message we're storing here + /// + private MacroType type; + /// + /// only for messages that talk about rolls + /// + private uint? rollNum; + /// + /// message itself + /// + private string message; + /// + /// additional emotes that character will play out after/before outputting the message + /// + private string emotes; +} diff --git a/HighRollerClassic/DataStructures/MacroType.cs b/HighRollerClassic/DataStructures/MacroType.cs new file mode 100644 index 0000000..005e54d --- /dev/null +++ b/HighRollerClassic/DataStructures/MacroType.cs @@ -0,0 +1,9 @@ +namespace HighRollerClassic.DataStructures; + +public enum MacroType +{ + Announce, + TargetBets, + WinsRoll, + LosesRoll +} diff --git a/HighRollerClassic/DataStructures/Settings.cs b/HighRollerClassic/DataStructures/Settings.cs index 86b8b7a..2f0120d 100644 --- a/HighRollerClassic/DataStructures/Settings.cs +++ b/HighRollerClassic/DataStructures/Settings.cs @@ -2,20 +2,25 @@ using System.Collections.Generic; namespace HighRollerClassic.DataStructures; -public struct Settings +public struct Settings() { /// - /// Contains data bout each multiplier, roll, etc. + /// Contains data about each multiplier, roll, etc. /// - public List rolls; + public readonly List rolls = []; + + /// + /// Contains messages such as announcements etc. + /// + public readonly List macros = []; /// /// Maximum bet that will be allowed to set /// - public uint maxBet; + public uint? maxBet = null; /// /// How much the bet will change when user adjusts their bet via +/- keys /// - public uint step; + public uint? step = null; } diff --git a/HighRollerClassic/Windows/GambaWindow.cs b/HighRollerClassic/Windows/GambaWindow.cs index 7159be2..c6aea6f 100644 --- a/HighRollerClassic/Windows/GambaWindow.cs +++ b/HighRollerClassic/Windows/GambaWindow.cs @@ -13,7 +13,7 @@ public class GambaWindow : Window, IDisposable // todo remove state as the window will only be opened by us calling it with parameters window id private readonly Player? player; private readonly Plugin plugin; - private string name; + private readonly string name; public GambaWindow(Plugin plugin, MenuTargetDefault target) : base($"High Roller Classic###{target.TargetContentId}", @@ -45,9 +45,15 @@ public class GambaWindow : Window, IDisposable } /* TODO check if all settings are set + bet/step roll settings message/macro settings */ + if (!configuration.SettingsInit) + { + ImGui.Text("Please set up settings"); + return; + } // todo if player is null, then allow user to set user by clicking on them manually if (player == null) diff --git a/HighRollerClassic/Windows/SettingsWindow.cs b/HighRollerClassic/Windows/SettingsWindow.cs index 40dc503..f5a8678 100644 --- a/HighRollerClassic/Windows/SettingsWindow.cs +++ b/HighRollerClassic/Windows/SettingsWindow.cs @@ -8,15 +8,14 @@ namespace HighRollerClassic.Windows; public class SettingsWindow : Window, IDisposable { - private readonly Configuration configuration; - private Settings settings; - private const int XOffset = 80; private const int Spacing = 5; private const int InputWidth = 105; private const int InputMaxLen = 11; private const uint MaxPossibleBet = 999_999_999; + private readonly Configuration configuration; + private Settings settings; // We give this window a constant ID using ###. // This allows for labels to be dynamic, like "{FPS Counter}fps###XYZ counter window", @@ -30,7 +29,7 @@ public class SettingsWindow : Window, IDisposable SizeCondition = ImGuiCond.Always; configuration = plugin.Configuration; - settings = configuration.settings; + settings = new Settings(); } public void Dispose() { } @@ -42,55 +41,72 @@ public class SettingsWindow : Window, IDisposable // todo set up multiplier, roll, color, etc // todo add button for rolls - ImGui.LabelText("###max_bet_label", "Max bet: "); - ImGui.SameLine(XOffset, Spacing); - ImGui.SetNextItemWidth(InputWidth); - - // TODO maybe throw it in a function because we have 2 fields behaving the same except for variables and label - var betBuf = settings.maxBet.ToString("N0"); - if (ImGui.InputText("###max_bet_text", ref betBuf, InputMaxLen)) - { - var num = betBuf.Replace(",", string.Empty).Replace(".", string.Empty); - if (uint.TryParse(num, out var parsedValue)) settings.maxBet = parsedValue; - } + if (ImGui.Button("Macro Settings")) { } + + if (ImGui.Button("Add roll")) { } + // todo add check that there is at least one roll + + NewInput("max_bet_label", "Max bet", "max_bet_text", ref settings.maxBet); ImGui.Spacing(); - ImGui.LabelText("###step_label", "Step: "); - ImGui.SameLine(XOffset, Spacing); - ImGui.SetNextItemWidth(InputWidth); - - var stepBuf = settings.step.ToString("N0"); - if (ImGui.InputText("###step_input", ref stepBuf, InputMaxLen)) - { - var num = stepBuf.Replace(",", string.Empty).Replace(".", string.Empty); - if (uint.TryParse(num, out var parsedValue)) settings.step = parsedValue; - } - + NewInput("step_label", "Step", "step_input", ref settings.step); + ImGui.Spacing(); - - // todo validation step? - var invalidInput = !ValidateInput(); - - ImGui.BeginDisabled(invalidInput); + + var inputValidation = ValidateInput(); + + ImGui.BeginDisabled(!inputValidation.valid); + if (ImGui.Button("Save")) { configuration.settings = settings; configuration.Save(); } + ImGui.EndDisabled(); + + if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) ImGui.SetTooltip(inputValidation.message); + } + + private static void NewInput(string labelId, string labelText, string inputId, ref uint? result) + { + ImGui.LabelText($"###{labelId}", $"{labelText}: "); + ImGui.SameLine(XOffset, Spacing); + ImGui.SetNextItemWidth(InputWidth); + + var buf = result?.ToString("N0") ?? ""; + if (ImGui.InputText($"###{inputId}", ref buf, InputMaxLen)) + { + var num = buf.Replace(",", string.Empty).Replace(".", string.Empty); + if (uint.TryParse(num, out var parsedValue)) result = parsedValue; + } } /// - /// Validates inputs for Max bet and Step + /// Validates inputs for Max bet and Step /// /// - private bool ValidateInput() + private (bool valid, string message) ValidateInput() { - // TODO add explanation why input validation failed - if (settings.maxBet > MaxPossibleBet) return false; - if (settings.step > configuration.settings.maxBet) return false; + var valid = true; + var message = string.Empty; - return true; + if (settings.maxBet > MaxPossibleBet) + { + message += "Entered bet amount exceeds maximum possible bet"; + valid = false; + } + + if (settings.step > configuration.settings.maxBet) + { + if (!valid) message += "\n"; + message += "Entered step change exceeds current maximum bet"; + valid = false; + } + + ; + + return (valid, message); } }