From 571939e58dd0908de87c3bc648389cdef02f4e55 Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 9 Nov 2005 10:47:40 +0000 Subject: [PATCH] replace hard-coded HUD config dialog with NewGUI dialog --- src/Cockpit/hud.cxx | 132 +++--------------------------------------- src/GUI/gui_funcs.cxx | 3 - src/GUI/menubar.cxx | 9 --- 3 files changed, 8 insertions(+), 136 deletions(-) diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index 98b4f1394..03bbe322b 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -53,7 +53,7 @@ #include #include -#include +#include #include
#include
#include @@ -84,7 +84,6 @@ float HUD_TextSize = 0; int HUD_style = 0; float HUD_matrix[16]; -static float hud_trans_alpha = 0.67f; //$$$ begin - added, Neetha, 28 Nov 2k @@ -173,8 +172,6 @@ static instr_item * readTBI( const SGPropertyNode * node); static void drawHUD(); static void fgUpdateHUDVirtual(); -void fgHUDalphaInit( void ); - class locRECT { public: RECT rect; @@ -754,7 +751,6 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) input.close(); } - fgHUDalphaInit(); fgHUDReshape(); if ( HUDtext ) { @@ -878,122 +874,6 @@ void HUD_brightkey( bool incr_bright ) } -#define fgAP_CLAMP(val,min,max) ( (val) = (val) > (max) ? (max) : (val) < (min) ? (min) : (val) ) - -static puDialogBox *HUDalphaDialog; -static puText *HUDalphaText; -static puSlider *HUDalphaHS0; -//static puText *HUDtextText; -//static puSlider *HUDalphaHS1; -static char SliderText[2][ 8 ]; - -static void alpha_adj( puObject *hs ) { - float val ; - - hs-> getValue ( &val ) ; - fgAP_CLAMP ( val, 0.1, 1.0 ) ; - // printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ; - hud_trans_alpha = val; - sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha ); - HUDalphaText -> setLabel ( SliderText[ 0 ] ) ; -} - -void fgHUDalphaAdjust( puObject * ) { - fgSetBool("/sim/hud/antialiased", true); - FG_PUSH_PUI_DIALOG( HUDalphaDialog ); -} - -static void goAwayHUDalphaAdjust (puObject *) -{ - FG_POP_PUI_DIALOG( HUDalphaDialog ); -} - -static void cancelHUDalphaAdjust (puObject *) -{ - fgSetBool("/sim/hud/antialiased", false); - FG_POP_PUI_DIALOG( HUDalphaDialog ); -} - -// Done once at system initialization -void fgHUDalphaInit( void ) { - - // printf("fgHUDalphaInit\n"); -#define HORIZONTAL FALSE - - int DialogX = 40; - int DialogY = 100; - int DialogWidth = 240; - - char Label[] = "HUD Adjuster"; - char *s; - - int labelX = (DialogWidth / 2) - - ( puGetDefaultLabelFont().getStringWidth( Label ) / 2); - - int nSliders = 1; - int slider_x = 10; - int slider_y = 55; - int slider_width = 220; - int slider_title_x = 15; - int slider_value_x = 160; - float slider_delta = 0.05f; - - puFont HUDalphaLegendFont; - puFont HUDalphaLabelFont; - puGetDefaultFonts ( &HUDalphaLegendFont, &HUDalphaLabelFont ); - - HUDalphaDialog = new puDialogBox ( DialogX, DialogY ); { - int horiz_slider_height = HUDalphaLabelFont.getStringHeight() + - HUDalphaLabelFont.getStringDescender() + - PUSTR_TGAP + PUSTR_BGAP + 5; - - /* puFrame * - HUDalphaFrame = new puFrame ( 0, 0, DialogWidth, - 85 + nSliders - * horiz_slider_height ); */ - - puText * - HUDalphaDialogMessage = new puText ( labelX, - 52 + nSliders - * horiz_slider_height ); - HUDalphaDialogMessage -> setDefaultValue ( Label ); - HUDalphaDialogMessage -> getDefaultValue ( &s ); - HUDalphaDialogMessage -> setLabel ( s ); - - HUDalphaHS0 = new puSlider ( slider_x, slider_y, - slider_width, HORIZONTAL ) ; - HUDalphaHS0-> setDelta ( slider_delta ) ; - HUDalphaHS0-> setValue ( hud_trans_alpha ) ; - HUDalphaHS0-> setCBMode ( PUSLIDER_DELTA ) ; - HUDalphaHS0-> setCallback ( alpha_adj ) ; - - puText * - HUDalphaTitle = new puText ( slider_title_x, slider_y ) ; - HUDalphaTitle-> setDefaultValue ( "Alpha" ) ; - HUDalphaTitle-> getDefaultValue ( &s ) ; - HUDalphaTitle-> setLabel ( s ) ; - - HUDalphaText = new puText ( slider_value_x, slider_y ) ; - sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha ); - HUDalphaText-> setLabel ( SliderText[ 0 ] ) ; - - puOneShot * - HUDalphaOkButton = new puOneShot ( 10, 10, 60, 45 ); - HUDalphaOkButton-> setLegend ( gui_msg_OK ); - HUDalphaOkButton-> makeReturnDefault ( TRUE ); - HUDalphaOkButton-> setCallback ( goAwayHUDalphaAdjust ); - - puOneShot * - HUDalphaNoButton = new puOneShot ( 160, 10, 230, 45 ); - HUDalphaNoButton-> setLegend ( gui_msg_CANCEL ); - HUDalphaNoButton-> setCallback ( cancelHUDalphaAdjust ); - } - FG_FINALIZE_PUI_DIALOG( HUDalphaDialog ); - -#undef HORIZONTAL -} - - void fgHUDReshape(void) { #if 0 if ( HUDtext ) { @@ -1017,9 +897,13 @@ void fgHUDReshape(void) { static void set_hud_color(float r, float g, float b) { - fgGetBool("/sim/hud/antialiased") ? - glColor4f(r,g,b,hud_trans_alpha) : - glColor3f(r,g,b); + static SGPropertyNode_ptr alias = fgGetNode("/sim/hud/antialiased", true); + static SGPropertyNode_ptr alpha = fgGetNode("/sim/hud/alpha", true); + + if (alias->getBoolValue()) + glColor4f(r, g, b, alpha->getFloatValue()); + else + glColor3f(r, g, b); } diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx index 07a1b215a..9c595bf52 100644 --- a/src/GUI/gui_funcs.cxx +++ b/src/GUI/gui_funcs.cxx @@ -97,8 +97,6 @@ SG_USING_STD(string); SG_USING_STD(cout); -extern void fgHUDalphaAdjust( puObject * ); - // from cockpit.cxx extern void fgLatLonFormatToggle( puObject *); @@ -131,7 +129,6 @@ const __fg_gui_fn_t __fg_gui_fn[] = { //View {"guiTogglePanel", guiTogglePanel}, - {"fgHUDalphaAdjust", fgHUDalphaAdjust}, {"prop_pickerView", prop_pickerView}, // Environment diff --git a/src/GUI/menubar.cxx b/src/GUI/menubar.cxx index 1bf4870f4..c31c34ee3 100644 --- a/src/GUI/menubar.cxx +++ b/src/GUI/menubar.cxx @@ -56,14 +56,6 @@ do_print_dialog (const SGPropertyNode * arg) } #endif -extern void fgHUDalphaAdjust (puObject *); -static bool -do_hud_alpha_dialog (const SGPropertyNode * arg) -{ - fgHUDalphaAdjust(0); - return true; -} - extern void prop_pickerView (puObject *); static bool do_properties_dialog (const SGPropertyNode * arg) @@ -133,7 +125,6 @@ static struct { #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__) { "old-print-dialog", do_print_dialog }, #endif - { "old-hud-alpha-dialog", do_hud_alpha_dialog }, { "old-properties-dialog", do_properties_dialog }, { "old-ap-add-waypoint-dialog", do_ap_add_waypoint_dialog }, { "old-ap-pop-waypoint-dialog", do_ap_pop_waypoint_dialog }, -- 2.39.5