Single Player Tutorial Part V

In Part V we will examine the non-ingame setup menu to see any special features it may contain.

As in all the previously examined menus, the first part of the file contains the itemDefs for the background, the main buttons and their associated glow and mouseover text. It is only after the section looking like the following that menu specific items are defined.

/*********************************************************************/
//
// Start of menu Specific Items
//
/*********************************************************************/

The setup Menu

This is another complicated menu that can be simplified by breaking it down into sections and looking at those individually. As with the other menus, the first section is the onOpen command in the Overall Menu Information section.

      onOpen 
{
playlooped "music/sonic1.wav" ;
uiScript update "ui_GetName" ;
setcvar "ui_q3model" 1 ;
setcvar "model" starman ;
setcvar "headmodel" starman ;
uiScript UpdateModel ;
show playerControls ;
hide videoControls ;
hide mvideoControls ;
hide soundControls ;
hide gameControls ;
hide defaultControls ;
hide applyChanges ;
hide vidset ;
setitemcolor playerbutton forecolor 1 1 1 1 ;
setitemcolor videobutton forecolor 0.64 0.65 1 1 ;
setitemcolor mvideobutton forecolor 0.64 0.65 1 1 ;
setitemcolor soundbutton forecolor 0.64 0.65 1 1 ;
setitemcolor gamebutton forecolor 0.64 0.65 1 1 ;
setitemcolor defaultbutton forecolor 0.64 0.65 1 1 ; hide model ;
}

The very first thing in this script is the uiScript update "ui_GetName" command. This updates the ui_Name cvar so it holds the current player name. We can then change the contents of that cvar without affecting anything inside the program. This is an important step when you wish to make changes to the player's name. The next four lines deal with the player model. Back in the onOpen command of the main menu we set these three cvars and updated the model but we will do it again here just to make sure that the model is correct.

As with other complex menus, we have placed items into groups so we can make them visible or invisible as we need. We show the playerControls group and hide the videoControls, mvideoControls, soundControls, gameControls, defaultControls and vidset groups. We also hide the applyChanges button item.

Next we set the foreground (ie. text) color of the playerbutton item to white and set all the other button's foreground color to off white so the PLAYER button is highlighted as active, since the group associated with that button is visible.

Lastly, we hide the rotating model with the hide model command. The reason for this that is when the PLAYER button group (playerControls) is visible the player model is displayed rather than the rotating model.

onClose

The onClose command in the Overall Menu Information section also plays a major role in this menu. This command is executed when the menu closes and it runs the uiScript update "ui_SetName" command. This takes the contents of the ui_Name cvar and updates the internals of the program to reflect the (possible) change to the player's name. This is important, since without it, the player's name would never be updated to reflect any changes made to it in this menu.

Group Buttons

The six buttons are next and are standard items with a background glow. The differences between them are in their action script and even there they are very similar. We'll look at the VIDEO button's action script to see what happens there.

        action
{
hide playerControls ;
show videoControls ;
hide mvideoControls ;
hide soundControls ;
hide gameControls ;
hide defaultControls ;
hide applyChanges ;
show model ;
hide vidset ;
setitemcolor videobutton forecolor 1 1 1 1 ;
setitemcolor playerbutton forecolor 0.64 0.65 1 1 ;
setitemcolor mvideobutton forecolor 0.64 0.65 1 1 ;
setitemcolor soundbutton forecolor 0.64 0.65 1 1 ;
setitemcolor gamebutton forecolor 0.64 0.65 1 1 ;
setitemcolor defaultbutton forecolor 0.64 0.65 1 1 ;
}

This script is very similar to what happened in the onOpen script in the Overall Menu Information section. We show the group associated with this button (videoControls) and hide all the other groups plus the applyChanges button item. We then set the button's text color to white and make all the other button's text color off white. Also, since this is not the PLAYER button we make the rotating model visible with the show model command. The player model item is part of the playerControls group and is automatically hidden when the group is hidden.

Background, Highlights and Messages

The next section of items is the background and highlights for the setup options. The setup_background item draws a background in the area where the setup options will be shown. The items highlight1 through highlight13 are the glow that will appear behind each option shown in the setup_background area. The highlight items are set to be invisible (visible MENU_FALSE) when the menu opens and are made visible only when the mouse is over the setup option item on top of them. By doing it this way, we can use the same background glow for options in different groups. The highlight13 item is a different size than the rest of the highlight items and is intended for use the crosshair option.

The playerControls

This group of items all contain the group playerControls command and are used to set the options for the player. The items in this group are :

  1. namefield
  2. effect
  3. playermodel

The namefield item is an edit field item using ui_Name as the attached cvar. This cvar is loaded with the player's name when the menu is opened and the cvar contents are saved in the program when the menu closes.

