more settings fuckery - does not compile

This commit is contained in:
2026-01-02 13:42:39 +01:00
parent 82262cc7d6
commit f42732dbc4
4 changed files with 93 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
namespace HighRollerClassic.DataStructures; namespace HighRollerClassic.DataStructures;
public class Misc public static class Misc
{ {
/// <summary> /// <summary>
/// Appends message if error par is true /// Appends message if error par is true

View File

@@ -2,5 +2,9 @@ namespace HighRollerClassic.DataStructures;
public enum SettingValueType public enum SettingValueType
{ {
Multiplier,
Roll,
Colour,
MaxBet,
Step,
} }

View File

@@ -28,6 +28,7 @@ public class Settings
/// Contains data about each multiplier, roll, etc. /// Contains data about each multiplier, roll, etc.
/// </summary> /// </summary>
public List<SettingsRoll> Rolls { get; private set; } = new(); public List<SettingsRoll> Rolls { get; private set; } = new();
// todo we'll make this a new class because we have 3 roll methods already 'polluting' this class
/// <summary> /// <summary>
/// Adds roll /// Adds roll
@@ -46,6 +47,11 @@ public class Settings
return null; return null;
} }
public void RemoveRoll(SettingsRoll roll)
{
Rolls.Remove(roll);
}
/// <summary> /// <summary>
/// Validates new roll /// Validates new roll
/// </summary> /// </summary>

View File

@@ -1,22 +1,95 @@
using System; using System;
using System.Diagnostics;
using System.Numerics;
using FFXIVClientStructs.FFXIV.Component.GUI;
namespace HighRollerClassic.DataStructures; namespace HighRollerClassic.DataStructures;
public class TrackedValue<TParent, TValue> /// <summary>
/// Tracks value and its validity and changes
/// </summary>
public class TrackedValue
{ {
public TValue Value { get; set; } private SettingValueType type;
public bool IsValid { get; set; } private Configuration configuration;
public bool HasChanged { get; set; }
private uint? Value { get;
set
{
SetValue(value);
field = value;
}
}
private Vector4? colourValue { get; set; }
public bool IsValid { get; private set; }
public bool HasChanged { get; private set; }
private const uint MinRoll = 1; private const uint MinRoll = 1;
private const uint MaxRoll = 999; private const uint MaxRoll = 999;
private const uint MaxGil = 999_999_999; private const uint MaxGil = 999_999_999;
private Func<uint, bool> multiplierRollValid = v => v is >= MinRoll and <= MaxRoll; private bool multiplierValid => Value is not null;
private Func<uint, bool> maxBetValid = v => v <= MaxGil; private bool rollValid => Value is >= MinRoll and <= MaxRoll;
private bool maxBetValid => Value is <= MaxGil;
private bool stepValid => CheckStepValid();
private static bool StepValid(uint step, uint bet) public TrackedValue(uint? value, SettingValueType type, Configuration configuration)
{ {
return step <= bet; Initialise(type, configuration);
Value = value;
}
public TrackedValue(Vector4? value, SettingValueType type, Configuration configuration)
{
Initialise(type, configuration);
colourValue = value;
}
private void Initialise(SettingValueType type, Configuration configuration)
{
this.type = type;
this.configuration = configuration;
}
private bool CheckStepValid()
{
return Value <= configuration.Settings.MaxBet;
}
private void SetValue(uint? value)
{
bool? valid = null;
bool? change = null;
switch (type)
{
case SettingValueType.Multiplier:
valid = multiplierValid;
break;
case SettingValueType.Roll:
valid = rollValid;
break;
case SettingValueType.Colour:
valid = true;
break;
case SettingValueType.MaxBet:
valid = maxBetValid;
change = value == configuration.Settings.MaxBet;
break;
case SettingValueType.Step:
valid = stepValid;
change = value == configuration.Settings.Step;
break;
}
if (valid.HasValue) IsValid = valid.Value;
if (change.HasValue) HasChanged = change.Value;
}
private void SetColourValue(Vector4? value)
{
IsValid = true; // colour will always be valid because we set it from colour picker
HasChanged = true; // todo we have to check
} }
} }