PDA

View Full Version : XML Gauge Sippets or Samples



rkruijer
12-08-2005, 08:36 AM
I am starting on XML programming. Did dl a lot of information like the Panel SDK. I was wondering if there is a place where I could find XML snippets or samples.

Example: I would like to start on a simple gauge that shows the Total Weigt of an aircraft. I know this is an A: variable so it is just a matter of showing it. There is more to it of course, that's why it would make life a lot easier if I could find a snippet that shows me an examle of how this sort of thing is put together.

Are these things available like you have them in C++?

Thanks for your time,


Roelof Kruijer

andyjohnston
12-08-2005, 08:42 AM
Take a look ai some of the default XML Cab files, for example the 747, which will give digital readouts of various conditions. Or check the file library, many aircraft will have what you're looking for. Lots of mine have digital gauges, and you're welcome to take a look at the syntax.

rkruijer
12-08-2005, 11:02 AM
Thanks,

So far I put this together and it is not working of course. :) Maybe a trained eye would see imidiately what's wrong with this.
Question: Must there always be a bitmap to show an A: var?
If So, must it be Black #000000? (transparent)? or could it be #151515 or any other color for that matter?

----------------------------------------------------------

<Gauge Name="Show Total Weight of Aircraft" Version="1.0">

<Image Name="TotWeight.bmp" Luminous="Yes" ImageSizes="100,30,0,0"/>


<Element>
<Visible>(A:TOTAL WEIGHT,kilogram)</Visible>
<Position X="0" Y="0"/>
<Text>
X="80" Y="20"
Bright="Yes"
Length="10"
Font="Quartz"
Color="#FFFF00"
<String>%((A:TOTAL WEIGHT,kilogram))%!06d!</String>
</Text>
</Element>
</Gauge>

Roelof

nickpike
12-08-2005, 05:14 PM
Hi Roelof,
pop over to the tutorials page at FS2x.com, where we have tutorials on XML and gauge graphics, as well as variable lists and some simpler (but clever) gauges,
cheers,
nick

andyjohnston
12-08-2005, 05:59 PM
Without opening one of my gauges forcompaison, lookat your settings
<text>
bunch
of
stuff
<string></string>
</text>

Bunch of stuff is floating in the middle of nowhere, all of it should be in the opening text tag. I believe the right way would be
<text X="x" Y="y" etc...

Oh to heck with it, hang on and I'll go look one up








Waiting










Still waiting









Are you coming back today?










Okay I'm back, sorry it took so long. Here's one for altitude, I don't have one for total weight:

<Gauge Name="Heading" Version="1.0">
<Element>
<Visible>(A:Circuit general panel on, bool)</Visible>
<Element>
<Text X="50" Y="16" Bright="Yes" Length="5" Font="Arial" Color="%('#00FF00' '#00FF00' (A:PLANE ALTITUDE, foot) 0 &gt;= ! ?)" Adjust="Center" VerticalAdjust="Center" Multiline="No" Fixed="No">
<String>%((A:INDICATED ALTITUDE, foot))%!4.0f!</String>
</Text>
</Element>
</Element>
<Mouse>
<Tooltip>%Altitude</Tooltip>
</Mouse>
</Gauge>

n4gix
12-09-2005, 02:46 AM
> <Visible>(A:TOTAL WEIGHT,kilogram)</Visible>

You will never see anything with this line...

rkruijer
12-09-2005, 02:58 AM
All of you, Thanks!
I Got it working.
---------------------------------
<Gauge Name="Show Total Weight of Aircraft" Version="1.0">
<Image Name="TotWeight.bmp" ImageSizes="40,15,64,24" Luminous="0"/>

<Element>
<Visible>(A:Circuit general panel on, bool) (A:Avionics master switch,bool) &&</Visible>
<Position X="4" Y="2"/>
<Text X="50" Y="12" Length="6" Fixed="Yes" Font="Quartz" Adjust="Center" VerticalAdjust="Center" Color="#FFFF00" Bright="Yes">
<String>%((A:TOTAL WEIGHT,kilogram))%!6d!</String>
<Failures>
<SYSTEM_ELECTRICAL_PANELS Action="0"/>
</Failures>
</Text>
</Element>
</Gauge>
-----------------------------------------------------
As you can see the problem was in the <Visible> </Visible> statement.
I was not aware that this is a condition to display it or not.
It looks at 2 things. Only if both are true will it be displayed.
This statement prevents display when you have a cold and dark startup.

I still have some Questions though:

1. How can I make my output larger? I took this from a Radio Alt gauge. Everything is the same. However, in the Radio Alt the digits are much larger.
2. What is the effect of Fixed="YES" Font Size?
3. The output is 37123 kilograms and it is nicely decreasing as you are using fuel. How would I display that with a period in between for clarity?
Thus 37.123!

Roelof

