diff --git a/HighRollerClassic/DataStructures/Settings.cs b/HighRollerClassic/DataStructures/Settings.cs
index eb5dba0..30d93c0 100644
--- a/HighRollerClassic/DataStructures/Settings.cs
+++ b/HighRollerClassic/DataStructures/Settings.cs
@@ -7,12 +7,12 @@ public struct Settings()
///
/// Contains data about each multiplier, roll, etc.
///
- public readonly List rolls = [];
+ public readonly List rolls = new();
///
/// Contains messages such as announcements etc.
///
- public readonly List macros = [];
+ public readonly List macros = new();
///
/// Maximum bet that will be allowed to set
@@ -23,4 +23,9 @@ public struct Settings()
/// How much the bet will change when user adjusts their bet via +/- keys
///
public uint? step = null;
+
+ ///
+ /// Whether developer options should be visible in the settings
+ ///
+ public bool devOptions = false;
}
diff --git a/HighRollerClassic/Windows/SettingsWindow.cs b/HighRollerClassic/Windows/SettingsWindow.cs
index d8ced25..2a94570 100644
--- a/HighRollerClassic/Windows/SettingsWindow.cs
+++ b/HighRollerClassic/Windows/SettingsWindow.cs
@@ -1,5 +1,6 @@
using System;
using System.Numerics;
+using System.Runtime.CompilerServices;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Components;
using Dalamud.Interface.Windowing;
@@ -15,20 +16,21 @@ public class SettingsWindow : Window, IDisposable
private const int InputMaxLen = 11;
private const uint RollSettingInputWidth = 50;
-
+
private const uint MaxAllowedGil = 999_999_999;
private readonly Configuration configuration;
- private Settings settings;
private bool maxBetFormatValid = true;
- private bool stepFormatValid = true;
-
- // todo proper implementation it's just a placeholder
- private bool TempRoll => newRoll.HasValue;
private SettingsRoll? newRoll;
private (uint min, uint max) rollInterval = (1, 999);
+ private Settings settings;
+ private bool stepFormatValid = true;
+ // colours
+ private readonly Vector4 yellow = new(249/255f, 180/255f, 45/255f, 1);
+ private readonly Vector4 red = new(1, 0, 0, 1f);
+
public SettingsWindow(Plugin plugin) : base("Settings##HRC Settings")
{
Flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
@@ -42,12 +44,40 @@ public class SettingsWindow : Window, IDisposable
settings = configuration.Settings;
}
+ // todo proper implementation it's just a placeholder
+ private bool TempRoll => newRoll.HasValue;
+
public void Dispose() { }
public override void PreDraw() { }
public override void Draw()
{
+ // todo integrate for every field
+ var drawList = ImGui.GetWindowDrawList();
+
+ var center = ImGui.GetCursorScreenPos();
+ const uint radius = 10;
+
+ var circleColor = ImGui.GetColorU32(yellow);
+ var borderColor = ImGui.GetColorU32(red);
+ var textColor = ImGui.GetColorU32(red);
+
+ drawList.AddCircleFilled(center + new Vector2(radius, radius), radius, circleColor);
+ drawList.AddCircle(center + new Vector2(radius, radius), radius, borderColor, 0, 2.5f);
+
+ const string text = "!";
+ var textSize = ImGui.CalcTextSize(text);
+ var textPos = center + new Vector2(
+ radius - (textSize.X * 0.5f),
+ radius - (textSize.Y * 0.5f)
+ );
+
+
+ drawList.AddText(textPos, textColor, text);
+
+ ImGui.Dummy(new Vector2(radius * 2f, radius * 2f));
+
// todo set up multiplier, roll, color, etc
// todo add button for rolls
@@ -56,25 +86,38 @@ public class SettingsWindow : Window, IDisposable
// TODO no new rolls must be there
newRoll = new SettingsRoll();
}
- if (ImGui.CollapsingHeader("Rolls###settings", ImGuiTreeNodeFlags.DefaultOpen))
+
+ if (ImGui.CollapsingHeader("Rolls##settings"))
{
// todo here we put new rolls
- foreach (var roll in settings.rolls)
- {
- // todo here we put existing rolls
- }
+ // foreach (var roll in settings.rolls)
+ // {
+ // // todo here we put existing rolls
+ // }
}
- var maxbetValid = NewInput("max_bet_label", "Max bet", "max_bet_text", ref settings.maxBet);
- if (maxbetValid.HasValue) maxBetFormatValid = maxbetValid.Value;
- ImGui.Spacing();
+ if (ImGui.CollapsingHeader("General##settings"))
+ {
+ var maxbetValid = LabelTextInput("max_bet_label", "Max bet", "max_bet_text", ref settings.maxBet);
+ if (maxbetValid.HasValue) maxBetFormatValid = maxbetValid.Value;
+ ImGui.Spacing();
- var stepValid = NewInput("step_label", "Step", "step_input", ref settings.step);
- if (stepValid.HasValue) stepFormatValid = stepValid.Value;
- ImGui.Spacing();
+ var stepValid = LabelTextInput("step_label", "Step", "step_input", ref settings.step);
+ if (stepValid.HasValue) stepFormatValid = stepValid.Value;
+ ImGui.Spacing();
+
+ ImGui.Checkbox("Developer options", ref settings.devOptions);
+ }
+
+ if (configuration.Settings.devOptions && ImGui.CollapsingHeader("Developer options"))
+ {
+ // todo add developer settings - like the ability to have every character have HRC open
+ }
var inputValidation = ValidateInput();
+ ImGui.Spacing();
+
ImGui.BeginDisabled(!inputValidation.valid);
if (ImGui.Button("Save"))
@@ -88,37 +131,39 @@ public class SettingsWindow : Window, IDisposable
ImGui.EndDisabled();
ImGui.SameLine();
- if (!inputValidation.valid && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) ImGui.SetTooltip(inputValidation.message);
+ if (!inputValidation.valid && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
+ ImGui.SetTooltip(inputValidation.message);
if (ImGui.Button("Reset")) settings = configuration.Settings;
-
}
///
- /// Returns false if the roll is to be removed
+ /// Returns false if the roll is to be removed
///
/// gil multiplication in case of a roll
/// if roll is checked on less/less or equal comparison
/// how much user rolls
/// colours the rolls in main window, depending on their value
/// tracks which roll we're setting so input fields don't have the same ids
- private bool? DisplayRollSetting(ref uint multiplier, ref bool exact, ref uint roll, ref Vector4 colour, ref uint id)
+ private bool? DisplayRollSetting(
+ ref uint multiplier, ref bool exact, ref uint roll, ref Vector4 colour, ref uint id)
{
ImGui.SetNextItemWidth(RollSettingInputWidth);
ImGui.InputUInt($"##multiplier{id}", ref multiplier);
-
+
ImGui.SameLine();
-
+
ImGui.Text("x");
ImGui.SameLine();
-
+
ImGui.SetNextItemWidth(RollSettingInputWidth);
ImGui.InputUInt($"##roll{id}", ref roll);
-
+
ImGui.SameLine();
var newColour = ImGuiComponents.ColorPickerWithPalette(
(int)id, "placeholder", colour);
+ ImGui.SameLine();
if (ImGui.Button("-"))
{
// signals to the colour to remove this roll setting
@@ -129,38 +174,37 @@ public class SettingsWindow : Window, IDisposable
// we need to verify if data inputted is "good"
return ValidateRollSetting();
-
}
private bool ValidateRollSetting()
{
// multiplier must not already exist
-
+
// roll must be between 1 and 999
-
+
// roll must not already exist
return true;
}
///
- /// Returns true if valid, false if invalid or null if validity has no changed
+ /// Returns true if valid, false if invalid or null if validity has no changed
///
/// id of the label field
/// text for the label input field
/// id of the input field
/// new value if parsing was successful
///
- private static bool? NewInput(string labelId, string labelText, string inputId, ref uint? result)
+ private bool? LabelTextInput(string labelId, string labelText, string inputId, ref uint? result)
{
bool? valid = null;
-
+
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);
@@ -170,10 +214,14 @@ public class SettingsWindow : Window, IDisposable
valid = true;
}
else
- {
valid = false;
- }
}
+
+ // todo alert that appears when field doesn't match the configuration
+ ImGui.SameLine();
+ ImGui.Text("*");
+
+ // todo place the alert if field validation fails
return valid;
}
@@ -187,20 +235,13 @@ public class SettingsWindow : Window, IDisposable
var valid = true;
var message = string.Empty;
- if (!maxBetFormatValid || !stepFormatValid)
- {
- SetError("Input fields have invalid data", ref message, ref valid);
- }
+ if (!maxBetFormatValid || !stepFormatValid) SetError("Input fields have invalid data", ref message, ref valid);
if (settings.maxBet > MaxAllowedGil)
- {
SetError("Entered bet amount exceeds maximum possible bet", ref message, ref valid);
- }
-
+
if (settings.step > configuration.Settings.maxBet || settings.maxBet < configuration.Settings.maxBet)
- {
SetError("Step change must not exceed current maximum bet", ref message, ref valid);
- }
return (valid, message);
}