Better support for pausing/unpausing sound.
Add support for controlling global volume of FlightGear.
This commit is contained in:
parent
2fce07a4ce
commit
3f3d3b2c6f
2 changed files with 28 additions and 4 deletions
|
@ -39,7 +39,9 @@
|
|||
#include "fg_fx.hxx"
|
||||
|
||||
|
||||
FGFX::FGFX ()
|
||||
FGFX::FGFX () :
|
||||
last_pause( true ),
|
||||
last_volume( 0.0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -105,10 +107,29 @@ FGFX::unbind ()
|
|||
void
|
||||
FGFX::update (double dt)
|
||||
{
|
||||
if (fgGetBool("/sim/sound/audible")) {
|
||||
for (unsigned int i = 0; i < _sound.size(); i++ )
|
||||
// command sound manger
|
||||
bool pause = fgGetBool("/sim/sound/pause");
|
||||
if ( pause != last_pause ) {
|
||||
if ( pause ) {
|
||||
globals->get_soundmgr()->pause();
|
||||
} else {
|
||||
globals->get_soundmgr()->resume();
|
||||
}
|
||||
last_pause = pause;
|
||||
}
|
||||
|
||||
double volume = fgGetDouble("/sim/sound/volume");
|
||||
if ( volume != last_volume ) {
|
||||
globals->get_soundmgr()->set_volume( volume );
|
||||
last_volume = volume;
|
||||
}
|
||||
|
||||
if ( !pause ) {
|
||||
// update sound effects if not paused
|
||||
for ( unsigned int i = 0; i < _sound.size(); i++ ) {
|
||||
_sound[i]->update(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// end of fg_fx.cxx
|
||||
|
|
|
@ -53,6 +53,9 @@ private:
|
|||
|
||||
vector<SGXmlSound *> _sound;
|
||||
|
||||
bool last_pause;
|
||||
double last_volume;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue