1
0
Fork 0

Replace hard-coded message boxes by ones managed by the gui subsystem.

Remove obsolete functions.
This commit is contained in:
mfranz 2005-10-20 13:05:02 +00:00
parent 685076e9ce
commit 8e1ae97d3d
3 changed files with 19 additions and 136 deletions

View file

@ -51,10 +51,6 @@
#include "preset_dlg.hxx" #include "preset_dlg.hxx"
#include "layout.hxx" #include "layout.hxx"
extern void initDialog (void);
extern void mkDialogInit (void);
extern void ConfirmExitDialogInit(void);
puFont guiFnt = 0; puFont guiFnt = 0;
fntTexFont *guiFntHandle = 0; fntTexFont *guiFntHandle = 0;
@ -74,8 +70,6 @@ void guiInit()
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ); //PUSTYLE_DEFAULT puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ); //PUSTYLE_DEFAULT
puSetDefaultColourScheme (0.8, 0.8, 0.9, 1); puSetDefaultColourScheme (0.8, 0.8, 0.9, 1);
initDialog();
// Next check home directory // Next check home directory
SGPath fntpath; SGPath fntpath;
char* envp = ::getenv( "FG_FONTS" ); char* envp = ::getenv( "FG_FONTS" );
@ -124,8 +118,5 @@ void guiInit()
initMouseQuat(); initMouseQuat();
// Set up our Dialog Boxes // Set up our Dialog Boxes
ConfirmExitDialogInit();
fgPresetInit(); fgPresetInit();
mkDialogInit();
} }

View file

@ -45,7 +45,6 @@ extern void guiInit();
extern void mkDialog(const char *txt); extern void mkDialog(const char *txt);
extern void guiErrorMessage(const char *txt); extern void guiErrorMessage(const char *txt);
extern void guiErrorMessage(const char *txt, const sg_throwable &throwable); extern void guiErrorMessage(const char *txt, const sg_throwable &throwable);
extern void ConfirmExitDialog(void);
extern void fgDumpSnapShot(); extern void fgDumpSnapShot();
@ -65,7 +64,6 @@ extern void fgHiResDump();
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__) #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
extern void printScreen(puObject *); extern void printScreen(puObject *);
#endif #endif
extern void MayBeGoodBye(puObject *);
extern void guiTogglePanel(puObject *); extern void guiTogglePanel(puObject *);
extern void PilotOffsetAdjust(puObject *); extern void PilotOffsetAdjust(puObject *);
extern void fgHUDalphaAdjust(puObject *); extern void fgHUDalphaAdjust(puObject *);

View file

@ -81,6 +81,7 @@
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/renderer.hxx> #include <Main/renderer.hxx>
#include <Main/viewmgr.hxx> #include <Main/viewmgr.hxx>
#include <GUI/new_gui.hxx>
#if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__) #if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__)
# include <simgear/screen/win32-printer.h> # include <simgear/screen/win32-printer.h>
@ -107,30 +108,14 @@ extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
GLfloat x_end, GLfloat y_end ); GLfloat x_end, GLfloat y_end );
#endif #endif
puDialogBox *dialogBox = 0;
puFrame *dialogFrame = 0;
puText *dialogBoxMessage = 0;
puOneShot *dialogBoxOkButton = 0;
puDialogBox *YNdialogBox = 0; // TODO: remove after the last hardcoded dialog has died
puFrame *YNdialogFrame = 0; char *gui_msg_OK = "OK";
puText *YNdialogBoxMessage = 0; char *gui_msg_NO = "NO";
puOneShot *YNdialogBoxOkButton = 0; char *gui_msg_YES = "YES";
puOneShot *YNdialogBoxNoButton = 0; char *gui_msg_CANCEL = "CANCEL";
char *gui_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"
char msg_OK[] = "OK";
char msg_NO[] = "NO";
char msg_YES[] = "YES";
char msg_CANCEL[] = "Cancel";
char msg_RESET[] = "Reset";
char global_dialog_string[256];
const __fg_gui_fn_t __fg_gui_fn[] = { const __fg_gui_fn_t __fg_gui_fn[] = {
@ -143,7 +128,6 @@ const __fg_gui_fn_t __fg_gui_fn[] = {
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__) #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
{"printScreen", printScreen}, {"printScreen", printScreen},
#endif #endif
{"MayBeGoodBye", MayBeGoodBye},
//View //View
{"guiTogglePanel", guiTogglePanel}, {"guiTogglePanel", guiTogglePanel},
@ -177,28 +161,25 @@ const __fg_gui_fn_t __fg_gui_fn[] = {
/* ================ General Purpose Functions ================ */ /* ================ General Purpose Functions ================ */
void initDialog(void) {
// 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"
}
// General Purpose Message Box // General Purpose Message Box
void mkDialog (const char *txt) void mkDialog (const char *txt)
{ {
strncpy(global_dialog_string, txt, 256); NewGUI *gui = (NewGUI *)globals->get_subsystem("gui");
dialogBoxMessage->setLabel(global_dialog_string); SGPropertyNode_ptr dlg = gui->getDialog("message");
FG_PUSH_PUI_DIALOG( dialogBox ); if (!dlg) {
SG_LOG(SG_GENERAL, SG_ALERT, "'message' dialog missing");
return;
}
dlg->setStringValue("text/label", txt);
dlg->setStringValue("button/legend", "OK");
gui->showDialog("message");
} }
// Message Box to report an error. // Message Box to report an error.
void guiErrorMessage (const char *txt) void guiErrorMessage (const char *txt)
{ {
SG_LOG(SG_GENERAL, SG_ALERT, txt); SG_LOG(SG_GENERAL, SG_ALERT, txt);
if (dialogBox != 0)
mkDialog(txt); mkDialog(txt);
} }
@ -214,16 +195,9 @@ void guiErrorMessage (const char *txt, const sg_throwable &throwable)
msg += ')'; msg += ')';
} }
SG_LOG(SG_GENERAL, SG_ALERT, msg); SG_LOG(SG_GENERAL, SG_ALERT, msg);
if (dialogBox != 0)
mkDialog(msg.c_str()); mkDialog(msg.c_str());
} }
// Intercept the Escape Key
void ConfirmExitDialog(void)
{
FG_PUSH_PUI_DIALOG( YNdialogBox );
}
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
@ -248,86 +222,6 @@ void guiTogglePanel(puObject *cb)
fgGetInt("/sim/startup/ysize")); fgGetInt("/sim/startup/ysize"));
} }
void goodBye(puObject *)
{
// SG_LOG( SG_INPUT, SG_ALERT,
// "Program exiting normally at user request." );
cout << "Program exiting normally at user request." << endl;
exit(0);
}
void goAwayCb (puObject *me)
{
FG_POP_PUI_DIALOG( dialogBox );
}
void mkDialogInit (void)
{
// printf("mkDialogInit\n");
int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
dialogBox = new puDialogBox (x, y); // 150, 50
{
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);
}
FG_FINALIZE_PUI_DIALOG( dialogBox );
}
void MayBeGoodBye(puObject *)
{
ConfirmExitDialog();
}
void goAwayYesNoCb(puObject *me)
{
FG_POP_PUI_DIALOG( YNdialogBox);
}
void ConfirmExitDialogInit(void)
{
char msg[] = "Really Quit";
char *s;
// printf("ConfirmExitDialogInit\n");
int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
YNdialogBox = new puDialogBox (x, y); // 150, 50
{
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 -> makeReturnDefault (TRUE );
YNdialogBoxOkButton -> setCallback (goodBye);
YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
YNdialogBoxNoButton -> setLegend (gui_msg_NO);
YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
}
FG_FINALIZE_PUI_DIALOG( YNdialogBox );
}
void notCb (puObject *)
{
mkDialog ("This function isn't implemented yet");
}
void helpCb (puObject *) void helpCb (puObject *)
{ {
string command; string command;