Sign in to follow this  
Guest erahmig

Changing color of displayed string dynamically

Recommended Posts

Hi,I'm trying to create a digital display as a way of learning simple XML gauge programming.I created a gauge to display height above the ground (AGL). The gauge works fine. Now I'd like to make the color of the display change based on the current height. For example, if height <= 300, display red numbers. If 300 < height <= 500, display yellow numbers. If 500 < height, display white numbers.My first attempt using <Select> and <Case> won't even display on my panel. My second attempt, shown below, shows the height but the color is always yellow. How can I change the color dynamically?Current gauge:<Gauge Name="RadarAltimeterColor3" Version="1.0"> <Element> <Visible>(A:Circuit General Panel On, bool)</Visible> <Visible>(A:Circuit Avionics On, bool)</Visible> <Element> <!-- The following assumes FontWeight="400" (the default for FS2004). For Arial, use a width of nine pixels per character and a height of ten pixels per character. Add four pixels on either end of the display. Add four pixels to the height to allow a border of two pixels along the top and two pixels along the bottom of the display. So, a display of three Arial characters would use an "X" parameter value of: 3 * 9 + 4 + 4 = 35 and a "Y" value of: 10 + 4 = 14 --> <!-- When placing on a panel, use the X and Y attributes of the Text element to determine the size parameters to use on the gaugeXX line. For this gauge the line might look something like this: gaugeXX=cabfile!RadarAltimeter3, xlocation, ylocation, 53, 14 --> <Text X="53" Y="14" Bright="Yes" Length="5" Font="Arial" BackgroundColor="#0A0A0A" Color="%(((A:Plane Altitude, feet) (A:Ground Altitude, feet) -) 500 >= if{ '#FFFFFF' } els{ '#FFFF00' } )" Adjust="Center" VerticalAdjust="Center" Multiline="No" Fixed="No"> <String>%((A:Plane Altitude, feet) (A:Ground Altitude, feet) -)%!05d!</String> </Text> </Element> </Element> <Mouse> <Tooltip>%Radar Altimeter Color 3</Tooltip> </Mouse></Gauge>Thanks for any help,Eric

Share this post


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

Hallo,Something like (you can use radio height):Color="%('red' 'yellow' 'white' (A:Radio Height,feet) sp1 l1 500 >= ! ? l1 300 < l1 500 >= ! && ?)" (Not tested)Hope it helps,Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites

Hi Jan,Thanks for your reply. I will try this out and also try to learn what it means :) .On my screen for some reason all the '1' digits in your reply look like the lowercase letter 'L' so it took me a bit to figure out you meant 'sp' followed by the digit '1' and two '1' digits together, not two lowercase 'L' letters together.Eric

Share this post


Link to post
Share on other sites

Hi Jan,I tried your suggestion. The height displayed but the numbers were always in the same color.I spent more time trying to figure out how to do this and ended up using a different approach. This works: (A:Circuit General Panel On, bool)(A:Circuit Avionics On, bool)(A:Plane Altitude, feet) (A:Ground Altitude, feet) - 500 >%((A:Plane Altitude, feet) (A:Ground Altitude, feet) -)%!05d!(A:Plane Altitude, feet) (A:Ground Altitude, feet) - 200 > sp0 (A:Plane Altitude, feet) (A:Ground Altitude, feet) - 501 < sp1 l0 l1 &&%((A:Plane Altitude, feet) (A:Ground Altitude, feet) -)%!05d!(A:Plane Altitude, feet) (A:Ground Altitude, feet) - 0 >= sp0 (A:Plane Altitude, feet) (A:Ground Altitude, feet) - 201 < sp1 l0 l1 &&%((A:Plane Altitude, feet) (A:Ground Altitude, feet) -)%!05d!(A:Plane Altitude, feet) (A:Ground Altitude, feet) - 0 <%- - -Thanks again for your suggestion.Eric

Share this post


Link to post
Share on other sites

Hi,You must use sp1 (sp-one) and l1 (lowercase L-one), so sp1 l1.For me this works ok in the EGT indicator.Then you need only one element without the tags.Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites

Hi Jan,Thanks for the clarification. I will keep trying that method to see whether I can get it to work.Since I am new to this I need to ask something. Is there anything wrong with doing it the way I did - by using many elements with tags? By this I mean is it better, from a gauge design point of view, to do it the way you suggested?Thanks again for helping me.Eric

Share this post


Link to post
Share on other sites

Hi Jan,I must have done something wrong earlier when trying your example. I tried it again and it works fine. Thank you.Eric

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