Sign in to follow this  
Guest grimmy69

switching between two bitmaps in warning panel

Recommended Posts

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
Help AVSIM continue to serve you!
Please donate today!

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

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

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

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

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

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

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

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

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

My original suggestion, which Bill expanded upon, was to do the following:1: Create a normal bmp background for your gauge..2: Create the "lit" and "unlit" versions of your warning lights.3: over that you create a "virtual" element that is drawn by the sim. This is the part Bill discribs. This virtual element is adjustible in its level of transparancy and can be toggled with the code Bill provided.4: to ensure the levels of transparency do not effect anything but the lit elements and not the background, you then add a mask. The mask is generally just your background with holes cut out (black areas) for the lit and unlit element to be visible through.These are all "layers" in the gauge.Layer1 - background - texturelayer2 - lit or unlit element - textures - depends on statelayer3 - sim drawn virtual transparency (coded not texture)layer4 - mask - textureDoes this make any sense now? Its a bit tough to conceptualized until you get it right once, then it will all seem so obvious.Good luckCheersShad

Share this post


Link to post
Share on other sites

I really appreciate all the help I have been given here! :)I have things working the way I want them with the warning panel now, but I want to do the same thing to a few more gauges. I tried, but the syntax of these gauges is a bit different and since I lack the knowledge I need to do it properly I would like to ask for some advice on where I can read more about the syntax and variables.Looking at a part of the original code of the gauge above(A:GENERAL ENG1 OIL PRESSURE, PSI) 18 < if{ 1 (>L:OILL, numbers) } els{ 0 (>L:OILL, numbers) } (L:OILL, numbers)The part with "A:GENERAL ENG1 OIL PRESSURE" can be found in the SDK documentation. However "L:OILL, numbers" I can't seem to find anywhere.This makes it more complicated with the "Deice Annunciator lights" and "landing gear transition" gauges I am now trying to modify since they only have the first variable like "A:General eng1 anti ice position,bool" and not the second set of variables. Are the second variables (OILL) custom variables defined elsewhere?Also, what purpose does numbers, and enum serve? I do understand that they handle numerical results, but I would appreciate a better explanation! :)Thanks!Roger

Share this post


Link to post
Share on other sites

Hi,(L:var's) can have any name you like.Example:(L:The name you want to give to this Var,bool) (L:The name you want to give to this Var,bool) ! (>L:The name you want to give to this Var,bool)or(L:The name you want to give to this Var,enum) etc.0 (>L:The name you want to give to this Var,enum)other area1 (>L:The name you want to give to this Var,enum)other area2 (>L:The name you want to give to this Var,enum)other area3 (>L:The name you want to give to this Var,enum)etc.enum or number doesn't differ so muchJan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Roger,>This makes it more complicated with the "Deice Annunciator>lights" and "landing gear transition" gauges I am now trying>to modify since they only have the first variable like>"A:General eng1 anti ice position,bool" and not the second set>of variables. Are the second variables (OILL) custom variables>defined elsewhere?Those gauges you name that have the (A:XX) var seem to be properly coded, that with the (OILL) custom var has a redundancy that isn't needed at all in these kind of cases.This is the idea:Suppose you want an annunciator light to go ON as a result of a warning condition.Then you use a bitmap that will show up to reflect that warning state.You put the bmp inside an and tell FS to make it ONLY when that condition is met. To find when does it happen, you use a related FS variable like (A:GENERAL ENG1 OIL PRESSURE, PSI) that needs to be compared to a limit value, ie "18 <". ALL kind of comparisons between variables in XML return a "bool" number; 1 if the condition is met and 0 if it is not.Following your example, you want your bmp to be visible only when (A:GENERAL ENG1 OIL PRESSURE, PSI) is lower than 18.So, the SIMPLEST code to obtain this is:(A:GENERAL ENG1 OIL PRESSURE, PSI) 18 <Of course the approach is different when you need to use a set of two or more bitmaps to reflect a situation, but that's another story :-) >>Also, what purpose does numbers, and enum serve? I do>understand that they handle numerical results, but I would>appreciate a better explanation! :)>>Thanks!>Roger>Those are the "units" in which the variables have to be expressed.There are quite a lot of different ones, most of them having direct equivalency. You might want to read this thread:http://forums.avsim.net/dcboard.php?az=sho...ing_type=searchto get a proper idea.Tom