rkruijer
12-09-2005, 03:27 AM
>Hi Roelof,
>pop over to the tutorials page at FS2x.com, where we have
>tutorials on XML and gauge graphics, as well as variable lists
>and some simpler (but clever) gauges,
>cheers,
>nick

Thank you Nick,
I had already done that and I am very impressed. I read and reread your tuts and use them for refreshing my mind. Once you understand something you go back to the tutorial and see, all of a sudden what you wrote Nick looks different. It starts making sence. You know of course that you don't do that just for the fun of it. :-). You want to get on with it because you want to create something. Reading stuff is one thing. Understanding is quite another. Gradually I'm beginning to see the light. That may have to do with my background. Basic, dBase, Assembly etc. It is a big help that I did a lot of programming in the past. Still this XML thing is quite different. The RPN notation dus not read easely. I have some plans for gauges and with the help of you people I may have them ready at some point. I hope. :) Don't hold your breath though. I have a lot of ground to cover.

Roelof (The Netherlands)

n4gix
12-09-2005, 10:30 AM
>As you can see the problem was in the <Visible> </Visible>
>statement.
>I was not aware that this is a condition to display it or
>not.

Yep... ;) That's why the earlier statement failed. The conditional expression was incomplete...

>I still have some Questions though:
>
>1. How can I make my output larger? I took this from a Radio
>Alt gauge. Everything is the same. However, in the Radio Alt
>the digits are much larger.
>2. What is the effect of Fixed="YES" Font Size?
>3. The output is 37123 kilograms and it is nicely decreasing
>as you are using fuel. How would I display that with a period
>in between for clarity?
>Thus 37.123!

1. The entry <Text X="50" Y="12" Length="6"
X is the length of the "box" in which the digits will be displayed, Y is the height of the "box", and Length is the number of characters that will be normally be seen, including the decimal character.

2) Fixed="Yes" means use fixed spacing between characters even if the font specified is a proportional font.

3) Change the display format to %!6.2f! This means display a minimum of six characters* with floating point, two decimal precision.

d is an integer format specification
f is a floating point format specification

*NOTE: "6" is the minimum number of digits to display (optional). You don't NEED to include this, but it does affect the position of the displayed digits within the invisible "box" you've defined.

I should point out that all of this is covered in the anchored thread at the top of this forum. It is a reprint of a post made by the lead programmer at Microsoft's Flight Simulator development studio: ACES... ;)

rkruijer
12-09-2005, 11:19 AM
Thanks for you help.

>>3. The output is 37123 kilograms and it is nicely decreasing
>>as you are using fuel. How would I display that with a period in between for clarity?
>>Thus 37.123!

>3) Change the display format to %!6.2f! This means display a
>minimum of six characters* with floating point, two decimal
>precision.

This dus not work. It shows 7123.x of which x is a quickly updated digit that seems to be a fraction. The first digit fals off.

>I should point out that all of this is covered in the anchored
>thread at the top of this forum. It is a reprint of a post
>made by the lead programmer at Microsoft's Flight Simulator
>development studio: ACES... ;)

Is that the Topic "Useful Tips, Code Samples & Tricks"?
I first thought that was for C programmers.
What's the name or nick bame of the Author?

I don't seem to see any other anchored topic that fit's the description.

Roelof

n4gix
12-09-2005, 06:55 PM
>Thanks for you help.
>
>>>3. The output is 37123 kilograms and it is nicely
>decreasing
>>>as you are using fuel. How would I display that with a
>period in between for clarity?
>>>Thus 37.123!
>
>>3) Change the display format to %!6.2f! This means display
>a
>>minimum of six characters* with floating point, two decimal
>>precision.
>
>This dus not work. It shows 7123.x of which x is a quickly
>updated digit that seems to be a fraction. The first digit
>fals off.

First of all, the value is in kilograms: 37 thousand 123. If you wish to display as a fractional, then you need to divide the value by 1000 to shift the decimal to the left three places, then use %!6.3f! for the display format.

<String>%((A:TOTAL WEIGHT,kilogram) 1000 /)%!6.3f!</String>

>Is that the Topic "Useful Tips, Code Samples & Tricks"?
>I first thought that was for C programmers.
>What's the name or nick bame of the Author?
>
>I don't seem to see any other anchored topic that fit's the
>description.

It contains both C and XML tips, code samples and tricks. The authors name is me, but it is an article by Engauged, the Lead Programmer for Flight Simulator at Microsoft. ;) It is the third article posted in that thread.

rkruijer
12-10-2005, 02:28 AM
>
> <String>%((A:TOTAL WEIGHT,kilogram) 1000 /)%!6.3f!</String>
>

Of course! I was looking at the option of string concattenation for a while and also tried this devision but that was when it didn't work at all.
Automatically you push the option from your brain as being the culprit.

>>Is that the Topic "Useful Tips, Code Samples & Tricks"?
>>I first thought that was for C programmers.

I printed that yesterday and is part of my lookup pages now.
Anne Bartels, Nick Pike, Yours and many more.

Thanks a million,

Roelof