Targetware: Customizing the User Interface


Widget Type: Button

Buttons are rectangular shapes that when clicked by the user, will cause a certain function to be performed. Buttons can be made simply programmatically, by the game drawing a rectangle of the size and color you tell it to, with a text label you supply, or you can create a texture for each button state (normal, mouse-over, disabled), and that will be displayed instead. If a button label is supplied, it will be drawn in the color specified, whether or not a texture is being used. So if your texture has the label on it, do not include a text label as well.

Sample Button Code

  [Page 1 Widget 11]
#Quit
type = button
pos = 260, 560
size = 540, 40
label =
label_color = 0, 0, 0, 255
disable_text_color = 76, 76, 76, 255
color = 255, 255, 255, 255
texture = pg1.tga
texcoord1 = 0.254, 0.54688
texcoord2 = 0.781, 0.58594
hl_color = 255, 255, 255, 255
hl_texture = pg1.tga
hl_texcoord1 = 0.254, 0.77344
hl_texcoord2 = 0.781, 0.81250
disable_color = 255, 255, 255, 255
disable_texture = pg2.tga
disable_texcoord1 = 0.0, 0.96191
disable_texcoord2 = 0.52734, 1.0
center = 0
disable = 0
emboss = 0
function = 1001

This is the code controlling the "QUIT" button on the default Targetware User Interface's Main Menu. Notice that the "label =" line is left blank, since the textures we are using have "QUIT" drawn on them with pixels. We have specified textures for all three buttons states; the button does not start off disabled, it uses no emboss (really only useful for non-textured items), and when pressed will cause function #1001 to take place (quit app).

Button Functions

All Buttons can (and should) have functions assigned to them. As long as the button is not disabled, clicking on it will cause the corresponding action to be taken. More than one fucntion can be assigned per button, simply separate the function numbers with commas.

    1-100 causes ui to go to that numbered page: "4" will jump to Page 4.
101-200 enable button on that page: 101 enables button 1
201-300 disables button on that page: 201 disabled button 1
301-400 toggles enable/disabled state of button
401-500 enables field of that number. Ex: 401 enables field #1
501-600 disable field
601-700 toggle field
701-800 set the joystick device to be calibrated
   1001 quit
   1002 toggle server list keywords (unimplemented)
   1003 toggle server list favorites (unimplemented)
   1004 toggle server list public only (unimplemented)
   1005 toggle server list ping filter (unimplemented)
   1006 refresh server list
   1007 update server (unimplemented)
   1008 get server info (unimplemented)
   1009 join server
   1010 create server
   1011 play offline
   1012 refresh meta data (right now thats just the mod data)
   1013 download selected mod
   1014 next calibration (this is a hack, may need to change)
   1015 start flight
   1016 end flight
   1017 disconnect