diff --git a/DelvCD/Config/ElementListConfig.cs b/DelvCD/Config/ElementListConfig.cs index 76c75ba..dce0132 100644 --- a/DelvCD/Config/ElementListConfig.cs +++ b/DelvCD/Config/ElementListConfig.cs @@ -5,6 +5,7 @@ using Dalamud.Interface; using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using DelvCD.Helpers; using DelvCD.UIElements; using Dalamud.Bindings.ImGui; @@ -103,8 +104,8 @@ private unsafe void DrawUIElementTable(Vector2 size, float padX) continue; } - ImGui.PushID($"##UIElements_Table_Row_{i}"); - + using var rowId = ImRaii.PushId($"##UIElements_Table_Row_{i}"); + ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); if (ImGui.TableSetColumnIndex(0)) diff --git a/DelvCD/Config/FontConfig.cs b/DelvCD/Config/FontConfig.cs index 55f4cdd..5cb118f 100644 --- a/DelvCD/Config/FontConfig.cs +++ b/DelvCD/Config/FontConfig.cs @@ -1,5 +1,6 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using DelvCD.Helpers; using Dalamud.Bindings.ImGui; using Newtonsoft.Json; @@ -103,7 +104,7 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad for (int i = 0; i < Fonts.Keys.Count; i++) { - ImGui.PushID($"##Font_Table_Row_{i}"); + using var rowId = ImRaii.PushId($"##Font_Table_Row_{i}"); ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); string key = Fonts.Keys.ElementAt(i); diff --git a/DelvCD/Config/LabelListConfig.cs b/DelvCD/Config/LabelListConfig.cs index 0f90b49..0587ee7 100644 --- a/DelvCD/Config/LabelListConfig.cs +++ b/DelvCD/Config/LabelListConfig.cs @@ -3,6 +3,7 @@ using Dalamud.Interface; using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using DelvCD.Helpers; using DelvCD.UIElements; using Dalamud.Bindings.ImGui; @@ -88,7 +89,7 @@ private void DrawLabelTable(Vector2 size, float padX) int i = 0; for (; i < Labels.Count; i++) { - ImGui.PushID($"##Label_Table_Row_{i}"); + using var rowId = ImRaii.PushId($"##Label_Table_Row_{i}"); ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); Label label = Labels[i]; @@ -112,23 +113,25 @@ private void DrawLabelTable(Vector2 size, float padX) } } - ImGui.PushID($"##Label_Table_Row_{i + 1}"); - ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); - if (ImGui.TableSetColumnIndex(0)) + using (ImRaii.PushId($"##Label_Table_Row_{i + 1}")) { - ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 1f * _scale); - ImGui.PushItemWidth(ImGui.GetColumnWidth()); - ImGui.InputTextWithHint("##LabelInput", "New Label Name", ref _labelInput, 10000); - ImGui.PopItemWidth(); - } + ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); + if (ImGui.TableSetColumnIndex(0)) + { + ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 1f * _scale); + ImGui.PushItemWidth(ImGui.GetColumnWidth()); + ImGui.InputTextWithHint("##LabelInput", "New Label Name", ref _labelInput, 10000); + ImGui.PopItemWidth(); + } - if (ImGui.TableSetColumnIndex(1)) - { - ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 1f); - DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Plus, () => AddLabel(_labelInput), "Create Label", buttonSize); + if (ImGui.TableSetColumnIndex(1)) + { + ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 1f); + DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Plus, () => AddLabel(_labelInput), "Create Label", buttonSize); - ImGui.SameLine(); - DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Download, () => ImportLabel(), "Import Label", buttonSize); + ImGui.SameLine(); + DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Download, () => ImportLabel(), "Import Label", buttonSize); + } } ImGui.EndTable(); diff --git a/DelvCD/Config/StatusTrigger.cs b/DelvCD/Config/StatusTrigger.cs index 819bfec..f426bca 100644 --- a/DelvCD/Config/StatusTrigger.cs +++ b/DelvCD/Config/StatusTrigger.cs @@ -113,10 +113,10 @@ public override bool IsTriggered(bool preview) _dataSource.Status_Stacks = status.Param; _dataSource.Max_Status_Stacks = trigger.MaxStacks; - if (_dataSource.Max_Status_Stacks > 0) { - _dataSource.Icon = (uint)(trigger.Icon + _dataSource.Status_Stacks - 1); + if (_dataSource.Max_Status_Stacks > 0) { + _dataSource.Icon = (uint)(trigger.Icon + _dataSource.Status_Stacks - 1); } - else + else { _dataSource.Icon = trigger.Icon; } @@ -155,7 +155,7 @@ public override void DrawTriggerOptions(Vector2 size, float padX, float padY) ImGui.Combo("Trigger Source", ref Unsafe.As(ref TriggerSource), _sourceOptions, _sourceOptions.Length); // Don't display the trigger source type option if the TriggerSource is set to Player, since player will always be friendly. - if( this.TriggerSource is not TriggerSource.Player) { + if( this.TriggerSource is not TriggerSource.Player) { ImGui.Combo("Trigger Source Type", ref Unsafe.As(ref this.TriggerSourceType), _sourceTypeOptions, _sourceTypeOptions.Length); } @@ -188,12 +188,12 @@ public override void DrawTriggerOptions(Vector2 size, float padX, float padY) Vector2 iconPos = ImGui.GetWindowPos() + new Vector2(width - 100 * _scale, 20 * _scale); DrawHelpers.DrawIcon( TriggerData[0].Icon, - iconPos, - new Vector2(40 * _scale, 54 * _scale), - false, - 0, - false, - 1f, + iconPos, + new Vector2(40 * _scale, 54 * _scale), + false, + 0, + false, + 1f, drawList ); } diff --git a/DelvCD/Config/Styles/StyleConditions.cs b/DelvCD/Config/Styles/StyleConditions.cs index 2b4545e..4be89bc 100644 --- a/DelvCD/Config/Styles/StyleConditions.cs +++ b/DelvCD/Config/Styles/StyleConditions.cs @@ -1,5 +1,6 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using DelvCD.Helpers; using DelvCD.Helpers.DataSources; using Dalamud.Bindings.ImGui; @@ -196,16 +197,18 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad for (int i = 0; i < Conditions.Count; i++) { - ImGui.PushID($"##Conditions_Table_Row_{i}"); + using var rowId = ImRaii.PushId($"##Conditions_Table_Row_{i}"); ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); DrawStyleConditionRow(i); } - ImGui.PushID($"##Conditions_Table_Row_{Conditions.Count}"); - ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); - ImGui.TableSetColumnIndex(5); - DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Plus, () => Conditions.Add(new StyleCondition(_defaultStyle)), "New Condition", buttonSize); + using (ImRaii.PushId($"##Conditions_Table_Row_{Conditions.Count}")) + { + ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); + ImGui.TableSetColumnIndex(5); + DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Plus, () => Conditions.Add(new StyleCondition(_defaultStyle)), "New Condition", buttonSize); + } ImGui.EndTable(); } diff --git a/DelvCD/Config/TriggerConfig.cs b/DelvCD/Config/TriggerConfig.cs index 50a1569..0bb4c6f 100644 --- a/DelvCD/Config/TriggerConfig.cs +++ b/DelvCD/Config/TriggerConfig.cs @@ -1,5 +1,6 @@ using Dalamud.Interface; using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using DelvCD.Helpers; using Dalamud.Bindings.ImGui; using Newtonsoft.Json; @@ -147,18 +148,20 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad for (int i = 0; i < TriggerOptions.Count; i++) { - ImGui.PushID($"##Conditions_Table_Row_{i}"); + using var rowId = ImRaii.PushId($"##Conditions_Table_Row_{i}"); ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); DrawTriggerRow(i); } - ImGui.PushID($"##Conditions_Table_Row_{TriggerOptions.Count}"); - ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); - ImGui.TableSetColumnIndex(3); - DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Plus, () => AddTrigger(), "New Trigger", buttonSize); - ImGui.SameLine(); - DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Download, () => ImportTrigger(), "Import Trigger", buttonSize); + using (ImRaii.PushId($"##Conditions_Table_Row_{TriggerOptions.Count}")) + { + ImGui.TableNextRow(ImGuiTableRowFlags.None, 28); + ImGui.TableSetColumnIndex(3); + DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Plus, () => AddTrigger(), "New Trigger", buttonSize); + ImGui.SameLine(); + DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Download, () => ImportTrigger(), "Import Trigger", buttonSize); + } ImGui.EndTable();