Fixed teleportation and dialog box crashes.
This commit is contained in:
parent
642b667b6a
commit
e03741be5f
6 changed files with 214 additions and 132 deletions
|
@ -44,33 +44,41 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <Include/general.hxx>
|
||||||
|
#include <Debug/logstream.hxx>
|
||||||
#include <Aircraft/aircraft.hxx>
|
#include <Aircraft/aircraft.hxx>
|
||||||
#include <Airports/simple.hxx>
|
#include <Airports/simple.hxx>
|
||||||
#include <Autopilot/autopilot.hxx>
|
|
||||||
#include <Debug/logstream.hxx>
|
|
||||||
#include <FDM/flight.hxx>
|
#include <FDM/flight.hxx>
|
||||||
#include <Include/general.hxx>
|
|
||||||
#include <Main/fg_init.hxx>
|
|
||||||
#include <Main/options.hxx>
|
#include <Main/options.hxx>
|
||||||
|
#include <Main/fg_init.hxx>
|
||||||
|
#include <Time/fg_time.hxx>
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
FG_USING_STD(string);
|
FG_USING_STD(string);
|
||||||
|
|
||||||
|
static puMenuBar *mainMenuBar;
|
||||||
|
static puButton *hideMenuButton;
|
||||||
|
|
||||||
puMenuBar *mainMenuBar;
|
static puDialogBox *dialogBox;
|
||||||
puButton *hideMenuButton;
|
static puFrame *dialogFrame;
|
||||||
puDialogBox *dialogBox;
|
static puText *dialogBoxMessage;
|
||||||
puText *dialogBoxMessage;
|
static puOneShot *dialogBoxOkButton;
|
||||||
puOneShot *dialogBoxOkButton;
|
|
||||||
puText *timerText;
|
|
||||||
|
|
||||||
|
extern void fgAPAdjust( puObject * );
|
||||||
|
// extern void fgLatLonFormatToggle( puObject *);
|
||||||
/* --------------------------------------------------------------------
|
/* --------------------------------------------------------------------
|
||||||
Mouse stuff
|
Mouse stuff
|
||||||
---------------------------------------------------------------------*/
|
---------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static int _mX = 0;
|
||||||
|
static int _mY = 0;
|
||||||
|
static int last_buttons = 0 ;
|
||||||
|
|
||||||
void guiMotionFunc ( int x, int y )
|
void guiMotionFunc ( int x, int y )
|
||||||
{
|
{
|
||||||
|
_mX = x;
|
||||||
|
_mY = y;
|
||||||
puMouse ( x, y ) ;
|
puMouse ( x, y ) ;
|
||||||
glutPostRedisplay () ;
|
glutPostRedisplay () ;
|
||||||
}
|
}
|
||||||
|
@ -78,10 +86,28 @@ void guiMotionFunc ( int x, int y )
|
||||||
|
|
||||||
void guiMouseFunc(int button, int updown, int x, int y)
|
void guiMouseFunc(int button, int updown, int x, int y)
|
||||||
{
|
{
|
||||||
|
_mX = x;
|
||||||
|
_mY = y;
|
||||||
|
if ( updown == PU_DOWN )
|
||||||
|
last_buttons |= ( 1 << button ) ;
|
||||||
|
else
|
||||||
|
last_buttons &= ~( 1 << button ) ;
|
||||||
|
|
||||||
puMouse (button, updown, x,y);
|
puMouse (button, updown, x,y);
|
||||||
glutPostRedisplay ();
|
glutPostRedisplay ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int guiGetMouseButton(void)
|
||||||
|
{
|
||||||
|
return last_buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
void guiGetMouse(int *x, int *y)
|
||||||
|
{
|
||||||
|
*x = _mX;
|
||||||
|
*y = _mY;
|
||||||
|
};
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
the Gui callback functions
|
the Gui callback functions
|
||||||
____________________________________________________________________*/
|
____________________________________________________________________*/
|
||||||
|
@ -91,19 +117,49 @@ void reInit(puObject *cb)
|
||||||
fgReInitSubsystems();
|
fgReInitSubsystems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void guiToggleMenu(void)
|
||||||
|
{
|
||||||
|
hideMenuButton ->
|
||||||
|
setValue ((int) !(hideMenuButton -> getValue() ) );
|
||||||
|
hideMenuButton -> invokeCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MenuHideMenuCb(puObject *cb)
|
||||||
|
{
|
||||||
|
mainMenuBar -> hide ();
|
||||||
|
// printf("Hiding Menu\n");
|
||||||
|
hideMenuButton -> setLegend ("Show Menu");
|
||||||
|
#if defined ( WIN32 ) || defined(__CYGWIN32__)
|
||||||
|
glutSetCursor(GLUT_CURSOR_NONE);
|
||||||
|
#else // I guess this is what we want to do ??
|
||||||
|
// puHideCursor(); // does not work with VooDoo
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void hideMenuCb (puObject *cb)
|
void hideMenuCb (puObject *cb)
|
||||||
{
|
{
|
||||||
if (cb -> getValue () )
|
if (cb -> getValue () )
|
||||||
{
|
{
|
||||||
mainMenuBar -> reveal();
|
mainMenuBar -> reveal();
|
||||||
printf("Showing Menu");
|
// printf("Showing Menu\n");
|
||||||
hideMenuButton -> setLegend ("Hide Menu");
|
hideMenuButton -> setLegend ("Hide Menu");
|
||||||
|
#if defined ( WIN32 ) || defined(__CYGWIN32__)
|
||||||
|
glutSetCursor(GLUT_CURSOR_INHERIT);
|
||||||
|
#else // I guess this is what we want to do ??
|
||||||
|
// puShowCursor(); // does not work with VooDoo
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mainMenuBar -> hide ();
|
mainMenuBar -> hide ();
|
||||||
printf("Hiding Menu");
|
// printf("Hiding Menu\n");
|
||||||
hideMenuButton -> setLegend ("Show Menu");
|
hideMenuButton -> setLegend ("Show Menu");
|
||||||
|
#if defined ( WIN32 ) || defined(__CYGWIN32__)
|
||||||
|
glutSetCursor(GLUT_CURSOR_NONE);
|
||||||
|
#else // I guess this is what we want to do ??
|
||||||
|
// puHideCursor(); // does not work with VooDoo
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +175,18 @@ void goodBye(puObject *)
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void goAwayCb (puObject *)
|
|
||||||
|
void goAwayCb (puObject *me)
|
||||||
{
|
{
|
||||||
|
delete dialogBoxOkButton;
|
||||||
|
dialogBoxOkButton = NULL;
|
||||||
|
|
||||||
|
delete dialogBoxMessage;
|
||||||
|
dialogBoxMessage = NULL;
|
||||||
|
|
||||||
|
delete dialogFrame;
|
||||||
|
dialogFrame = NULL;
|
||||||
|
|
||||||
delete dialogBox;
|
delete dialogBox;
|
||||||
dialogBox = NULL;
|
dialogBox = NULL;
|
||||||
}
|
}
|
||||||
|
@ -129,9 +195,9 @@ void mkDialog (char *txt)
|
||||||
{
|
{
|
||||||
dialogBox = new puDialogBox (150, 50);
|
dialogBox = new puDialogBox (150, 50);
|
||||||
{
|
{
|
||||||
new puFrame (0,0,400, 100);
|
dialogFrame = new puFrame (0,0,400, 100);
|
||||||
dialogBoxMessage = new puText (10, 70);
|
dialogBoxMessage = new puText (10, 70);
|
||||||
dialogBoxMessage -> setLabel (txt);
|
dialogBoxMessage -> setLabel (txt);
|
||||||
dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
|
dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
|
||||||
dialogBoxOkButton -> setLegend ("OK");
|
dialogBoxOkButton -> setLegend ("OK");
|
||||||
dialogBoxOkButton -> makeReturnDefault (TRUE );
|
dialogBoxOkButton -> makeReturnDefault (TRUE );
|
||||||
|
@ -141,147 +207,6 @@ void mkDialog (char *txt)
|
||||||
dialogBox -> reveal();
|
dialogBox -> reveal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// The beginnings of teleportation :-)
|
|
||||||
// Needs cleaning up but works
|
|
||||||
// These statics should disapear when this is a class
|
|
||||||
static puDialogBox *AptDialog;
|
|
||||||
static puFrame *AptDialogFrame;
|
|
||||||
static puText *AptDialogMessage;
|
|
||||||
static puInput *AptDialogInput;
|
|
||||||
|
|
||||||
static puOneShot *AptDialogOkButton;
|
|
||||||
static puOneShot *AptDialogCancelButton;
|
|
||||||
static puOneShot *AptDialogResetButton;
|
|
||||||
|
|
||||||
static string AptDialog_OldAptId;
|
|
||||||
static string AptDialog_NewAptId;
|
|
||||||
static int AptDialog_ValidAptId;
|
|
||||||
|
|
||||||
static void validateApt (puObject *inpApt)
|
|
||||||
{
|
|
||||||
char *s;
|
|
||||||
AptDialog_ValidAptId = 0;
|
|
||||||
|
|
||||||
inpApt->getValue(&s);
|
|
||||||
|
|
||||||
AptDialog_NewAptId = s;
|
|
||||||
|
|
||||||
FG_LOG( FG_GENERAL, FG_INFO, "Validating apt id = " << s );
|
|
||||||
|
|
||||||
if ( AptDialog_NewAptId.length() ) {
|
|
||||||
// set initial position from airport id
|
|
||||||
|
|
||||||
fgAIRPORTS airports;
|
|
||||||
fgAIRPORT a;
|
|
||||||
|
|
||||||
FG_LOG( FG_GENERAL, FG_INFO,
|
|
||||||
"Attempting to set starting position from airport code "
|
|
||||||
<< s );
|
|
||||||
|
|
||||||
airports.load("apt_simple");
|
|
||||||
if ( ! airports.search( AptDialog_NewAptId, &a ) ) {
|
|
||||||
string err_string = "Failed to find ";
|
|
||||||
err_string += s;
|
|
||||||
err_string += " in database.";
|
|
||||||
mkDialog(err_string.c_str());
|
|
||||||
FG_LOG( FG_GENERAL, FG_ALERT,
|
|
||||||
"Failed to find " << s << " in database." );
|
|
||||||
} else {
|
|
||||||
AptDialog_ValidAptId = 1;
|
|
||||||
AptDialog_OldAptId = s;
|
|
||||||
current_options.set_airport_id(AptDialog_NewAptId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( AptDialog_ValidAptId ) {
|
|
||||||
fgReInitSubsystems();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AptDialog_Cancel(puObject *)
|
|
||||||
{
|
|
||||||
delete AptDialogResetButton;
|
|
||||||
AptDialogResetButton = NULL;
|
|
||||||
|
|
||||||
delete AptDialogCancelButton;
|
|
||||||
AptDialogCancelButton = NULL;
|
|
||||||
|
|
||||||
delete AptDialogOkButton;
|
|
||||||
AptDialogOkButton = NULL;
|
|
||||||
|
|
||||||
delete AptDialogInput;
|
|
||||||
AptDialogInput = NULL;
|
|
||||||
|
|
||||||
delete AptDialogMessage;
|
|
||||||
AptDialogMessage = NULL;
|
|
||||||
|
|
||||||
delete AptDialogFrame;
|
|
||||||
AptDialogFrame = NULL;
|
|
||||||
|
|
||||||
delete AptDialog;
|
|
||||||
AptDialog = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AptDialog_OK (puObject *me)
|
|
||||||
{
|
|
||||||
validateApt(AptDialogInput);
|
|
||||||
AptDialog_Cancel(me);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AptDialog_Reset(puObject *)
|
|
||||||
{
|
|
||||||
AptDialogInput->setValue ( AptDialog_OldAptId.c_str() );
|
|
||||||
AptDialogInput->setCursor( 0 ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NewAirportInit(puObject *cb)
|
|
||||||
{
|
|
||||||
FGInterface *f;
|
|
||||||
f = current_aircraft.fdm_state;
|
|
||||||
|
|
||||||
char *AptLabel = "Enter New Airport ID";
|
|
||||||
int len = 350/2 - puGetStringWidth(NULL, AptLabel)/2;
|
|
||||||
|
|
||||||
AptDialog_OldAptId = current_options.get_airport_id();
|
|
||||||
char *s = AptDialog_OldAptId.c_str();
|
|
||||||
|
|
||||||
AptDialog = new puDialogBox (150, 50);
|
|
||||||
{
|
|
||||||
AptDialogFrame = new puFrame (0,0,350, 150);
|
|
||||||
AptDialogMessage = new puText (len, 110);
|
|
||||||
AptDialogMessage -> setLabel (AptLabel);
|
|
||||||
|
|
||||||
AptDialogInput = new puInput ( 50, 70, 300, 100 );
|
|
||||||
AptDialogInput -> setValue ( s );
|
|
||||||
// Uncomment the next line to have input active on startup
|
|
||||||
AptDialogInput -> acceptInput ( );
|
|
||||||
// cursor at begining or end of line ?
|
|
||||||
//len = strlen(s);
|
|
||||||
len = 0;
|
|
||||||
AptDialogInput -> setCursor ( len );
|
|
||||||
AptDialogInput -> setSelectRegion ( 5, 9 );
|
|
||||||
|
|
||||||
AptDialogOkButton = new puOneShot (50, 10, 110, 50);
|
|
||||||
AptDialogOkButton -> setLegend ("OK");
|
|
||||||
AptDialogOkButton -> makeReturnDefault (TRUE );
|
|
||||||
AptDialogOkButton -> setCallback (AptDialog_OK);
|
|
||||||
|
|
||||||
AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
|
|
||||||
AptDialogCancelButton -> setLegend ("Cancel");
|
|
||||||
AptDialogCancelButton -> makeReturnDefault (TRUE );
|
|
||||||
AptDialogCancelButton -> setCallback (AptDialog_Cancel);
|
|
||||||
|
|
||||||
AptDialogResetButton = new puOneShot (240, 10, 300, 50);
|
|
||||||
AptDialogResetButton -> setLegend ("Reset");
|
|
||||||
AptDialogResetButton -> makeReturnDefault (TRUE );
|
|
||||||
AptDialogResetButton -> setCallback (AptDialog_Reset);
|
|
||||||
}
|
|
||||||
AptDialog -> close();
|
|
||||||
AptDialog -> reveal();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void notCb (puObject *)
|
void notCb (puObject *)
|
||||||
{
|
{
|
||||||
mkDialog ("This function isn't implemented yet");
|
mkDialog ("This function isn't implemented yet");
|
||||||
|
@ -315,26 +240,173 @@ void helpCb (puObject *)
|
||||||
system( command.c_str() );
|
system( command.c_str() );
|
||||||
string text = "Help started in netscape window.";
|
string text = "Help started in netscape window.";
|
||||||
|
|
||||||
mkDialog ( (char*)text.c_str() );
|
mkDialog (text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The beginnings of teleportation :-)
|
||||||
|
// Needs cleaning up but works
|
||||||
|
// These statics should disapear when this is a class
|
||||||
|
static puDialogBox *AptDialog;
|
||||||
|
static puFrame *AptDialogFrame;
|
||||||
|
static puText *AptDialogMessage;
|
||||||
|
static puInput *AptDialogInput;
|
||||||
|
|
||||||
|
static puOneShot *AptDialogOkButton;
|
||||||
|
static puOneShot *AptDialogCancelButton;
|
||||||
|
static puOneShot *AptDialogResetButton;
|
||||||
|
|
||||||
|
static string AptDialog_OldAptId;
|
||||||
|
static string AptDialog_NewAptId;
|
||||||
|
static int AptDialog_ValidAptId;
|
||||||
|
|
||||||
|
static void validateApt (puObject *inpApt)
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
AptDialog_ValidAptId = 0;
|
||||||
|
|
||||||
|
inpApt->getValue(&s);
|
||||||
|
|
||||||
|
AptDialog_NewAptId = s;
|
||||||
|
|
||||||
|
if ( AptDialog_NewAptId.length() ) {
|
||||||
|
// set initial position from airport id
|
||||||
|
|
||||||
|
fgAIRPORTS airports;
|
||||||
|
fgAIRPORT a;
|
||||||
|
|
||||||
|
FG_LOG( FG_GENERAL, FG_INFO,
|
||||||
|
"Attempting to set starting position from airport code "
|
||||||
|
<< s );
|
||||||
|
|
||||||
|
airports.load("apt_simple");
|
||||||
|
if ( ! airports.search( AptDialog_NewAptId, &a ) ) {
|
||||||
|
string err_string = "Failed to find ";
|
||||||
|
err_string += s;
|
||||||
|
err_string += " in database.";
|
||||||
|
mkDialog(err_string.c_str());
|
||||||
|
FG_LOG( FG_GENERAL, FG_ALERT,
|
||||||
|
"Failed to find " << s << " in database." );
|
||||||
|
} else {
|
||||||
|
AptDialog_ValidAptId = 1;
|
||||||
|
AptDialog_OldAptId = s;
|
||||||
|
current_options.set_airport_id(AptDialog_NewAptId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( AptDialog_ValidAptId ) {
|
||||||
|
fgReInitSubsystems();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AptDialog_Cancel(puObject *)
|
||||||
|
{
|
||||||
|
FGTime *t = FGTime::cur_time_params;
|
||||||
|
|
||||||
|
delete AptDialogResetButton;
|
||||||
|
AptDialogResetButton = NULL;
|
||||||
|
|
||||||
|
delete AptDialogCancelButton;
|
||||||
|
AptDialogCancelButton = NULL;
|
||||||
|
|
||||||
|
delete AptDialogOkButton;
|
||||||
|
AptDialogOkButton = NULL;
|
||||||
|
|
||||||
|
delete AptDialogInput;
|
||||||
|
AptDialogInput = NULL;
|
||||||
|
|
||||||
|
delete AptDialogMessage;
|
||||||
|
AptDialogMessage = NULL;
|
||||||
|
|
||||||
|
delete AptDialogFrame;
|
||||||
|
AptDialogFrame = NULL;
|
||||||
|
|
||||||
|
delete AptDialog;
|
||||||
|
AptDialog = NULL;
|
||||||
|
|
||||||
|
t->togglePauseMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AptDialog_OK (puObject *me)
|
||||||
|
{
|
||||||
|
validateApt(AptDialogInput);
|
||||||
|
AptDialog_Cancel(me);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AptDialog_Reset(puObject *)
|
||||||
|
{
|
||||||
|
AptDialogInput->setValue ( AptDialog_OldAptId.c_str() );
|
||||||
|
AptDialogInput->setCursor( 0 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewAirportInit(puObject *cb)
|
||||||
|
{
|
||||||
|
FGInterface *f;
|
||||||
|
FGTime *t;
|
||||||
|
|
||||||
|
f = current_aircraft.fdm_state;
|
||||||
|
t = FGTime::cur_time_params;
|
||||||
|
|
||||||
|
char *AptLabel = "Enter New Airport ID";
|
||||||
|
int len = 350/2 - puGetStringWidth(NULL, AptLabel)/2;
|
||||||
|
|
||||||
|
AptDialog_OldAptId = current_options.get_airport_id();
|
||||||
|
char *s = AptDialog_OldAptId.c_str();
|
||||||
|
|
||||||
|
AptDialog = new puDialogBox (150, 50);
|
||||||
|
{
|
||||||
|
AptDialogFrame = new puFrame (0,0,350, 150);
|
||||||
|
AptDialogMessage = new puText (len, 110);
|
||||||
|
AptDialogMessage -> setLabel (AptLabel);
|
||||||
|
|
||||||
|
AptDialogInput = new puInput ( 50, 70, 300, 100 );
|
||||||
|
AptDialogInput -> setValue ( s );
|
||||||
|
// Uncomment the next line to have input active on startup
|
||||||
|
AptDialogInput -> acceptInput ( );
|
||||||
|
// cursor at begining or end of line ?
|
||||||
|
//len = strlen(s);
|
||||||
|
len = 0;
|
||||||
|
AptDialogInput -> setCursor ( len );
|
||||||
|
AptDialogInput -> setSelectRegion ( 5, 9 );
|
||||||
|
|
||||||
|
AptDialogOkButton = new puOneShot (50, 10, 110, 50);
|
||||||
|
AptDialogOkButton -> setLegend ("OK");
|
||||||
|
AptDialogOkButton -> makeReturnDefault (TRUE );
|
||||||
|
AptDialogOkButton -> setCallback (AptDialog_OK);
|
||||||
|
|
||||||
|
AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
|
||||||
|
AptDialogCancelButton -> setLegend ("Cancel");
|
||||||
|
AptDialogCancelButton -> makeReturnDefault (TRUE );
|
||||||
|
AptDialogCancelButton -> setCallback (AptDialog_Cancel);
|
||||||
|
|
||||||
|
AptDialogResetButton = new puOneShot (240, 10, 300, 50);
|
||||||
|
AptDialogResetButton -> setLegend ("Reset");
|
||||||
|
AptDialogResetButton -> makeReturnDefault (TRUE );
|
||||||
|
AptDialogResetButton -> setCallback (AptDialog_Reset);
|
||||||
|
}
|
||||||
|
AptDialog -> close();
|
||||||
|
AptDialog -> reveal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
The menu stuff
|
The menu stuff
|
||||||
---------------------------------------------------------------------*/
|
---------------------------------------------------------------------*/
|
||||||
char *fileSubmenu [] = { "Exit", "Close", "---------", "Print",
|
char *fileSubmenu [] = {
|
||||||
"---------", "Save", "Reset", NULL };
|
"Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL };
|
||||||
char *editSubmenu [] = { "Edit text", NULL };
|
char *editSubmenu [] = {
|
||||||
char *viewSubmenu [] = { "Cockpit View > ", "View >","------------",
|
"Edit text", NULL };
|
||||||
"View options...", NULL };
|
char *viewSubmenu [] = {
|
||||||
char *aircraftSubmenu [] = { "Autopilot ...", "Engine ...", "Navigation",
|
"Cockpit View > ", "View >","------------", "View options...", NULL };
|
||||||
"Communication", NULL};
|
char *aircraftSubmenu [] = {
|
||||||
char *environmentSubmenu [] = { "Airport", "Terrain", "Weather", NULL};
|
"Autopilot ...", "Engine ...", "Navigation", "Communication", NULL};
|
||||||
char *optionsSubmenu [] = { "Preferences", "Realism & Reliablity...",
|
char *environmentSubmenu [] = {
|
||||||
NULL};
|
"Airport", "Terrain", "Weather", NULL};
|
||||||
char *helpSubmenu [] = { "About...", "Help", NULL };
|
char *optionsSubmenu [] = {
|
||||||
|
"Preferences", "Realism & Reliablity...", NULL};
|
||||||
|
char *helpSubmenu [] = {
|
||||||
|
"About...", "Help", NULL };
|
||||||
|
|
||||||
puCallback fileSubmenuCb [] = { goodBye, hideMenuCb, NULL, notCb,
|
puCallback fileSubmenuCb [] = { goodBye, MenuHideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL};
|
||||||
NULL, notCb, reInit, NULL};
|
|
||||||
puCallback editSubmenuCb [] = { notCb, NULL };
|
puCallback editSubmenuCb [] = { notCb, NULL };
|
||||||
puCallback viewSubmenuCb [] = { notCb, notCb, NULL, notCb, NULL };
|
puCallback viewSubmenuCb [] = { notCb, notCb, NULL, notCb, NULL };
|
||||||
puCallback aircraftSubmenuCb [] = { fgAPAdjust, notCb, notCb, notCb, NULL };
|
puCallback aircraftSubmenuCb [] = { fgAPAdjust, notCb, notCb, notCb, NULL };
|
||||||
|
@ -380,15 +452,11 @@ void guiInit()
|
||||||
|
|
||||||
// puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED );
|
// puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED );
|
||||||
puSetDefaultStyle ( PUSTYLE_DEFAULT );
|
puSetDefaultStyle ( PUSTYLE_DEFAULT );
|
||||||
// puSetDefaultColourScheme (0.2, 0.4, 0.8, 0.5);
|
// puSetDefaultColourScheme (0.2, 0.4, 0.8, 0.5);
|
||||||
puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.5);
|
puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.4);
|
||||||
|
|
||||||
/* OK the rest is largely put in here to mimick Steve Baker's
|
/* OK the rest is largely put in here to mimick Steve Baker's
|
||||||
"complex" example It should change in future versions */
|
"complex" example It should change in future versions */
|
||||||
|
|
||||||
// timerText = new puText (300, 10);
|
|
||||||
// timerText -> setColour (PUCOL_LABEL, 1.0, 1.0, 1.0);
|
|
||||||
|
|
||||||
/* Make a button to hide the menu bar */
|
/* Make a button to hide the menu bar */
|
||||||
hideMenuButton = new puButton (10,10, 150, 50);
|
hideMenuButton = new puButton (10,10, 150, 50);
|
||||||
hideMenuButton -> setValue (TRUE);
|
hideMenuButton -> setValue (TRUE);
|
||||||
|
|
|
@ -27,16 +27,11 @@
|
||||||
|
|
||||||
#include <plib/pu.h>
|
#include <plib/pu.h>
|
||||||
|
|
||||||
extern puMenuBar *mainMenuBar;
|
|
||||||
extern puButton *hideMenuButton;
|
|
||||||
extern puDialogBox *dialogBox;
|
|
||||||
extern puText *dialogBoxMessage;
|
|
||||||
extern puOneShot *dialogBoxOkButton;
|
|
||||||
extern puText *timerText;
|
|
||||||
|
|
||||||
extern void guiMotionFunc ( int x, int y );
|
extern void guiMotionFunc ( int x, int y );
|
||||||
extern void guiMouseFunc(int button, int updown, int x, int y);
|
extern void guiMouseFunc(int button, int updown, int x, int y);
|
||||||
extern void guiInit();
|
extern void guiInit();
|
||||||
|
extern void guiToggleMenu(void);
|
||||||
|
extern void mkDialog (char *txt);
|
||||||
|
|
||||||
extern void mkDialog (char *txt);
|
extern void mkDialog (char *txt);
|
||||||
|
|
||||||
|
|
|
@ -364,9 +364,7 @@ void GLUTspecialkey(int k, int x, int y) {
|
||||||
return;
|
return;
|
||||||
case GLUT_KEY_F10: // F10 toggles menu on and off...
|
case GLUT_KEY_F10: // F10 toggles menu on and off...
|
||||||
FG_LOG(FG_INPUT, FG_INFO, "Invoking call back function");
|
FG_LOG(FG_INPUT, FG_INFO, "Invoking call back function");
|
||||||
hideMenuButton ->
|
guiToggleMenu();
|
||||||
setValue ((int) !(hideMenuButton -> getValue() ) );
|
|
||||||
hideMenuButton -> invokeCallback();
|
|
||||||
//exit(1);
|
//exit(1);
|
||||||
return;
|
return;
|
||||||
case GLUT_KEY_UP:
|
case GLUT_KEY_UP:
|
||||||
|
|
|
@ -457,10 +457,13 @@ static void fgMainLoop( void ) {
|
||||||
FGTime *t;
|
FGTime *t;
|
||||||
static long remainder = 0;
|
static long remainder = 0;
|
||||||
long elapsed, multi_loop;
|
long elapsed, multi_loop;
|
||||||
// int i;
|
#ifdef FANCY_FRAME_COUNTER
|
||||||
// double accum;
|
int i;
|
||||||
|
double accum;
|
||||||
|
#else
|
||||||
static time_t last_time = 0;
|
static time_t last_time = 0;
|
||||||
static int frames = 0;
|
static int frames = 0;
|
||||||
|
#endif // FANCY_FRAME_COUNTER
|
||||||
|
|
||||||
f = current_aircraft.fdm_state;
|
f = current_aircraft.fdm_state;
|
||||||
t = FGTime::cur_time_params;
|
t = FGTime::cur_time_params;
|
||||||
|
@ -521,6 +524,25 @@ static void fgMainLoop( void ) {
|
||||||
<< ", previous remainder is = " << remainder );
|
<< ", previous remainder is = " << remainder );
|
||||||
|
|
||||||
// Calculate frame rate average
|
// Calculate frame rate average
|
||||||
|
#ifdef FANCY_FRAME_COUNTER
|
||||||
|
/* old fps calculation */
|
||||||
|
if ( elapsed > 0 ) {
|
||||||
|
double tmp;
|
||||||
|
accum = 0.0;
|
||||||
|
for ( i = FG_FRAME_RATE_HISTORY - 2; i >= 0; i-- ) {
|
||||||
|
tmp = general.get_frame(i);
|
||||||
|
accum += tmp;
|
||||||
|
// printf("frame[%d] = %.2f\n", i, g->frames[i]);
|
||||||
|
general.set_frame(i+1,tmp);
|
||||||
|
}
|
||||||
|
tmp = 1000000.0 / (float)elapsed;
|
||||||
|
general.set_frame(0,tmp);
|
||||||
|
// printf("frame[0] = %.2f\n", general.frames[0]);
|
||||||
|
accum += tmp;
|
||||||
|
general.set_frame_rate(accum / (float)FG_FRAME_RATE_HISTORY);
|
||||||
|
// printf("ave = %.2f\n", general.frame_rate);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if ( (t->get_cur_time() != last_time) && (last_time > 0) ) {
|
if ( (t->get_cur_time() != last_time) && (last_time > 0) ) {
|
||||||
general.set_frame_rate( frames );
|
general.set_frame_rate( frames );
|
||||||
FG_LOG( FG_ALL, FG_DEBUG,
|
FG_LOG( FG_ALL, FG_DEBUG,
|
||||||
|
@ -529,22 +551,7 @@ static void fgMainLoop( void ) {
|
||||||
}
|
}
|
||||||
last_time = t->get_cur_time();
|
last_time = t->get_cur_time();
|
||||||
++frames;
|
++frames;
|
||||||
|
#endif
|
||||||
/* old fps calculation
|
|
||||||
if ( elapsed > 0 ) {
|
|
||||||
accum = 0.0;
|
|
||||||
for ( i = FG_FRAME_RATE_HISTORY - 2; i >= 0; i-- ) {
|
|
||||||
accum += g->frames[i];
|
|
||||||
// printf("frame[%d] = %.2f\n", i, g->frames[i]);
|
|
||||||
g->frames[i+1] = g->frames[i];
|
|
||||||
}
|
|
||||||
g->frames[0] = 1000.0 / (float)elapsed;
|
|
||||||
// printf("frame[0] = %.2f\n", g->frames[0]);
|
|
||||||
accum += g->frames[0];
|
|
||||||
g->frame_rate = accum / (float)FG_FRAME_RATE_HISTORY;
|
|
||||||
// printf("ave = %.2f\n", g->frame_rate);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Run flight model
|
// Run flight model
|
||||||
if ( ! use_signals ) {
|
if ( ! use_signals ) {
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
#include <Debug/logstream.hxx>
|
#include <Debug/logstream.hxx>
|
||||||
#include <Airports/genapt.hxx>
|
#include <Airports/genapt.hxx>
|
||||||
// #include <Bucket/bucketutils.hxx>
|
#include <Bucket/newbucket.hxx>
|
||||||
#include <Main/options.hxx>
|
#include <Main/options.hxx>
|
||||||
#include <Main/views.hxx>
|
#include <Main/views.hxx>
|
||||||
#include <Misc/fgpath.hxx>
|
#include <Misc/fgpath.hxx>
|
||||||
|
@ -64,9 +64,9 @@ fgTILECACHE::init( void )
|
||||||
for ( i = 0; i < FG_TILE_CACHE_SIZE; i++ ) {
|
for ( i = 0; i < FG_TILE_CACHE_SIZE; i++ ) {
|
||||||
if ( tile_cache[i].used ) {
|
if ( tile_cache[i].used ) {
|
||||||
entry_free(i);
|
entry_free(i);
|
||||||
tile_cache[i].tile_bucket.make_bad();
|
|
||||||
}
|
}
|
||||||
tile_cache[i].used = 0;
|
tile_cache[i].used = 0;
|
||||||
|
tile_cache[i].tile_bucket.make_bad();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,10 +71,21 @@
|
||||||
# define FG_MEM_COPY(to,from,n) bcopy(from, to, n)
|
# define FG_MEM_COPY(to,from,n) bcopy(from, to, n)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Tile loading state
|
||||||
|
enum fgTileLoadState {
|
||||||
|
START = 0,
|
||||||
|
INITED = 1,
|
||||||
|
RUNNING = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// closest (potentially viewable) tiles, centered on current tile.
|
// closest (potentially viewable) tiles, centered on current tile.
|
||||||
// This is an array of pointers to cache indexes.
|
// This is an array of pointers to cache indexes.
|
||||||
int tiles[FG_LOCAL_X_Y];
|
int tiles[FG_LOCAL_X_Y];
|
||||||
|
|
||||||
|
static fgTileLoadState state = START;
|
||||||
|
|
||||||
|
|
||||||
// Initialize the Tile Manager subsystem
|
// Initialize the Tile Manager subsystem
|
||||||
int fgTileMgrInit( void ) {
|
int fgTileMgrInit( void ) {
|
||||||
|
@ -85,6 +96,8 @@ int fgTileMgrInit( void ) {
|
||||||
material_mgr.load_lib();
|
material_mgr.load_lib();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state = INITED;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +126,6 @@ static double point_line_dist_squared( const Point3D& tc, const Point3D& vp,
|
||||||
MAT3vec d )
|
MAT3vec d )
|
||||||
{
|
{
|
||||||
MAT3vec p, p0;
|
MAT3vec p, p0;
|
||||||
double dist;
|
|
||||||
|
|
||||||
p[0] = tc.x(); p[1] = tc.y(); p[2] = tc.z();
|
p[0] = tc.x(); p[1] = tc.y(); p[2] = tc.z();
|
||||||
p0[0] = vp.x(); p0[1] = vp.y(); p0[2] = vp.z();
|
p0[0] = vp.x(); p0[1] = vp.y(); p0[2] = vp.z();
|
||||||
|
@ -349,12 +361,14 @@ int fgTileMgrUpdate( void ) {
|
||||||
dw = tile_diameter / 2;
|
dw = tile_diameter / 2;
|
||||||
dh = tile_diameter / 2;
|
dh = tile_diameter / 2;
|
||||||
|
|
||||||
if ( p1 == p_last ) {
|
if ( (p1 == p_last) && (state == RUNNING) ) {
|
||||||
// same bucket as last time
|
// same bucket as last time
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG, "Same bucket as last time" );
|
FG_LOG( FG_TERRAIN, FG_DEBUG, "Same bucket as last time" );
|
||||||
} else if ( p_last.get_lon() == -1000 ) {
|
} else if ( (state == START) || (state == INITED) ) {
|
||||||
// First time through, initialize the system and load all
|
state = RUNNING;
|
||||||
// relavant tiles
|
|
||||||
|
// First time through or we have teleporte, initialize the
|
||||||
|
// system and load all relavant tiles
|
||||||
|
|
||||||
FG_LOG( FG_TERRAIN, FG_INFO, "Updating Tile list for " << p1 );
|
FG_LOG( FG_TERRAIN, FG_INFO, "Updating Tile list for " << p1 );
|
||||||
FG_LOG( FG_TERRAIN, FG_INFO, " First time through ... " );
|
FG_LOG( FG_TERRAIN, FG_INFO, " First time through ... " );
|
||||||
|
|
Loading…
Add table
Reference in a new issue