Jump to content

n4gix

Moderators
  • Posts

    336
  • Joined

Everything posted by n4gix

  1. Reposted here from http://blogs.technet.com/engauged/default.aspx Displaying Text in Gauges Formatting numbers To display the value of a sim variable in text, use the following syntax: %(VARIABLE NAME)%!XY! Where: VARIABLE NAME is any of the variables listed in parameters.doc. Be sure to include parentheses around the variable name in addition to the parentheses included with the %’s. (see example below) Note that there must not be a space between the ‘%’ and the ‘!’. Y (required, case-sensitive) is the formatting of the variable, where: * s = string. * d = number (integer). If the number is not an integer, it is rounded to the nearest integer. Note that rounding, not truncation occurs. * f = number (floating point) X is the minimum number of digits to display (optional) If Y=’d’, the following rules apply: * If X is preceded by the digit ‘0’, then leading zeros are added if necessary. * If X is preceded by ‘-‘, text is left-aligned * If X is preceded by ‘+’, a ‘+’ is indicated in front of the number when the number is greater than 0 (a ‘-‘ is always used to indicate numbers less than 0) * If X is preceded by ‘ ‘ (space), leading spaces are added if necessary. If Y=’f’, the following rule applies: * If a decimal point is used in the number X, the digit after the decimal point specifies the number of digits to display after the decimal point. See examples below, Script Result %( 12.34 )%!4.3f! 12.340 %( 12.34 )%!04.3f! 12.340 (Leading ‘0’s not added to floating point numbers) %( 12345.6789 )%!4.3f! 12345.679 (Number before decimal point does not limit the number of digits displayed before decimal point) %( 34.56 )%!+d! +35 (Note that rounding, not truncation, occurs) %(234)%!5d! 234 (note 2 leading spaces) %( ‘foo’ )%!5s! foo (note 2 leading spaces) %( 234 )%!3s! 234 Using Sim variables and expressions in text For example: %((A:Indicated Altitude, feet))%!05f! Any of the operators described above (Boolean, string, arithmetic, etc.) may be used within the %() to create the intended expression. In other words, %(EXPRESSION)%!XY! Is valid, where EXPRESSION is any combination of valid sim variables and operators. For example, the following string will display the current altitude in hundreds of feet or hundreds of meters, depending on the current international settings, %( (P:Units of measure, enum) 2 == if{ (A:Indicated Altitude, meters) } els{ (A:Indicated Altitude, feet) } 100 / )%!5d! Keep in mind that the element must be a child of a element, for example: X="80" Y="20" Bright="Yes" Length="10" Font="Quartz" Color="#E0E0E0" > String>05d: %((P:Local time,hours) flr)%!02d!
  2. Cut-and-Paste the following code to your gauges.h file, or save it as BCD2DEC.h, place it in your \inc folder and then #include it somewhere in your gauge project. /*--------------------------------------*/ #include #define Bcd2Dec(BcdNum) HornerScheme(BcdNum,0x10,10) #define Dec2Bcd(DecNum) HornerScheme(DecNum,10,0x10) UINT32 HornerScheme(UINT32 Num,UINT32 Divider,UINT32 Factor) { UINT32 Remainder=0,Quotient=0,Result=0; Remainder=Num%Divider; Quotient=Num/Divider; if(!(Quotient==0&&Remainder==0)) Result+=HornerScheme(Quotient,Divider,Factor)*Factor+Remainder; return Result; } /*--------------------------------------*/ Usage is quite simple... To convert the FS COM or NAV variable to Decimal: COM1freq = Bcd2Dec(COM_FREQUENCYvar.var_value.n); COM1freq = COM1freq/100 + 100; To convert a decimal frequency to BCD: COM1_bcd = (COM_dec - 100) * 1000; COM1_bcd = Dec2Bcd( COM1_dec);
  3. Here is a collection of useful Tips, Code Samples and Tricks for gauge development...
  4. Lifted with no shame directly from here: http://blogs.technet.com/engauged/default.aspx Creating alpha gauge images by: EnGauged (Gauge & Panel Programmer from the MSFS ACES Studio) Warning: I'm not a technical writer. I just play one on TV. There are no guarantees that the following instructions will work for you. Sometimes a gauge author/developer will want to add a (static) shadow element to a gauge. This is pretty easy to do, especially with XML gauges. With C gauges, it’s easy but there appears to be a bug with the system in the virtual cockpits. So if you have special gauges for the 2D cockpit, you can safely use an image that has alpha. Otherwise you’ll have to wait for the next version of Flight Sim. Creating an image that will alpha blend in the panel system requires the use of Photoshop. The RGB channel can contain whatever colors you wish, although it will typically be black (for a shadow) or white (for a highlight). In my example, I’ve used a red & white checkerboard pattern to illustrate the point. http://www.theyak.com/msgs/59721/59722_ul8.jpg Now there must be another channel that specifies the how to blend this with the elements below it in the Z order. My simple example uses vertical stripes of black, white, and varying shades of gray: http://www.theyak.com/msgs/59721/59727_jtl.jpg The name that you give this channel doesn’t matter. There should only be one alpha channel in the file. After creating the .psd, the next step is to run imagetool on the file. Unfortunately, this step must be run from the command line; the menus don’t have an option for creating a bitmap-with-alpha. Run the following from the commandline if the file is named “foo.psd”: imagetool -gauge -gaugealpha -nogui -nobeep foo.psd Now we should have a bitmap that flight sim and imagetool will interpret as having an alpha channel. To test this theory, open the resulting .bmp with imagetool and click on the “View”…”Alpha Channel” menu item. To see this image in-game, add it to your favorite gauge. Add the image as you would any other image (how to do this is out of the scope of this tutorial, as it’s one of the basics of gauge creation), but make sure that you indicate that the image should be alpha blended. In the case of XML gauges, this would mean adding “Alpha=True” as an attribute. In the case of C gauges, this would mean adding the IMAGE_USE_ALPHA flag in the DRAW_FLAGS parameter for the STATIC_IMAGE macro. When I created a gauge with a white background and added the above image, I get the following result: http://www.theyak.com/msgs/59721/59726_hkZ.jpg In other words, black = transparent, white=opaque, and grey = everything in between. So, try using the 3 easy steps (create psd, run imagetool, modify XML/C) to add alpha to your gauge! Let me know how it goes.
  5. Greetings, fellow modelers! Here is a link to my tutorial on "VC Gauge Backlighting: Using Emissive Textures". It is intended to further my quest to ensure that there are no remaining excuses for not having decent lighting in all freeware/payware aircraft! While I haven't exposed all that I know on the subject, it should help even the novice achieve stunning results in their first project! The tutorial is available here: FS9 Version: http://www.freeflightdesign.org/tutorials/VC_Lighting_Tutorial.zip FSX Version: http://www.freeflightdesign.org/tutorials/FSX_Emissive_Textures_and_VCLighting.zip I certainly hope this will be helpful to everyone! http://img100.imageshack.us/img100/6540/cirrussr20vccompas037ly.jpg
×
×
  • Create New...