Global Asset Definition

In one menu we must define assets and values that will be used by all the menus in the current menu system. These must be defined only once and are used by both the ingame menu system and the non-ingame menu system. Normally you would place this data in the main menu but it can go in any menu which is loaded by the program. This section of the menu system is called the assetGlobalDef and gives us a file that looks like :

    #include "ui/menudef.h" 
    {
      assetGlobalDef
      {

      }
    }

Everything between the curly braces after assetGlobalDef will define assets and values which apply to all menus. It is in this section that we define such things as the font used for menu text, the cursor used and menu sounds. Certain things must be defined in this section or the menu system will not work correctly.

Fonts

If you plan to use any text in the menus, which almost always happens, you must specify the font used to draw this text. This is a somewhat confusing procedure since you must define three different sizes of the font, each with its own data. Go to Using Q3Font to see how to generate the font data required. The data for each font size consists of a fontimage_xx.dat file and one or more fontimage_n_xx.tga files, where the xx is the point size of the font and n is 0, 1, .. . These files must be placed in the fonts directory.

When you use text in a menu you specify a scale for the text. This scale roughly translates to the following point sizes :

  • a scale of 1.0 is about a 48 pt font
  • a scale of 0.4 is about a 20 pt font
  • a scale of 0.25 is about a 12 pt font

The menu system requires you to define three different size versions of the same font. These are called smallFont, font and bigFont. If the text scale is 0.25 or less then the data from the smallFont is used to generate the text in the correct size. If the text scale is 0.4 or greater the bigFont data is used to generate the text. Otherwise the font data is used. This ensures that the text looks correct since it is generated from font data that is close to the actual text size. If only one set of font data was used then the large and small scales would be distorted by the extreme stretching and shrinking required. Team Arena uses font sizes of 12, 16 and 20 for the three different sizes. If you were using mostly larger text sizes then you may want to use something like 20, 26 and 34. A little experimentation will show which font sizes result in the best looking text. The actual definition of the fonts looks like this :

    smallFont "fonts/smallfont" 12
    font "fonts/font" 16
    bigFont "fonts/bigfont" 20
        

The name in between the quotes is not used (it is part of the unused builtin font generation code) but must be present. The number at the end is the font point size you used when generating the data in Q3Font. It corresponds to the xx in the name of the font data files

Cursor

Another mandatory definition in the assetGlobalDef section is the graphic used as the mouse cursor. The definition looks like this :

cursor <name>

where <name> is either the path and name of the graphic ( "ui/assets/3_cursor3.tga" ) or the name of the shader to use ( "menucursor" ). To use the regular Quake 3 menu cursor the definition would be :

cursor "menu/art/3_cursor2.tga"

Menu Fading

Under certain conditions you can specify that the background of a menu will fade in when activated or fade out when closed. This is done by changing the alpha of the background from transparent to solid or vise versa. The speed and amount of the fade is controlled by three values, fadeClamp, fadeAmount and fadeCycle.

  • fadeClamp is used to set the maximum alpha value for the background when fading in. It can range from 0.0 (transparent) to 1.0 (solid).
  • fadeCycle is the number of milliseconds between changes to the alpha value during the fade in/out. The larger the value, the slower the fade.
  • fadeAmount is the amount the alpha changes each time. The larger the value, the faster the fade.

The values used by Team Arena are :

    fadeClamp 1.0
    fadeCycle 1
    fadeAmount 0.1

Even though the values set here are global and are usable by all menus, it is also possible to set these values for individual menus. This is done in the Menu Definition part of the script file.

Sounds

Also in this section you can define the sound file to be played when a menu item receives the focus, either by keyboard or mouse. This definition is done using the itemFocusSound command. Team Arena defines the sound as this :

itemFocusSound "sound/misc/menu2.wav"

If you do not define the focus sound, then nothing will be heard when an item receives focus. It is also possible to set this sound for individual menus. This is done in the Menu Definition part of the script file.

Gradient Bar

When a menu item's window style is set to WINDOW_STYLE_GRADIENT the program uses a special graphic and the item's background color to draw a gradiant effect. This graphic is defined as ui\assets\gradiantbar2.tga by default and an attempt is made to load the graphic when the program initalizes. If you wish to use a different graphic for the gradiant you can specify it using the gradientBar command. The definition looks like this :

gradientBar <name>

where <name> is either the path and name of the graphic ( "ui/assets/gradientbar2.tga" ) or the name of the shader to use ( "gradiantbar" ). Team Arena defines it (by default) as :

gradientBar "ui/assets/gradientbar2.tga"

Menu Names

