diff --git a/src/client/menu/header/qmenu.h b/src/client/menu/header/qmenu.h index 47c9cea0..e131eec8 100644 --- a/src/client/menu/header/qmenu.h +++ b/src/client/menu/header/qmenu.h @@ -113,6 +113,7 @@ typedef struct float maxvalue; float slidestep; char * printformat; + qboolean abs; } menuslider_s; typedef struct diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c index ff822e0e..bb9bea97 100644 --- a/src/client/menu/menu.c +++ b/src/client/menu/menu.c @@ -1699,6 +1699,7 @@ Gyro_MenuInit(void) s_gyro_yawsensitivity_slider.cvar = "gyro_yawsensitivity"; s_gyro_yawsensitivity_slider.minvalue = 0.1f; s_gyro_yawsensitivity_slider.maxvalue = 8.0f; + s_gyro_yawsensitivity_slider.abs = true; s_gyro_pitchsensitivity_slider.generic.type = MTYPE_SLIDER; s_gyro_pitchsensitivity_slider.generic.x = 0; @@ -1707,6 +1708,7 @@ Gyro_MenuInit(void) s_gyro_pitchsensitivity_slider.cvar = "gyro_pitchsensitivity"; s_gyro_pitchsensitivity_slider.minvalue = 0.1f; s_gyro_pitchsensitivity_slider.maxvalue = 8.0f; + s_gyro_pitchsensitivity_slider.abs = true; s_calibrating_text[0].generic.type = MTYPE_SEPARATOR; s_calibrating_text[0].generic.x = 48 * scale + 32; diff --git a/src/client/menu/qmenu.c b/src/client/menu/qmenu.c index d5c4f20c..d13a2ed9 100644 --- a/src/client/menu/qmenu.c +++ b/src/client/menu/qmenu.c @@ -661,13 +661,20 @@ Slider_DoSlide(menuslider_s *s, int dir) { float value = Cvar_VariableValue(s->cvar); float step = 0.1f; + float sign = 1.0f; if (s->slidestep) { step = s->slidestep; } + if (s->abs && value < 0) // absolute value treatment + { + value = -value; + sign = -1.0f; + } + value += dir * step; - Cvar_SetValue(s->cvar, ClampCvar(s->minvalue, s->maxvalue, value)); + Cvar_SetValue(s->cvar, ClampCvar(s->minvalue, s->maxvalue, value) * sign); if (s->generic.callback) { @@ -688,6 +695,10 @@ Slider_Draw(menuslider_s *s) int y = s->generic.parent->y + s->generic.y; float value = Cvar_VariableValue(s->cvar); + if (s->abs && value < 0) // absolute value + { + value = -value; + } float range = (ClampCvar(s->minvalue, s->maxvalue, value) - s->minvalue) / (s->maxvalue - s->minvalue);