#include STL_FSTREAM
#include <simgear/debug/logstream.hxx>
+#include <simgear/math/sg_random.h>
#include <simgear/misc/commands.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/sg_inlines.h>
return result;
}
-
/**
* Built-in command: suspend one or more subsystems.
*
return false;
}
SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path);
- current_panel->unbind();
- delete current_panel;
- current_panel = new_panel;
- current_panel->bind();
+ globals->get_current_panel()->unbind();
+ delete globals->get_current_panel();
+ globals->set_current_panel( new_panel );
+ globals->get_current_panel()->bind();
return true;
}
static bool
do_panel_mouse_click (const SGPropertyNode * arg)
{
- if (current_panel != 0)
- return current_panel
+ if (globals->get_current_panel() != 0)
+ return globals->get_current_panel()
->doMouseAction(arg->getIntValue("button"),
arg->getBoolValue("is-down") ? PU_DOWN : PU_UP,
arg->getIntValue("x-pos"),
}
+/**
+ * Built-in command: randomize a numeric property value.
+ *
+ * property: the name of the property value to randomize.
+ * min: the minimum allowed value.
+ * max: the maximum allowed value.
+ */
+static bool
+do_property_randomize (const SGPropertyNode * arg)
+{
+ SGPropertyNode * prop = get_prop(arg);
+ double min = arg->getDoubleValue("min", DBL_MIN);
+ double max = arg->getDoubleValue("max", DBL_MAX);
+ prop->setDoubleValue(sg_random() * (max - min) + min);
+ return true;
+}
+
+
/**
* Built-in command: Show an XML-configured dialog.
*
do_dialog_close (const SGPropertyNode * arg)
{
NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
- gui->closeActiveDialog();
+ return gui->closeActiveDialog();
}
globals->get_tile_mgr()->update( fgGetDouble("/environment/visibility-m") );
+#if 0
if ( ! fgGetBool("/sim/presets/onground") ) {
fgSetBool( "/sim/freeze/master", true );
fgSetBool( "/sim/freeze/clock", true );
}
+#endif
return true;
}
+/**
+ * Built-in command: set log level (0 ... 7)
+ */
+static bool
+do_log_level (const SGPropertyNode * arg)
+{
+ sglog().setLogLevels( SG_ALL, (sgDebugPriority)arg->getIntValue() );
+
+ return true;
+}
+
+
\f
////////////////////////////////////////////////////////////////////////
{ "property-swap", do_property_swap },
{ "property-scale", do_property_scale },
{ "property-cycle", do_property_cycle },
+ { "property-randomize", do_property_randomize },
{ "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 },
{ "presets-commit", do_presets_commit },
+ { "log-level", do_log_level },
{ 0, 0 } // zero-terminated
};