1 // fg_commands.cxx - internal FGFS commands.
3 #include <string.h> // strcmp()
5 #include <simgear/compiler.h>
10 #include <simgear/sg_inlines.h>
11 #include <simgear/debug/logstream.hxx>
12 #include <simgear/math/sg_random.h>
13 #include <simgear/structure/exception.hxx>
14 #include <simgear/structure/commands.hxx>
15 #include <simgear/props/props.hxx>
17 #include <Cockpit/panel.hxx>
18 #include <Cockpit/panel_io.hxx>
19 #include <FDM/flight.hxx>
21 #include <GUI/new_gui.hxx>
22 #include <GUI/dialog.hxx>
23 #include <Replay/replay.hxx>
24 #include <Scenery/tilemgr.hxx>
25 #if defined(HAVE_PLIB_PSL)
26 # include <Scripting/scriptmgr.hxx>
28 #include <Time/sunsolver.hxx>
29 #include <Time/tmp.hxx>
31 #include "fg_init.hxx"
32 #include "fg_commands.hxx"
33 #include "fg_props.hxx"
36 SG_USING_STD(ifstream);
37 SG_USING_STD(ofstream);
39 #include "fg_props.hxx"
41 #include "globals.hxx"
43 #include "viewmgr.hxx"
47 ////////////////////////////////////////////////////////////////////////
48 // Static helper functions.
49 ////////////////////////////////////////////////////////////////////////
52 static inline SGPropertyNode *
53 get_prop (const SGPropertyNode * arg)
55 return fgGetNode(arg->getStringValue("property[0]", "/null"), true);
58 static inline SGPropertyNode *
59 get_prop2 (const SGPropertyNode * arg)
61 return fgGetNode(arg->getStringValue("property[1]", "/null"), true);
66 * Get a double value and split it as required.
69 split_value (double full_value, const char * mask,
70 double * unmodifiable, double * modifiable)
72 if (!strcmp("integer", mask)) {
73 *modifiable = (full_value < 0 ? ceil(full_value) : floor (full_value));
74 *unmodifiable = full_value - *modifiable;
75 } else if (!strcmp("decimal", mask)) {
76 *unmodifiable = (full_value < 0 ? ceil(full_value) : floor(full_value));
77 *modifiable = full_value - *unmodifiable;
79 if (strcmp("all", mask))
80 SG_LOG(SG_GENERAL, SG_ALERT, "Bad value " << mask << " for mask;"
81 << " assuming 'all'");
83 *modifiable = full_value;
89 * Clamp or wrap a value as specified.
92 limit_value (double * value, const SGPropertyNode * arg)
94 const SGPropertyNode * min_node = arg->getChild("min");
95 const SGPropertyNode * max_node = arg->getChild("max");
97 bool wrap = arg->getBoolValue("wrap");
99 if (min_node == 0 || max_node == 0)
102 if (wrap) { // wrap such that min <= x < max
103 double min_val = min_node->getDoubleValue();
104 double max_val = max_node->getDoubleValue();
105 double resolution = arg->getDoubleValue("resolution");
106 if (resolution > 0.0) {
107 // snap to (min + N*resolution), taking special care to handle imprecision
108 int n = (int)floor((*value - min_val) / resolution + 0.5);
109 int steps = (int)floor((max_val - min_val) / resolution + 0.5);
110 SG_NORMALIZE_RANGE(n, 0, steps);
111 *value = min_val + resolution * n;
113 // plain circular wrapping
114 SG_NORMALIZE_RANGE(*value, min_val, max_val);
116 } else { // clamp such that min <= x <= max
117 if ((min_node != 0) && (*value < min_node->getDoubleValue()))
118 *value = min_node->getDoubleValue();
119 else if ((max_node != 0) && (*value > max_node->getDoubleValue()))
120 *value = max_node->getDoubleValue();
125 compare_values (SGPropertyNode * value1, SGPropertyNode * value2)
127 switch (value1->getType()) {
128 case SGPropertyNode::BOOL:
129 return (value1->getBoolValue() == value2->getBoolValue());
130 case SGPropertyNode::INT:
131 return (value1->getIntValue() == value2->getIntValue());
132 case SGPropertyNode::LONG:
133 return (value1->getLongValue() == value2->getLongValue());
134 case SGPropertyNode::FLOAT:
135 return (value1->getFloatValue() == value2->getFloatValue());
136 case SGPropertyNode::DOUBLE:
137 return (value1->getDoubleValue() == value2->getDoubleValue());
139 return !strcmp(value1->getStringValue(), value2->getStringValue());
145 ////////////////////////////////////////////////////////////////////////
146 // Command implementations.
147 ////////////////////////////////////////////////////////////////////////
151 * Built-in command: do nothing.
154 do_null (const SGPropertyNode * arg)
159 #if defined(HAVE_PLIB_PSL)
161 * Built-in command: run a PSL script.
163 * script: the PSL script to execute
166 do_script (const SGPropertyNode * arg)
168 FGScriptMgr * mgr = (FGScriptMgr *)globals->get_subsystem("scripting");
169 return mgr->run(arg->getStringValue("script"));
171 #endif // HAVE_PLIB_PSL
175 * Built-in command: exit FlightGear.
177 * status: the exit status to return to the operating system (defaults to 0)
180 do_exit (const SGPropertyNode * arg)
182 SG_LOG(SG_INPUT, SG_INFO, "Program exit requested.");
183 fgExit(arg->getIntValue("status", 0));
189 * Built-in command: reinitialize one or more subsystems.
191 * subsystem[*]: the name(s) of the subsystem(s) to reinitialize; if
192 * none is specified, reinitialize all of them.
195 do_reinit (const SGPropertyNode * arg)
199 vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem");
200 if (subsystems.size() == 0) {
201 globals->get_subsystem_mgr()->reinit();
203 for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
204 const char * name = subsystems[i]->getStringValue();
205 SGSubsystem * subsystem = globals->get_subsystem(name);
206 if (subsystem == 0) {
208 SG_LOG( SG_GENERAL, SG_ALERT,
209 "Subsystem " << name << "not found" );
216 globals->get_event_mgr()->reinit();
222 * Built-in command: suspend one or more subsystems.
224 * subsystem[*] - the name(s) of the subsystem(s) to suspend.
227 do_suspend (const SGPropertyNode * arg)
231 vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem");
232 for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
233 const char * name = subsystems[i]->getStringValue();
234 SGSubsystem * subsystem = globals->get_subsystem(name);
235 if (subsystem == 0) {
237 SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << "not found");
239 subsystem->suspend();
246 * Built-in command: suspend one or more subsystems.
248 * subsystem[*] - the name(s) of the subsystem(s) to suspend.
251 do_resume (const SGPropertyNode * arg)
255 vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem");
256 for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
257 const char * name = subsystems[i]->getStringValue();
258 SGSubsystem * subsystem = globals->get_subsystem(name);
259 if (subsystem == 0) {
261 SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << "not found");
271 * Built-in command: load flight.
273 * file (optional): the name of the file to load (relative to current
274 * directory). Defaults to "fgfs.sav"
277 do_load (const SGPropertyNode * arg)
279 const string &file = arg->getStringValue("file", "fgfs.sav");
280 ifstream input(file.c_str());
281 if (input.good() && fgLoadFlight(input)) {
283 SG_LOG(SG_INPUT, SG_INFO, "Restored flight from " << file);
286 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight from " << file);
293 * Built-in command: save flight.
295 * file (optional): the name of the file to save (relative to the
296 * current directory). Defaults to "fgfs.sav".
299 do_save (const SGPropertyNode * arg)
301 const string &file = arg->getStringValue("file", "fgfs.sav");
302 bool write_all = arg->getBoolValue("write-all", false);
303 SG_LOG(SG_INPUT, SG_INFO, "Saving flight");
304 ofstream output(file.c_str());
305 if (output.good() && fgSaveFlight(output, write_all)) {
307 SG_LOG(SG_INPUT, SG_INFO, "Saved flight to " << file);
310 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight to " << file);
317 * Built-in command: (re)load the panel.
319 * path (optional): the file name to load the panel from
320 * (relative to FG_ROOT). Defaults to the value of /sim/panel/path,
321 * and if that's unspecified, to "Panels/Default/default.xml".
324 do_panel_load (const SGPropertyNode * arg)
327 arg->getStringValue("path",
328 fgGetString("/sim/panel/path",
329 "Panels/Default/default.xml"));
330 FGPanel * new_panel = fgReadPanel(panel_path);
331 if (new_panel == 0) {
332 SG_LOG(SG_INPUT, SG_ALERT,
333 "Error reading new panel from " << panel_path);
336 SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path);
337 globals->get_current_panel()->unbind();
338 delete globals->get_current_panel();
339 globals->set_current_panel( new_panel );
340 globals->get_current_panel()->bind();
346 * Built-in command: pass a mouse click to the panel.
348 * button: the mouse button number, zero-based.
349 * is-down: true if the button is down, false if it is up.
350 * x-pos: the x position of the mouse click.
351 * y-pos: the y position of the mouse click.
354 do_panel_mouse_click (const SGPropertyNode * arg)
356 if (globals->get_current_panel() != 0)
357 return globals->get_current_panel()
358 ->doMouseAction(arg->getIntValue("button"),
359 arg->getBoolValue("is-down") ? PU_DOWN : PU_UP,
360 arg->getIntValue("x-pos"),
361 arg->getIntValue("y-pos"));
368 * Built-in command: (re)load preferences.
370 * path (optional): the file name to load the panel from (relative
371 * to FG_ROOT). Defaults to "preferences.xml".
374 do_preferences_load (const SGPropertyNode * arg)
377 fgLoadProps(arg->getStringValue("path", "preferences.xml"),
378 globals->get_props());
379 } catch (const sg_exception &e) {
380 guiErrorMessage("Error reading global preferences: ", e);
383 SG_LOG(SG_INPUT, SG_INFO, "Successfully read global preferences.");
391 if ( !strcmp(fgGetString("/sim/flight-model"), "ada") ) {
392 globals->get_props()->setBoolValue( "/sim/hud/visibility", true );
393 if ( globals->get_viewmgr()->get_current() == 1 ) {
394 globals->get_props()->setBoolValue( "/sim/hud/visibility", false );
402 globals->get_current_view()->setHeadingOffset_deg(0.0);
403 globals->get_viewmgr()->next_view();
404 fix_hud_visibility();
405 globals->get_tile_mgr()->refresh_view_timestamps();
411 globals->get_current_view()->setHeadingOffset_deg(0.0);
412 globals->get_viewmgr()->prev_view();
413 fix_hud_visibility();
414 globals->get_tile_mgr()->refresh_view_timestamps();
418 * Built-in command: cycle view.
421 do_view_cycle (const SGPropertyNode * arg)
423 globals->get_current_view()->setHeadingOffset_deg(0.0);
424 globals->get_viewmgr()->next_view();
425 fix_hud_visibility();
426 globals->get_tile_mgr()->refresh_view_timestamps();
427 // fgReshape(fgGetInt("/sim/startup/xsize"), fgGetInt("/sim/startup/ysize"));
432 * Built-in command: capture screen.
435 do_screen_capture (const SGPropertyNode * arg)
443 * Reload the tile cache.
446 do_tile_cache_reload (const SGPropertyNode * arg)
448 static const SGPropertyNode *master_freeze
449 = fgGetNode("/sim/freeze/master");
450 bool freeze = master_freeze->getBoolValue();
451 SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache");
453 fgSetBool("/sim/freeze/master", true);
456 if ( globals->get_tile_mgr()->init() ) {
457 // Load the local scenery data
458 double visibility_meters = fgGetDouble("/environment/visibility-m");
459 globals->get_tile_mgr()->update( visibility_meters );
461 SG_LOG( SG_GENERAL, SG_ALERT,
462 "Error in Tile Manager initialization!" );
467 fgSetBool("/sim/freeze/master", false);
474 * Update the lighting manually.
477 do_timeofday (const SGPropertyNode * arg)
479 const string &offset_type = arg->getStringValue("timeofday", "noon");
481 static const SGPropertyNode *longitude
482 = fgGetNode("/position/longitude-deg");
483 static const SGPropertyNode *latitude
484 = fgGetNode("/position/latitude-deg");
485 static const SGPropertyNode *cur_time_override
486 = fgGetNode("/sim/time/cur-time-override", true);
488 int orig_warp = globals->get_warp();
489 SGTime *t = globals->get_time_params();
490 time_t cur_time = t->get_cur_time();
491 // cout << "cur_time = " << cur_time << endl;
492 // cout << "orig_warp = " << orig_warp << endl;
495 if ( offset_type == "real" ) {
497 } else if ( offset_type == "dawn" ) {
498 warp = fgTimeSecondsUntilSunAngle( cur_time,
499 longitude->getDoubleValue()
500 * SGD_DEGREES_TO_RADIANS,
501 latitude->getDoubleValue()
502 * SGD_DEGREES_TO_RADIANS,
504 } else if ( offset_type == "morning" ) {
505 warp = fgTimeSecondsUntilSunAngle( cur_time,
506 longitude->getDoubleValue()
507 * SGD_DEGREES_TO_RADIANS,
508 latitude->getDoubleValue()
509 * SGD_DEGREES_TO_RADIANS,
511 } else if ( offset_type == "noon" ) {
512 warp = fgTimeSecondsUntilSunAngle( cur_time,
513 longitude->getDoubleValue()
514 * SGD_DEGREES_TO_RADIANS,
515 latitude->getDoubleValue()
516 * SGD_DEGREES_TO_RADIANS,
518 } else if ( offset_type == "afternoon" ) {
519 warp = fgTimeSecondsUntilSunAngle( cur_time,
520 longitude->getDoubleValue()
521 * SGD_DEGREES_TO_RADIANS,
522 latitude->getDoubleValue()
523 * SGD_DEGREES_TO_RADIANS,
525 } else if ( offset_type == "dusk" ) {
526 warp = fgTimeSecondsUntilSunAngle( cur_time,
527 longitude->getDoubleValue()
528 * SGD_DEGREES_TO_RADIANS,
529 latitude->getDoubleValue()
530 * SGD_DEGREES_TO_RADIANS,
532 } else if ( offset_type == "evening" ) {
533 warp = fgTimeSecondsUntilSunAngle( cur_time,
534 longitude->getDoubleValue()
535 * SGD_DEGREES_TO_RADIANS,
536 latitude->getDoubleValue()
537 * SGD_DEGREES_TO_RADIANS,
539 } else if ( offset_type == "midnight" ) {
540 warp = fgTimeSecondsUntilSunAngle( cur_time,
541 longitude->getDoubleValue()
542 * SGD_DEGREES_TO_RADIANS,
543 latitude->getDoubleValue()
544 * SGD_DEGREES_TO_RADIANS,
547 // cout << "warp = " << warp << endl;
548 globals->set_warp( orig_warp + warp );
550 t->update( longitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS,
551 latitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS,
552 cur_time_override->getLongValue(),
553 globals->get_warp() );
560 * Built-in command: toggle a bool property value.
562 * property: The name of the property to toggle.
565 do_property_toggle (const SGPropertyNode * arg)
567 SGPropertyNode * prop = get_prop(arg);
568 return prop->setBoolValue(!prop->getBoolValue());
573 * Built-in command: assign a value to a property.
575 * property: the name of the property to assign.
576 * value: the value to assign; or
577 * property[1]: the property to copy from.
580 do_property_assign (const SGPropertyNode * arg)
582 SGPropertyNode * prop = get_prop(arg);
583 const SGPropertyNode * prop2 = get_prop2(arg);
584 const SGPropertyNode * value = arg->getNode("value");
587 return prop->setUnspecifiedValue(value->getStringValue());
589 return prop->setUnspecifiedValue(prop2->getStringValue());
596 * Built-in command: increment or decrement a property value.
598 * If the 'step' argument is present, it will be used; otherwise,
599 * the command uses 'offset' and 'factor', usually from the mouse.
601 * property: the name of the property to increment or decrement.
602 * step: the amount of the increment or decrement (default: 0).
603 * offset: offset from the current setting (used for the mouse; multiplied
605 * factor: scaling amount for the offset (defaults to 1).
606 * min: the minimum allowed value (default: no minimum).
607 * max: the maximum allowed value (default: no maximum).
608 * mask: 'integer' to apply only to the left of the decimal point,
609 * 'decimal' to apply only to the right of the decimal point,
610 * or 'all' to apply to the whole number (the default).
611 * wrap: true if the value should be wrapped when it passes min or max;
612 * both min and max must be present for this to work (default:
616 do_property_adjust (const SGPropertyNode * arg)
618 SGPropertyNode * prop = get_prop(arg);
621 if (arg->hasValue("step"))
622 amount = arg->getDoubleValue("step");
624 amount = (arg->getDoubleValue("factor", 1)
625 * arg->getDoubleValue("offset"));
627 double unmodifiable, modifiable;
628 split_value(prop->getDoubleValue(), arg->getStringValue("mask", "all"),
629 &unmodifiable, &modifiable);
630 modifiable += amount;
631 limit_value(&modifiable, arg);
633 prop->setDoubleValue(unmodifiable + modifiable);
640 * Built-in command: multiply a property value.
642 * property: the name of the property to multiply.
643 * factor: the amount by which to multiply.
644 * min: the minimum allowed value (default: no minimum).
645 * max: the maximum allowed value (default: no maximum).
646 * mask: 'integer' to apply only to the left of the decimal point,
647 * 'decimal' to apply only to the right of the decimal point,
648 * or 'all' to apply to the whole number (the default).
649 * wrap: true if the value should be wrapped when it passes min or max;
650 * both min and max must be present for this to work (default:
654 do_property_multiply (const SGPropertyNode * arg)
656 SGPropertyNode * prop = get_prop(arg);
657 double factor = arg->getDoubleValue("factor", 1);
659 double unmodifiable, modifiable;
660 split_value(prop->getDoubleValue(), arg->getStringValue("mask", "all"),
661 &unmodifiable, &modifiable);
662 modifiable *= factor;
663 limit_value(&modifiable, arg);
665 prop->setDoubleValue(unmodifiable + modifiable);
672 * Built-in command: swap two property values.
674 * property[0]: the name of the first property.
675 * property[1]: the name of the second property.
678 do_property_swap (const SGPropertyNode * arg)
680 SGPropertyNode * prop1 = get_prop(arg);
681 SGPropertyNode * prop2 = get_prop2(arg);
683 // FIXME: inefficient
684 const string & tmp = prop1->getStringValue();
685 return (prop1->setUnspecifiedValue(prop2->getStringValue()) &&
686 prop2->setUnspecifiedValue(tmp.c_str()));
691 * Built-in command: Set a property to an axis or other moving input.
693 * property: the name of the property to set.
694 * setting: the current input setting, usually between -1.0 and 1.0.
695 * offset: the offset to shift by, before applying the factor.
696 * factor: the factor to multiply by (use negative to reverse).
699 do_property_scale (const SGPropertyNode * arg)
701 SGPropertyNode * prop = get_prop(arg);
702 double setting = arg->getDoubleValue("setting");
703 double offset = arg->getDoubleValue("offset", 0.0);
704 double factor = arg->getDoubleValue("factor", 1.0);
705 bool squared = arg->getBoolValue("squared", false);
706 int power = arg->getIntValue("power", (squared ? 2 : 1));
708 int sign = (setting < 0 ? -1 : 1);
714 setting = setting * setting * sign;
717 setting = setting * setting * setting;
720 setting = setting * setting * setting * setting * sign;
723 setting = pow(setting, power);
724 if ((power % 2) == 0)
729 return prop->setDoubleValue((setting + offset) * factor);
734 * Built-in command: cycle a property through a set of values.
736 * If the current value isn't in the list, the cycle will
737 * (re)start from the beginning.
739 * property: the name of the property to cycle.
740 * value[*]: the list of values to cycle through.
743 do_property_cycle (const SGPropertyNode * arg)
745 SGPropertyNode * prop = get_prop(arg);
746 vector<SGPropertyNode_ptr> values = arg->getChildren("value");
748 int nSelections = values.size();
750 if (nSelections < 1) {
751 SG_LOG(SG_GENERAL, SG_ALERT, "No values for property-cycle");
755 // Try to find the current selection
756 for (int i = 0; i < nSelections; i++) {
757 if (compare_values(prop, values[i])) {
763 // Default or wrap to the first selection
764 if (selection < 0 || selection >= nSelections)
767 prop->setUnspecifiedValue(values[selection]->getStringValue());
773 * Built-in command: randomize a numeric property value.
775 * property: the name of the property value to randomize.
776 * min: the minimum allowed value.
777 * max: the maximum allowed value.
780 do_property_randomize (const SGPropertyNode * arg)
782 SGPropertyNode * prop = get_prop(arg);
783 double min = arg->getDoubleValue("min", DBL_MIN);
784 double max = arg->getDoubleValue("max", DBL_MAX);
785 prop->setDoubleValue(sg_random() * (max - min) + min);
791 * Built-in command: Show an XML-configured dialog.
793 * dialog-name: the name of the GUI dialog to display.
796 do_dialog_show (const SGPropertyNode * arg)
798 NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
799 gui->showDialog(arg->getStringValue("dialog-name"));
805 * Built-in Command: Hide the active XML-configured dialog.
808 do_dialog_close (const SGPropertyNode * arg)
810 NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
811 return gui->closeActiveDialog();
816 * Update a value in the active XML-configured dialog.
818 * object-name: The name of the GUI object(s) (all GUI objects if omitted).
821 do_dialog_update (const SGPropertyNode * arg)
823 NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
824 FGDialog * dialog = gui->getActiveDialog();
826 if (arg->hasValue("object-name")) {
827 dialog->updateValue(arg->getStringValue("object-name"));
829 dialog->updateValues();
839 * Apply a value in the active XML-configured dialog.
841 * object-name: The name of the GUI object(s) (all GUI objects if omitted).
844 do_dialog_apply (const SGPropertyNode * arg)
846 NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
847 FGDialog * dialog = gui->getActiveDialog();
849 if (arg->hasValue("object-name")) {
850 const char * name = arg->getStringValue("object-name");
851 dialog->applyValue(name);
852 dialog->updateValue(name);
854 dialog->applyValues();
855 dialog->updateValues();
865 * Built-in command: commit presets (read from in /sim/presets/)
868 do_presets_commit (const SGPropertyNode * arg)
870 // unbind the current fdm state so property changes
871 // don't get lost when we subsequently delete this fdm
872 // and create a new one.
873 cur_fdm_state->unbind();
875 // set position from presets
879 fgReInitSubsystems();
881 globals->get_tile_mgr()->update( fgGetDouble("/environment/visibility-m") );
884 if ( ! fgGetBool("/sim/presets/onground") ) {
885 fgSetBool( "/sim/freeze/master", true );
886 fgSetBool( "/sim/freeze/clock", true );
894 * Built-in command: set log level (0 ... 7)
897 do_log_level (const SGPropertyNode * arg)
899 sglog().setLogLevels( SG_ALL, (sgDebugPriority)arg->getIntValue() );
905 * Built-in command: replay the FDR buffer
908 do_replay (const SGPropertyNode * arg)
910 // freeze the master fdm
911 fgSetBool( "/sim/freeze/replay", true );
913 FGReplay *r = (FGReplay *)(globals->get_subsystem( "replay" ));
915 fgSetDouble( "/sim/replay/start-time", r->get_start_time() );
916 fgSetDouble( "/sim/replay/end-time", r->get_end_time() );
917 double duration = fgGetDouble( "/sim/replay/duration" );
918 if( duration && duration < (r->get_end_time() - r->get_start_time()) ) {
919 fgSetDouble( "/sim/replay/time", r->get_end_time() - duration );
921 fgSetDouble( "/sim/replay/time", r->get_start_time() );
924 cout << "start = " << r->get_start_time()
925 << " end = " << r->get_end_time() << endl;
933 do_decrease_visibility (const SGPropertyNode * arg)
935 double new_value = fgGetDouble("/environment/visibility-m") * 0.9;
936 fgSetDouble("/environment/visibility-m", new_value);
937 fgDefaultWeatherValue("visibility-m", new_value);
938 globals->get_subsystem("environment")->reinit();
944 do_increase_visibility (const SGPropertyNode * arg)
946 double new_value = fgGetDouble("/environment/visibility-m") * 1.1;
947 fgSetDouble("/environment/visibility-m", new_value);
948 fgDefaultWeatherValue("visibility-m", new_value);
949 globals->get_subsystem("environment")->reinit();
955 ////////////////////////////////////////////////////////////////////////
957 ////////////////////////////////////////////////////////////////////////
961 * Table of built-in commands.
963 * New commands do not have to be added here; any module in the application
964 * can add a new command using globals->get_commands()->addCommand(...).
968 SGCommandMgr::command_t command;
971 #if defined(HAVE_PLIB_PSL)
972 { "script", do_script },
973 #endif // HAVE_PLIB_PSL
975 { "reinit", do_reinit },
976 { "suspend", do_reinit },
977 { "resume", do_reinit },
980 { "panel-load", do_panel_load },
981 { "panel-mouse-click", do_panel_mouse_click },
982 { "preferences-load", do_preferences_load },
983 { "view-cycle", do_view_cycle },
984 { "screen-capture", do_screen_capture },
985 { "tile-cache-reload", do_tile_cache_reload },
986 { "timeofday", do_timeofday },
987 { "property-toggle", do_property_toggle },
988 { "property-assign", do_property_assign },
989 { "property-adjust", do_property_adjust },
990 { "property-multiply", do_property_multiply },
991 { "property-swap", do_property_swap },
992 { "property-scale", do_property_scale },
993 { "property-cycle", do_property_cycle },
994 { "property-randomize", do_property_randomize },
995 { "dialog-show", do_dialog_show },
996 { "dialog-close", do_dialog_close },
997 { "dialog-show", do_dialog_show },
998 { "dialog-update", do_dialog_update },
999 { "dialog-apply", do_dialog_apply },
1000 { "presets-commit", do_presets_commit },
1001 { "log-level", do_log_level },
1002 { "replay", do_replay },
1003 { "decrease-visibility", do_decrease_visibility },
1004 { "increase-visibility", do_increase_visibility },
1005 { 0, 0 } // zero-terminated
1010 * Initialize the default built-in commands.
1012 * Other commands may be added by other parts of the application.
1017 SG_LOG(SG_GENERAL, SG_INFO, "Initializing basic built-in commands:");
1018 for (int i = 0; built_ins[i].name != 0; i++) {
1019 SG_LOG(SG_GENERAL, SG_INFO, " " << built_ins[i].name);
1020 globals->get_commands()->addCommand(built_ins[i].name,
1021 built_ins[i].command);
1024 typedef bool (*dummy)();
1025 fgTie( "/command/view/next", dummy(0), do_view_next );
1026 fgTie( "/command/view/prev", dummy(0), do_view_prev );
1029 // end of fg_commands.cxx