The effect item is actually two items with the same name. One displays the text for the option and the other uses the ownerdraw UI_EFFECTS command to draw the player effects slider. It is done this way due to the way the effects slider is drawn in the item's window area. See here for details.

The playermodel item uses the ownerdraw UI_PLAYERMODEL command to display the player model in place of the rotating model.

 

The soundControls

This group of items all contain the group soundControls command and are used to set the sound options. The items in this group are :

  1. effects_volume
  2. music_volume
  3. soundquality
  4. doppler

The effects_volume item is a slider attached to the s_volume cvar. It allows you to change the cvar value from 0 to 1, which affects the sound effects volume.

The music_volume item is also a slider attached to the s_musicvolume cvar. It allows you to change the cvar value from 0 to 1, which affects the music volume.

The soundquality item is a multi selection item that is attached to the s_khz cvar. A choice of High sets this cvar to 22 while a Low choice sets it to 11.

The doppler item is a Yes/No item attached to the s_doppler cvar. This affects doppler sound in the game.

 

The gameControls

This group of items all contain the group gameControls command and are used to set the game options. The items in this group are :

  1. simpleitems
  2. wallmarks
  3. brass
  4. dlight
  5. identify
  6. sky
  7. sync
  8. network
  9. crosshair

The simpleitems item is a multi selection item that is attached to the cg_simpleItems cvar. It sets the cvar to 1 (ON) or 0 (OFF) and allows the setting of simple items in the game.

The wallmarks item is a multi selection item attached to the cg_marks cvar. It sets the cvar to 1 (ON) or 0 (OFF) and allows the setting of wall marks in the game.

The brass item is also a multi selection item, this time attached to the cg_brassTime cvar. It allows the settings of High (2500), Med (1250) or Off (0) to control the ejection of brass from the weapons in the game.

The dlight item is yet another multi selection item attached to the r_dynamiclight cvar. It allows turning on and off the game's dynamic lights.

Another multi selection item, identify, is attached to the cg_drawCrosshairNames cvar and allows turning on or off the player name above the crosshair.

The sky item is a multi selection item attached to the r_fastsky cvar. This enables high quality skies by setting this cvar to 0 or disabling them by setting it to 1.

The sync item is yet another multi selection item attached to the r_finish cvar. This gives the option of having the game sync every frame by setting this cvar to 0 or 1.

The network item is a multi selection item attached to the rate cvar. It is used to set the network data rate of the user by selecting one of the values in the multi list. It also has an action script that is executed each time the data rate is changed. This runs the uiScript update ui_setRate command which updates all the cvars associated with the network data rate.

The crosshair item is actually two items with the same name. The first item draws the text for this option while the second uses the ownerdraw UI_CROSSHAIR command to draw the current selected crosshair. It uses the special highlight item, highlight13, as the glow behind the crosshair. This option is drawn this way due to the way the crosshair is drawn. See here for details.

 

The defaultControls

This group of items all contain the group defaultControls command and are used to reset the game options back to their default values. This group of items does not give you any seperate options to choose from but does display a screen warning you that all the game options are about to be reset.

The background for the warning screen and the WARNING text are drawn by the two items named vidrestart. These two items are also used by the APPLY CHANGES button for its warning screen, although in that case they are made visible and invisible by use of their name rather than their group. The rest of the warning text is displayed by the three items named warning.

There are two buttons in this group, the YES and NO buttons, defined by the defaultyesbutton item and the defaultnobutton item. These are standard buttons with an associated glow item. The differences bewtween the two are in their action script.

In the action script for the defaultyesbutton item we first hide the button glow item so it won't accidentally be shown later on. Then we close all the menus that are open with the close all command. Lastly, we set all the options back to their defaults using the uiscript resetdefaults command. This will reset the values and then open the main menu.

In the action script for the defaultnobutton item we first hide the button glow item so it won't accidentally be shown later on. Since we are cancelling the reset operation we have to reset the menu to it's base configuration. To do this we show the playerControls group and hide any other items that may be visible, such as the APPLY CHANGES button and the defaultControls group. Next we set the button colors so the PLAYER button is highlighted and then we hide the rotating model, since we are showing the playerControls group and that includes the player model.

 

The videoControls

This group of items all contain the group videoControls command and are used to set various video options in the program. The items in this group are :

  1. gldriver
  2. graphics
  3. videomode
  4. colordepth
  5. fullscreen
  6. lighting
  7. geodetail
  8. texdetail
  9. texquality
  10. texfilter
  11. texcompress

All of these items, except the gldriver item, are multi selection items with an attached cvar. They all have an action script in their definition that shows the APPLY CHANGES button and then runs various uiScript commands to update all the related cvars. The APPLY CHANGES button is used to apply the changes to the video and then restart the system. This step must be done in order for the changes you have made to appear.

