Jump to content
Sign in to follow this  
Guest jimcooper1

MAKE_STRING multiple lines

Recommended Posts

Guest Magma

Is it possible to print multiple lines using one MAKE_STRING callback routine. I've tried code like:sprintf(pelement->string,"%s%f","Test n",val);and:sprintf(pelement->string,"%s%f","Test rn",val);The r and n are recognized as special characters but it doesn't do the carriage return line feed and start a new line. Has anyone ever done this or know how to do multiple lines using one MAKE_STRING callback routine? Thanks,Thomas Magma

Share this post


Link to post
Share on other sites

I do not believe it is possible.


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest Magma

I am designing a gauge with up to 6-8 lines of text. So that means 6-8 MAKE_STRING callback routines @ 18 per second. That seems like a big waste of processing power (and messy code) when all I really need to do is update these lines of text once per second. Is there any other way to overlay text onto your static background image other than using MAKE_STRING. Thanks,T Magma

Share this post


Link to post
Share on other sites

Don't worry about it - just go ahead and draw the strings. You are no where near hanicapping FS with an overly expensive gauge.By way of comparison, I have a diagnostic gauge with something like 50 text elements on it. Among a few other things, it displays capacity, level and average fuel flow for each of FS's 11 defined fuel tanks. Average fuel flow per tank is updated on each instance of PANEL_SERVICE_PRE_UPDATE.There is no noticeable frame rate hit when I put this gauge on the screen.Doug

Share this post


Link to post
Share on other sites
Guest bartels

You can use multiline MAKE_STRINGs by not using DT_SINGLELINE in the MAKE_STATIC macro, but it would always effect the scaling, more precisely you have to scale the font size by yourself. I only tried it once, can't recall all facts.On the other hand for MCDUs/FMCs an approach via several MAKE_STRINGs can be used. In FS9 you don't have to care about redrawing the MAKE_STRINGs, every time the pelement->string is changed, the element is redrawn. For pre-FS9 you might return a changing return value from the drawing callback to make a redraw if needed, either the TICK18 variable for premaent redraw (might hit frame rate), or you store the previous string and return a changing value if the string has changed, or you use a slower update rate by returning e.g. TICK18 div 18.Alternatevily use only one GDI(+) element and draw for yourself.

Share this post


Link to post
Share on other sites
Guest Magma

Thanks to all that responded,What I settled on was keeping all the MAKE_STRING callbacks but minimizing what was done in each routine. Then I use the PRE_DRAW routine to process local variables every 18th time it is called. These local variables are the ones that get printed during a MAKE_STRING callback. So the callback routines are minimized down to:FLOAT64 FSAPI textline_1_callback(PELEMENT_STRING pelement ){sprintf(pelement->string,"%s%f","Lat ",latitude);return 0;}FLOAT64 FSAPI textline_2_callback(PELEMENT_STRING pelement ){sprintf(pelement->string,"%s%f","Long ",longitude);return 0;}etc...

Share this post


Link to post
Share on other sites
Guest jimcooper1

>Thanks to all that responded,>>What I settled on was keeping all the MAKE_STRING callbacks>but minimizing what was done in each routine. Then I use the>PRE_DRAW routine to process local variables every 18th time it>is called. These local variables are the ones that get printed>during a MAKE_STRING callback. So the callback routines are>minimized down to:>>FLOAT64 FSAPI textline_1_callback(PELEMENT_STRING pelement ){>sprintf(pelement->string,"%s%f","Lat ",latitude);>return 0;>}>>FLOAT64 FSAPI textline_2_callback(PELEMENT_STRING pelement ){>sprintf(pelement->string,"%s%f","Long ",longitude);>return 0;>}>>etc...Alternatively you can use:>sprintf(pelement->string,"Lat %f",latitude);RegardsJim

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...