From 342554fadb990680ac23eb04b8dbffe36b5e2d73 Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 8 Jul 2000 06:29:19 +0000 Subject: [PATCH] Fix up simulator freeze functionality. --- src/GUI/gui.cxx | 59 ++++++++++++++++++++++++------------------- src/Main/fg_init.cxx | 12 ++++----- src/Main/globals.hxx | 4 +-- src/Main/keyboard.cxx | 12 ++++----- src/Main/main.cxx | 2 +- src/Main/options.cxx | 23 +++++++++-------- src/Main/options.hxx | 4 --- 7 files changed, 60 insertions(+), 56 deletions(-) diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index c6e227ad6..904321d4b 100644 --- a/src/GUI/gui.cxx +++ b/src/GUI/gui.cxx @@ -64,11 +64,12 @@ #include #include #include -#include
+#include
#include
+#include
+#include
#include
#include
-#include
#ifdef FG_NETWORK_OLK #include #endif @@ -669,16 +670,21 @@ void mkDialog (const char *txt) // Repair any damage done to the Panel by other Gui Items void guiFixPanel( void ) { - int toggle_pause; +#if 0 // this function does nothing anyway + bool freeze = globals->get_freeze(); if ( current_options.get_panel_status() ) { // FGView *v = ¤t_view; - if( (toggle_pause = !current_options.get_pause()) ) - current_options.toggle_pause(); + if( !freeze ) + globals->set_freeze( true ); - if(toggle_pause) - current_options.toggle_pause(); + // we must have some something here at some point but this + // function does nothing now. + + if( !freeze ) + globals->set_freeze( false ); } +#endif } // Toggle the Menu and Mouse display state @@ -1029,9 +1035,9 @@ void AptDialog_OK (puObject *) FGAirport a; - int PauseMode = current_options.get_pause(); - if(!PauseMode) - current_options.toggle_pause(); + int freeze = globals->get_freeze(); + if(!freeze) + globals->set_freeze( true ); char *s; AptDialogInput->getValue(&s); @@ -1058,8 +1064,8 @@ void AptDialog_OK (puObject *) mkDialog(AptId.c_str()); } } - if( PauseMode != current_options.get_pause() ) - current_options.toggle_pause(); + if(!freeze) + globals->set_freeze( false ); } void AptDialog_Reset(puObject *) @@ -1139,9 +1145,9 @@ void NetIdDialog_OK (puObject *) { string NetId; - int PauseMode = current_options.get_pause(); - if(!PauseMode) - current_options.toggle_pause(); + bool freeze = globals->get_freeze(); + if(!freeze) + globals->set_freeze( true ); /* The following needs some cleanup because "string options.NetId" and "char *net_callsign" @@ -1156,8 +1162,8 @@ void NetIdDialog_OK (puObject *) /* Entering a callsign indicates : user wants Net HUD Info */ net_hud_display = 1; - if( PauseMode != current_options.get_pause() ) - current_options.toggle_pause(); + if(!freeze) + globals->set_freeze( false ); } void NewCallSign(puObject *cb) @@ -1257,15 +1263,16 @@ void NetFGDDialog_OK (puObject *) { char *NetFGD; - int PauseMode = current_options.get_pause(); - if(!PauseMode) current_options.toggle_pause(); + bool freeze = globals->get_freeze(); + if(!freeze) + globals->set_freeze( true ); NetFGDHostDialogInput->getValue( &NetFGD ); strcpy( fgd_host, NetFGD); NetFGDPortLoDialogInput->getValue( (int *) &base_port ); NetFGDPortHiDialogInput->getValue( (int *) &end_port ); NetFGDDialog_Cancel( NULL ); - if( PauseMode != current_options.get_pause() ) - current_options.toggle_pause(); + if(!freeze) + globals->set_freeze( false ); } void NetFGDDialog_SCAN (puObject *) @@ -1273,8 +1280,9 @@ void NetFGDDialog_SCAN (puObject *) char *NetFGD; int fgd_port; - int PauseMode = current_options.get_pause(); - if(!PauseMode) current_options.toggle_pause(); + bool freeze = globals->get_freeze(); + if(!freeze) + globals->set_freeze( true ); // printf("Vor getvalue %s\n"); NetFGDHostDialogInput->getValue( &NetFGD ); // printf("Vor strcpy %s\n", (char *) NetFGD); @@ -1285,9 +1293,8 @@ void NetFGDDialog_SCAN (puObject *) base_port, end_port); net_resolv_fgd(fgd_host); printf("Resolve : %d\n", net_r); - if( PauseMode != current_options.get_pause() ) { - current_options.toggle_pause(); - } + if(!freeze) + globals->set_freeze( false ); if ( net_r == 0 ) { fgd_port = 10000; strcpy( fgd_name, ""); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index adb7877e9..3cb462ec2 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -91,6 +91,7 @@ #include "fg_init.hxx" #include "fg_io.hxx" +#include "globals.hxx" #include "options.hxx" #include "views.hxx" #include "bfi.hxx" @@ -592,10 +593,9 @@ bool fgInitSubsystems( void ) { void fgReInitSubsystems( void ) { - int toggle_pause = current_options.get_pause(); - - if( !toggle_pause ) - current_options.toggle_pause(); + bool freeze = globals->get_freeze(); + if( !freeze ) + globals->set_freeze( true ); fgInitPosition(); if( global_tile_mgr.init() ) { @@ -682,6 +682,6 @@ void fgReInitSubsystems( void ) controls.reset_all(); current_autopilot->reset(); - if( !toggle_pause ) - current_options.toggle_pause(); + if( !freeze ) + globals->set_freeze( false ); } diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index bc225f998..9c2f59902 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -55,8 +55,8 @@ public: FGGlobals(); ~FGGlobals(); - inline bool get_frozen() const { return freeze; } - inline void toggle_frozen() { freeze = !freeze; } + inline bool get_freeze() const { return freeze; } + inline void set_freeze( bool f ) { freeze = f; } inline long int get_warp() const { return warp; } inline void set_warp( long int w ) { warp = w; } diff --git a/src/Main/keyboard.cxx b/src/Main/keyboard.cxx index 3171b28d7..ddf52d44b 100644 --- a/src/Main/keyboard.cxx +++ b/src/Main/keyboard.cxx @@ -342,7 +342,7 @@ void GLUTkey(unsigned char k, int x, int y) { fgUpdateSkyAndLightingParams(); return; case 112: // p key - current_options.toggle_pause(); + globals->set_freeze( ! globals->get_freeze() ); { FGBucket p( f->get_Longitude() * RAD_TO_DEG, @@ -471,10 +471,10 @@ void GLUTspecialkey(int k, int x, int y) { switch (k) { case GLUT_KEY_F2: // F2 Reload Tile Cache... { - int toggle_pause; + bool freeze; FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache"); - if( (toggle_pause = !current_options.get_pause()) ) - current_options.toggle_pause(); + if ( !freeze ) + globals->set_freeze( true ); BusyCursor(0); if( global_tile_mgr.init() ) { // Load the local scenery data @@ -486,8 +486,8 @@ void GLUTspecialkey(int k, int x, int y) { exit(-1); } BusyCursor(1); - if(toggle_pause) - current_options.toggle_pause(); + if ( !freeze ) + globals->set_freeze( false ); return; } case GLUT_KEY_F3: // F3 Take a screen shot diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 179b7beb8..af66a3b94 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -615,7 +615,7 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) { multi_loop = 1; } - if ( !current_options.get_pause() ) { + if ( !globals->get_freeze() ) { // run Autopilot system current_autopilot->run(); diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 15f4851c2..f8bc50070 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -156,7 +156,6 @@ fgOPTIONS::fgOPTIONS() : splash_screen(1), intro_music(1), mouse_pointer(0), - pause(0), control_mode(FG_JOYSTICK), auto_coordination(FG_AUTO_COORD_NOT_SPECIFIED), @@ -232,8 +231,10 @@ fgOPTIONS::fgOPTIONS() : void fgOPTIONS::toggle_panel() { - if( !pause ) - toggle_pause(); + bool freeze = globals->get_freeze(); + + if( !freeze ) + globals->set_freeze(true); if( panel_status ) { panel_status = false; @@ -252,8 +253,8 @@ fgOPTIONS::toggle_panel() { // fgReshape( xsize, ysize); fgReshape( current_view.get_winWidth(), current_view.get_winHeight() ); - if( !pause ) - toggle_pause(); + if( !freeze ) + globals->set_freeze( false ); } double @@ -594,10 +595,10 @@ int fgOPTIONS::parse_option( const string& arg ) { mouse_pointer = 1; } else if ( arg == "--enable-mouse-pointer" ) { mouse_pointer = 2; - } else if ( arg == "--disable-pause" ) { - pause = false; - } else if ( arg == "--enable-pause" ) { - pause = true; + } else if ( arg == "--disable-freeze" ) { + globals->set_freeze( false ); + } else if ( arg == "--enable-freeze" ) { + globals->set_freeze( true ); } else if ( arg == "--disable-anti-alias-hud" ) { anti_alias_hud = false; } else if ( arg == "--enable-anti-alias-hud" ) { @@ -916,8 +917,8 @@ void fgOPTIONS::usage ( void ) { cout << "\t--enable-mouse-pointer: enable extra mouse pointer (i.e. for" << endl; cout << "\t\tfull screen voodoo/voodoo-II based cards.)" << endl; - cout << "\t--disable-pause: start out in an active state" << endl; - cout << "\t--enable-pause: start out in a paused state" << endl; + cout << "\t--disable-freeze: start out in an running state" << endl; + cout << "\t--enable-freeze: start out in a frozen state" << endl; cout << "\t--control=mode: primary control mode " << "(joystick, keyboard, mouse)" << endl; cout << endl; diff --git a/src/Main/options.hxx b/src/Main/options.hxx index 185f89b69..09e2d87b5 100644 --- a/src/Main/options.hxx +++ b/src/Main/options.hxx @@ -147,7 +147,6 @@ private: bool splash_screen; // show splash screen bool intro_music; // play introductory music int mouse_pointer; // show mouse pointer - bool pause; // pause intially enabled/disabled fgControlMode control_mode; // primary control mode fgAutoCoordMode auto_coordination; // enable auto coordination @@ -242,7 +241,6 @@ public: inline bool get_splash_screen() const { return splash_screen; } inline bool get_intro_music() const { return intro_music; } inline int get_mouse_pointer() const { return mouse_pointer; } - inline bool get_pause() const { return pause; } inline bool get_anti_alias_hud() const { return anti_alias_hud; } inline fgControlMode get_control_mode() const { return control_mode; } inline void set_control_mode( fgControlMode mode ) { control_mode = mode; } @@ -312,8 +310,6 @@ public: inline void set_splash_screen (bool value) { splash_screen = value; } inline void set_intro_music (bool value) { intro_music = value; } inline void set_mouse_pointer (int value) { mouse_pointer = value; } - inline void set_pause (bool value) { pause = value; } - inline void toggle_pause () { pause = !pause; } inline void set_anti_alias_hud (bool value) { anti_alias_hud = value; } inline void set_hud_status( bool status ) { hud_status = status; } inline void set_sound (bool value) { sound = value; } -- 2.39.5