Jump to content
Sign in to follow this  
Guest grimmy69

switching between two bitmaps in warning panel

Recommended Posts

Guest grimmy69

Hi!I hope I am not climbing too big a rock here again... ;)I have a warning panel that has a dark background image showing the non-lit warning lights. As the lights come on a "lit" bitmap becomes visible. No problem here... ---(A:GENERAL ENG1 OIL PRESSURE, PSI) 18 < if{ 1 (>L:OILL, numbers) } els{ 0 (>L:OILL, numbers) } (L:OILL, numbers) - ---However, I would like to be able to toggle the strenght of the lighting in the warning panel. Can I somehow assign and toggle "lightness" values to the "Bright"-bitmaps or make the warning panel toggle between two sets of bitmaps when a switch is toggled?I have a vague notion that I could:1. Create a custom variable that is toggled by a switch. 2. Modify the warning lights to check the status of this variable and choose between two sets of bitmaps depending on the results of this status check. The same variable should be checked by all warning lights.However, I really don't know how to program this. Could anyone please help and figure out how to do this, by looking at the snippet above?The reasons for all this is that the aircraft I am working on, has the ability to do this for night flying. However it isn't included in the payware model, and I would very much like to add it.I am slowly getting to grips with the syntax of XML-coding and FS gauges now and I am getting closer and closer to getting my simpit working the way I want it too! :)Btw, thanks to all those of you who have helped me previously! I really appreciate it!Thanks!Roger

Share this post


Link to post
Share on other sites

Hi,No tested but may be something like this works:(A:GENERAL ENG1 OIL PRESSURE, PSI) 18 < if{ (L:your var,enum) 0 == (You could take e.g. time of the day)if{ 1 (>L:oil warning,enum) } els{ 2 (>L:oil warning,enum) } } els{ 0 (>L:oil warning,enum) }(L:oil warning,enum)Hope it helps,Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites
Guest iholrf

Perhaps you could layer a transparent element between a mask and the lighting element and toggle as many lighting levels as you would like?I use such a method to dim the GPS unit at night.CheersShad

Share this post


Link to post
Share on other sites
Guest grimmy69

Both suggestions seem great and although I probably should choose the first solution so that I can learn more XML, I chose the second with a transparent bitmap since it is a lot quicker and simpler.Thanks to both of you! :DI have it working now, but I need to make it semi-transparent as well. I understand that I should use a mask image. Could you possibly show an example of how it is done?I tried:(L:Nightlight,bool) 1 ==(L:Nightlight,bool)But it isn't working properly. Either the code is wrong or I messed up the mask image.Thanks!Roger

Share this post


Link to post
Share on other sites

You don't need to use a bitmap at all. Use something like the following instead, adjusting the Width & Height for your own needs, of course: (L:brt, enum) 0 ==(L:brt, enum) 1 ==(L:brt, enum) 2 ==(L:brt, enum) 3 ==You may have as many "levels" of brightness as you desire simply by adding more (or less) s to the code. Adjust the values of as desired. 1.0 is fully transparent, 0.0 is fully opaque (black, or whatever FillColor is specified)... ;)


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 grimmy69

I just realized an important difference between the two solutions: The bitmap solution will also make the warning panel appear darker when the warning lights are off, which isn't relly a good solution in this specific case.Therefore, I will have to try to make the first solution work, with several cases depending on the state of my custom variable.A bit more work to do...However, I will use the bitmap solution for another thing that has been bothering me, so the question about mask image still remains important! Thanks,Roger

Share this post


Link to post
Share on other sites

>I just realized an important difference between the two>solutions: The bitmap solution will also make the warning>panel appear darker when the warning lights are off, which>isn't relly a good solution in this specific case.Actually, using the code I just showed you, you can create a set of 'transparency masks' that are exactly the size of your "lights" and they will therefore NOT affect the 'warning panel' at all... ;)


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

Hi,In my opinion, this is the BEST solution I find to your case:1) Use a set of two bitmaps (Jan's example), the dark one as bottom image, with a Bright="Yes" flag to keep the same color tone both for day/night; and the colored ones as a signal of warnings lit, also with the Bright="Yes" flag. 2) Use the "Rectangle" collection of elements (Bill's example) to add lighting control, (switch and Lvar to handle)I can't see how a mask image could be used here. Personally, I only find them valuable when you need to add antialiasing to certain gauges, otherwise it seems there are better solutions using XML code instead.Tom

