1998-06-12 01:07:06 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* gui.cxx
|
|
|
|
*
|
|
|
|
* Written 1998 by Durk Talsma, started Juni, 1998. For the flight gear
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
**************************************************************************/
|
|
|
|
|
1998-07-04 00:48:41 +00:00
|
|
|
|
1999-03-11 23:09:26 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
1999-05-08 02:33:13 +00:00
|
|
|
#include <Include/compiler.h>
|
|
|
|
|
|
|
|
#ifdef FG_MATH_EXCEPTION_CLASH
|
|
|
|
# include <math.h>
|
|
|
|
#endif
|
|
|
|
|
1999-03-11 23:09:26 +00:00
|
|
|
#ifdef HAVE_WINDOWS_H
|
1999-05-06 21:14:06 +00:00
|
|
|
# include <windows.h>
|
1999-03-11 23:09:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <GL/glut.h>
|
|
|
|
#include <XGL/xgl.h>
|
|
|
|
|
|
|
|
#if defined(FX) && defined(XMESA)
|
|
|
|
# include <GL/xmesa.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include STL_STRING
|
|
|
|
|
1998-07-04 00:48:41 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
1999-05-06 21:14:06 +00:00
|
|
|
#include <Include/general.hxx>
|
|
|
|
#include <Debug/logstream.hxx>
|
1999-04-27 15:43:08 +00:00
|
|
|
#include <Aircraft/aircraft.hxx>
|
|
|
|
#include <Airports/simple.hxx>
|
1999-05-06 22:16:12 +00:00
|
|
|
#include <Cockpit/panel.hxx>
|
1999-04-27 15:43:08 +00:00
|
|
|
#include <FDM/flight.hxx>
|
1998-07-06 21:31:57 +00:00
|
|
|
#include <Main/options.hxx>
|
1999-05-06 21:14:06 +00:00
|
|
|
#include <Main/fg_init.hxx>
|
1999-05-06 22:16:12 +00:00
|
|
|
#include <Main/views.hxx>
|
1999-06-05 12:45:40 +00:00
|
|
|
#include <Misc/fgpath.hxx>
|
1999-05-06 21:14:06 +00:00
|
|
|
#include <Time/fg_time.hxx>
|
1998-07-04 00:48:41 +00:00
|
|
|
|
1998-06-12 01:07:06 +00:00
|
|
|
#include "gui.h"
|
1998-07-04 00:48:41 +00:00
|
|
|
|
1999-03-11 23:09:26 +00:00
|
|
|
FG_USING_STD(string);
|
|
|
|
|
1999-05-27 00:21:22 +00:00
|
|
|
puFont guiFnt = 0;
|
|
|
|
fntTexFont *guiFntHandle = 0;
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
static puMenuBar *mainMenuBar = 0;
|
|
|
|
//static puButton *hideMenuButton = 0;
|
|
|
|
|
|
|
|
static puDialogBox *dialogBox = 0;
|
|
|
|
static puFrame *dialogFrame = 0;
|
|
|
|
static puText *dialogBoxMessage = 0;
|
|
|
|
static puOneShot *dialogBoxOkButton = 0;
|
|
|
|
|
|
|
|
|
|
|
|
static puDialogBox *YNdialogBox = 0;
|
|
|
|
static puFrame *YNdialogFrame = 0;
|
|
|
|
static puText *YNdialogBoxMessage = 0;
|
|
|
|
static puOneShot *YNdialogBoxOkButton = 0;
|
|
|
|
static puOneShot *YNdialogBoxNoButton = 0;
|
|
|
|
|
1999-06-01 21:17:10 +00:00
|
|
|
static char msg_OK[] = "OK";
|
|
|
|
static char msg_NO[] = "NO";
|
|
|
|
static char msg_YES[] = "YES";
|
|
|
|
static char msg_CANCEL[] = "Cancel";
|
|
|
|
static char msg_RESET[] = "Reset";
|
|
|
|
|
|
|
|
char *gui_msg_OK; // "OK"
|
|
|
|
char *gui_msg_NO; // "NO"
|
|
|
|
char *gui_msg_YES; // "YES"
|
|
|
|
char *gui_msg_CANCEL; // "CANCEL"
|
|
|
|
char *gui_msg_RESET; // "RESET"
|
|
|
|
|
|
|
|
static char global_dialog_string[256];
|
|
|
|
|
|
|
|
extern void NewAltitude( puObject *cb );
|
|
|
|
extern void NewHeading( puObject *cb );
|
1999-05-06 21:14:06 +00:00
|
|
|
extern void fgAPAdjust( puObject * );
|
1999-05-12 01:11:17 +00:00
|
|
|
extern void fgLatLonFormatToggle( puObject *);
|
|
|
|
|
1998-06-12 01:07:06 +00:00
|
|
|
/* --------------------------------------------------------------------
|
1999-05-06 21:14:06 +00:00
|
|
|
Mouse stuff
|
|
|
|
---------------------------------------------------------------------*/
|
1999-05-27 00:21:22 +00:00
|
|
|
|
|
|
|
static int _mX = 0;
|
|
|
|
static int _mY = 0;
|
|
|
|
static int last_buttons = 0 ;
|
|
|
|
static int mouse_active = 0;
|
|
|
|
static int menu_on = 0;
|
|
|
|
|
1998-06-12 01:07:06 +00:00
|
|
|
void guiMotionFunc ( int x, int y )
|
|
|
|
{
|
1999-05-06 21:14:06 +00:00
|
|
|
_mX = x;
|
|
|
|
_mY = y;
|
1999-04-27 15:43:08 +00:00
|
|
|
puMouse ( x, y ) ;
|
|
|
|
glutPostRedisplay () ;
|
1998-06-12 01:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void guiMouseFunc(int button, int updown, int x, int y)
|
|
|
|
{
|
1999-05-06 21:14:06 +00:00
|
|
|
_mX = x;
|
|
|
|
_mY = y;
|
|
|
|
if ( updown == PU_DOWN )
|
1999-05-12 01:11:17 +00:00
|
|
|
last_buttons |= ( 1 << button ) ;
|
1999-05-06 21:14:06 +00:00
|
|
|
else
|
1999-05-12 01:11:17 +00:00
|
|
|
last_buttons &= ~( 1 << button ) ;
|
1998-06-12 01:07:06 +00:00
|
|
|
puMouse (button, updown, x,y);
|
|
|
|
glutPostRedisplay ();
|
|
|
|
}
|
|
|
|
|
1999-05-06 21:14:06 +00:00
|
|
|
int guiGetMouseButton(void)
|
|
|
|
{
|
|
|
|
return last_buttons;
|
|
|
|
}
|
|
|
|
|
|
|
|
void guiGetMouse(int *x, int *y)
|
|
|
|
{
|
|
|
|
*x = _mX;
|
|
|
|
*y = _mY;
|
|
|
|
};
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
static inline void TurnCursorOn( void )
|
|
|
|
{
|
|
|
|
mouse_active = ~0;
|
|
|
|
#if defined ( WIN32 ) || defined(__CYGWIN32__)
|
|
|
|
glutSetCursor(GLUT_CURSOR_INHERIT);
|
|
|
|
#endif
|
|
|
|
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
|
|
|
|
glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH)/2, glutGet(GLUT_SCREEN_HEIGHT)/2);
|
|
|
|
#endif
|
|
|
|
}
|
1998-06-12 01:07:06 +00:00
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
static inline void TurnCursorOff( void )
|
1999-04-27 15:43:08 +00:00
|
|
|
{
|
1999-05-12 01:11:17 +00:00
|
|
|
mouse_active = 0;
|
|
|
|
#if defined ( WIN32 ) || defined(__CYGWIN32__)
|
|
|
|
glutSetCursor(GLUT_CURSOR_NONE);
|
|
|
|
#else // I guess this is what we want to do ??
|
1999-06-01 21:17:10 +00:00
|
|
|
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
|
1999-05-12 01:11:17 +00:00
|
|
|
glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT));
|
1999-06-01 21:17:10 +00:00
|
|
|
#endif
|
1999-05-12 01:11:17 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void maybeToggleMouse( void )
|
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
#ifdef WIN32
|
1999-05-12 01:11:17 +00:00
|
|
|
static int first_time = ~0;
|
|
|
|
static int mouse_changed = 0;
|
|
|
|
|
|
|
|
if ( first_time ) {
|
|
|
|
if(!mouse_active) {
|
|
|
|
mouse_changed = ~mouse_changed;
|
|
|
|
TurnCursorOn();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if( mouse_changed ) {
|
|
|
|
mouse_changed = ~mouse_changed;
|
|
|
|
if(mouse_active) {
|
|
|
|
TurnCursorOff();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
first_time = ~first_time;
|
1999-06-01 21:17:10 +00:00
|
|
|
#endif // #ifdef WIN32
|
1999-05-12 01:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Call with FALSE to init and TRUE to restore
|
|
|
|
void BusyCursor( int restore )
|
|
|
|
{
|
|
|
|
static int cursor = 0;
|
|
|
|
if( restore ) {
|
|
|
|
glutSetCursor(cursor);
|
|
|
|
} else {
|
|
|
|
cursor = glutGet( GLUT_WINDOW_CURSOR );
|
1999-06-01 21:17:10 +00:00
|
|
|
#ifdef WIN32
|
1999-05-12 01:11:17 +00:00
|
|
|
TurnCursorOn();
|
1999-06-01 21:17:10 +00:00
|
|
|
#endif
|
1999-05-12 01:11:17 +00:00
|
|
|
glutSetCursor( GLUT_CURSOR_WAIT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* ================ General Purpose Functions ================ */
|
|
|
|
|
|
|
|
// Intercept the Escape Key
|
|
|
|
void ConfirmExitDialog(void)
|
|
|
|
{
|
|
|
|
FG_PUSH_PUI_DIALOG( YNdialogBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
// General Purpose Message Box
|
1999-06-01 21:17:10 +00:00
|
|
|
void mkDialog (const char *txt)
|
1999-05-12 01:11:17 +00:00
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
strncpy(global_dialog_string, txt, 256);
|
|
|
|
dialogBoxMessage->setLabel(global_dialog_string);
|
1999-05-12 01:11:17 +00:00
|
|
|
FG_PUSH_PUI_DIALOG( dialogBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Repair any damage done to the Panel by other Gui Items
|
|
|
|
void guiFixPanel( void )
|
|
|
|
{
|
|
|
|
int toggle_pause;
|
1999-06-01 21:17:10 +00:00
|
|
|
|
1999-05-06 22:16:12 +00:00
|
|
|
if ( current_options.get_panel_status() ) {
|
1999-06-01 21:17:10 +00:00
|
|
|
FGView *v = ¤t_view;
|
|
|
|
FGTime *t = FGTime::cur_time_params;
|
1999-05-12 01:11:17 +00:00
|
|
|
|
1999-06-01 21:17:10 +00:00
|
|
|
if( (toggle_pause = !t->getPause()) )
|
|
|
|
t->togglePauseMode();
|
|
|
|
|
|
|
|
// this seems to be the only way to do this :-(
|
|
|
|
// problem is the viewport has been mucked with
|
|
|
|
xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
|
|
|
|
FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
|
|
|
|
|
|
|
|
if(toggle_pause)
|
|
|
|
t->togglePauseMode();
|
1999-05-06 22:16:12 +00:00
|
|
|
}
|
1999-04-27 15:43:08 +00:00
|
|
|
}
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
// Toggle the Menu and Mouse display state
|
1999-05-06 21:14:06 +00:00
|
|
|
void guiToggleMenu(void)
|
|
|
|
{
|
1999-05-12 01:11:17 +00:00
|
|
|
if( menu_on ) {
|
1999-06-01 21:17:10 +00:00
|
|
|
// printf("Hiding Menu\n");
|
|
|
|
mainMenuBar->hide ();
|
|
|
|
#ifdef WIN32
|
|
|
|
TurnCursorOff();
|
|
|
|
#endif // #ifdef WIN32
|
1999-05-12 01:11:17 +00:00
|
|
|
} else {
|
1999-06-01 21:17:10 +00:00
|
|
|
// printf("Showing Menu\n");
|
|
|
|
mainMenuBar->reveal();
|
|
|
|
#ifdef WIN32
|
|
|
|
TurnCursorOn();
|
|
|
|
#endif // #ifdef WIN32
|
1999-05-12 01:11:17 +00:00
|
|
|
}
|
|
|
|
menu_on = ~menu_on;
|
1999-05-06 21:14:06 +00:00
|
|
|
}
|
1999-05-12 01:11:17 +00:00
|
|
|
|
|
|
|
/* -----------------------------------------------------------------------
|
|
|
|
the Gui callback functions
|
|
|
|
____________________________________________________________________*/
|
|
|
|
|
|
|
|
void reInit(puObject *cb)
|
1999-05-06 22:16:12 +00:00
|
|
|
{
|
1999-05-12 01:11:17 +00:00
|
|
|
BusyCursor(0);
|
|
|
|
fgReInitSubsystems();
|
|
|
|
BusyCursor(1);
|
1999-05-06 22:16:12 +00:00
|
|
|
}
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
// This is the accessor function
|
|
|
|
void guiTogglePanel(puObject *cb)
|
1999-05-06 21:14:06 +00:00
|
|
|
{
|
1999-05-12 01:11:17 +00:00
|
|
|
current_options.toggle_panel();
|
1999-05-06 21:14:06 +00:00
|
|
|
}
|
1999-05-12 01:11:17 +00:00
|
|
|
|
|
|
|
//void MenuHideMenuCb(puObject *cb)
|
1998-06-12 01:07:06 +00:00
|
|
|
void hideMenuCb (puObject *cb)
|
|
|
|
{
|
1999-05-12 01:11:17 +00:00
|
|
|
guiToggleMenu();
|
1999-04-27 15:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void goodBye(puObject *)
|
|
|
|
{
|
1999-05-27 00:21:22 +00:00
|
|
|
// FG_LOG( FG_INPUT, FG_ALERT,
|
1999-06-01 21:17:10 +00:00
|
|
|
// "Program exiting normally at user request." );
|
1999-04-27 15:43:08 +00:00
|
|
|
cout << "Program exiting normally at user request." << endl;
|
|
|
|
|
1999-06-01 21:17:10 +00:00
|
|
|
// if(gps_bug)
|
|
|
|
// fclose(gps_bug);
|
|
|
|
|
1999-04-27 15:43:08 +00:00
|
|
|
exit(-1);
|
|
|
|
}
|
1999-05-06 21:14:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
void goAwayCb (puObject *me)
|
1999-04-27 15:43:08 +00:00
|
|
|
{
|
1999-05-12 01:11:17 +00:00
|
|
|
FG_POP_PUI_DIALOG( dialogBox );
|
1999-04-27 15:43:08 +00:00
|
|
|
}
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
void mkDialogInit (void)
|
1999-04-27 15:43:08 +00:00
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
// printf("mkDialogInit\n");
|
1999-05-27 00:21:22 +00:00
|
|
|
int x = (current_options.get_xsize()/2 - 400/2);
|
|
|
|
int y = (current_options.get_ysize()/2 - 100/2);
|
|
|
|
dialogBox = new puDialogBox (x, y); // 150, 50
|
1998-06-12 01:07:06 +00:00
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
dialogFrame = new puFrame (0,0,400,100);
|
|
|
|
dialogBoxMessage = new puText (10, 70);
|
|
|
|
dialogBoxMessage -> setLabel ("");
|
|
|
|
dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
|
|
|
|
dialogBoxOkButton -> setLegend (gui_msg_OK);
|
|
|
|
dialogBoxOkButton -> makeReturnDefault (TRUE );
|
|
|
|
dialogBoxOkButton -> setCallback (goAwayCb);
|
1998-06-12 01:07:06 +00:00
|
|
|
}
|
1999-05-12 01:11:17 +00:00
|
|
|
FG_FINALIZE_PUI_DIALOG( dialogBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MayBeGoodBye(puObject *)
|
|
|
|
{
|
|
|
|
ConfirmExitDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
void goAwayYesNoCb(puObject *me)
|
|
|
|
{
|
|
|
|
FG_POP_PUI_DIALOG( YNdialogBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfirmExitDialogInit(void)
|
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
char msg[] = "Really Quit";
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
// printf("ConfirmExitDialogInit\n");
|
|
|
|
int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
|
|
|
|
|
1999-05-27 00:21:22 +00:00
|
|
|
int x = (current_options.get_xsize()/2 - 400/2);
|
|
|
|
int y = (current_options.get_ysize()/2 - 100/2);
|
|
|
|
|
|
|
|
YNdialogBox = new puDialogBox (x, y); // 150, 50
|
1999-06-01 21:17:10 +00:00
|
|
|
// YNdialogBox = new puDialogBox (150, 50);
|
1999-05-12 01:11:17 +00:00
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
YNdialogFrame = new puFrame (0,0,400, 100);
|
|
|
|
|
|
|
|
YNdialogBoxMessage = new puText (len, 70);
|
|
|
|
YNdialogBoxMessage -> setDefaultValue (msg);
|
|
|
|
YNdialogBoxMessage -> getDefaultValue (&s);
|
|
|
|
YNdialogBoxMessage -> setLabel (s);
|
|
|
|
|
|
|
|
YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
|
|
|
|
YNdialogBoxOkButton -> setLegend (gui_msg_OK);
|
|
|
|
YNdialogBoxOkButton -> setCallback (goodBye);
|
|
|
|
|
|
|
|
YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
|
|
|
|
YNdialogBoxNoButton -> setLegend (gui_msg_NO);
|
|
|
|
// YNdialogBoxNoButton -> makeReturnDefault (TRUE );
|
|
|
|
YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
|
1999-05-12 01:11:17 +00:00
|
|
|
}
|
|
|
|
FG_FINALIZE_PUI_DIALOG( YNdialogBox );
|
1999-04-27 15:43:08 +00:00
|
|
|
}
|
|
|
|
|
1999-05-06 21:14:06 +00:00
|
|
|
void notCb (puObject *)
|
|
|
|
{
|
|
|
|
mkDialog ("This function isn't implemented yet");
|
|
|
|
}
|
|
|
|
|
|
|
|
void helpCb (puObject *)
|
|
|
|
{
|
|
|
|
string command;
|
|
|
|
|
|
|
|
#if defined(FX) && !defined(WIN32)
|
|
|
|
# if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
|
|
|
|
if ( global_fullscreen ) {
|
1999-06-01 21:17:10 +00:00
|
|
|
global_fullscreen = false;
|
|
|
|
XMesaSetFXmode( XMESA_FX_WINDOW );
|
1999-05-06 21:14:06 +00:00
|
|
|
}
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(WIN32)
|
|
|
|
string url = "http://www.flightgear.org/Docs/InstallGuide/getstart.html";
|
|
|
|
|
|
|
|
if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
|
1999-06-01 21:17:10 +00:00
|
|
|
command = "netscape -remote \"openURL(" + url + ")\" &";
|
1999-05-06 21:14:06 +00:00
|
|
|
} else {
|
1999-06-01 21:17:10 +00:00
|
|
|
command = "netscape " + url + " &";
|
1999-05-06 21:14:06 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
command = "webrun.bat";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
system( command.c_str() );
|
1999-06-01 21:17:10 +00:00
|
|
|
//string text = "Help started in netscape window.";
|
|
|
|
|
|
|
|
//mkDialog (text.c_str());
|
|
|
|
mkDialog ("Help started in netscape window.");
|
1999-05-06 21:14:06 +00:00
|
|
|
}
|
1999-04-27 15:43:08 +00:00
|
|
|
|
|
|
|
/// The beginnings of teleportation :-)
|
|
|
|
// Needs cleaning up but works
|
|
|
|
// These statics should disapear when this is a class
|
1999-05-12 01:11:17 +00:00
|
|
|
static puDialogBox *AptDialog = 0;
|
|
|
|
static puFrame *AptDialogFrame = 0;
|
|
|
|
static puText *AptDialogMessage = 0;
|
|
|
|
static puInput *AptDialogInput = 0;
|
1999-04-27 15:43:08 +00:00
|
|
|
|
1999-06-01 21:17:10 +00:00
|
|
|
static char NewAirportId[16];
|
|
|
|
static char NewAirportLabel[] = "Enter New Airport ID";
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
static puOneShot *AptDialogOkButton = 0;
|
|
|
|
static puOneShot *AptDialogCancelButton = 0;
|
|
|
|
static puOneShot *AptDialogResetButton = 0;
|
1999-04-27 15:43:08 +00:00
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
void AptDialog_Cancel(puObject *)
|
1999-04-27 15:43:08 +00:00
|
|
|
{
|
1999-05-12 01:11:17 +00:00
|
|
|
FG_POP_PUI_DIALOG( AptDialog );
|
1998-06-12 01:07:06 +00:00
|
|
|
}
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
void AptDialog_OK (puObject *)
|
1999-04-27 15:43:08 +00:00
|
|
|
{
|
1999-05-12 01:11:17 +00:00
|
|
|
string AptId;
|
|
|
|
|
1999-05-06 21:14:06 +00:00
|
|
|
FGTime *t = FGTime::cur_time_params;
|
1999-05-12 01:11:17 +00:00
|
|
|
int PauseMode = t->getPause();
|
|
|
|
if(!PauseMode)
|
1999-06-01 21:17:10 +00:00
|
|
|
t->togglePauseMode();
|
1999-04-27 15:43:08 +00:00
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
char *s;
|
|
|
|
AptDialogInput->getValue(&s);
|
|
|
|
AptId = s;
|
|
|
|
|
|
|
|
AptDialog_Cancel( NULL );
|
|
|
|
|
|
|
|
if ( AptId.length() ) {
|
1999-06-01 21:17:10 +00:00
|
|
|
// 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( AptId, &a ) )
|
|
|
|
{
|
|
|
|
current_options.set_airport_id( AptId.c_str() );
|
|
|
|
BusyCursor(0);
|
|
|
|
fgReInitSubsystems();
|
|
|
|
BusyCursor(1);
|
|
|
|
} else {
|
|
|
|
AptId += " not in database.";
|
|
|
|
mkDialog(AptId.c_str());
|
|
|
|
}
|
1999-05-12 01:11:17 +00:00
|
|
|
}
|
|
|
|
if( PauseMode != t->getPause() )
|
1999-06-01 21:17:10 +00:00
|
|
|
t->togglePauseMode();
|
1998-06-12 01:07:06 +00:00
|
|
|
}
|
|
|
|
|
1999-04-27 15:43:08 +00:00
|
|
|
void AptDialog_Reset(puObject *)
|
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
// strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
|
|
|
|
sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
|
|
|
|
AptDialogInput->setValue ( NewAirportId );
|
1999-04-27 15:43:08 +00:00
|
|
|
AptDialogInput->setCursor( 0 ) ;
|
|
|
|
}
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
void NewAirport(puObject *cb)
|
1998-06-12 01:07:06 +00:00
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
// strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
|
|
|
|
sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
|
|
|
|
AptDialogInput->setValue( NewAirportId );
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
FG_PUSH_PUI_DIALOG( AptDialog );
|
|
|
|
}
|
1999-04-27 15:43:08 +00:00
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
static void NewAirportInit(void)
|
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
|
|
|
|
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
|
|
|
|
NewAirportLabel ) / 2;
|
1999-04-27 15:43:08 +00:00
|
|
|
|
|
|
|
AptDialog = new puDialogBox (150, 50);
|
|
|
|
{
|
1999-06-01 21:17:10 +00:00
|
|
|
AptDialogFrame = new puFrame (0,0,350, 150);
|
|
|
|
AptDialogMessage = new puText (len, 110);
|
|
|
|
AptDialogMessage -> setLabel (NewAirportLabel);
|
|
|
|
|
|
|
|
AptDialogInput = new puInput (50, 70, 300, 100);
|
|
|
|
AptDialogInput -> setValue (NewAirportId);
|
|
|
|
AptDialogInput -> acceptInput();
|
|
|
|
|
|
|
|
AptDialogOkButton = new puOneShot (50, 10, 110, 50);
|
|
|
|
AptDialogOkButton -> setLegend (gui_msg_OK);
|
|
|
|
AptDialogOkButton -> setCallback (AptDialog_OK);
|
|
|
|
AptDialogOkButton -> makeReturnDefault(TRUE);
|
|
|
|
|
|
|
|
AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
|
|
|
|
AptDialogCancelButton -> setLegend (gui_msg_CANCEL);
|
|
|
|
AptDialogCancelButton -> setCallback (AptDialog_Cancel);
|
|
|
|
|
|
|
|
AptDialogResetButton = new puOneShot (240, 10, 300, 50);
|
|
|
|
AptDialogResetButton -> setLegend (gui_msg_RESET);
|
|
|
|
AptDialogResetButton -> setCallback (AptDialog_Reset);
|
1999-04-27 15:43:08 +00:00
|
|
|
}
|
1999-05-12 01:11:17 +00:00
|
|
|
FG_FINALIZE_PUI_DIALOG( AptDialog );
|
1998-06-12 01:07:06 +00:00
|
|
|
}
|
|
|
|
|
1999-04-27 15:43:08 +00:00
|
|
|
|
1998-06-12 01:07:06 +00:00
|
|
|
/* -----------------------------------------------------------------------
|
1999-05-27 00:21:22 +00:00
|
|
|
The menu stuff
|
|
|
|
---------------------------------------------------------------------*/
|
1999-05-06 22:16:12 +00:00
|
|
|
char *fileSubmenu [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
"Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL
|
|
|
|
};
|
1999-05-06 22:16:12 +00:00
|
|
|
puCallback fileSubmenuCb [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
MayBeGoodBye, hideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL
|
|
|
|
};
|
|
|
|
|
1999-05-06 22:16:12 +00:00
|
|
|
char *editSubmenu [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
"Edit text", NULL
|
|
|
|
};
|
1999-05-06 22:16:12 +00:00
|
|
|
puCallback editSubmenuCb [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
notCb, NULL
|
|
|
|
};
|
1999-05-12 01:11:17 +00:00
|
|
|
|
1999-05-06 22:16:12 +00:00
|
|
|
char *viewSubmenu [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
"Cockpit View > ", "View >","------------", "Toggle Panel...", NULL
|
|
|
|
};
|
1999-05-06 22:16:12 +00:00
|
|
|
puCallback viewSubmenuCb [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
notCb, notCb, NULL, guiTogglePanel, NULL
|
|
|
|
};
|
|
|
|
|
1999-05-06 22:16:12 +00:00
|
|
|
char *aircraftSubmenu [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
"Autopilot", "Heading", "Altitude", "Navigation", "Communication", NULL
|
|
|
|
};
|
1999-05-06 22:16:12 +00:00
|
|
|
puCallback aircraftSubmenuCb [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, notCb, NULL
|
|
|
|
};
|
1999-05-06 22:16:12 +00:00
|
|
|
|
|
|
|
char *environmentSubmenu [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
"Airport", "Terrain", "Weather", NULL
|
|
|
|
};
|
1999-05-06 22:16:12 +00:00
|
|
|
puCallback environmentSubmenuCb [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
NewAirport, notCb, notCb, NULL
|
|
|
|
};
|
1999-05-06 22:16:12 +00:00
|
|
|
|
|
|
|
char *optionsSubmenu [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
"Preferences", "Realism & Reliablity...", NULL
|
|
|
|
};
|
1999-05-06 22:16:12 +00:00
|
|
|
puCallback optionsSubmenuCb [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
notCb, notCb, NULL
|
|
|
|
};
|
1999-05-06 21:14:06 +00:00
|
|
|
|
1999-05-06 22:16:12 +00:00
|
|
|
char *helpSubmenu [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
"About...", "Help", NULL
|
|
|
|
};
|
1999-05-06 22:16:12 +00:00
|
|
|
puCallback helpSubmenuCb [] = {
|
1999-06-01 21:17:10 +00:00
|
|
|
notCb, helpCb, NULL
|
|
|
|
};
|
1998-06-12 01:07:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------
|
1999-06-01 21:17:10 +00:00
|
|
|
init the gui
|
|
|
|
_____________________________________________________________________*/
|
1998-06-12 01:07:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
void guiInit()
|
|
|
|
{
|
1998-07-04 00:48:41 +00:00
|
|
|
char *mesa_win_state;
|
|
|
|
|
|
|
|
// Initialize PUI
|
|
|
|
puInit();
|
1999-06-01 21:17:10 +00:00
|
|
|
puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
|
1999-05-12 01:11:17 +00:00
|
|
|
puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.4);
|
1998-07-04 00:48:41 +00:00
|
|
|
|
1999-06-01 21:17:10 +00:00
|
|
|
// Initialize our GLOBAL GUI STRINGS
|
|
|
|
gui_msg_OK = msg_OK; // "OK"
|
|
|
|
gui_msg_NO = msg_NO; // "NO"
|
|
|
|
gui_msg_YES = msg_YES; // "YES"
|
|
|
|
gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
|
|
|
|
gui_msg_RESET = msg_RESET; // "RESET"
|
|
|
|
|
|
|
|
// Next check home directory
|
1999-06-05 12:45:40 +00:00
|
|
|
FGPath fntpath;
|
1999-06-01 21:17:10 +00:00
|
|
|
char* envp = ::getenv( "FG_FONTS" );
|
|
|
|
if ( envp != NULL ) {
|
1999-06-05 12:45:40 +00:00
|
|
|
fntpath.set( envp );
|
1999-06-01 21:17:10 +00:00
|
|
|
} else {
|
1999-06-05 12:45:40 +00:00
|
|
|
fntpath.set( current_options.get_fg_root() );
|
|
|
|
fntpath.append( "Fonts" );
|
1999-06-01 21:17:10 +00:00
|
|
|
}
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
// Install our fast fonts
|
1999-06-05 12:45:40 +00:00
|
|
|
fntpath.append( "typewriter.txf" );
|
1999-05-12 01:11:17 +00:00
|
|
|
guiFntHandle = new fntTexFont ;
|
|
|
|
guiFntHandle -> load ( fntpath.c_str() ) ;
|
|
|
|
puFont GuiFont ( guiFntHandle, 15 ) ;
|
|
|
|
puSetDefaultFonts( GuiFont, GuiFont ) ;
|
|
|
|
guiFnt = puGetDefaultLabelFont();
|
|
|
|
|
1998-07-13 21:00:09 +00:00
|
|
|
if ( current_options.get_mouse_pointer() == 0 ) {
|
1999-06-01 21:17:10 +00:00
|
|
|
// no preference specified for mouse pointer, attempt to autodetect...
|
|
|
|
// Determine if we need to render the cursor, or if the windowing
|
|
|
|
// system will do it. First test if we are rendering with glide.
|
|
|
|
if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
|
|
|
|
// Test for the MESA_GLX_FX env variable
|
|
|
|
if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
|
|
|
|
// test if we are fullscreen mesa/glide
|
|
|
|
if ( (mesa_win_state[0] == 'f') ||
|
|
|
|
(mesa_win_state[0] == 'F') ) {
|
|
|
|
puShowCursor ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mouse_active = ~mouse_active;
|
1998-07-13 21:00:09 +00:00
|
|
|
} else if ( current_options.get_mouse_pointer() == 1 ) {
|
1999-06-01 21:17:10 +00:00
|
|
|
// don't show pointer
|
1998-07-13 21:00:09 +00:00
|
|
|
} else if ( current_options.get_mouse_pointer() == 2 ) {
|
1999-06-01 21:17:10 +00:00
|
|
|
// force showing pointer
|
|
|
|
puShowCursor();
|
|
|
|
mouse_active = ~mouse_active;
|
1998-07-04 00:48:41 +00:00
|
|
|
}
|
|
|
|
|
1999-05-12 01:11:17 +00:00
|
|
|
// Set up our Dialog Boxes
|
|
|
|
ConfirmExitDialogInit();
|
|
|
|
NewAirportInit();
|
|
|
|
mkDialogInit();
|
|
|
|
|
1998-07-04 00:48:41 +00:00
|
|
|
// Make the menu bar
|
|
|
|
mainMenuBar = new puMenuBar ();
|
|
|
|
mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
|
|
|
|
mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
|
|
|
|
mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
|
|
|
|
mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
|
1999-05-12 01:11:17 +00:00
|
|
|
mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
|
1998-07-04 00:48:41 +00:00
|
|
|
mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
|
|
|
|
mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
|
|
|
|
mainMenuBar-> close ();
|
1999-05-12 01:11:17 +00:00
|
|
|
// Set up menu bar toggle
|
|
|
|
menu_on = ~0;
|
1998-06-12 01:07:06 +00:00
|
|
|
}
|