From e85982232527aa1aadc2cde375959cff090ebb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Tue, 25 Apr 2023 11:21:42 +0800 Subject: [PATCH] fix: add status list for esuna or invinsibility. --- .../Configuration/PluginConfiguration.cs | 33 +++ RotationSolver.Basic/Helpers/StatusHelper.cs | 37 +--- RotationSolver/ActionSequencer/BaseStatus.cs | 14 +- .../ActionSequencer/ConditionSet.cs | 1 - .../ActionSequencer/TargetCondition.cs | 2 +- RotationSolver/Localization/Strings.cs | 10 +- RotationSolver/UI/ImGuiHelper.cs | 1 - .../UI/RotationConfigWindow_List.cs | 124 +++++++++++ .../UI/RotationConfigWindow_Major.cs | 155 ++++++++++++++ .../UI/RotationConfigWindow_Param.cs | 202 ------------------ 10 files changed, 336 insertions(+), 243 deletions(-) create mode 100644 RotationSolver/UI/RotationConfigWindow_List.cs diff --git a/RotationSolver.Basic/Configuration/PluginConfiguration.cs b/RotationSolver.Basic/Configuration/PluginConfiguration.cs index cef52cccf..52aa1120d 100644 --- a/RotationSolver.Basic/Configuration/PluginConfiguration.cs +++ b/RotationSolver.Basic/Configuration/PluginConfiguration.cs @@ -88,6 +88,39 @@ public class PluginConfiguration : IPluginConfiguration public bool TargetFriendly = false; public float AlphaInFill = 0.15f; + public List DangerousStatus { get; set; } = new List() + { + (uint)StatusID.Doom, + (uint)StatusID.Amnesia, + (uint)StatusID.Stun, + (uint)StatusID.Stun2, + (uint)StatusID.Sleep, + (uint)StatusID.Sleep2, + (uint)StatusID.Sleep3, + (uint)StatusID.Pacification, + (uint)StatusID.Pacification2, + (uint)StatusID.Silence, + (uint)StatusID.Slow, + (uint)StatusID.Slow2, + (uint)StatusID.Slow3, + (uint)StatusID.Slow4, + (uint)StatusID.Slow5, + (uint)StatusID.Blind, + (uint)StatusID.Blind2, + (uint)StatusID.Blind3, + (uint)StatusID.Paralysis, + (uint)StatusID.Paralysis2, + (uint)StatusID.Nightmare, + (uint)StatusID.Necrosis, + }; + + public List InvincibleStatus = new List() + { + (uint)StatusID.StoneSkin, + (uint)StatusID.IceSpikesInvincible, + (uint)StatusID.VortexBarrier, + }; + public Dictionary HealingOfTimeSubtractSingles { get; set; } = new Dictionary(); public Dictionary HealingOfTimeSubtractAreas { get; set; } = new Dictionary(); diff --git a/RotationSolver.Basic/Helpers/StatusHelper.cs b/RotationSolver.Basic/Helpers/StatusHelper.cs index 5358069c8..ebe3922fe 100644 --- a/RotationSolver.Basic/Helpers/StatusHelper.cs +++ b/RotationSolver.Basic/Helpers/StatusHelper.cs @@ -145,51 +145,18 @@ private static IEnumerable GetAllStatus(this BattleChara obj, bool isFro || status.SourceObject?.OwnerId == Service.Player.ObjectId : true); } - static readonly StatusID[] invincibleStatus = new StatusID[] - { - StatusID.StoneSkin, - StatusID.IceSpikesInvincible, - StatusID.VortexBarrier, - }; - public static bool IsInvincible(this Status status) { if (status.GameData.Icon == 15024) return true; - return invincibleStatus.Any(id => (uint)id == status.StatusId); + return Service.Config.InvincibleStatus.Any(id => (uint)id == status.StatusId); } - static readonly StatusID[] dangerousStatus = new StatusID[] - { - StatusID.Doom, - StatusID.Amnesia, - StatusID.Stun, - StatusID.Stun2, - StatusID.Sleep, - StatusID.Sleep2, - StatusID.Sleep3, - StatusID.Pacification, - StatusID.Pacification2, - StatusID.Silence, - StatusID.Slow, - StatusID.Slow2, - StatusID.Slow3, - StatusID.Slow4, - StatusID.Slow5, - StatusID.Blind, - StatusID.Blind2, - StatusID.Blind3, - StatusID.Paralysis, - StatusID.Paralysis2, - StatusID.Nightmare, - StatusID.Necrosis, - }; - public static bool IsDangerous(this Status status) { if (!status.CanDispel()) return false; if (status.StackCount > 2) return true; - return dangerousStatus.Any(id => (uint)id == status.StatusId); + return Service.Config.DangerousStatus.Any(id => id == status.StatusId); } public static bool CanDispel(this Status status) diff --git a/RotationSolver/ActionSequencer/BaseStatus.cs b/RotationSolver/ActionSequencer/BaseStatus.cs index 30a0a0c18..f23bdc435 100644 --- a/RotationSolver/ActionSequencer/BaseStatus.cs +++ b/RotationSolver/ActionSequencer/BaseStatus.cs @@ -7,14 +7,24 @@ internal class BaseStatus : ITexture public Status _status; public uint IconID => _status.Icon; public StatusID ID => (StatusID)_status.RowId; - public string Name => $"{_status.Name}[{_status.RowId}]"; + public string Name => $"{_status.Name} ({_status.RowId})"; public string Description => string.Empty; public bool IsEnabled { get; set; } public BaseStatus(StatusID id) + : this((uint)id) { - _status = Service.GetSheet().GetRow((uint)id); + } + + public BaseStatus(uint id) + : this(Service.GetSheet().GetRow(id)) + { + } + + public BaseStatus(Status status) + { + _status = status; } } diff --git a/RotationSolver/ActionSequencer/ConditionSet.cs b/RotationSolver/ActionSequencer/ConditionSet.cs index d6a1daac0..b1f075798 100644 --- a/RotationSolver/ActionSequencer/ConditionSet.cs +++ b/RotationSolver/ActionSequencer/ConditionSet.cs @@ -72,7 +72,6 @@ private void AddOneCondition(string name) where T : ICondition { if (ImGui.Selectable(name)) { - Conditions.Add(Activator.CreateInstance()); ImGui.CloseCurrentPopup(); } diff --git a/RotationSolver/ActionSequencer/TargetCondition.cs b/RotationSolver/ActionSequencer/TargetCondition.cs index 02c76a89e..7a81da406 100644 --- a/RotationSolver/ActionSequencer/TargetCondition.cs +++ b/RotationSolver/ActionSequencer/TargetCondition.cs @@ -8,7 +8,7 @@ namespace RotationSolver.Timeline; internal class TargetCondition : ICondition { private static BaseStatus[] _allStatus = null; - private static BaseStatus[] AllStatus + public static BaseStatus[] AllStatus { get { diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index 4d0302b4f..083a45f07 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -19,6 +19,7 @@ internal partial class Strings public string ConfigWindow_Header { get; set; } = "Rotation Solver Settings v"; public string ConfigWindow_RotationItem { get; set; } = "Rotation"; public string ConfigWindow_ParamItem { get; set; } = "Param"; + public string ConfigWindow_ListItem { get; set; } = "List"; public string ConfigWindow_EventItem { get; set; } = "Event"; public string ConfigWindow_ActionItem { get; set; } = "Action"; public string ConfigWindow_ControlItem { get; set; } = "Control"; @@ -237,7 +238,7 @@ internal partial class Strings public string ConfigWindow_Param_RaiseBrinkOfDeath { get; set; } = "Raise player even has Brink of Death"; public string ConfigWindow_Param_MoveAreaActionFarthest { get; set; } = "Moving Area Ability to farthest"; public string ConfigWindow_Param_MoveAreaActionFarthestDesc { get; set; } = "Move to the furthest position from character's face direction."; - public string ConfigWindow_Param_Hostile { get; set; } = "Hostile"; + public string ConfigWindow_Param_HostileDesc { get; set; } = "You can set the logic of hostile target selection to allow flexibility in switching the logic of selecting hostile in battle."; public string ConfigWindow_Param_AddHostileCondition { get; set; } = "Add selection condition"; public string ConfigWindow_Param_HostileCondition { get; set; } = "Hostile target selection condition"; @@ -280,6 +281,13 @@ internal partial class Strings public string ConfigWindow_Rotation_InvalidRotation { get; set; } = "Invalid Rotation! \nPlease update to the latest version or contact to the {0}!"; public string ConfigWindow_Rotation_ResetToDefault { get; set; } = "Click to reset the rotation configuration to default!"; + + public string ConfigWindow_List_Description { get; set; } = "In this window, you can set the parameters about some list things."; + public string ConfigWindow_List_Hostile { get; set; } = "Hostile"; + + public string ConfigWindow_List_Invinsibility { get; set; } = "Invincibility"; + public string ConfigWindow_List_DangerousStatus { get; set; } = "Dangerous Status"; + #endregion #region ScriptWindow diff --git a/RotationSolver/UI/ImGuiHelper.cs b/RotationSolver/UI/ImGuiHelper.cs index bc385ac74..17891512c 100644 --- a/RotationSolver/UI/ImGuiHelper.cs +++ b/RotationSolver/UI/ImGuiHelper.cs @@ -258,7 +258,6 @@ internal static void SearchCombo(string popId, string name, ref string search if (ImGui.BeginCombo(popId, name, ImGuiComboFlags.HeightLargest)) { SearchItems(ref searchTxt, actions, selectAction); - ImGui.EndCombo(); } } diff --git a/RotationSolver/UI/RotationConfigWindow_List.cs b/RotationSolver/UI/RotationConfigWindow_List.cs new file mode 100644 index 000000000..482746518 --- /dev/null +++ b/RotationSolver/UI/RotationConfigWindow_List.cs @@ -0,0 +1,124 @@ +using Lumina.Excel.GeneratedSheets; +using RotationSolver.Localization; +using RotationSolver.Timeline; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RotationSolver.UI; + +internal partial class RotationConfigWindow +{ + private static BaseStatus[] _allStatus = null; + public static BaseStatus[] AllStatus + { + get + { + if (_allStatus == null) + { + _allStatus = Service.GetSheet() + .Where(s => s.CanDispel) + .Select(s => new BaseStatus(s)) + .ToArray(); + } + return _allStatus; + } + } + + private void DrawListTab() + { + ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_Description); + + ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f)); + + if (ImGui.BeginTabBar("List Items")) + { + DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_Hostile, DrawParamHostile); + + DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_Invinsibility, DrawInvinsibility); + + DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_DangerousStatus, DrawDangerousStatus); + + ImGui.EndTabBar(); + } + ImGui.PopStyleVar(); + } + + private void DrawParamHostile() + { + if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Param_AddHostileCondition)) + { + Service.Config.TargetingTypes.Add(TargetingType.Big); + } + ImGui.SameLine(); + ImGuiHelper.Spacing(); + ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Param_HostileDesc); + + for (int i = 0; i < Service.Config.TargetingTypes.Count; i++) + { + ImGui.Separator(); + + var names = Enum.GetNames(typeof(TargetingType)); + var targingType = (int)Service.Config.TargetingTypes[i]; + if (ImGui.Combo(LocalizationManager.RightLang.ConfigWindow_Param_HostileCondition + "##HostileCondition" + i.ToString(), ref targingType, names, names.Length)) + { + Service.Config.TargetingTypes[i] = (TargetingType)targingType; + Service.Config.Save(); + } + + if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Param_ConditionUp + "##HostileUp" + i.ToString())) + { + if (i != 0) + { + var value = Service.Config.TargetingTypes[i]; + Service.Config.TargetingTypes.RemoveAt(i); + Service.Config.TargetingTypes.Insert(i - 1, value); + } + } + ImGui.SameLine(); + ImGuiHelper.Spacing(); + if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Param_ConditionDown + "##HostileDown" + i.ToString())) + { + if (i < Service.Config.TargetingTypes.Count - 1) + { + var value = Service.Config.TargetingTypes[i]; + Service.Config.TargetingTypes.RemoveAt(i); + Service.Config.TargetingTypes.Insert(i + 1, value); + } + } + + ImGui.SameLine(); + ImGuiHelper.Spacing(); + + if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Param_ConditionDelete + "##HostileDelete" + i.ToString())) + { + Service.Config.TargetingTypes.RemoveAt(i); + } + } + } + + private void DrawDangerousStatus() + { + if (ImGuiHelper.IconButton(FontAwesomeIcon.Plus, "AddDangerousStatus")) + { + Service.Config.DangerousStatus.Add(0); + } + + for (int i = 0; i < Service.Config.DangerousStatus.Count; i++) + { + //ImGuiHelper.SearchCombo() + } + } + + private void DrawInvinsibility() + { + if (ImGuiHelper.IconButton(FontAwesomeIcon.Plus, "AddInvinsibilityStatus")) + { + Service.Config.InvincibleStatus.Add(0); + } + + TargetCondition.AllStatus; + } +} diff --git a/RotationSolver/UI/RotationConfigWindow_Major.cs b/RotationSolver/UI/RotationConfigWindow_Major.cs index 0880c6322..e856ba69b 100644 --- a/RotationSolver/UI/RotationConfigWindow_Major.cs +++ b/RotationSolver/UI/RotationConfigWindow_Major.cs @@ -32,6 +32,12 @@ public override unsafe void Draw() ImGui.EndTabItem(); } + if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_ListItem)) + { + DrawListTab(); + ImGui.EndTabItem(); + } + if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_ControlItem)) { DrawControlTab(); @@ -72,4 +78,153 @@ public override unsafe void Draw() } ImGui.End(); } + + internal static void DrawCheckBox(string name, SettingsCommand command, string description = "", Action otherThing = null) + { + var value = Service.Config.GetValue(command); + DrawCheckBox(name, ref value, command.GetDefault(), description, () => + { + Service.Config.SetValue(command, value); + otherThing?.Invoke(); + }); + + ImGui.SameLine(); + ImGuiHelper.Spacing(); + ImGuiHelper.DisplayCommandHelp(OtherCommandType.Settings, command.ToString()); + } + + internal static void DrawCheckBox(string name, ref bool value, bool @default, string description = "", Action otherThing = null) + { + if (ImGui.Checkbox(name, ref value)) + { + otherThing?.Invoke(); + Service.Config.Save(); + } + if (ImGuiHelper.HoveredStringReset(description) && value != @default) + { + otherThing?.Invoke(); + value = @default; + Service.Config.Save(); + } + } + + private static void DrawRangedFloat(string name, ref float minValue, ref float maxValue, float defaultMin, float defaultMax, float speed = 0.01f, float min = 0, float max = 3, string description = "") + { + ImGui.SetNextItemWidth(100); + if (ImGui.DragFloatRange2(name, ref minValue, ref maxValue, speed, min, max)) + { + Service.Config.Save(); + } + if (ImGuiHelper.HoveredStringReset(description) && (minValue != defaultMin || maxValue != defaultMax)) + { + minValue = defaultMin; + maxValue = defaultMax; + Service.Config.Save(); + } + } + + private static void DrawRangedInt(string name, ref int minValue, ref int maxValue, int defaultMin, int defaultMax, float speed = 0.01f, int min = 0, int max = 3, string description = "") + { + ImGui.SetNextItemWidth(100); + if (ImGui.DragIntRange2(name, ref minValue, ref maxValue, speed, min, max)) + { + Service.Config.Save(); + } + if (ImGuiHelper.HoveredStringReset(description) && (minValue != defaultMin || maxValue != defaultMax)) + { + minValue = defaultMin; + maxValue = defaultMax; + Service.Config.Save(); + } + } + + private static void DrawFloatNumber(string name, ref float value, float @default, float speed = 0.002f, float min = 0, float max = 1, string description = "", Action otherThing = null) + { + ImGui.SetNextItemWidth(100); + if (ImGui.DragFloat(name, ref value, speed, min, max)) + { + Service.Config.Save(); + otherThing?.Invoke(); + } + if (ImGuiHelper.HoveredStringReset(description) && value != @default) + { + value = @default; + Service.Config.Save(); + otherThing?.Invoke(); + } + } + + private static void DrawIntNumber(string name, ref int value, int @default, float speed = 0.2f, int min = 0, int max = 1, string description = "", Action otherThing = null) + { + ImGui.SetNextItemWidth(100); + if (ImGui.DragInt(name, ref value, speed, min, max)) + { + Service.Config.Save(); + otherThing?.Invoke(); + } + if (ImGuiHelper.HoveredStringReset(description) && value != @default) + { + value = @default; + Service.Config.Save(); + otherThing?.Invoke(); + } + } + + private static void DrawColor3(string name, ref Vector3 value, Vector3 @default, string description = "") + { + ImGui.SetNextItemWidth(210); + if (ImGui.ColorEdit3(name, ref value)) + { + Service.Config.Save(); + } + if (ImGuiHelper.HoveredStringReset(description) && value != @default) + { + value = @default; + Service.Config.Save(); + } + } + + private static void DrawCombo(string name, ref int value, Func toString, T[] choices = null, string description = "") where T : struct, Enum + { + choices = choices ?? Enum.GetValues(); + + ImGui.SetNextItemWidth(100); + if (ImGui.BeginCombo(name, toString(choices[value]))) + { + for (int i = 0; i < choices.Length; i++) + { + if (ImGui.Selectable(toString(choices[i]))) + { + value = i; + Service.Config.Save(); + } + } + ImGui.EndCombo(); + } + ImGuiHelper.HoveredString(description); + } + + private static void DrawInputText(string name, ref string value, uint maxLength, string description = "") + { + ImGui.SetNextItemWidth(210); + if (ImGui.InputText(name, ref value, maxLength)) + { + Service.Config.Save(); + } + ImGuiHelper.HoveredString(description); + } + + private static void DrawParamTabItem(string name, Action act) + { + if (act == null) return; + if (ImGui.BeginTabItem(name)) + { + if (ImGui.BeginChild("Param", new Vector2(0f, -1f), true)) + { + act(); + ImGui.EndChild(); + } + ImGui.EndTabItem(); + } + } } diff --git a/RotationSolver/UI/RotationConfigWindow_Param.cs b/RotationSolver/UI/RotationConfigWindow_Param.cs index 18b6b505d..9ca299b12 100644 --- a/RotationSolver/UI/RotationConfigWindow_Param.cs +++ b/RotationSolver/UI/RotationConfigWindow_Param.cs @@ -4,20 +4,6 @@ namespace RotationSolver.UI; internal partial class RotationConfigWindow { - private static void DrawParamTabItem(string name, Action act) - { - if (act == null) return; - if (ImGui.BeginTabItem(name)) - { - if (ImGui.BeginChild("Param", new Vector2(0f, -1f), true)) - { - act(); - ImGui.EndChild(); - } - ImGui.EndTabItem(); - } - } - private void DrawParamTab() { ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Params_Description); @@ -32,7 +18,6 @@ private void DrawParamTab() DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Action, DrawParamAction); DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Conditon, DrawParamCondition); DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Target, DrawParamTarget); - DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Hostile, DrawParamHostile); DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Advanced, DrawParamAdvanced); ImGui.EndTabBar(); @@ -439,191 +424,4 @@ private void DrawParamTarget() DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_RaiseBrinkOfDeath, ref Service.Config.RaiseBrinkOfDeath, Service.Default.RaiseBrinkOfDeath); } - - private void DrawParamHostile() - { - if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Param_AddHostileCondition)) - { - Service.Config.TargetingTypes.Add(TargetingType.Big); - } - ImGui.SameLine(); - ImGuiHelper.Spacing(); - ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Param_HostileDesc); - for (int i = 0; i < Service.Config.TargetingTypes.Count; i++) - { - ImGui.Separator(); - - var names = Enum.GetNames(typeof(TargetingType)); - var targingType = (int)Service.Config.TargetingTypes[i]; - if (ImGui.Combo(LocalizationManager.RightLang.ConfigWindow_Param_HostileCondition + "##HostileCondition" + i.ToString(), ref targingType, names, names.Length)) - { - Service.Config.TargetingTypes[i] = (TargetingType)targingType; - Service.Config.Save(); - } - - if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Param_ConditionUp + "##HostileUp" + i.ToString())) - { - if (i != 0) - { - var value = Service.Config.TargetingTypes[i]; - Service.Config.TargetingTypes.RemoveAt(i); - Service.Config.TargetingTypes.Insert(i - 1, value); - } - } - ImGui.SameLine(); - ImGuiHelper.Spacing(); - if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Param_ConditionDown + "##HostileDown" + i.ToString())) - { - if (i < Service.Config.TargetingTypes.Count - 1) - { - var value = Service.Config.TargetingTypes[i]; - Service.Config.TargetingTypes.RemoveAt(i); - Service.Config.TargetingTypes.Insert(i + 1, value); - } - } - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - - if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_Param_ConditionDelete + "##HostileDelete" + i.ToString())) - { - Service.Config.TargetingTypes.RemoveAt(i); - } - } - } - - internal static void DrawCheckBox(string name, SettingsCommand command, string description = "", Action otherThing = null) - { - var value = Service.Config.GetValue(command); - DrawCheckBox(name, ref value, command.GetDefault(), description, () => - { - Service.Config.SetValue(command, value); - otherThing?.Invoke(); - }); - - ImGui.SameLine(); - ImGuiHelper.Spacing(); - ImGuiHelper.DisplayCommandHelp(OtherCommandType.Settings, command.ToString()); - } - - internal static void DrawCheckBox(string name, ref bool value, bool @default, string description = "", Action otherThing = null) - { - if (ImGui.Checkbox(name, ref value)) - { - otherThing?.Invoke(); - Service.Config.Save(); - } - if (ImGuiHelper.HoveredStringReset(description) && value != @default) - { - otherThing?.Invoke(); - value = @default; - Service.Config.Save(); - } - } - - private static void DrawRangedFloat(string name, ref float minValue, ref float maxValue, float defaultMin, float defaultMax, float speed = 0.01f, float min = 0, float max = 3, string description = "") - { - ImGui.SetNextItemWidth(100); - if (ImGui.DragFloatRange2(name, ref minValue, ref maxValue, speed, min, max)) - { - Service.Config.Save(); - } - if (ImGuiHelper.HoveredStringReset(description) && (minValue != defaultMin || maxValue != defaultMax)) - { - minValue = defaultMin; - maxValue = defaultMax; - Service.Config.Save(); - } - } - - private static void DrawRangedInt(string name, ref int minValue, ref int maxValue, int defaultMin, int defaultMax, float speed = 0.01f, int min = 0, int max = 3, string description = "") - { - ImGui.SetNextItemWidth(100); - if (ImGui.DragIntRange2(name, ref minValue, ref maxValue, speed, min, max)) - { - Service.Config.Save(); - } - if (ImGuiHelper.HoveredStringReset(description) && (minValue != defaultMin || maxValue != defaultMax)) - { - minValue = defaultMin; - maxValue = defaultMax; - Service.Config.Save(); - } - } - - private static void DrawFloatNumber(string name, ref float value, float @default, float speed = 0.002f, float min = 0, float max = 1, string description = "", Action otherThing = null) - { - ImGui.SetNextItemWidth(100); - if (ImGui.DragFloat(name, ref value, speed, min, max)) - { - Service.Config.Save(); - otherThing?.Invoke(); - } - if (ImGuiHelper.HoveredStringReset(description) && value != @default) - { - value = @default; - Service.Config.Save(); - otherThing?.Invoke(); - } - } - - private static void DrawIntNumber(string name, ref int value, int @default, float speed = 0.2f, int min = 0, int max = 1, string description = "", Action otherThing = null) - { - ImGui.SetNextItemWidth(100); - if (ImGui.DragInt(name, ref value, speed, min, max)) - { - Service.Config.Save(); - otherThing?.Invoke(); - } - if (ImGuiHelper.HoveredStringReset(description) && value != @default) - { - value = @default; - Service.Config.Save(); - otherThing?.Invoke(); - } - } - - private static void DrawColor3(string name, ref Vector3 value, Vector3 @default, string description = "") - { - ImGui.SetNextItemWidth(210); - if (ImGui.ColorEdit3(name, ref value)) - { - Service.Config.Save(); - } - if (ImGuiHelper.HoveredStringReset(description) && value != @default) - { - value = @default; - Service.Config.Save(); - } - } - - private static void DrawCombo(string name, ref int value, Func toString, T[] choices = null, string description = "") where T : struct, Enum - { - choices = choices ?? Enum.GetValues(); - - ImGui.SetNextItemWidth(100); - if (ImGui.BeginCombo(name, toString(choices[value]))) - { - for (int i = 0; i < choices.Length; i++) - { - if (ImGui.Selectable(toString(choices[i]))) - { - value = i; - Service.Config.Save(); - } - } - ImGui.EndCombo(); - } - ImGuiHelper.HoveredString(description); - } - - private static void DrawInputText(string name, ref string value, uint maxLength, string description = "") - { - ImGui.SetNextItemWidth(210); - if (ImGui.InputText(name, ref value, maxLength)) - { - Service.Config.Save(); - } - ImGuiHelper.HoveredString(description); - } }