Hud Completion

Code Changes

Acknowledgement for this feature must go to the Tremulous mod, as much of the code was taken from their source and modified to fit my circumstances. The code changes required to implement the Hud Completion can be found on the Hud Completion Code page.

Scripting

By default, all the Hud Completion extensions are disabled so regular Hud scripts will work correctly with no changes. The extensions are broken down into five areas and these can be enabled individually or all together. The five areas are :

  1. Player identities displayed when the crosshair is placed over them.
  2. Items usually drawn in the upper right of the screen, such as the timer.
  3. Console text normally displayed in the upper left of the screen.
  4. Weapon selection icons when changing a weapon.
  5. Text normally displayed in the center of the screen

To enable these extensions we must add some commands to the assetGlobalDef section of the Hud script. If you wish to enable all five areas at once you use this command :

allHudExtensions MENU_TRUE

To enable the areas individually you use the following commands :

Player identities xhairExtension MENU_TRUE
Upper right corner items upperRightExtension MENU_TRUE
Console text consoleExtension MENU_TRUE
Weapon selection icons weaponSelectExtension MENU_TRUE
Center print text centerPrintExtension MENU_TRUE

For example, the assetGlobalDef section that enables all areas would look like :

  assetGlobalDef
{
font "fonts/font" 16
smallFont "fonts/smallfont" 12
bigFont "fonts/bigfont" 20
allHudExtensions MENU_TRUE
}

while one that enabled just the console text and the weapon selection icons would look like :

  assetGlobalDef
{
font "fonts/font" 16
smallFont "fonts/smallfont" 12
bigFont "fonts/bigfont" 20
consoleExtension MENU_TRUE
weaponSelectExtension MENU_TRUE
}

Once an area is enabled the program will no longer display that information as usual but will require you to provide a scripted item that will display it. If the information in question is enabled/disabled by a cvar (like the lagometer, for example) then it still must be enabled by that cvar even though you are using a script to display it.

Player Identities

To script the location and text size used to display the identity of a player when the crosshair is placed over him you use the ownerdraw CG_PLAYER_CROSSHAIRNAMES command like the following :

    itemDef  
{
name "playername"
rect 200 240 240 25
visible MENU_TRUE
decoration
textScale .3
ownerdraw CG_PLAYER_CROSSHAIRNAMES
}

The text will be centered horizontally and vertically in the item's window area. The textScale command determines the size of the text used.

Upper Right Corner

There are four different things that are normally displayed in the upper right corner of the screen. These are the timer, framerate, lagometer and the snapshot info. Each of these has its own ownerdraw command so they can be displayed in different areas.

For the timer you use the ownerdraw CG_TIMER command like this :

    itemDef
{
name "timer"
rect 40 10 48 22
visible MENU_TRUE
decoration
forecolor 1 1 1 1
align ITEM_ALIGN_CENTER
textalignx 4
textaligny 14
textscale 0.3
ownerdraw CG_TIMER
}

The align command is used to set the alignment point of the timer text rather than the textalign command normally used for text. The other text formatting commands are used like normal.

For the framerate you use the ownerdraw CG_FPS command as follows :

    itemDef
{
name "fps"
rect 36 32 56 22
visible MENU_TRUE
decoration
forecolor 1 1 1 1
align ITEM_ALIGN_CENTER
textalignx 4
textaligny 14
textscale 0.3
ownerdraw CG_FPS
}

Again, the align command is used to set the alignment point of the framerate text rather than the textalign command and the rest of the text formatting commands are as usual. The text displayed includes the "fps" on the end.

For the lagometer the ownerdraw CG_LAGOMETER command is used like :

    itemDef
{
name "lagometer"
rect 596 8 32 20
style WINDOW_STYLE_EMPTY
visible MENU_TRUE
decoration
forecolor 1 1 1 1
textscale 0.3
textalignx 1
textaligny 0.5
ownerdraw CG_LAGOMETER
}

The text is centered in the item's window and the textalignx and textaligny commands position it from there. The item's window area will be colored to reflect the amount of lag occuring and the packet graph line will be shown as well.

The snapshot info is displayed by the ownerdraw CG_SNAPSHOT command as follows :

    itemDef
{
name "snapshot"
rect 160 200 300 22
style WINDOW_STYLE_EMPTY
visible MENU_TRUE
decoration
forecolor 1 1 1 1
align ITEM_ALIGN_CENTER
textalignx 0
textaligny 18
textscale 0.3
textstyle ITEM_TEXTSTYLE_NORMAL
ownerdraw CG_SNAPSHOT
}

Again, the align command is used to set the alignment point of the snapshot text rather than the textalign command and the rest of the text formatting commands are as usual.

Console Text

To change the location and text size of the console text that is normally displayed in the upper left of the screen you use the ownerdraw CG_CONSOLE command as follows :

    itemDef
{
name "console"
rect 8 1 200 30
style WINDOW_STYLE_EMPTY
visible MENU_TRUE
decoration
forecolor 1 1 1 1
align ITEM_ALIGN_LEFT
textalignx 0
textaligny 10
textscale 0.2
textstyle ITEM_TEXTSTYLE_NORMAL
ownerdraw CG_CONSOLE
}

The align command is used to set the alignment point of the console text rather than the textalign command and the other text formatting commands are used as normal. The text will automatically wrap around when it reaches the right edge of the item's window and will scroll up when it reaches the window's bottom. The text will never be displayed outside the item's window.

Weapon Selection Icons

When you change weapons during the game the icons for all the weapons you have are displayed with a box around the currently selected one. If you don't want this to appear at all then add the weaponSelectExtension MENU_TRUE command to the assetGlobalDef section but don't provide a script item that displays the icons. To display the icons in a location of your choice, use the ownerdraw CG_WEAPONSELECT command as follows :

    itemDef
{
name "weaponselect"
rect 615 150 20 20
visible MENU_TRUE
ownerdraw CG_WEAPONSELECT
special 4
align HUD_VERTICAL
decoration
}

The orientation of the list is determined by the align command. Using align HUD_VERTICAL will cause the icons to be drawn in a vertical column, while using the align HUD_HORIZONTAL command will draw the icons in a horizontal row. The size of the icons is set by the width and height of the item window, in this case 20x20. The spacing between the icons is set by the special command. In this case there is a 4 pixel space between each icon.

Center Print Text

At various different times during a game the program displays text centered on the screen. Since these may interfere with text already on the screen it is nice to move the display location. This is done using the ownerdraw CG_CENTERPRINT command like :

    itemDef
{
name "centerprint"
rect 240 38 200 22
visible MENU_TRUE
decoration
align ITEM_ALIGN_CENTER
textalignx 100
textaligny 14
textscale 0.3
ownerdraw CG_CENTERPRINT
}

The align command is used to set the alignment point of the console text rather than the textalign command and the other text formatting commands are used as normal.

Return to Home Page