@@ -847,23 +847,7 @@ void hud_config_check_regions_by_mouse(int mx, int my)
847847 */
848848void hud_config_check_regions (int mx, int my)
849849{
850- if (hud_config_check_mouse_in_hud_area (mx, my)) {
851- HC_gauge_hot = " -2" ;
852- }
853-
854- if (HC_gauge_hot == " -2" && mouse_down (MOUSE_LEFT_BUTTON)) {
855- HC_gauge_selected.clear ();
856- HC_color_sliders[HCS_RED].hide ();
857- HC_color_sliders[HCS_GREEN].hide ();
858- HC_color_sliders[HCS_BLUE].hide ();
859- HC_color_sliders[HCS_ALPHA].hide ();
860-
861- HC_color_sliders[HCS_RED].disable ();
862- HC_color_sliders[HCS_GREEN].disable ();
863- HC_color_sliders[HCS_BLUE].disable ();
864- HC_color_sliders[HCS_ALPHA].disable ();
865- }
866-
850+ // If we click on one of the new arrows then try to select a new HUD
867851 if (HC_arrow_hot >= 0 && mouse_down (MOUSE_LEFT_BUTTON)) {
868852 gamesnd_play_iface (InterfaceSounds::USER_SELECT);
869853 if (HC_arrow_hot == 0 ) {
@@ -875,51 +859,65 @@ void hud_config_check_regions(int mx, int my)
875859 return ;
876860 }
877861
878- hud_config_check_regions_by_mouse (mx, my);
862+ // If we're not in the HUD area then nothing else applies here
863+ if (!hud_config_check_mouse_in_hud_area (mx, my)) {
864+ mouse_flush ();
865+ return ;
866+ }
879867
880- if (!HC_gauge_hot.empty () && mouse_down (MOUSE_LEFT_BUTTON)) {
881- gamesnd_play_iface (InterfaceSounds::USER_SELECT);
882- HC_gauge_selected = HC_gauge_hot;
868+ // Sets HC_gauge_hot to a gauge name if we're hovering over one of them
869+ hud_config_check_regions_by_mouse (mx, my);
883870
884- // turn off select all
885- hud_config_select_all_toggle (false );
871+ // If we click inside the HUD area then reset the UI
872+ if (mouse_down (MOUSE_LEFT_BUTTON)) {
873+ HC_gauge_selected.clear ();
874+ HC_color_sliders[HCS_RED].hide ();
875+ HC_color_sliders[HCS_GREEN].hide ();
876+ HC_color_sliders[HCS_BLUE].hide ();
877+ HC_color_sliders[HCS_ALPHA].hide ();
886878
887- const auto gauge = hud_config_get_gauge_pointer (HC_gauge_selected);
879+ HC_color_sliders[HCS_RED].disable ();
880+ HC_color_sliders[HCS_GREEN].disable ();
881+ HC_color_sliders[HCS_BLUE].disable ();
882+ HC_color_sliders[HCS_ALPHA].disable ();
888883
889- // maybe setup rgb sliders
890- if (gauge != nullptr && gauge->getConfigUseIffColor ()) {
891- HC_color_sliders[HCS_RED].hide ();
892- HC_color_sliders[HCS_GREEN].hide ();
893- HC_color_sliders[HCS_BLUE].hide ();
894- HC_color_sliders[HCS_ALPHA].hide ();
895-
896- HC_color_sliders[HCS_RED].disable ();
897- HC_color_sliders[HCS_GREEN].disable ();
898- HC_color_sliders[HCS_BLUE].disable ();
899- HC_color_sliders[HCS_ALPHA].disable ();
900- } else {
901- HC_color_sliders[HCS_RED].enable ();
902- HC_color_sliders[HCS_GREEN].enable ();
903- HC_color_sliders[HCS_BLUE].enable ();
904- HC_color_sliders[HCS_ALPHA].enable ();
884+ // Turn off select all
885+ hud_config_select_all_toggle (false );
905886
906- HC_color_sliders[HCS_RED].unhide ();
907- HC_color_sliders[HCS_GREEN].unhide ();
908- HC_color_sliders[HCS_BLUE].unhide ();
909- HC_color_sliders[HCS_ALPHA].unhide ();
887+ // See if we have a gauge that we were hovering over when we clicked
888+ const auto gauge = hud_config_get_gauge_pointer (HC_gauge_hot);
910889
911- color clr = HUD_config.get_gauge_color (HC_gauge_selected);
890+ // If we clicked on a gauge then set the UI up for managing that gauge
891+ if (gauge) {
892+ gamesnd_play_iface (InterfaceSounds::USER_SELECT);
893+ HC_gauge_selected = HC_gauge_hot;
894+
895+ // Setup rgb sliders if the gauge doesn't use IFF colors
896+ if (!gauge->getConfigUseIffColor ()) {
897+ HC_color_sliders[HCS_RED].enable ();
898+ HC_color_sliders[HCS_GREEN].enable ();
899+ HC_color_sliders[HCS_BLUE].enable ();
900+ HC_color_sliders[HCS_ALPHA].enable ();
901+
902+ HC_color_sliders[HCS_RED].unhide ();
903+ HC_color_sliders[HCS_GREEN].unhide ();
904+ HC_color_sliders[HCS_BLUE].unhide ();
905+ HC_color_sliders[HCS_ALPHA].unhide ();
906+
907+ color clr = HUD_config.get_gauge_color (HC_gauge_selected);
908+
909+ HC_color_sliders[HCS_RED].force_currentItem (HCS_CONV (clr.red ));
910+ HC_color_sliders[HCS_GREEN].force_currentItem (HCS_CONV (clr.green ));
911+ HC_color_sliders[HCS_BLUE].force_currentItem (HCS_CONV (clr.blue ));
912+ HC_color_sliders[HCS_ALPHA].force_currentItem (HCS_CONV (clr.alpha ));
913+ }
912914
913- HC_color_sliders[HCS_RED].force_currentItem (HCS_CONV (clr.red ));
914- HC_color_sliders[HCS_GREEN].force_currentItem (HCS_CONV (clr.green ));
915- HC_color_sliders[HCS_BLUE].force_currentItem (HCS_CONV (clr.blue ));
916- HC_color_sliders[HCS_ALPHA].force_currentItem (HCS_CONV (clr.alpha ));
915+ // recalc alpha slider
916+ hud_config_recalc_alpha_slider ();
917917 }
918-
919- // recalc alpha slider
920- hud_config_recalc_alpha_slider ();
921- mouse_flush ();
922918 }
919+
920+ mouse_flush ();
923921}
924922
925923// set the display flags for a HUD gauge
0 commit comments