properties, though they will ignore any that are not relevant:
x - the X position of the bottom left corner of the object, in
- pseudo-pixels. The default is 0.
+ pseudo-pixels. The default is to center the dialog.
y - the Y position of the bottom left corner of the object, in
- pseudo-pixels. The default is 0.
+ pseudo-pixels. The default is to center the dialog.
width - the width of the object, in pseudo-pixels. The default is
the width of the parent container.
</combo>
+
+select
+------
+
+A scrollable list of selections.
+
+ selection - a path in the property tree which holds the selectable items.
+
+Example:
+
+ <select>
+ <x>10</x>
+ <y>50</y>
+ <width>200</width>
+ <height>25</height>
+ <property>/sim/aircraft</property>
+ <selection>/sim/aircraft-types</selection>
+ </select>
+
+
+
slider
------
#include <stdio.h>
+#include <string.h> // strdup
+
+#include <plib/ul.h>
+#include <plib/ssg.h>
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
+#include <simgear/misc/sg_path.hxx>
+#include <simgear/misc/commands.hxx>
+#include <simgear/misc/exception.hxx>
#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
+#include <Main/fgfs.hxx>
#include "aircraft.hxx"
+extern void fgInitFDM(void);
+class FGFX;
+
// This is a record containing all the info for the aircraft currently
// being operated
fgAIRCRAFT current_aircraft;
}
+// Show available aircraft types
+void fgReadAircraft(void) {
+
+ SGPropertyNode *aircraft_types = fgGetNode("/sim/aircraft-types", true);
+
+ SGPath path( globals->get_fg_root() );
+ path.append("Aircraft");
+
+ ulDirEnt* dire;
+ ulDir *dirp;
+
+ dirp = ulOpenDir(path.c_str());
+ if (dirp == NULL) {
+ SG_LOG( SG_AIRCRAFT, SG_ALERT, "Unable to open aircraft directory." );
+ ulCloseDir(dirp);
+ return;
+ }
+
+ while ((dire = ulReadDir(dirp)) != NULL) {
+ char *ptr;
+
+ if ((ptr = strstr(dire->d_name, "-set.xml")) && strlen(ptr) == 8) {
+
+ *ptr = '\0';
+#if 0
+ SGPath afile = path;
+ afile.append(dire->d_name);
+
+ SGPropertyNode root;
+ try {
+ readProperties(afile.str(), &root);
+ } catch (...) {
+ continue;
+ }
+
+ SGPropertyNode *node = root.getNode("sim");
+ if (node) {
+ SGPropertyNode *desc = node->getNode("description");
+
+ if (desc) {
+#endif
+ SGPropertyNode *aircraft =
+ aircraft_types->getChild(dire->d_name, 0, true);
+#if 0
+
+ aircraft->setStringValue(strdup(desc->getStringValue()));
+ }
+ }
+#endif
+ }
+ }
+
+ ulCloseDir(dirp);
+
+ globals->get_commands()->addCommand("load-aircraft", fgLoadAircraft);
+}
+
+static inline bool
+fgLoadAircraft (const SGPropertyNode * arg)
+{
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
+
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
+
+ cur_fdm_state->unbind();
+
+ string aircraft = fgGetString("/sim/aircraft", "");
+ globals->restoreInitialState();
+
+ if ( aircraft.size() > 0 ) {
+ SGPath aircraft_path(globals->get_fg_root());
+ aircraft_path.append("Aircraft");
+ aircraft_path.append(aircraft);
+ aircraft_path.concat("-set.xml");
+ SG_LOG(SG_INPUT, SG_INFO, "Reading default aircraft: " << aircraft
+ << " from " << aircraft_path.str());
+ try {
+ readProperties(aircraft_path.str(), globals->get_props());
+ } catch (const sg_exception &e) {
+ string message = "Error reading default aircraft: ";
+ message += e.getFormattedMessage();
+ SG_LOG(SG_INPUT, SG_ALERT, message);
+ exit(2);
+ }
+ } else {
+ SG_LOG(SG_INPUT, SG_ALERT, "No default aircraft specified");
+ }
+
+ // Update the FDM
+ //
+ fgSetString("/sim/aircraft", aircraft.c_str());
+ fgInitFDM();
+
+ // update our position based on current presets
+ fgInitPosition();
+
+ SGTime *t = globals->get_time_params();
+ delete t;
+ t = fgInitTime();
+ globals->set_time_params( t );
+
+ fgReInitSubsystems();
+
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", false);
+ }
+
+ return true;
+}
return;
}
- _object = makeObject(props, 1024, 768);
+ _object = makeObject(props,
+ globals->get_props()->getIntValue("/sim/startup/xsize"),
+ globals->get_props()->getIntValue("/sim/startup/ysize"));
if (_object != 0) {
_object->reveal();
dial->setWrap(props->getBoolValue("wrap", true));
setupObject(dial, props);
return dial;
+ } else if (type == "select") {
+ vector<SGPropertyNode_ptr> value_nodes;
+ SGPropertyNode * selection_node =
+ fgGetNode(props->getChild("selection")->getStringValue(), true);
+
+ for (int q = 0; q < selection_node->nChildren(); q++)
+ value_nodes.push_back(selection_node->getChild(q));
+
+ char ** entries = make_char_array(value_nodes.size());
+ for (int i = 0, j = value_nodes.size() - 1;
+ i < value_nodes.size();
+ i++, j--)
+ entries[i] = strdup((char *)value_nodes[i]->getName());
+ puSelectBox * select =
+ new puSelectBox(x, y, x + width, y + height, entries);
+ setupObject(select, props);
+ return select;
} else {
return 0;
}