In order to function, the program must know the names of certain menus. These include the name of the first menu to run (the main menu), the name of the first menu to run when ingame (the ingame menu) and the menu to open when an error occurs (the error menu). All of these menus are assigned default names when the program initalizes but you can change them to something else if desired. The default names for these menus are :

    main          - first menu to run when not ingame
    ingame        - first menu to run when ingame
    error_popmenu - menu to open when an error occurs
    connect       - menu to open when connecting to a server
    endofGame     - menu to open at the end of the game

To change these names you use the following commands :

    mainMenu <name>     - first menu to run when not ingame
    ingameMenu <name>   - first menu to run when ingame
    errorMenu <name>    - menu to open when an error occurs
    connectMenu <name>  - menu to open when connecting to a server
    endgamemenu <name>  - menu to open at end of game

where <name> is the name of the menu in quotes (ie. "main").

Scrollbars

The graphics used and size of scrollbars is set by default when the program initalizes but this can be changed if desired. By default the width (vertical) or height (horizontal) of the scrollbar is set to 16. If you wish to make the bar narrower or wider use the scrollbarSize command like this :

    scrollbarSize 20    - to make it wider (20 pixels wide)
    scrollbarSize 12    - to make it narrower (12 pixels wide)

The graphics used to make the scrollbar can also be changed and you can assign different graphics for the background used by horizontal and vertical bars, something not done by default.

The background used by the scrollbar is assigned by the scrollBarHorz (for horizontal scrollbars) and scrollBarVert (for vertical scrollbars) commands, which are used like this :

    scrollBarHorz  <name>
    scrollBarVert  <name>

where <name> is either the path and name of the graphic ( "ui/assets/scrollbar.tga" ) or the name of the shader to use ( "scrollbar" ). The rest of the graphics used by the scrollbar (left arrow, right arrow, up arrow, down arrow and bar thumb ) can be changed in a similar way by using these commands :

    scrollBarArrowLeft  <name>
    scrollBarArrowRight <name>

    scrollBarArrowUp    <name>

    scrollBarArrowDown  <name>

    scrollBarThumb      <name>
where again <name> is either the path and name of the graphic or the name of the shader.

Sliderbar

If you wish, you can change the default sizes and the graphics used by the sliderbar. The height and width of the slider background are changed using the sliderWidth and sliderHeight commands. The background graphic will be stretched (or shrunk) to fit the box so defined. The default settings would be set by :

    sliderWidth  96
    sliderHeight 16 

The size of the slider thumb is changed by using the sliderthumbWidth and sliderthumbHeight commands. Again, the thumb graphic will be stretched to fit this box. The default values are :

    sliderthumbWidth  12
    sliderthumbHeight 20

The background graphic for the sliderbar is set by the sliderBar command, the graphic for the thumb is set by the sliderThumb command and the graphic for the selected thumb is set by the sliderThumbSel command, which are used this way :

    sliderBar   <name>
    sliderThumb <name> 
    sliderThumbSel <name>

where <name> is either the path and name of the graphic or the name of the shader.

Effects Slider

The slider used to select the player's effect color is made up of a number of graphics from vanilla Quake 3. These graphics are loaded by default when the program starts but you can change them if you desire. The effects slider is 128 pixels wide and 8 pixels high and this size is not changable. The selected color highlights are 16 pixels wide by 12 pixels high, also fixed in size.

The background graphic of the slider can be changed by using the fxBase command, which is used like this :

fxBase <name>

where <name> is either the path and name of the graphic ( "menu/art/fx_base.tga" ) or the name of the shader to use ( "fxbase" ). The seven highlight graphics (blue, cyan, green, red, teal, white and yellow) can be changed using the following :

    fxRed    <name>
    fxYellow <name>
    fxCyan   <name>
    fxBlue   <name>
    fxGreen  <name>
    fxTeal   <name>
    fxWhite  <name>
where, as usual, <name> is either the path and name of the graphic or the name of the shader to use.

If you used the graphics loaded by default when the program loaded you would still have to load the text fonts and the cursor in the assetGlobalDef section, in order for the menu to work correctly. The script file would look like this :

    #include "ui/menudef.h" 
    {
      assetGlobalDef
      {
        smallFont "fonts/smallfont" 12
        font "fonts/font" 16
        bigFont "fonts/bigfont" 20
        cursor "menu/art/3_cursor3.tga"
      }
    } 

A somewhat more complete assetGlobalDef section, with sound and fading would look like :

    #include "ui/menudef.h" 
    {
      assetGlobalDef
      {
        smallFont "fonts/smallfont" 12
        font "fonts/font" 16
        bigFont "fonts/bigfont" 20
        cursor "menu/art/3_cursor3.tga"
        itemFocusSound "sound/misc/menu2.wav"
        fadeClamp 1.0
        fadeCycle 1
        fadeAmount 0.1
      } 
    } 

 

Return to Home Page