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/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) ),
_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) )
_volume( fgGetNode("/sim/sound/effects/volume", 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::_refname = refname;
SGSampleGroup::_smgr->add(this, refname);
@ -67,7 +71,7 @@ FGFX::~FGFX ()
void
FGFX::init()
{
SGPropertyNode *node = fgGetNode("/sim/sound", true);
SGPropertyNode *node = _props->getNode("sim/sound", true);
string path_str = node->getStringValue("path");
if (path_str.empty()) {
@ -121,12 +125,12 @@ FGFX::reinit()
void
FGFX::update (double dt)
{
bool active = _avionics_external->getBoolValue() ||
bool active = _avionics_ext->getBoolValue() ||
_internal->getBoolValue();
if ( active && _avionics_enabled->getBoolValue() )
if ( active && _avionics_enabled->getBoolValue() ) {
_avionics->resume(); // no-op if already in resumed state
else
} else
_avionics->suspend();
_avionics->set_volume( _avionics_volume->getFloatValue() );

View file

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