The Quake 4 GUI system was designed to be driven mainly by the code. To do this, gui variables are often used so that when certain states change, the GUI automatically handles it and doesn't have to do any state determination on its own (since it's not really up to that task).

The syntax for a GUI variable is gui::variablename. The most common use for this is to set the visibility or text of GUI elements. For example, you may want to include a lag icon in your HUD to tell the player that their connection is unstable. The code can tell the HUD when to display this icon by setting a boolean GUI variable to true or false, and the icon's visibility in the HUD can be set to the GUI variable accordingly:

        windowDef icon_lag
        {
                rect           0,0,100,100
                visible        "gui::lagged"
                background     "gfx/guis/hud/lag"
        }

When the boolean GUI variable is true ( 1 ), the visibility of the lag icon will be automatically set to 1, and vice versa when the variable is false ( 0 ).

There are instances, particularly in HUDs, when windowDefs can be used in a generic way to serve as message windows for the player:

        windowDef text_spectate
        {
                rect       0,0,640,20
                visible    1
                text       "gui::spectatetext" 
        }

In the example above, the text string would always be set in the code and displayed in that window. When the text string is empty, nothing will show up.

GUI variables can also be set and checked just like desktop variables. For example, gui::inGame is often used by the mainmenu in an if-statement check to determine if the player is in-game and thus which menu items to show.

GUI Variables (last edited 2005-11-02 22:51:05 by MattVainio)