More settings additions and fixes

This commit is contained in:
2025-12-31 01:00:54 +01:00
parent aa7553d9f9
commit 21b9e84fec
6 changed files with 70 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
namespace HighRollerClassic.DataStructures; namespace HighRollerClassic.DataStructures;
public struct Roll public struct RollHistory
{ {
private uint value; private uint value;
private uint multiplier; private uint multiplier;

View File

@@ -7,7 +7,7 @@ public struct Settings()
/// <summary> /// <summary>
/// Contains data about each multiplier, roll, etc. /// Contains data about each multiplier, roll, etc.
/// </summary> /// </summary>
public readonly List<SettingsRolls> rolls = []; public readonly List<SettingsRoll> rolls = [];
/// <summary> /// <summary>
/// Contains messages such as announcements etc. /// Contains messages such as announcements etc.

View File

@@ -2,10 +2,9 @@ using System.Numerics;
namespace HighRollerClassic.DataStructures; namespace HighRollerClassic.DataStructures;
public struct SettingsRolls public struct SettingsRoll
{ {
private uint multiplier; private uint multiplier;
private uint roll; private uint roll;
private bool exact;
private Vector4 color; private Vector4 color;
} }

View File

@@ -5,7 +5,7 @@ namespace HighRollerClassic;
public class Player(MenuTargetDefault target) public class Player(MenuTargetDefault target)
{ {
private Roll rolls = new(); private RollHistory rollsHistory = new();
public int Bank { get; private set; } = 0; public int Bank { get; private set; } = 0;
public ulong ContentId { get; private set; } = target.TargetContentId; public ulong ContentId { get; private set; } = target.TargetContentId;

View File

@@ -18,7 +18,7 @@ public class GambaWindow : Window, IDisposable
private bool SettingsSet => configuration.Settings is { maxBet: not null, step: not null, rolls.Count: > 0, macros.Count: > 0 }; private bool SettingsSet => configuration.Settings is { maxBet: not null, step: not null, rolls.Count: > 0, macros.Count: > 0 };
public GambaWindow(Plugin plugin, MenuTargetDefault target) public GambaWindow(Plugin plugin, MenuTargetDefault target)
: base($"High Roller Classic - {target.TargetName}###HRC{target.TargetContentId}", : base($"High Roller Classic - {target.TargetName}##HRC{target.TargetContentId}",
ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse) ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)
{ {
SizeConstraints = new WindowSizeConstraints SizeConstraints = new WindowSizeConstraints

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Numerics; using System.Numerics;
using Dalamud.Bindings.ImGui; using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Components;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using HighRollerClassic.DataStructures; using HighRollerClassic.DataStructures;
@@ -13,6 +14,8 @@ public class SettingsWindow : Window, IDisposable
private const int InputWidth = 105; private const int InputWidth = 105;
private const int InputMaxLen = 11; private const int InputMaxLen = 11;
private const uint RollSettingInputWidth = 50;
private const uint MaxAllowedGil = 999_999_999; private const uint MaxAllowedGil = 999_999_999;
private readonly Configuration configuration; private readonly Configuration configuration;
private Settings settings; private Settings settings;
@@ -21,12 +24,12 @@ public class SettingsWindow : Window, IDisposable
private bool stepFormatValid = true; private bool stepFormatValid = true;
// todo proper implementation it's just a placeholder // todo proper implementation it's just a placeholder
private bool NoTempRolls => true; private bool TempRoll => newRoll.HasValue;
private Roll? new_roll; private SettingsRoll? newRoll;
private (uint min, uint max) rollInterval = (1, 999); private (uint min, uint max) rollInterval = (1, 999);
public SettingsWindow(Plugin plugin) : base("Settings###HRC Settings") public SettingsWindow(Plugin plugin) : base("Settings##HRC Settings")
{ {
Flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | Flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollWithMouse; ImGuiWindowFlags.NoScrollWithMouse;
@@ -48,10 +51,10 @@ public class SettingsWindow : Window, IDisposable
// todo set up multiplier, roll, color, etc // todo set up multiplier, roll, color, etc
// todo add button for rolls // todo add button for rolls
if (ImGui.Button("Add roll") && NoTempRolls) if (ImGui.Button("Add roll") && TempRoll)
{ {
// TODO no new rolls must be there // TODO no new rolls must be there
newRoll = new SettingsRoll();
} }
if (ImGui.CollapsingHeader("Rolls###settings", ImGuiTreeNodeFlags.DefaultOpen)) if (ImGui.CollapsingHeader("Rolls###settings", ImGuiTreeNodeFlags.DefaultOpen))
{ {
@@ -91,6 +94,63 @@ public class SettingsWindow : Window, IDisposable
} }
/// <summary>
/// Returns false if the roll is to be removed
/// </summary>
/// <param name="multiplier">gil multiplication in case of a roll</param>
/// <param name="exact">if roll is checked on less/less or equal comparison</param>
/// <param name="roll">how much user rolls</param>
/// <param name="colour">colours the rolls in main window, depending on their value</param>
/// <param name="id">tracks which roll we're setting so input fields don't have the same ids</param>
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);
if (ImGui.Button("-"))
{
// signals to the colour to remove this roll setting
return null;
}
// TODO verify input
// 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;
}
/// <summary>
/// Returns true if valid, false if invalid or null if validity has no changed
/// </summary>
/// <param name="labelId">id of the label field</param>
/// <param name="labelText">text for the label input field</param>
/// <param name="inputId">id of the input field</param>
/// <param name="result">new value if parsing was successful</param>
/// <returns></returns>
private static bool? NewInput(string labelId, string labelText, string inputId, ref uint? result) private static bool? NewInput(string labelId, string labelText, string inputId, ref uint? result)
{ {
bool? valid = null; bool? valid = null;