The gldriver item is an editfield attached to the r_gldriver cvar so the contents of that cvar are displayed in the edit field. Since this information is for display purposes only and is not to be changed, we have added the decoration command to the item definition. This stops the item from receiving the focus and therefore it can not be altered.

The graphics item is attached to the ui_glCustom cvar and is used to set the quality of the video. When you make a change to the value of this cvar the APPLY CHANGES button is shown and the uiScript update "ui_glCustom" command is executed. This updates all the cvars associated with the ui_glCustom cvar. It also may cause other items in this group to change their values to reflect the change in video quality.

The videomode item is attached to the r_mode cvar and allows you to change the screen resolution of the game. As usual, the APPLY CHANGES button is made to appear in the action script and then the uiScript glCustom command is run. This sets the video quality (shown by the graphics item) to Custom.

The colordepth item is attached to the r_colorbits cvar and allows changing the color resolution from 16 to 32 bits. The action script shows the APPLY CHANGES button, sets the video quality to Custom and then updates any cvar associated with the r_colorbits cvar.

The fullscreen item is attached to the r_fullscreen cvar and gives the option of running the game in a window or full screen. As usual, the APPLY CHANGES button is made to appear in the action script and then the uiScript glCustom command is run. This sets the video quality (shown by the graphics item) to Custom.

The lighting item is attached to the r_vertexlight cvar and gives the choice between Light Map or Vertex lighting. The action script shows the APPLY CHANGES button and sets the video quality to Custom.

The geodetail item is attached to the r_lodbais cvar and allows setting the geometric detail to Low, Medium or High. The action script shows the APPLY CHANGES button and sets the video quality to Custom.

The texdetail item is attached to the r_picmip cvar and lets you set the level of detail in the textures to Low, Normal or High. The action script shows the APPLY CHANGES button and sets the video quality to Custom.

The texquality item is attached to the r_texturebits cvar and allows setting the texture quality to 16 or 32 bit. The action script only shows the APPLY CHANGES button and nothing else.

The texfilter item is attached to the r_texturemode cvar and allows a choice between Bilinear or Trilinear filtering of the textures. The action script shows the APPLY CHANGES button and sets the video quality to Custom.

The texcompress item is attached to the r_ext_compressed_textures cvar and allows turning on and off the compression of the textures. The action script shows the APPLY CHANGES button and sets the video quality to Custom.

 

The mvideoControls

This group of items all contain the group mvideoControls command and are used to set various video options in the program that could not be fitted into the videoControls group. The items in this group are :

  1. brightness
  2. screensize
  3. driverbutton

The brightness item is a slider attached to the r_gamma cvar and allows you to control the gamma setting of the screen. The range is from 0.5 to 2.

The screensize item is a slider attached to the cg_viewsize cvar and it allows you to adjust the size of the game's viewing area. The viewing area is set to a percentage of the screen size and can be in the range 30 to 100 percent.

The driverbutton item is a button with an associated glow item that is used to open the driverinfo popup menu. This displays information on the OpenGl driver being used by the game. When this menu closes you will be returned to the main menu. The action script of this button hides the button glow before opening the driverinfo menu.

 

The APPLY CHANGES Button

This applyChanges item is a button that is normally hidden and is shown only when a change is made to one of the video options. It is a standard button with a glow item and an action script. When the button is clicked and the action script is run various things happen.

Since this button is only visible when either the videoControls or the mvideoControls group is visible we only have to change the text color of the VIDEO and MORE VIDEO buttons to off white to not highlight them. We also only have to hide the above two groups since they are the only groups that could be visible at this time. Next we show the two items from the defaultControls group whose name is vidrestart. This displays the red box with the WARNING text in it. Then we show the vidset group of items, which includes more text and two buttons. Lastly we run the uiScript update "ui_SetName" command so any changes we have made to the player's name will be saved when the system is restarted.

In the vidset group there are three items named awarning that display the rest of the warning text. There are also two buttons, the adefaultyesbutton item and adefaultnobutton item. These are standard buttons with glow items associated with them.

The action script of the adefaultyesbutton item closes all the open menus and runs the exec "vid_restart" command. This does a video system restart and then opens the main menu. This makes sure that any changes you made to the video options are applied properly.

The action script of the adefaultnobutton item is run when you don't wish to apply the changes. It hides the button glow, the two items named vidrestart, the vidset group and the APPLY CHANGES button. Then it shows the playerControls group, hides the rotating model and sets the PLAYER button's text color to white to highlight it.

 

Part VI : Ingame, Indriverinfo, Inquit, Incontrols and Insetup Menus

 

[Part 1] [Part II] [Part III] [Part IV] [Part V] [Part VI] [Part VII]

 

Return to Home Page