Share this post


Link to post
Share on other sites
Guest grimmy69

You boys are making me dizzy with options... The polish syntax of Gauge coding really gives me a strong sense of vertigo everytime I put my actionscript-oriented mind to it! ;)My main problem is that although I do understand your examples I still have problems implementing them, since I have so little experience in coding gauges.Could anyone possibly help and adjust a small portion of my code, so I can use it as a base for the rest of the warning panel?I have an xml-gauge called nightlight which toggles a variable called "Nightlight" and it working just fine.(L:Nightlight,bool)(L:Nightlight, bool)(L:Nightlight, bool) ! (>L:Nightlight, bool)Also, I have a warning panel with 15 lights on it and here is where I need some help with the actual coding. I already tried copying some code above, but I managed to mess it up.(A:Circuit general panel on, bool) 1 ==(A:GENERAL ENG1 OIL PRESSURE, PSI) 18 < if{ 1 (>L:OILL, numbers) } els{ 0 (>L:OILL, numbers) } (L:OILL, numbers)Slowly, I am beginning to learn this moonwalk-coding. Moving forward, by going backwards, that is... ;)Thanks for taking the time, guys!Roger

Share this post


Link to post
Share on other sites

Hi,With your switch (L:Nightlight,bool) there is another option, but then you need some more elements:(A:Circuit general panel on, bool) (L:Nightlight,bool) ! and (A:GENERAL ENG1 OIL PRESSURE, PSI) 18 < if{ 1 (>L:OILL, numbers) } els{ 0 (>L:OILL, numbers) } (L:OILL, numbers)(A:Circuit general panel on, bool) (L:Nightlight,bool) and (A:GENERAL ENG1 OIL PRESSURE, PSI) 18 < if{ 1 (>L:OILL, numbers) } els{ 0 (>L:OILL, numbers) } (L:OILL, numbers)You can add as many elements as you want after the visibles.They all become bright when switching the "Nightlight" on.Hope it helps,Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites
Guest grimmy69

Hi Jan! :)I must be missing something, because when I copy your whole code into the warniglights.xml gauge and replace my code, all lights are on and doesn't toggle with the nightlight switch.Any ideas?Roger

Share this post


Link to post
Share on other sites
Guest grimmy69

I'm an idiot... I missed the < ">" bits...Sorry!Roger

Share this post


Link to post
Share on other sites

Roger,I made some changes to your original code. It may be useful for you to know about XML optimized code (with comments included) :-)Better seen if copied and pasted to an XML editor.(L:Nightlight,bool) (* NOT USED IF FOR FS2004 ONLY= ImageSizes="320,227,0,0"/> *) (L:Nightlight, bool) ! (>L:Nightlight, bool) (* This should be a dark image *) (A:Circuit general panel on, bool) (* Not need to use == 1 as always returns 1/0 *) THIS IS THE FIRST LIGHT (A:GENERAL ENG1 OIL PRESSURE, PSI) 18 < (* This short syntax is enough for what you're looking for *) (* No need to add lVars to control anything here *) THIS IS THE SECOND LIGHT (A:GENERAL ENG2 OIL PRESSURE, PSI) 18 < (* EACH LIGHT ELEMENT GOES HERE ONE AFTER OTHER *) If you want I can add a structure for the Light dimming code .Tom

Share this post


Link to post
Share on other sites
Guest grimmy69

My,my this is a quite a mouthful to chew on... Thanks everyone for sharing your thoughts! :DI finally got Jan's initial suggestion with two bitmaps working. However, I really don't understand the purpose of or how to use the suggested "rectangle" option.Btw, it would be great if those of you who post code could use the box right above the message area for making the message format into "plain text". That makes it a lot easier to copy the code. :DRoger

Share this post


Link to post
Share on other sites

Hi,You can put behind a text, bitmap or other visible element a rectangle with some color and transparancy. IMAGE 40 x 40(L:Your Var,enum) 0 ==(L:Your Var,enum) 1 ==etc,You can add as many as you like and they become visible depending on the state of (L:Your Var,enum) (L:Your Var,enum) 1 - 0 max(L:Your Var,enum) 1 + 10 minMake a testgauge and try, colors, degree of transparancy 0 - 10Jan"Beatus ille qui procul negotiis..."

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