Skip to content

Commit

Permalink
Represent sfx and music volumes as percentages
Browse files Browse the repository at this point in the history
Also removed underscores.
  • Loading branch information
bradharding committed Nov 25, 2014
1 parent 59220b0 commit 840160e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions msvc/Release/doomretro.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mouse_sensitivity 16
mouse_strafe -
mouse_threshold 10
mouse_use -
music_volume 15
musicvolume 100%
novert on
pixelwidth 2
pixelheight 2
Expand All @@ -79,7 +79,7 @@ savegame 0
screensize 7
screenwidth desktop
screenheight desktop
sfx_volume 15
sfxvolume 100%
shadows on
skilllevel "Hurt me plenty."
smoketrails player|revenant2|cyberdemon
Expand Down
11 changes: 7 additions & 4 deletions src/m_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#include "m_misc.h"
#include "version.h"

int musicvolume_percent;
int sfxvolume_percent;

//
// DEFAULTS
//
Expand Down Expand Up @@ -273,7 +276,7 @@ static default_t doom_defaults_list[] =
CONFIG_VARIABLE_INT (mouse_strafe, mousebstrafe, 4),
CONFIG_VARIABLE_INT (mouse_threshold, mouse_threshold, 0),
CONFIG_VARIABLE_INT (mouse_use, mousebuse, 4),
CONFIG_VARIABLE_INT (music_volume, musicVolume, 0),
CONFIG_VARIABLE_INT_PERCENT(musicvolume, musicvolume_percent, 0),
CONFIG_VARIABLE_INT (novert, novert, 1),
CONFIG_VARIABLE_INT (pixelwidth, pixelwidth, 0),
CONFIG_VARIABLE_INT (pixelheight, pixelheight, 0),
Expand All @@ -285,7 +288,7 @@ static default_t doom_defaults_list[] =
CONFIG_VARIABLE_INT (screensize, screensize, 0),
CONFIG_VARIABLE_INT (screenwidth, screenwidth, 5),
CONFIG_VARIABLE_INT (screenheight, screenheight, 5),
CONFIG_VARIABLE_INT (sfx_volume, sfxVolume, 0),
CONFIG_VARIABLE_INT_PERCENT(sfxvolume, sfxvolume_percent, 0),
CONFIG_VARIABLE_INT (shadows, shadows, 1),
CONFIG_VARIABLE_INT (skilllevel, selectedskilllevel, 10),
CONFIG_VARIABLE_INT (smoketrails, smoketrails, 13),
Expand Down Expand Up @@ -1161,7 +1164,7 @@ static void M_CheckDefaults(void)
|| mousebuse == mousebnextweapon || mousebuse == mousebstrafe)
mousebuse = MOUSEUSE_DEFAULT;

musicVolume = BETWEEN(MUSICVOLUME_MIN, musicVolume, MUSICVOLUME_MAX);
musicVolume = BETWEEN(MUSICVOLUME_MIN, musicvolume_percent, MUSICVOLUME_MAX) * 15 / 100;

if (novert != false && novert != true)
novert = NOVERT_DEFAULT;
Expand Down Expand Up @@ -1200,7 +1203,7 @@ static void M_CheckDefaults(void)

selectedskilllevel = BETWEEN(SKILLLEVEL_MIN, selectedskilllevel, SKILLLEVEL_MAX);

sfxVolume = BETWEEN(SFXVOLUME_MIN, sfxVolume, SFXVOLUME_MAX);
sfxVolume = BETWEEN(SFXVOLUME_MIN, sfxvolume_percent, SFXVOLUME_MAX) * 15 / 100;

if (shadows != false && shadows != true)
shadows = SHADOWS_DEFAULT;
Expand Down
8 changes: 4 additions & 4 deletions src/m_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@
#define MOUSEUSE_DEFAULT -1

#define MUSICVOLUME_MIN 0
#define MUSICVOLUME_DEFAULT 15
#define MUSICVOLUME_MAX 15
#define MUSICVOLUME_DEFAULT 100
#define MUSICVOLUME_MAX 100

#define NOVERT_DEFAULT true

Expand Down Expand Up @@ -220,8 +220,8 @@
#define SCREENHEIGHT_DEFAULT 0

#define SFXVOLUME_MIN 0
#define SFXVOLUME_DEFAULT 15
#define SFXVOLUME_MAX 15
#define SFXVOLUME_DEFAULT 100
#define SFXVOLUME_MAX 100

#define SHADOWS_DEFAULT true

Expand Down
8 changes: 4 additions & 4 deletions src/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1332,15 +1332,15 @@ void M_SfxVol(int choice)
switch (choice)
{
case 0:
if (sfxVolume > SFXVOLUME_MIN)
if (sfxVolume > 0)
{
S_SetSfxVolume((int)(--sfxVolume * (127.0f / 15.0f)));
S_StartSound(NULL, sfx_stnmov);
M_SaveDefaults();
}
break;
case 1:
if (sfxVolume < SFXVOLUME_MAX)
if (sfxVolume < 15)
{
S_SetSfxVolume((int)(++sfxVolume * (127.0f / 15.0f)));
S_StartSound(NULL, sfx_stnmov);
Expand All @@ -1358,15 +1358,15 @@ void M_MusicVol(int choice)
switch (choice)
{
case 0:
if (musicVolume > MUSICVOLUME_MIN)
if (musicVolume > 0)
{
S_SetMusicVolume((int)(--musicVolume * (127.0f / 15.0f)));
S_StartSound(NULL, sfx_stnmov);
M_SaveDefaults();
}
break;
case 1:
if (musicVolume < MUSICVOLUME_MAX)
if (musicVolume < 15)
{
S_SetMusicVolume((int)(++musicVolume * (127.0f / 15.0f)));
S_StartSound(NULL, sfx_stnmov);
Expand Down

0 comments on commit 840160e

Please sign in to comment.