Skip to content

Commit b667743

Browse files
Merge pull request #18 from FFXIV-CombatReborn/burst-button-crash
Fixes burst button crashing when clicked
2 parents 8fb701d + 0d5c395 commit b667743

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

RotationSolver/UI/ControlWindow.cs

+32-7
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,52 @@ public override unsafe void Draw()
7575

7676
var color = *ImGui.GetStyleColorVec4(ImGuiCol.TextDisabled);
7777

78-
var isAoe = Service.Config.UseAoeAction
79-
&& (!DataCenter.IsManual
80-
|| Service.Config.UseAoeWhenManual);
78+
var isAoe = Service.Config.UseAoeAction && (!DataCenter.IsManual || Service.Config.UseAoeWhenManual);
79+
80+
// Track whether the style color was pushed
81+
bool pushedStyleColor = false;
82+
83+
if (!isAoe)
84+
{
85+
ImGui.PushStyleColor(ImGuiCol.Text, color);
86+
pushedStyleColor = true; // Indicate that a style color has been pushed
87+
}
8188

82-
if (!isAoe) ImGui.PushStyleColor(ImGuiCol.Text, color);
8389
if (ImGuiHelper.SelectableButton("AOE"))
8490
{
8591
Service.Config.UseAoeAction.Value = !isAoe;
8692
Service.Config.UseAoeWhenManual.Value = !isAoe;
8793
}
88-
if (!isAoe) ImGui.PopStyleColor();
94+
95+
// Ensure PopStyleColor is called only if PushStyleColor was called
96+
if (pushedStyleColor)
97+
{
98+
ImGui.PopStyleColor();
99+
}
100+
89101

90102
ImGui.SameLine();
91103

92104
var isBurst = Service.Config.AutoBurst;
93-
if (!isBurst) ImGui.PushStyleColor(ImGuiCol.Text, color);
105+
// Track whether the style color was pushed
106+
pushedStyleColor = false;
107+
108+
if (!isBurst)
109+
{
110+
ImGui.PushStyleColor(ImGuiCol.Text, color);
111+
pushedStyleColor = true; // Indicate that a style color has been pushed
112+
}
113+
94114
if (ImGuiHelper.SelectableButton("Burst"))
95115
{
96116
Service.Config.AutoBurst.Value = !isBurst;
97117
}
98-
if (!isBurst) ImGui.PopStyleColor();
118+
119+
// Ensure PopStyleColor is called only if PushStyleColor was called
120+
if (pushedStyleColor)
121+
{
122+
ImGui.PopStyleColor();
123+
}
99124
ImGui.SameLine();
100125
columnWidth = Math.Max(columnWidth, ImGui.GetCursorPosX());
101126
ImGui.NewLine();

0 commit comments

Comments
 (0)