mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Add music and sound volume config options
This adds <musicvolume> and <soundvolume> tags to unlock.vvv and settings.vvv, so users' volume preferences will be persistent across game sessions. This does not add the user interface to change them from in-game; the next commit will do that.
This commit is contained in:
parent
2a3f17f1f7
commit
27874e1dc6
4 changed files with 26 additions and 2 deletions
|
@ -4222,6 +4222,16 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* s
|
||||||
graphics.showmousecursor = help.Int(pText);
|
graphics.showmousecursor = help.Int(pText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SDL_strcmp(pKey, "musicvolume") == 0)
|
||||||
|
{
|
||||||
|
music.user_music_volume = help.Int(pText);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SDL_strcmp(pKey, "soundvolume") == 0)
|
||||||
|
{
|
||||||
|
music.user_sound_volume = help.Int(pText);
|
||||||
|
}
|
||||||
|
|
||||||
if (SDL_strcmp(pKey, "flipButton") == 0)
|
if (SDL_strcmp(pKey, "flipButton") == 0)
|
||||||
{
|
{
|
||||||
SDL_GameControllerButton newButton;
|
SDL_GameControllerButton newButton;
|
||||||
|
@ -4453,6 +4463,10 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode, const ScreenSetting
|
||||||
|
|
||||||
xml::update_tag(dataNode, "vsync", (int) screen_settings->useVsync);
|
xml::update_tag(dataNode, "vsync", (int) screen_settings->useVsync);
|
||||||
|
|
||||||
|
xml::update_tag(dataNode, "musicvolume", music.user_music_volume);
|
||||||
|
|
||||||
|
xml::update_tag(dataNode, "soundvolume", music.user_sound_volume);
|
||||||
|
|
||||||
// Delete all controller buttons we had previously.
|
// Delete all controller buttons we had previously.
|
||||||
// dataNode->FirstChildElement() shouldn't be NULL at this point...
|
// dataNode->FirstChildElement() shouldn't be NULL at this point...
|
||||||
// we've already added a bunch of elements
|
// we've already added a bunch of elements
|
||||||
|
|
|
@ -17,6 +17,9 @@ musicclass::musicclass(void)
|
||||||
musicVolume = 0;
|
musicVolume = 0;
|
||||||
FadeVolAmountPerFrame = 0;
|
FadeVolAmountPerFrame = 0;
|
||||||
|
|
||||||
|
user_music_volume = USER_VOLUME_MAX;
|
||||||
|
user_sound_volume = USER_VOLUME_MAX;
|
||||||
|
|
||||||
currentsong = 0;
|
currentsong = 0;
|
||||||
nicechange = -1;
|
nicechange = -1;
|
||||||
nicefade = false;
|
nicefade = false;
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
|
|
||||||
#define musicroom(rx, ry) ((rx) + ((ry) * 20))
|
#define musicroom(rx, ry) ((rx) + ((ry) * 20))
|
||||||
|
|
||||||
|
/* The amount of "space" for the scale of the user-set volume. */
|
||||||
|
#define USER_VOLUME_MAX 256
|
||||||
|
|
||||||
class musicclass
|
class musicclass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -52,6 +55,10 @@ public:
|
||||||
int FadeVolAmountPerFrame;
|
int FadeVolAmountPerFrame;
|
||||||
int musicVolume;
|
int musicVolume;
|
||||||
|
|
||||||
|
/* 0..USER_VOLUME_MAX */
|
||||||
|
int user_music_volume;
|
||||||
|
int user_sound_volume;
|
||||||
|
|
||||||
bool quick_fade;
|
bool quick_fade;
|
||||||
|
|
||||||
// MMMMMM mod settings
|
// MMMMMM mod settings
|
||||||
|
|
|
@ -771,7 +771,7 @@ static enum LoopCode loop_end(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Mix_Volume(-1,MIX_MAX_VOLUME);
|
Mix_Volume(-1,MIX_MAX_VOLUME * music.user_sound_volume / USER_VOLUME_MAX);
|
||||||
|
|
||||||
if (game.musicmuted)
|
if (game.musicmuted)
|
||||||
{
|
{
|
||||||
|
@ -779,7 +779,7 @@ static enum LoopCode loop_end(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Mix_VolumeMusic(music.musicVolume);
|
Mix_VolumeMusic(music.musicVolume * music.user_music_volume / USER_VOLUME_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue