@@ -13,6 +13,9 @@ vector MENU_TEXT_SMALL = '12 12 0';
1313vector MENU_TEXT_MEDIUM = '14 14 0' ;
1414vector MENU_TEXT_LARGE = '28 28 0' ;
1515
16+ float menu_leftarrow_pressed;
17+ float menu_rightarrow_pressed;
18+
1619void () input_tester =
1720{
1821 float char = 0 ;
@@ -561,11 +564,11 @@ void(vector pos, vector size, vector minmaxsteps, string cvar_s, string name, st
561564};
562565
563566//
564- // Menu_CvarSlider(order, minmaxsteps, cvar_s, is_int, no_text, zero_is_one)
567+ // Menu_CvarSlider(order, button_id, minmaxsteps, cvar_s, is_int, no_text, zero_is_one)
565568// Draws a Slider at the given order position
566569// that controls a cvar.
567570//
568- void (float order, vector minmaxsteps, string cvar_s, float is_int, float no_text, float zero_is_one) Menu_CvarSlider =
571+ void (float order, string button_id, vector minmaxsteps, string cvar_s, float is_int, float no_text, float zero_is_one) Menu_CvarSlider =
569572{
570573 float current = cvar(cvar_s);
571574 float old = current;
@@ -575,6 +578,24 @@ void(float order, vector minmaxsteps, string cvar_s, float is_int, float no_text
575578
576579 my_slider(strcat(cvar_s, "sldr" ), [position_x, (position_y - 17 ) + size_y * 0.5 ], [size_x, size_y * 0.5 ], minmaxsteps, current);
577580
581+ // For keyboard/gamepad navigation -- we need to check if the button associated
582+ // with this slider is active and then do input checks to test if we should
583+ // adjust the related cvar.
584+ if (sui_is_hovered(button_id)) {
585+ float interval = ((minmaxsteps[1 ] - minmaxsteps[0 ]) / minmaxsteps[2 ]);
586+ if (menu_leftarrow_pressed) {
587+ current -= interval;
588+ } else if (menu_rightarrow_pressed) {
589+ current += interval;
590+ }
591+
592+ if (current < minmaxsteps[0 ])
593+ current = minmaxsteps[0 ];
594+
595+ if (current > minmaxsteps[1 ])
596+ current = minmaxsteps[1 ];
597+ }
598+
578599 if (current != old) {
579600 if (is_int)
580601 cvar_set(cvar_s, ftos(rint(current)));
@@ -881,6 +902,16 @@ void(float type) Menu_PlaySound =
881902 localsound(sound, 0 , cvar("nzp_uivolume" ));
882903};
883904
905+ void () Menu_LeftArrowPressed =
906+ {
907+ menu_leftarrow_pressed = TRUE;
908+ };
909+
910+ void () Menu_RightArrowPressed =
911+ {
912+ menu_rightarrow_pressed = TRUE;
913+ };
914+
884915float last_menu;
885916void (vector size) root_menu =
886917{
@@ -922,6 +953,9 @@ void(vector size) root_menu =
922953 default : break ;
923954 }
924955
956+ menu_leftarrow_pressed = false;
957+ menu_rightarrow_pressed = false;
958+
925959 // Menu enter sound
926960 if (last_menu != current_menu) {
927961 Menu_PlaySound(MENU_SND_ENTER);
0 commit comments