Menu System

Collaboration diagram for Menu System:

A generalized system for opertating simple menus. More...


Files

file  menu.c
 Implements the menu system.
file  menu.h
 Defines the data type and functions used by the menu system.

Modules

 Network Status Menu Item
 Displays the current network status and provides a path to a network options submenu.
 Team Selection Menu Item
 Allows the user to select a team as designed in Team Selection.

Data Structures

struct  MenuItem_t
 Represents a user interface component on a menu. More...

Typedefs

typedef MenuItem_t MenuItem
typedef void(*) MenuItemFocus (MenuItem *item)
 Responds to a change in focus for an item.
typedef int(*) MenuItemInput (MenuItem *item, Uint8 *ec, rtsa_char keyval)
 Responds to player input for the menu item.
typedef int(*) MenuItemUpdate (MenuItem *item)
 Called once per frame to update the graphics on a menu item.

Functions

int MenuRun ()
 Runs a menu operating state.
void RemoveMenu ()
 Removes intenal menu system data and prepares for a new menu.
void SetupMenu (MenuItem *menu, int first, int count)
 Initalizes the menu system's internal data for a new menu.

Variables

static int focus
 

For internal use only.

The index of the menu item that has input focus.


static MenuItemitems
 

For internal use only.

A pointer to the start of an array of items that will comprise the menu.


static int numItems
 

For internal use only.

The number of elements in the items array.



Detailed Description

A generalized system for opertating simple menus.


Typedef Documentation

typedef struct MenuItem_t MenuItem

Definition at line 49 of file menu.h.

typedef void(*) MenuItemFocus(MenuItem *item)

Responds to a change in focus for an item.

An item will be notified about losing focus before another item is notified about gaining focus. When a menu is initalized, the item that has focus will receive a call to this function. Check MenuItem::hasFocus for the new focus status of the item.

Parameters:
item The MenuItem to operate upon.

Definition at line 58 of file menu.h.

typedef int(*) MenuItemInput(MenuItem *item, Uint8 *ec, rtsa_char keyval)

Responds to player input for the menu item.

Called once per frame only on the item with input focus.

Warning:
If the player presses the space bar, keyval will be set to the character value for a space, and the flag for the fire event will be set.
Parameters:
item The MenuItem to operate upon.
ec A pointer to event codes that describe the player's input.
keyval The character value of a key pressed, or zero. Generally, the values in ec should be inspected first.
Returns:
If non-zero, the operating state (STATE_CODES) that should run next. If zero, no state change will occur.

Definition at line 73 of file menu.h.

typedef int(*) MenuItemUpdate(MenuItem *item)

Called once per frame to update the graphics on a menu item.

This is called after the focus change function and after the input function. The function is responsible for placing the menu item's render items when the flag MenuItem::isPlaced is clear, which can occur when the program's window is resized, and when the update function is called for the first time on a given menu item.

Parameters:
item The MenuItem to operate upon.
Returns:
If non-zero, the operating state (STATE_CODES) that should run next. If zero, no state change will occur.

Definition at line 86 of file menu.h.


Function Documentation

int MenuRun (  ) 

Runs a menu operating state.

The corresponding initalization and uninitalization must be cusotm made for each menu.

Precondition:
textItems[TEXTITEM_TITLE] has been initalized to the game title. It will be displayed above the menu.
Returns:
The next operating state to run.
Author:
Jeff Jackowski

Definition at line 275 of file menu.c.

References background, dInfo, EC_BACKWARD, EC_CHARACTER, EC_FIRE, EC_FORWARD, EC_ROTLEFT, EC_ROTRIGHT, eventState, FALSE, focus, MenuItem_t::hasFocus, items, RenderItem_t::loc, numItems, DisplayInfo_t::ph, PlaceMarkers(), PlaceRenderItem(), ProcessNetworkMessages(), DisplayInfo_t::pw, ResizeMenu(), ResizeWindow(), SetupColorVals(), state, STATE_QUIT, STATE_SPLASH, TRUE, and MenuItem_t::update.

Here is the call graph for this function:

void RemoveMenu (  ) 

Removes intenal menu system data and prepares for a new menu.

Author:
Jeff Jackowski

Definition at line 262 of file menu.c.

References background, FALSE, markers, and RemoveRenderItem().

Referenced by MenuRootUninit().

Here is the call graph for this function:

void SetupMenu ( MenuItem menu,
int  first,
int  count 
)

Initalizes the menu system's internal data for a new menu.

Parameters:
menu A pointer to an array of menu items that will make up the menu. The items must already be initalized with correct data, all RenderItems must already be added to a layer, and the RenderItems should already be placed if they need to be visible. When the player provides a down input, the focus will move to an item with a greater index.
first The index of the menu item that will be initially given input focus.
count The number of items in the menu array.
Author:
Jeff Jackowski

Definition at line 215 of file menu.c.

References AddRenderItem(), background, COLOR_OBSTACLE, COLOR_REGBACK, colorVals, RenderItem_t::data, dInfo, focus, MenuItem_t::hasFocus, items, LAYER_BACKGROUND, LAYER_OBSTACLES, RenderItem_t::loc, MARKER_LENGTH, MARKER_THICKNESS, markers, menu, numItems, DisplayInfo_t::ph, PlaceRenderItem(), DisplayInfo_t::pw, RenderItem_t::renderer, ResizeMenu(), SolidFillRenderer(), textItems, TOP_MARGIN, and TRUE.

Referenced by MenuRootInit().

Here is the call graph for this function:


Variable Documentation

int focus [static]

For internal use only.

The index of the menu item that has input focus.

Definition at line 77 of file menu.c.

Referenced by MenuRun(), PlaceMarkers(), and SetupMenu().

MenuItem* items [static]

For internal use only.

A pointer to the start of an array of items that will comprise the menu.

Definition at line 70 of file menu.c.

Referenced by MenuRun(), PlaceMarkers(), RemoveBadSamples(), ResizeMenu(), SetupMenu(), VectorHeapSort(), VectorInsertMany(), and VectorRemoveMany().

int numItems [static]

For internal use only.

The number of elements in the items array.

Definition at line 84 of file menu.c.

Referenced by MenuRun(), ResizeMenu(), and SetupMenu().


Generated on Mon May 28 04:41:41 2007 for Retro Tank Super Attack by  doxygen 1.5.2