Share this post


Link to post
Share on other sites

I think I was a bit unclear about what I was having problems with... My fault, but your answers are very interesting to read anyways and is a great help in understanding how it all connects!I already have two working gauges with the following code:(A:General eng1 anti ice position,bool)(L:Test_W, bool) 1 ==AND(L:OILL, numbers) (L:OILR, numbers) + (L:GENL, numbers) + (L:GENR, numbers) + (L:HYDL, numbers) + (L:HYDR, numbers) + (L:UMFX, numbers) + (L:UMFY, numbers) + (L:DACH, numbers) + (L:LOFUL, numbers) + (L:LOFUR, numbers) + (L:Test_W, bool) + (A:ENG1 ON FIRE, bool) + (A:ENG2 ON FIRE, bool) + (>L:Current warnings, numbers) (L:Current warnings, numbers) (L:Check, numbers) < if{ (L:Current warnings, numbers) (>L:Check, numbers)(P:Absolute time, seconds) 1 % 0.5 > (A:Circuit general panel on, bool) &&(L:Current warnings, numbers) (L:Check, numbers) >(L:Current warnings, numbers) (>L:Check, numbers)What I want to do is to modify and convert them to rely on the same "nightlight" variable just as the warning panel does: (A:GENERAL ENG1 OIL PRESSURE, PSI) 18 < if{ (L:Nightlight,enum) 1 == if{ 1 (>L:OILL, numbers) } els{ 2 (>L:OILL, numbers) } } els{ 0 (>L:OILL, numbers) }(L:OILL, numbers) The problem is that there is no equivalent to the "OILL" variable in the warning panel. So I assume that the OILL variable is not a "default" variable but a custom variable defined in another gauge.I really wish someone would write a "xml-gauge programming for dummys" book, but I guess the market is a bit too small... ;)Thanks!Roger

Share this post


Link to post
Share on other sites

Ok.If you only need to have them work using (L:Nightlight,enum), then replace those gauge's code with this one:(A:General eng1 anti iceposition,bool) (L:Nightlight,enum) 1 != 1 + * (* YOU NEED TO PROVIDE THIS BMP *) (L:Test_W, bool) 1 == (L:Nightlight,enum) 1 != 1 + *And (L:OILL, numbers) (L:OILR, numbers) + (L:GENL, numbers) + (L:GENR, numbers) + (L:HYDL, numbers) + (L:HYDR, numbers) + (L:UMFX, numbers) + (L:UMFY, numbers) + (L:DACH, numbers) + (L:LOFUL, numbers) + (L:LOFUR, numbers) + (L:Test_W, bool) + (A:ENG1 ON FIRE, bool) + (A:ENG2 ON FIRE,bool) + (>L:Current warnings, numbers) (L:Current warnings, numbers) (L:Check,numbers) < if{ (L:Current warnings, numbers)(>L:Check, numbers) } (P:Absolute time, seconds) 1 % 0.5 > (A:Circuit general panel on, bool) and (L:Current warnings, numbers) (L:Check,numbers) > (L:Nightlight,enum) 1 != 1 + *(* YOU NEED TO PROVIDE THIS BMP *) (L:Current warnings, numbers)(>L:Check, numbers)NOTE: please replace the ">" and "<" comparators with "&amp"gt; and "&amp"lt; >I really wish someone would write a "xml-gauge>programming for dummys" book, but I guess the market is>a bit too small... ;)Nick Pike has written a great set of XML tutorials for beginers.You can find it here:http://www.fs2x.comTom

Share this post


Link to post
Share on other sites

Brilliant! Thank you so much both for the perfectly working code and the link. I'll make sure to read all the tutorials available there!Just a short note to anyone reading the code above... Should be:The "" end tag was missing. :)Cheers!Roger

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