1
0
Fork 0

Allow for a different property root location besides '/'

This commit is contained in:
Erik Hofman 2011-11-20 15:03:48 +01:00
parent 269595a366
commit 64102d0da9
2 changed files with 17 additions and 12 deletions

View file

@ -39,14 +39,18 @@
#include <simgear/sound/soundmgr_openal.hxx> #include <simgear/sound/soundmgr_openal.hxx>
#include <simgear/sound/xmlsound.hxx> #include <simgear/sound/xmlsound.hxx>
FGFX::FGFX ( SGSoundMgr *smgr, const string &refname ) : FGFX::FGFX ( SGSoundMgr *smgr, const string &refname, SGPropertyNode *props ) :
_props( props ),
_enabled( fgGetNode("/sim/sound/effects/enabled", true) ), _enabled( fgGetNode("/sim/sound/effects/enabled", true) ),
_volume( fgGetNode("/sim/sound/effects/volume", true) ), _volume( fgGetNode("/sim/sound/effects/volume", true) )
_avionics_enabled( fgGetNode("/sim/sound/avionics/enabled", true) ),
_avionics_volume( fgGetNode("/sim/sound/avionics/volume", true) ),
_avionics_external( fgGetNode("/sim/sound/avionics/external-view", true) ),
_internal( fgGetNode("/sim/current-view/internal", true) )
{ {
if (!props) _props = globals->get_props();
_avionics_enabled = _props->getNode("sim/sound/avionics/enabled", true);
_avionics_volume = _props->getNode("sim/sound/avionics/volume", true);
_avionics_ext = _props->getNode("sim/sound/avionics/external-view", true);
_internal = _props->getNode("sim/current-view/internal", true);
SGSampleGroup::_smgr = smgr; SGSampleGroup::_smgr = smgr;
SGSampleGroup::_refname = refname; SGSampleGroup::_refname = refname;
SGSampleGroup::_smgr->add(this, refname); SGSampleGroup::_smgr->add(this, refname);
@ -67,7 +71,7 @@ FGFX::~FGFX ()
void void
FGFX::init() FGFX::init()
{ {
SGPropertyNode *node = fgGetNode("/sim/sound", true); SGPropertyNode *node = _props->getNode("sim/sound", true);
string path_str = node->getStringValue("path"); string path_str = node->getStringValue("path");
if (path_str.empty()) { if (path_str.empty()) {
@ -121,12 +125,12 @@ FGFX::reinit()
void void
FGFX::update (double dt) FGFX::update (double dt)
{ {
bool active = _avionics_external->getBoolValue() || bool active = _avionics_ext->getBoolValue() ||
_internal->getBoolValue(); _internal->getBoolValue();
if ( active && _avionics_enabled->getBoolValue() ) if ( active && _avionics_enabled->getBoolValue() ) {
_avionics->resume(); // no-op if already in resumed state _avionics->resume(); // no-op if already in resumed state
else } else
_avionics->suspend(); _avionics->suspend();
_avionics->set_volume( _avionics_volume->getFloatValue() ); _avionics->set_volume( _avionics_volume->getFloatValue() );

View file

@ -49,7 +49,7 @@ class FGFX : public SGSampleGroup
public: public:
FGFX ( SGSoundMgr *smgr, const string &refname ); FGFX ( SGSoundMgr *smgr, const string &refname, SGPropertyNode *props = 0 );
virtual ~FGFX (); virtual ~FGFX ();
virtual void init (); virtual void init ();
@ -61,11 +61,12 @@ private:
SGSharedPtr<SGSampleGroup> _avionics; SGSharedPtr<SGSampleGroup> _avionics;
std::vector<SGXmlSound *> _sound; std::vector<SGXmlSound *> _sound;
SGPropertyNode_ptr _props;
SGPropertyNode_ptr _enabled; SGPropertyNode_ptr _enabled;
SGPropertyNode_ptr _volume; SGPropertyNode_ptr _volume;
SGPropertyNode_ptr _avionics_enabled; SGPropertyNode_ptr _avionics_enabled;
SGPropertyNode_ptr _avionics_volume; SGPropertyNode_ptr _avionics_volume;
SGPropertyNode_ptr _avionics_external; SGPropertyNode_ptr _avionics_ext;
SGPropertyNode_ptr _internal; SGPropertyNode_ptr _internal;
}; };