#include <GUI/gui.h>
#include <GUI/new_gui.hxx>
#include <GUI/dialog.hxx>
-#include <Replay/replay.hxx>
+#include <Aircraft/replay.hxx>
#include <Scenery/tilemgr.hxx>
#if defined(HAVE_PLIB_PSL)
# include <Scripting/scriptmgr.hxx>
}
+/**
+ * Built-in command: hires capture screen.
+ */
+static bool
+do_hires_screen_capture (const SGPropertyNode * arg)
+{
+ fgHiResDump();
+ return true;
+}
+
+
/**
* Reload the tile cache.
*/
}
+/**
+ * Redraw GUI (applying new widget colors). Doesn't reload the dialogs,
+ * unlike reinit().
+ */
+static bool
+do_gui_redraw (const SGPropertyNode * arg)
+{
+ NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
+ gui->redraw();
+ return true;
+}
+
/**
* Built-in command: commit presets (read from in /sim/presets/)
*/
do_replay (const SGPropertyNode * arg)
{
// freeze the master fdm
- fgSetBool( "/sim/freeze/replay", true );
+ fgSetInt( "/sim/freeze/replay-state", 1 );
FGReplay *r = (FGReplay *)(globals->get_subsystem( "replay" ));
return true;
}
+/**
+ * An fgcommand to allow loading of xml files via nasal,
+ * the xml file's structure will be made available within
+ * a (definable) property tree node
+ *
+ * @param filename a string to hold the complete path & filename of a XML file
+ * @param targetnode a string pointing to a location within the property tree
+ * where to store the parsed XML file
+ */
+
+static bool
+do_load_xml_to_proptree(const SGPropertyNode * node)
+{
+ // SG_LOG(SG_GENERAL, SG_ALERT, "fgcommand loadxml executed");
+
+ SGPropertyNode * targetnode;
+ targetnode = fgGetNode(node->getNode("targetnode")->getStringValue(),true);
+
+ const char *filename = node->getNode("filename")->getStringValue();
+ try {
+ fgLoadProps(filename, targetnode);
+ } catch (const sg_exception &e) {
+ string errmsg = "Error reading file " + string(filename) + ":\n";
+ guiErrorMessage(errmsg.c_str(), e);
+ return false;
+ }
+
+ return true;
+}
+
+
+/**
+ * an fgcommand to allow saving of xml files via nasal,
+ * the file's structure will be determined based on what's
+ * encountered in the passed (source) property tree node
+ *
+ * @param filename a string to hold the complete path & filename of the (new)
+ * XML file
+ * @param sourcenode a string pointing to a location within the property tree
+ * where to find the nodes that should be written recursively into an XML file
+ *
+ * TODO:
+ * deal with already existing filenames, optionally return error/success
+ * values in a separate node to provide status information
+ *
+ * note: it's directly using writeProperties, which is not necessarily
+ * preferable, but for now it should work ...
+ */
+
+static bool
+do_save_xml_from_proptree(const SGPropertyNode * node)
+{
+ //TODO: do Parameter validation !
+ SGPropertyNode * sourcenode;
+ sourcenode = fgGetNode(node->getNode("sourcenode")->getStringValue(),true);
+
+ const char *filename = node->getNode("filename")->getStringValue();
+ try {
+ writeProperties (filename, sourcenode, true);
+ } catch (const sg_exception &e) {
+ string errmsg = "Error writing file " + string(filename) + ":\n";
+ guiErrorMessage(errmsg.c_str(), e);
+ return false;
+ }
+
+ return true;
+}
+
+
////////////////////////////////////////////////////////////////////////
// Command setup.
////////////////////////////////////////////////////////////////////////
{ "preferences-load", do_preferences_load },
{ "view-cycle", do_view_cycle },
{ "screen-capture", do_screen_capture },
+ { "hires-screen-capture", do_hires_screen_capture },
{ "tile-cache-reload", do_tile_cache_reload },
{ "set-sea-level-air-temp-degc", do_set_sea_level_degc },
{ "set-outside-air-temp-degc", do_set_oat_degc },
{ "dialog-new", do_dialog_new },
{ "dialog-show", do_dialog_show },
{ "dialog-close", do_dialog_close },
- { "dialog-show", do_dialog_show },
{ "dialog-update", do_dialog_update },
{ "dialog-apply", do_dialog_apply },
+ { "gui-redraw", do_gui_redraw },
{ "presets-commit", do_presets_commit },
{ "log-level", do_log_level },
{ "replay", do_replay },
{ "hud-masterswitch", do_hud_masterswitch },
{ "hud-init", do_hud_init },
{ "hud-init2", do_hud_init2 },
+ { "loadxml", do_load_xml_to_proptree},
+ { "savexml", do_save_xml_from_proptree },
{ 0, 0 } // zero-terminated
};