Skip to content

Commit

Permalink
Sliders with visible values
Browse files Browse the repository at this point in the history
  • Loading branch information
protocultor committed Dec 13, 2023
1 parent ec7ba3c commit 0a7e2b9
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Quake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ void M_AdjustSliders (int dir)
}


void M_DrawSlider (int x, int y, float range)
void M_DrawSlider (int x, int y, float range, const char *val)
{
int i;

Expand All @@ -1150,6 +1150,7 @@ void M_DrawSlider (int x, int y, float range)
M_DrawCharacter (x + i*8, y, 129);
M_DrawCharacter (x+i*8, y, 130);
M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131);
M_Print (x + (SLIDER_RANGE + 1) * 8, y, val);
}

void M_DrawCheckbox (int x, int y, int on)
Expand All @@ -1170,6 +1171,7 @@ void M_Options_Draw (void)
{
float r, l;
qpic_t *p;
char slid_val[5] = {0};

M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic ("gfx/p_option.lmp");
Expand All @@ -1187,42 +1189,50 @@ void M_Options_Draw (void)
M_Print (16, 32 + 8*OPT_SCALE, " Scale");
l = (vid.width / 320.0) - 1;
r = l > 0 ? (scr_conscale.value - 1) / l : 0;
M_DrawSlider (220, 32 + 8*OPT_SCALE, r);
snprintf(slid_val, 5, "%.1f", scr_conscale.value);
M_DrawSlider (220, 32 + 8*OPT_SCALE, r, slid_val);

// OPT_SCRSIZE:
M_Print (16, 32 + 8*OPT_SCRSIZE, " Screen size");
r = (scr_viewsize.value - 30) / (120 - 30);
M_DrawSlider (220, 32 + 8*OPT_SCRSIZE, r);
snprintf(slid_val, 5, "%.0f", scr_viewsize.value);
M_DrawSlider (220, 32 + 8*OPT_SCRSIZE, r, slid_val);

// OPT_GAMMA:
M_Print (16, 32 + 8*OPT_GAMMA, " Brightness");
r = (1.0 - vid_gamma.value) / 0.5;
M_DrawSlider (220, 32 + 8*OPT_GAMMA, r);
snprintf(slid_val, 5, "%.2f", vid_gamma.value);
M_DrawSlider (220, 32 + 8*OPT_GAMMA, r, slid_val);

// OPT_CONTRAST:
M_Print (16, 32 + 8*OPT_CONTRAST, " Contrast");
r = vid_contrast.value - 1.0;
M_DrawSlider (220, 32 + 8*OPT_CONTRAST, r);
snprintf(slid_val, 5, "%.1f", vid_contrast.value);
M_DrawSlider (220, 32 + 8*OPT_CONTRAST, r, slid_val);

// OPT_MOUSESPEED:
M_Print (16, 32 + 8*OPT_MOUSESPEED, " Mouse Speed");
r = (sensitivity.value - 1)/10;
M_DrawSlider (220, 32 + 8*OPT_MOUSESPEED, r);
snprintf(slid_val, 5, "%.1f", sensitivity.value);
M_DrawSlider (220, 32 + 8*OPT_MOUSESPEED, r, slid_val);

// OPT_SBALPHA:
M_Print (16, 32 + 8*OPT_SBALPHA, " Statusbar alpha");
r = (1.0 - scr_sbaralpha.value) ; // scr_sbaralpha range is 1.0 to 0.0
M_DrawSlider (220, 32 + 8*OPT_SBALPHA, r);
snprintf(slid_val, 5, "%.2f", scr_sbaralpha.value);
M_DrawSlider (220, 32 + 8*OPT_SBALPHA, r, slid_val);

// OPT_SNDVOL:
M_Print (16, 32 + 8*OPT_SNDVOL, " Sound Volume");
r = sfxvolume.value;
M_DrawSlider (220, 32 + 8*OPT_SNDVOL, r);
snprintf(slid_val, 5, "%.1f", sfxvolume.value);
M_DrawSlider (220, 32 + 8*OPT_SNDVOL, r, slid_val);

// OPT_MUSICVOL:
M_Print (16, 32 + 8*OPT_MUSICVOL, " Music Volume");
r = bgmvolume.value;
M_DrawSlider (220, 32 + 8*OPT_MUSICVOL, r);
snprintf(slid_val, 5, "%.1f", bgmvolume.value);
M_DrawSlider (220, 32 + 8*OPT_MUSICVOL, r, slid_val);

// OPT_MUSICEXT:
M_Print (16, 32 + 8*OPT_MUSICEXT, " External Music");
Expand Down

0 comments on commit 0a7e2b9

Please sign in to comment.