]> git.mxchange.org Git - flightgear.git/commitdiff
Better support for pausing/unpausing sound.
authorcurt <curt>
Fri, 14 May 2004 15:51:43 +0000 (15:51 +0000)
committercurt <curt>
Fri, 14 May 2004 15:51:43 +0000 (15:51 +0000)
Add support for controlling global volume of FlightGear.

src/Sound/fg_fx.cxx
src/Sound/fg_fx.hxx

index 6b1a16eb3e897410b9d415926a4f6f0eba0892c5..4db24d88ed7722e594ec0e4ae3d7637d49ee16ab 100644 (file)
@@ -39,7 +39,9 @@
 #include "fg_fx.hxx"
 
 
-FGFX::FGFX ()
+FGFX::FGFX () :
+    last_pause( true ),
+    last_volume( 0.0 )
 {
 }
 
@@ -51,7 +53,7 @@ FGFX::~FGFX ()
 void
 FGFX::init()
 {
-   SGPropertyNode * node = fgGetNode("/sim/sound", true);
+   SGPropertyNode *node = fgGetNode("/sim/sound", true);
    int i;
 
    string path_str = node->getStringValue("path");
@@ -105,9 +107,28 @@ 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);
+        }
     }
 }
 
index 5c43db42d2d3403372548b120db5a33d0ac1cabc..a5ad0a85b607ffe00a54ae4d4443220c19ee403d 100644 (file)
@@ -53,6 +53,9 @@ private:
 
   vector<SGXmlSound *> _sound;
 
+  bool last_pause;
+  double last_volume;
+
 };