Collaboration diagram for Menu System:
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 MenuItem * | items |
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. |
typedef struct MenuItem_t MenuItem |
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.
item | The MenuItem to operate upon. |
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.
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. |
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.
item | The MenuItem to operate upon. |
int MenuRun | ( | ) |
Runs a menu operating state.
The corresponding initalization and uninitalization must be cusotm made for each menu.
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.
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.
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. |
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:
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().
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().