12#include <simgear/debug/logstream.hxx>
13#include <simgear/props/props_io.hxx>
28 explicit NodeValue(
const std::string& s) : v(s) {}
29 bool operator()(
const SGPropertyNode_ptr n)
const
31 return (v == n->getStringValue());
38SGPropertyNode_ptr nodeForState(
const std::string& nm)
40 SGPropertyNode_ptr sim =
fgGetNode(
"/sim");
41 const PropertyList& states = sim->getChildren(
"state");
42 PropertyList::const_iterator it;
43 for (it = states.begin(); it != states.end(); ++it) {
44 const PropertyList& names = (*it)->getChildren(
"name");
45 if (std::find_if(names.begin(), names.end(), NodeValue(nm)) != names.end()) {
50 return SGPropertyNode_ptr();
59 SGPropertyNode_ptr n = nodeForState(
name);
65 std::string nm =
fgGetString(
"/sim/aircraft-state");
70 SGPropertyNode_ptr stateNode = nodeForState(nm);
72 SG_LOG(SG_AIRCRAFT, SG_WARN,
"missing state node for:" << nm);
73 std::string aircraft =
fgGetString(
"/sim/aircraft");
75 "The selected aircraft (" + aircraft +
") does not have a state '" + nm +
"'");
80 SG_LOG(SG_AIRCRAFT, SG_INFO,
"Applying aircraft state:" << nm);
83 copyProperties(stateNode->getChild(
"overlay"),
globals->get_props());
std::string fgGetString(const char *name, const char *defaultValue)
Get a string value for a property.
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
MessageBoxResult modalMessageBox(const std::string &caption, const std::string &msg, const std::string &moreText)
bool isInitialStateName(const std::string &name)
is the supplied name a defined initial-state, or alias of one
SGPropertyNode * fgGetNode(const char *path, bool create)
Get a property node.