Single Player Tutorial Part I

This part of the tutorial will take a look at a complete set of single player menu scripts. These scripts are used as the front end for a slightly modified version of The Dark Conjunction mod but they are quite generic and could be used as a template for any single player game. The media used in these menus is borrowed from various different games (mostly Jedi Knight 2) and can not be used in a game without permission of the owners. This tutorial is meant to explain how to script the menus and not to provide a ready to use package.

Script Files

The single player menu system consists of two parts, the non-ingame menus and the ingame menus. The non-ingame menu file names are prefaced with out_ and the ingame menu file names by in_. The file menus.txt is used to load the non-ingame menus and the file ingame.txt loads the ingame menus. Let's take a look at these files more closely.

In menus.txt we load the following files :

  • out_main.menu - contains the main menu and the assetGlobalDef section.
  • out_play.menu - contains the play menu.
  • out_demo.menu - contains the demo menu.
  • out_credits.menu - contains the credits menu.
  • out_controls.menu - contains the controls menu.
  • out_setup.menu - contains the setup menu.
  • out_mod.menu - contains the mod menu.
  • out_connect.menu - contains the connect menu.
  • out_driver.menu - contains the driverinfo menu.
  • out_quit.menu - contains the quit menu.

In ingame.txt we load the following files :

  • in_main.menu - contains the ingame menu.
  • in_controls.menu - contains the incontrols menu.
  • in_setup.menu - contains the insetup menu.
  • in_load.menu - contains the inload menu.
  • in_save.menu - contains the insave menu.
  • in_driver.menu - contains the indriverinfo menu.
  • in_quit.menu - contains the inquit menu.

As you can see from the above, each file contains a single named menu. You will also notice that, even though a menu may be identical in both the non-ingame and ingame (the quit menu for example), you can not share it between them. Therefore, the non-ingame section has the quit menu while the ingame section has the inquit menu. The only difference between the two menus is their name but it must be done this way to avoid strange things from happening.

The assetGlobalDef Section

The assetGlobalDef section of our menu system is defined in the out_main.menu file. The settings and assets defined here are used by all the menus, be they non-ingame or ingame.

    assetGlobalDef 
    {
      font "fonts/font" 16
      smallFont "fonts/smallfont" 12
      bigFont "fonts/bigfont" 20
      cursor "ui/assets/3_cursor3"
      itemFocusSound "sound/misc/menu2.wav"
	
      fadeClamp 1.0
      fadeCycle 1
      fadeAmount 0.1
    }

There is nothing special defined in this section that wasn't already explained in the Global Asset Definition section. We define the fonts to use, define the cursor graphic, set the item focus sound and set the fade values.

The Menu Style

The style of this single player menu is based on the style of the single player menu from Jedi Knight 2. In this menu style, all of the major submenus are accessable from every menu. You do not have to return to a "Main" menu to access the submenus. A look at the following will explain this further.

This is the non-ingame main menu. You will see that there are five buttons on this menu, PLAY, CONTROLS, SETUP, CREDITS and QUIT. Each of these take you to another submenu, except QUIT, which pops up a menu.

This is the non-ingame setup menu, which you would access from the SETUP button on the main menu. You will see the same five buttons, PLAY, CONTROLS, SETUP, CREDITS and QUIT, are also present in this menu so you are able to access those submenus without having to return to the main menu.

The Menu Background

All the menus share a common background with one slight exception. In the controls menu and the Player section of the setup menu the rotating model is replaced by the player model. Other than this the backgrounds are identical. Each background consists of the following itemDefs :

  • background - a shader that covers the entire screen with the blue background.
  • columnglow - a shader producing the vertical column on the left side of the screen.
  • halo - the glowing halo in the center of the column.
  • titlebanner - the Reaction Factory title graphic at the top of the screen.
  • model - the rotating model on the top of the column and halo.
  • header_line - a shader that draws a line under the top row of buttons.

All of these items have been covered in the Backgrounds, Graphics, Text and Models examples, found here. The titlebanner and the model items use different assets than the examples but otherwise are identical. In the controls menu the model item is replaced by the modelselection item, which uses the ownerdraw UI_PLAYERMODEL command to draw the player model.

The Menu Buttons

In the non-ingame menus there are five buttons, four in the top row and one at the bottom, that are present in every menu. These are PLAY, CONTROLS, SETUP, CREDITS and QUIT. In the ingame menus there are six buttons, four in the top row and two at the bottom, that are present in every menu, SAVE, CONTROLS, SETUP, LOAD, QUIT and RESUME. All of these buttons are created in the same manner, using an item for the mouseover glow and an item for the text button. This was covered in the Button examples here. Only the action command has a different script for each button. Except for the QUIT and RESUME buttons, this script closes the currently open menu and opens the menu associated with that button. The QUIT button, in both non-ingame and ingame menus, doesn't close the current menu but does open the quit or inquit pop up menu. The RESUME button executes the uiScript closeingame command to close all menus and return to the game.

Each button also has a mouseover text item associated with it that is displayed when the mouse is over the button. For the non-ingame menus these items are :

  1. newgametext
  2. controlstext
  3. setuptext
  4. credittext
  5. exittext

The ingame menus use these items for mouseover text :

  1. savegametext
  2. controlstext
  3. setuptext
  4. loadtext
  5. exittext
  6. resumetext

The method by which the text is displayed is explained here, with the only difference being we use the mouseEnter and mouseExit commands rather than the focus commands.

There is one other slight difference between each button. In the menu associated with that button (for example, the setup menu for the SETUP button) the associated button has no action command script at all. This prevents the button from reloading the current menu, an unnecessary task that only wastes time.

Part II : Main, Credits, Quit and Play Menus

 

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

 

Return to Home Page