Sign in to follow this  
Guest Patrick_Waugh

Dynamically changing the resource_id

Recommended Posts

Anyone had any luck doing something like the following?FLOAT64 FSAPI Adf_Card_cb(PELEMENT_SPRITE pelement){ // Change RES_ID based on Day/Night & Power if (Time::IsDay()) { // Use DAY resource pelement->header.resource_id = BMP_GAUGE_ADF_CARD; } else { // NIGHT if(mainBus.PowerOn() && InstLights::IsPanelLtOn() && cbInstLt.Closed()) { // If power display instrument light switch(InstLights::GetRheoStat()) { case InstLights::BRT: pelement->header.resource_id = BMP_GAUGE_ADF_CARD_LT_BRT; break; case InstLights::ON75: pelement->header.resource_id = BMP_GAUGE_ADF_CARD_LT_75; break; case InstLights::ON50: pelement->header.resource_id = BMP_GAUGE_ADF_CARD_LT_50; break; case InstLights::ON25: pelement->header.resource_id = BMP_GAUGE_ADF_CARD_LT_25; break; default: // Should never get here OFF pelement->header.resource_id = BMP_GAUGE_ADF_CARD; break; } } } // Return Card Azimuth return pelement->source_var_0.var_value.n; // Force redraw REDRAW_IMAGE(pelement);}Seems to have no effect.

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Well... It would seem that thispelement->header.resource_idis a cheap, imitation copy of thisLinkage.gauge_header_ptr[n]->elements_list[0]->next_element[0]->resource_idHowever, that is not the whole story, as the above noted substitution will produce a gauge that requires a switch to/from full screen/windowed mode to effect the change in bitmaps.This would seem to indicate that one also needs to trigger the INITIALIZE and GENERATE routines in order to get the new bitmap on the screen.All in all, it would probably be easier to simply declare an icon element for these things.Doug

Share this post


Link to post
Share on other sites

Thanks Doug for your input. Makes sense now that I think back to the game loop.Can't use another ICON here as it is a SPRITE, and I wanted to avoid using a second one as this seemed more straight forward, avoid all the HIDE/SHOW logic.But forcing an INITIALIZE doesn't seem like a FPS saver at all, haha.So, I guess in the end it is wiser to create the 2nd dreaded SPRITE.Not sure I even know how to do that right now other than resizing a panel either.

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