alert icon implementation
This commit is contained in:
@@ -7,12 +7,12 @@ public struct Settings()
|
||||
/// <summary>
|
||||
/// Contains data about each multiplier, roll, etc.
|
||||
/// </summary>
|
||||
public readonly List<SettingsRoll> rolls = [];
|
||||
public readonly List<SettingsRoll> rolls = new();
|
||||
|
||||
/// <summary>
|
||||
/// Contains messages such as announcements etc.
|
||||
/// </summary>
|
||||
public readonly List<MessageMacro> macros = [];
|
||||
public readonly List<MessageMacro> macros = new();
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public uint? step = null;
|
||||
|
||||
/// <summary>
|
||||
/// Whether developer options should be visible in the settings
|
||||
/// </summary>
|
||||
public bool devOptions = false;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -18,16 +19,17 @@ public class SettingsWindow : Window, IDisposable
|
||||
|
||||
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")
|
||||
{
|
||||
@@ -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 (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);
|
||||
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,10 +131,10 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -102,7 +145,8 @@ public class SettingsWindow : Window, IDisposable
|
||||
/// <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)
|
||||
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);
|
||||
@@ -119,6 +163,7 @@ public class SettingsWindow : Window, IDisposable
|
||||
var newColour = ImGuiComponents.ColorPickerWithPalette(
|
||||
(int)id, "placeholder", colour);
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("-"))
|
||||
{
|
||||
// signals to the colour to remove this roll setting
|
||||
@@ -129,7 +174,6 @@ public class SettingsWindow : Window, IDisposable
|
||||
// we need to verify if data inputted is "good"
|
||||
|
||||
return ValidateRollSetting();
|
||||
|
||||
}
|
||||
|
||||
private bool ValidateRollSetting()
|
||||
@@ -151,7 +195,7 @@ public class SettingsWindow : Window, IDisposable
|
||||
/// <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 bool? LabelTextInput(string labelId, string labelText, string inputId, ref uint? result)
|
||||
{
|
||||
bool? valid = null;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user