The regular Hud consists of those elements that are displayed all the time to provide information to the player. The other part of the Hud that is only displayed when requested is the scoreboard. We will look at what makes up the scoreboard and how it is implemented in the program.
The Hud scoreboard is only displayed when the key bound to the +scores cvar is held down. When this occurs, the regular Hud is hidden and only the scoreboard is shown. When the key is released, the scoreboard is hidden and the regular Hud appears once more.
To accomplish this action the program makes certain requirements of your Hud scripts. The first is the names of the menuDefs that make up the scoreboard. If the game type is nonteam based, such as FFA or Tournament, then the menuDef used for the scoreboard must be named score_menu. If the game is team based then the menuDef used for the scoreboard must be named teamscore_menu. These names are hardcoded into the program and are unchangable. The second is that the entire scoreboard must be displayed using just the one named menuDef. Unlike the rest of the Hud, the scoreboard is contained in only one menuDef. Third is the visibility of the two menuDefs. By default these menuDefs must be invisible and include the visible MENU_FALSE command in the Overall Menu Information section.
So, as you can see from the above, we must have two different scoreboard scripts. This makes sense, as the different game types require different information to be displayed. We'll look at each script in this section.
A sample menuDef for the nonteam based scoreboard would look like this :
#include "ui/menudef.h"
{
menuDef
{
name "score_menu"
visible MENU_FALSE
rect 0 0 640 480
itemDef
{
}
}
}
By making the menuDef cover the entire screen area, but not have a background, we can place our elements anywhere without any problems and the game won't be covered completely up by the scoreboard.
NonTeam Based Scoreboard
In the nonteam based scoreboard ( score_menu menuDef ) there are certain amounts of information we want to display regarding us and the other players in the game. We'll look at this information here.
The type of game we are currently playing can be shown by :
itemDef
{
name gametype
ownerdraw CG_GAME_TYPE
textscale .25
rect 30 382 50 17
textalignx 0
textaligny 10
textalign ITEM_ALIGN_RIGHT
visible MENU_TRUE
decoration
}
The ranking of the player and the number of kills can be shown as text centered in the item's window area using the following :
itemDef
{
name score
ownerdraw CG_GAME_STATUS
textscale .4
rect 0 20 640 35
textalignx 320
textaligny 0
textalign ITEM_ALIGN_CENTER
visible MENU_TRUE
decoration
}
The player's score is shown by :
itemDef
{
name "Score"
rect 30 420 40 10
visible MENU_TRUE
textstyle ITEM_TEXTSTYLE_SHADOWED
text "Score:"
decoration
textalignx 0
textaligny 10
textalign ITEM_ALIGN_RIGHT
textscale .25
ownerdraw CG_PLAYER_SCORE
}
The frag limit of the game is shown by :
itemDef
{
name "fraglimit"
rect 30 405 40 10
visible MENU_TRUE
textstyle ITEM_TEXTSTYLE_SHADOWED
text "Frag Limit:"
decoration
textalignx 0
textaligny 10
textalign ITEM_ALIGN_RIGHT
textscale .25
ownerdraw CG_CAPFRAGLIMIT
}
The awards the player has garnered can also be shown. The ownerdraw commands for these display the number of that particular award as text so you have to indicate, through more text or a graphic, what the award actually is for. In Team Arena they place a graphic underneath each award that shows what it is for but you could use text to describe it as well. A sample from TA is :
itemdef
{
name medal_accuracy
ownerdraw CG_ACCURACY
rect 276 388 32 32
background "ui/assets/medal_accuracy.tga"
forecolor 1 1 1 .5
visible MENU_TRUE
decoration
textscale 0.25
}
The foreground color has an alpha of 0.5 so the graphic and text is made partially transparent so you can still see the game. The list of awards you can display is described here.
The last and largest part of the scoreboard is the list of information about the players in the game. This information is displayed using a List box with a scoreboard feeder. This feeder returns seven columns of text and graphic information about each player so the data must be formated using the columns command. Since there may be more players than can be fitted in the List box area at one time the List box is scrollable using the keys bound to the scoresUp and scoresDown cvars. For the nonteam games the feeder that is used is the feeder FEEDER_SCOREBOARD and the item looks like the following :
itemDef
{
name playerlist
rect 14 90 610 290
forecolor .75 .75 .75 1
visible MENU_TRUE
type ITEM_TYPE_LISTBOX
elementwidth 592
elementheight 20
textscale .25
elementtype LISTBOX_TEXT
feeder FEEDER_SCOREBOARD
notselectable
columns 7
5 20 20
5 20 20
65 50 50
150 100 40
365 20 20
463 20 20
532 20 20
}
This is a fairly standard List box for displaying text information. The information is formatted using the columns command and this is where things of interest happen. Since, unlike the List boxes used in the menu scripts, this feeder can return graphic information as well as text information the <width> value of the column comes into play. See here for more details about the columns command. The first and second column of data from this feeder can be a graphic so we set the <width> to the size we want the graphic to be displayed as. In this case it will be displayed as a 20x20 graphic.
Team Based Scoreboard
In the team based scoreboard ( teamscore_menu menuDef ) there are certain amounts of information we want to display regarding us, the other players in the game and the teams. We'll look at this information here.
The type of game we are currently playing can be shown by :
itemDef
{
name gametype
ownerdraw CG_GAME_TYPE
textscale .25
rect 18 440 50 20
textalignx 0
textaligny 0
textalign ITEM_ALIGN_RIGHT
visible MENU_TRUE
decoration
}
The score of the game (team vs team) can be shown as text centered in the item's window area using the following :
itemDef
{
name score
ownerdraw CG_GAME_STATUS
textscale .4
rect 0 78 640 23
textalignx 320
textaligny 0
textalign ITEM_ALIGN_CENTER
visible MENU_TRUE
decoration
}
The player's score is shown by :
itemDef
{
name "Score"
rect 430 440 40 21
visible MENU_TRUE
textstyle ITEM_TEXTSTYLE_SHADOWED
text "Score:"
decoration
textalignx 0
textaligny 10
textalign ITEM_ALIGN_RIGHT
textscale .25
ownerdraw CG_PLAYER_SCORE
}
The name of each team is shown by :
itemDef
{
name redteamname
ownerdraw CG_RED_NAME
textalign ITEM_ALIGN_RIGHT
textscale .3
rect 20 78 306 23
forecolor 1 0 0 1
decoration
visible MENU_TRUE
}
itemDef
{
name blueteamname
ownerdraw CG_BLUE_NAME
text " "
textalign ITEM_ALIGN_LEFT
textscale .3
rect 600 78 0 23
forecolor 0 0 1 1
decoration
decoration
visible MENU_TRUE
}
The list of people who are spectating (ie. not joined a team) is displayed as a horizontal scrolling marquee moving from right to left as follows :
itemDef
{
name spectatingwindow
rect 100 414 520 24
style WINDOW_STYLE_FILLED
forecolor 1 1 1 1
textscale .33
visible MENU_TRUE
ownerdraw CG_SPECTATORS
decoration
}
The awards the player has garnered can also be shown. The ownerdraw commands for these display the number of that particular award as text so you have to indicate, through more text or a graphic, what the award actually is for. In Team Arena they place a graphic underneath each award that shows what it is for but you could use text to describe it as well. A sample from TA is :
itemdef
{
name medal_accuracy
ownerdraw CG_ACCURACY
rect 43 368 32 32
background "ui/assets/medal_accuracy.tga"
forecolor 1 1 1 .5
visible MENU_TRUE
decoration
textscale 0.25
}
The foreground color has an alpha of 0.5 so the graphic and text is made partially transparent so you can still see the game. The list of awards you can display is described here.
Information about the players on each team is displayed using a List box, just it was done for the nonteam games. Each team has its own feeder to supply a List box with information about that team. This feeder returns seven columns of text and graphic information about each player so the data must be formated using the columns command. For team games the feeder that is used is the feeder FEEDER_REDTEAM_LIST for the Red team and feeder FEEDER_BLUETEAM_LIST for the Blue team. Since there may be more players than can be fitted in the List box area at one time the List box is scrollable using the keys bound to the scoresUp and scoresDown cvars. It should be noted that when scrolling, all List boxes in the scoreboard are scrolled at the same time.
itemDef
{
name redteamlist
rect 14 142 306 60
forecolor .75 .75 .75 1
visible MENU_TRUE
type ITEM_TYPE_LISTBOX
elementwidth 135
elementheight 20
textscale .25
elementtype LISTBOX_TEXT
feeder FEEDER_REDTEAM_LIST
notselectable
columns 7
2 12 12
18 12 12
34 20 20
78 75 16
183 20 20
221 20 20
251 10 10
}
itemDef
{
name blueteamlist
rect 320 142 306 60
forecolor .75 .75 .75 1
visible MENU_TRUE
type ITEM_TYPE_LISTBOX
elementwidth 135
elementheight 20
textscale .25
elementtype LISTBOX_TEXT
feeder FEEDER_BLUETEAM_LIST
notselectable
columns 7
2 12 12
18 12 12
34 20 20
78 75 16
183 20 20
221 20 20
251 10 10
}
These are fairly standard List boxes for displaying text information. The information is formatted using the columns command and this is where things of interest happen. Since, unlike the List boxes used in the menu scripts, these feeders can return graphic information as well as text information the <width> value of the column comes into play. See here for more details about the columns command. The first and second column of data from these feeders can be a graphic so we set the <width> to the size we want the graphic to be displayed as. In this case it will be displayed as a 12x12 graphic.
This completes our look at the Hud scoreboard. Of course, you can use graphics, borders and colors in other items to improve the look of the scoreboard but the above are the essentials needed when constructing the display.