Jump to content
Sign in to follow this  
Guest bartels

C Gauges

Recommended Posts

Guest harry3

Hi!As FS2002 doesn't work any more on my PC, I'm now flying FS98 again. As FS98 doesn't support XML, I'll try my best in C...Some questions: ===============MODULE_SETUP( GAUGE_HEADER_VERSION, 57, gauge_name, &list );What does the number 57 mean???What if a gauge is built of more than 1 Bitmap for the icon???MAKE_ICON( icon_strobe, BMP_ICON, plist10, NULL, IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY | IMAGE_HIDDEN, 0,NULL, {247,83}, STROBE_LIGHTS, ICON_SWITCH_TYPE_SET_CUR_ICON, 1, 0, 0, ); And than, could you please have a short look at my first C gauge? It doesn't really want to compile! Would be nice!Regards,Harry :-)

Share this post


Link to post
Share on other sites

Not sure what the 57 means.To change the number of bitmaps used in an ICON, change the 1 after ICON_SWITCH_TYPE_SET_CUR_ICON to however many are used. Use a callback function to set the index of the one being shown.I'm not sure if the MAKE_ICON macro is different for FS98, but the one shown may need some changes. plist10 should be &plist10. After the "image flags," there should only be a 0...the ",NULL" shouldn't be there. "{247,83}," should be "247,83,". After STROBE_LIGHTS, you'll need to use a callback function to set the image number, such as: "STROBE_LIGHTS, strobe_cb,". If all of this is different for FS98, I'm sorry. ;)MAKE_ICON( icon_strobe,BMP_ICON,&plist10,NULL,IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY | IMAGE_HIDDEN,0,247,83,STROBE_LIGHTS, strobe_cb,ICON_SWITCH_TYPE_SET_CUR_ICON,1,0,0, );I'll be glad to take a look at the gauge. What kind of error messages are you getting?Edit: I made some changes to the gauge, see if it makes any difference. I'm assuming you're trying to make a switch or light or something showing if the Strobe Lights are on or off. You need 2 seperate bitmaps: one if they're on and one if they're off.Matt

Share this post


Link to post
Share on other sites
Guest harry3

Thanks for the answer. So, I forgot the callback. Must there allwasy be a callback?Compiling now works. IN FS, there just shows up 1 bitmap of one strobe-state.I now made 2 MAKE_ICON as you said with 2 different bitmaps. But it doesn't really work. I also tried the callback the other way round for the second MAKE_ICON.(I mean if val == 1 return 0;....)Regards,Harri:-)FLOAT64 FSAPI strobe_cb( PELEMENT_ICON pelement ){ VAR32 val = pelement->source_var.var_value.n; if (val == 1) return 1; else return 0;}MAKE_ICON( icon_strobe, BMP_STROBE_OFF, NULL, NULL, IMAGE_USE_TRANSPARENCY, 0, 0,0, STROBE_LIGHTS, strobe_cb, ICON_SWITCH_TYPE_SET_CUR_ICON, 2, 0, 0, )MAKE_ICON( icon_strobe2, BMP_STROBE_ON, NULL, NULL, IMAGE_USE_TRANSPARENCY, 0, 0,0, STROBE_LIGHTS, strobe_cb, ICON_SWITCH_TYPE_SET_CUR_ICON, 2, 0, 0, )PELEMENT_HEADER plist[] ={ &icon_strobe.header, &icon_strobe2.header, NULL

Share this post


Link to post
Share on other sites

You only need 1 ICON element. ICONs can change what bitmap they are showing. You tell it the first bitmap, such as BMP_STROBE_OFF, and then later tell it how many bitmaps it can switch between (in this case 2). The callback function tells it which bitmap to show. If the strobes are off it returns 0, which shows BMP_STROBE_OFF. If strobes are on it returns 1, which shows BMP_STROBE_ON (the next bitmap, as defined in the header file). You don't always need a callback, only when you need to do this with data before returning it.Matt

Share this post


Link to post
Share on other sites
Guest bartels

You really use FS98? Then using a FS200x style icon callback in a FS98 gauge could be dangerous. Please have a look in the FS98 SDK and the associated gauges.h. The callbacks are different to later versions. Also use an offset of 3 to distinguish between the different bitmaps of the MAKE_ICON instead of 1 for FS200x.Arne Bartels

Share this post


Link to post
Share on other sites
Guest harry3

First of all: Thakns for all your answers!@Arne: Yes, I really *MUST* use FS98. Because since last month, no one of the other Flightsims works any more.I have to use FS98 in software mode not to cash this sim too. About the gauge:Just don't hink to complex, because it all would work that easy! No callback, just that simple code:Look here :MODULE_VAR light = {STROBE_LIGHTS};MAKE_ICON( icon_strobe, BMP_STROBE_OFF, NULL, NULL, IMAGE_USE_TRANSPARENCY, 0, {0, 0}, STROBE_LIGHTS, NULL, ICON_SWITCH_TYPE_SET_CUR_ICON, 2, 0, 0 )PELEMENT_HEADER plist[] ={ &icon_strobe.header, NULL};Regards,Harry :-)

Share this post


Link to post
Share on other sites
Guest harry3

What is wrong if you get an error in the gauges.h!!!???I think it has something to do with the windows.h I had to use for a string macro!!!Regards,Harry :-)--------------------Configuration: string - Win32 Release--------------------Compiling...string.cC:ProgrammeMicrosoft Visual StudioMyProjectsstring_2gauges.h(1124) : warning C4142: benign redefinition of typeC:ProgrammeMicrosoft Visual StudioMyProjectsstring_2gauges.h(1124) : warning C4142: benign redefinition of typeC:ProgrammeMicrosoft Visual StudioMyProjectsstring_2gauges.h(1145) : error C2371: 'UINT64' : redefinition; different basic types C:ProgrammeMicrosoft Visual StudioVC98INCLUDEbasetsd.h(167) : see declaration of 'UINT64'C:ProgrammeMicrosoft Visual StudioMyProjectsstring_2gauges.h(1145) : error C2371: 'PUINT64' : redefinition; different basic types C:ProgrammeMicrosoft Visual StudioVC98INCLUDEbasetsd.h(167) : see declaration of 'PUINT64'C:ProgrammeMicrosoft Visual StudioMyProjectsstring_2string.c(46) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'void *'Error executing cl.exe.string.gau - 2 error(s), 3 warning(s)

Share this post


Link to post
Share on other sites
Guest bartels

You seem to use the original MS hgauges.h. Unfortunately buggy or only compatible to VC++ 4.xx. Look for the "old" tutorials from Dai Griffiths (gauhlpxx), it includes proper gauges.h's. Or look in the corresponding areas of the new Fs2002 gauges.h (e.g. fs2k2gauges.h from sd2gauxx.zip by Dai) and copy it. They are pretty similar there. Something like :#if !defined( _BASETSD_H_) && !defined(_BASETSD_H)typedef unsigned int UINT32, *PUINT32;#endif..#if !defined( _BASETSD_H_) && !defined(_BASETSD_H)typedef unsigned __int64 UINT64, *PUINT64, **PPUINT64;#endifinstead oftypedef unsigned long UINT32, *PUINT32, **PPUINT32;...typedef struct UINT64{ UINT32 lo; UINT32 hi;} UINT64, *PUINT64, **PPUINT64;Arne Bartels

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...