Browse Source

fix: Add conditional rendering for GUI dropdowns

Wrapped GuiDropdownBox calls in render_maneuver_create_tab() with validity checks:
- Direction dropdown: Only renders when craft_index is valid
- Trigger dropdown: Only renders when craft_index is valid
- Prevents accessing invalid array indices
- Makes UI more robust

Dropdowns now only appear when spacecraft is properly selected.
main
cinnaboot 5 months ago
parent
commit
f45b111064
  1. 12
      src/ui_renderer.cpp

12
src/ui_renderer.cpp

@ -494,8 +494,10 @@ void render_maneuver_create_tab(SimulationState* sim, UIState* ui_state, int x,
Rectangle dir_label = {(float)x, (float)current_y, 80, 25};
GuiLabel(dir_label, "Direction:");
Rectangle dir_combo = {(float)x + 85, (float)current_y, (float)(width - 95), 25};
GuiDropdownBox(dir_combo, "Prograde;Retrograde;Normal;Antinormal;Radial In;Radial Out;Custom", &ui_state->maneuver_dialog.direction_active, false);
if (ui_state->maneuver_dialog.craft_index >= 0 && ui_state->maneuver_dialog.craft_index < sim->craft_count) {
Rectangle dir_combo = {(float)x + 85, (float)current_y, (float)(width - 95), 25};
GuiDropdownBox(dir_combo, "Prograde;Retrograde;Normal;Antinormal;Radial In;Radial Out;Custom", &ui_state->maneuver_dialog.direction_active, false);
}
current_y += 35;
Rectangle dv_label = {(float)x, (float)current_y, 80, 25};
@ -515,8 +517,10 @@ void render_maneuver_create_tab(SimulationState* sim, UIState* ui_state, int x,
Rectangle trigger_label = {(float)x, (float)current_y, 80, 25};
GuiLabel(trigger_label, "Trigger:");
Rectangle trigger_combo = {(float)x + 85, (float)current_y, (float)(width - 95), 25};
GuiDropdownBox(trigger_combo, "Time;True Anomaly", &ui_state->maneuver_dialog.trigger_type_active, false);
if (ui_state->maneuver_dialog.craft_index >= 0 && ui_state->maneuver_dialog.craft_index < sim->craft_count) {
Rectangle trigger_combo = {(float)x + 85, (float)current_y, (float)(width - 95), 25};
GuiDropdownBox(trigger_combo, "Time;True Anomaly", &ui_state->maneuver_dialog.trigger_type_active, false);
}
current_y += 35;
Rectangle value_label = {(float)x, (float)current_y, 80, 25};

Loading…
Cancel
Save