music volume is now saved to config file, and read from it

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3413 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-20 18:44:35 +00:00
parent 3a8fc00861
commit f92c52582e
4 changed files with 11 additions and 6 deletions

View File

@ -41,7 +41,7 @@ SoundManager* sound_manager= NULL;
SoundManager::SoundManager()
{
m_current_music= NULL;
setMasterMusicVolume(0.7f);
setMasterMusicVolume(user_config->m_music_volume);
ALCdevice* device = alcOpenDevice ( NULL ); //The default sound device
if( device == NULL )
@ -160,6 +160,8 @@ void SoundManager::setMasterMusicVolume(float gain)
m_masterGain = gain;
if(m_current_music) m_current_music->volumeMusic(m_masterGain);
user_config->m_music_volume = m_masterGain;
}
//-----------------------------------------------------------------------------

View File

@ -339,10 +339,8 @@ namespace StateManager
else if(name == "music_volume")
{
GUIEngine::GaugeWidget* w = dynamic_cast<GUIEngine::GaugeWidget*>(widget);
// GUIEngine::getCurrentScreen()->getWidget("music_volume")
assert(w != NULL);
// TODO - save value to file, load value from file
sound_manager->setMasterMusicVolume( w->getValue() );
}
else if(name == "sfx_volume")
@ -359,7 +357,7 @@ namespace StateManager
sfx_manager->setMasterSFXVolume( w->getValue() );
user_config->m_sfx_volume = w->getValue();
std::cout << "w->getValue()=" << w->getValue() << std::endl;
// std::cout << "w->getValue()=" << w->getValue() << std::endl;
// play a sample sound to show the user what this volume is like
sample_sound->position ( Vec3(0,0,0) );

View File

@ -105,6 +105,7 @@ void UserConfig::setDefaults()
m_print_kart_sizes = false;
m_max_fps = 120;
m_sfx_volume = 1.0f;
m_music_volume = 0.7f;
m_width = 800;
m_height = 600;
m_prev_width = m_width;
@ -296,7 +297,8 @@ void UserConfig::loadConfig(const std::string& filename)
lisp->get("background-music", m_background_music);
lisp->get("max-fps", m_max_fps);
lisp->get("sfx-volume", m_sfx_volume);
lisp->get("music-volume", m_music_volume);
/*get resolution width/height*/
lisp->get("width", m_width);
lisp->get("height", m_height);
@ -476,7 +478,8 @@ void UserConfig::saveConfig(const std::string& filename)
writer->write("max-fps\t", m_max_fps);
writer->writeComment("Volume for sound effects, see openal AL_GAIN for interpretation");
writer->write("sfx-volume", m_sfx_volume);
writer->write("music-volume", m_music_volume);
writer->writeComment("screen resolution and windowing mode");
writer->write("width\t", m_width);
writer->write("height\t", m_height);

View File

@ -172,6 +172,8 @@ public:
bool m_print_kart_sizes; // print all kart sizes
// 0 if no profiling. Never saved in config file!
float m_sfx_volume;
float m_music_volume;
int m_max_fps;
std::string m_item_style;
std::string m_username;