September 15, 200619 yr Hi,I'm just starting a gauge project in FS2004 for the first time. I'm needing a debug tool and am planning to use MAKE_STRING to display certain variables to the screen during the coarse of a flight. I know my code is running fine but the MAKE_STRING macro does not display anything on the screen. I use the PANEL_SERVICE_PRE_DRAW callback to call a routine that contains MAKE_STRING. Here is the relevant code I am using:#define GAUGE_CHARSET DEFAULT_CHARSET#define GAUGE_FONT_DEFAULT "Courier New"#define GAUGE_WEIGHT_DEFAULT FW_NORMAL void testredraw(){ MAKE_STRING( update_code, NULL, NULL, IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY, 0, 28, 9, 60, 29, 30, TOTAL_AIR_TEMP, DISPLAY_UNITS, MODULE_VAR_NONE, RGB(0,255,0), RGB(255,0,0), RGB(0,0,255), GAUGE_FONT_DEFAULT, GAUGE_WEIGHT_DEFAULT, GAUGE_CHARSET, 0, DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL, NULL) PELEMENT_HEADER update_code_list[] ={&update_code.header,NULL}; }When I call this testredraw() routine should it not be drawing these system variable to the screen?Thanks,Magma
September 15, 200619 yr Commercial Member You'll also need a MAKE_STATIC background to display the string on - all gauges have to have a MAKE_STATIC macro as the last item in the gauge macro stack. There's nothing to stop the background from being completely transparent so that the string acts like a HUD; in fact I have a hud-type debug gauge that outputs ten variables (plus other info) at any one time.If you haven't already got it, I think that reading sd2gau18.zip may be a great help.-Dai
September 15, 200619 yr Yes I already have a background image and it is showing up just fine. Here is the MAKE_STATIC code:MAKE_STATIC(test_background,BMP_SMALL_test,NULL,NULL,IMAGE_USE_TRANSPARENCY,0,0,0);PELEMENT_HEADER test_Small = &test_background.header;I know my testredraw() routine is being called, but nothing is being displayed. Can you see anything I'm doing wrong? Thanks,Magma
September 15, 200619 yr Commercial Member If that is all of your MAKE_STRING code then it looks like the callback routine that actually writes the information to the screen is missing. What you actually put into the callback routine depends on the data you are trying to display (string, integer etc). I really would download sd2gau18.zip and read the tutorial because I go into a lot of detail as to how all of the macros work. There is a lot of sample code included with it, all of which came from my own experience when I started programming gauges back in FS98 days. I know the learning curve you're going through.... I've been there :)-Dai
September 15, 200619 yr And Dai, I can't imagine what the learning curve would have been like for me withut your awesome tutorials. It's great to see you back around these parts.CheersBob ScottATP IMEL Gulfstream II-III-IV-V L-300Santiago de Chile Bob Scott | President and CEO, AVSIM Inc ATP Gulfstream II-III-IV-V Sys1 (MSFS20+24/XPlane12+11): AMD 9800X3D, water 2x240mm, MSI MPG X670E Carbon, 64GB GSkill 6000/30, nVidia RTX4090FE Alienware AW3821DW 38" 21:9 GSync, 2x4TB Crucial T705 PCIe5 + 2x2TB Samsung 990 SSD, EVGA 1000P2 PSU, 12.9" iPad Pro Thrustmaster TCA Boeing Yoke, TCA Airbus Sidestick, Twin TCA Airbus Throttle quads, PFC Cirrus Pedals, Coolermaster HAF932 case Sys2 (P3Dv5/v4): i9-13900KS, water 2x360mm, ASUS Z790 Hero, 32GB GSkill 7800MHz CAS36, ASUS RTX4090 Samsung 55" JS8500 4K TV@60Hz, 3x 2TB WD SN850X 1x 4TB Crucial P3 M.2 NVME SSD, EVGA 1600T2 PSU Fiber link to Yamaha RX-V467 Home Theater Receiver, Polk/Klipsch 6" bookshelf speakers, Polk 12" subwoofer, 12.9" iPad Pro PFC yoke/throttle quad/pedals with custom Hall sensor retrofit, Thermaltake View 71 case, Stream Deck XL button box Sys3 (DCS/P3Dv4/ATS/ETS): AMD 7800X3D, MSI MPG X870E Carbon, Noctua NH-D15S, 64GB GSkill 6000/30, EVGA RTX3090 Alienware AW3420DW 34" 21:9 GSync, Corsair HX1000i PSU, 4TB Crucial T705 PCIe5 + 2TB Samsung 970Evo Plus, TM TCA Officer Pack, Saitek combat pedals, TM Warthog, TM RS300 FF wheel/pedals, Coolermaster HAF XB case
September 16, 200619 yr Commercial Member Many thanks for those kind words, Bob. Yes, I am working on an updated version! :)-Dai
September 16, 200619 yr >And Dai, I can't imagine what the learning curve would have>been like for me withut your awesome tutorials. It's great to>see you back around these parts.>>Cheers>>Bob Scott>ATP IMEL Gulfstream II-III-IV-V L-300>Santiago de Chile>I'd like to second those thanks. The MS SDK has more holes than swiss cheese. Dai's tutorial is a Gauge designers Bible!!Thanks for putting in the effort to share it with us Dai!!RegardsJim
September 16, 200619 yr Author Moderator As has been pointed out, you don't provide the actual callback for the MAKE_STRING macro...The more important question might be, why are you putting the macro in the PRE_DRAW case anyway?The entire gauge is nothing but a gigantic callback to begin with that executes the loop at 18/sec. Placing the macro in the case switch simply adds a level of obscurity that's totally unnecessary. ;)I prefer using a more structured layout whereby the code is logically structured... One such layout is based loosely on the format generated by Easy Gauge:Gauge Header InformationVariable DeclarationsModule DeclarationsGauge CallbackCase Switch StructureFailure DeclarationsMouse CallbacksMouse MacrosGauge Element CallbacksGauge Element MacrosThe major advantage of this type structure is that all of the Gauge Element Macros are listed in top-to-bottom order, which makes the logical flow of the linked list crystal clear with zero ambiguity... ;) Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
September 18, 200619 yr I'm just going through a bit of a learning curve, and the fog is beginning to lift. sd2gau18.zip totally helped. I can see what you mean by "the entire gauge is nothing but a gigantic callback to begin with". You define certain parameters in the macro and also declare your callback routine. Then write your code in the callback routine...correct? I think I understand but I'm still having problems with this small chunk of code. My MAKE_STRING callback is still not being called for some reason. Here is the code:#include "..incgauges.h"#include #include "test.h"//#include #define GAUGE_NAME "Test0"#define GAUGEHDR_VAR_NAME gaugehdr_test#define GAUGE_W 100#define GAUGE_CHARSET DEFAULT_CHARSET#define GAUGE_FONT_DEFAULT "Courier New"#define GAUGE_WEIGHT_DEFAULT FW_NORMALextern PELEMENT_HEADER test_Small;STRING_UPDATE_CALLBACK update_callback;char test_gauge_name[] = GAUGE_NAME;GAUGE_HEADER_FS700(GAUGE_W, test_gauge_name, &test_Small, NULL, NULL, 0, 0, 0);MAKE_STATIC(test_background,BMP_SMALL_test,NULL,NULL,IMAGE_USE_TRANSPARENCY,0,0,0);MAKE_STRING(update_code,NULL,NULL,IMAGE_USE_ERASE | IMAGE_USE_BRIGHT , 0,50, 50,60, 29,30,CLOCK_SECOND ,MODULE_VAR_NONE ,MODULE_VAR_NONE ,RGB(0,255,0),RGB(0,0,0), RGB(92,92,92),GAUGE_FONT_DEFAULT,GAUGE_WEIGHT_DEFAULT,GAUGE_CHARSET,0,DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL,update_callback)PELEMENT_HEADER update_code_list[] ={&update_code.header,NULL};PELEMENT_HEADER test_Small = &test_background.header;FLOAT64 FSAPI update_callback(PELEMENT_STRING pelement ){ FLOAT64 val=pelement->source_var[0].var_value.n; val = !val; wsprintf(pelement->string, "%3d", (UINT32)val); return val;}void FSAPI ModuleInit(void){}void FSAPI ModuleDeinit(void){}GAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&gaugehdr_BLD) GAUGE_TABLE_END()I'm trying to use the CLOCK_SECOND token variable to trigger my update_callback routine once every second. Is this the right approach or do I still have some learning curve to go?Magma
September 18, 200619 yr The update_callback routine will automatically be called every 18th of a second.Your code is drawing a background referenced by BMP_SMALL_test, it is then placing a text box on it at the coordinates (50,50),the text box will be 60px wide and 29px high,it will then allow you to write up to 30 characters to this box.Because your textbox is 60px wide and you have told it that you want to write 30 characters in it it will only assign 2 pxs per characterYour update_callback will examine the value of CLOCK_SECONDS every 18th of a second.val=!val is an 'unrecognised' C routine (well I've never seen or used it) so will probably assign the value 0 to val.wsprintf(pelement->string, "%3d",(UINT32)val);This will print the value of val in the first 3 chracter spaces of the text box.If your code compiles... all it will do is print a zero, which you probably won't be able to see because its only 2pxs wideChange your code from ... 0,50,50,60,29,30 .... to... 0,50,50,60,29,3 .....Also remove the line val=!val;This should then display the value of CLOCK_SECONDS and you should see it count from 0 to 59RegardsJim
September 18, 200619 yr Thanks Jim,I tried as you suggested but without success. Still nothing shows up when I run FS. I'm pretty sure that my update_callback routine is never being called by FS. I know this because I can put a routine inside of update_callback that is suppose to paint text to the screen using HDC and hBrush but nothing happens like it does when I set up a callback function through GAUGE_HEADER_FS700 macro. That works fine. So I don't know where the problem is and why my callback routine is never getting called. Am I suppose to export the function in my .h header file or .rc? Magma
September 18, 200619 yr MagmaChangeGAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&gaugehdr_BLD) GAUGE_TABLE_END()To:GAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&gaugehdr_test) GAUGE_TABLE_END()RegardsJim
September 18, 200619 yr Good eye Jim, but it has already been changed. I had changed some of the names to "test" in order to protect the proprietary project. Guess I missed one when I posted. So anyways it still doesn't work. I've looked at other sample code and it doesn't look like I'm doing anything wrong. It must be something silly I'm not doing.Magma
September 18, 200619 yr The 'next_element' item in the static macro has to indicate the string. Try this:MAKE_STRING(update_code,NULL,NULL,IMAGE_USE_ERASE | IMAGE_USE_BRIGHT , 0,50, 50,60, 29,30,CLOCK_SECOND ,MODULE_VAR_NONE ,MODULE_VAR_NONE ,RGB(0,255,0),RGB0,0,0),RGB(92,92,92),GAUGE_FONT_DEFAULT,GAUGE_WEIGHT_DEFAULT,GAUGE_CHARSET,0,DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL,update_callback)PELEMENT_HEADER update_code_list[] = {&update_code.header,NULL};MAKE_STATIC( test_background, BMP_SMALL_test, &update_code_list, NULL, IMAGE_USE_TRANSPARENCY, 0, 0, 0 );PELEMENT_HEADER test_Small = &test_background.header;Doug
September 18, 200619 yr Yep, Doug's found itMAKE_STATIC( test_background, BMP_SMALL_test, &update_code_list,Goes back to Bill's point about being methodical in your layout. I always put every element on a new line like this:MAKE_STATIC( test_background, BMP_SMALL_test, &update_code_list, NULL, IMAGE_USE_TRANSPARENCY, 0, 0,0 .....................(but keep coordnates together)makes it so much easier to de-bugRegardsJim
Create an account or sign in to comment