Dumb-ways-to-memorize
2D game
|
#include "globals.h"
#include "graphics.h"
#include "menu.h"
#include "mystrings.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "parsepowerup.h"
#include "parselevel.h"
#include "player.h"
Go to the source code of this file.
Functions | |
void | DeselectItemByNum (menu_t *self, int item) |
void | SelectItemByNum (menu_t *self, int item) |
void | UpdateVerticalMenu (menu_t *self, SDL_GameControllerButton button) |
void | UpdatePowerUpMenu (menu_t *self, SDL_GameControllerButton button) |
void | UpdatePowerSelectMenu (menu_t *self, SDL_GameControllerButton button) |
int | InitMenuSystem () |
void | DrawMenuByNum (menu_t *self) |
void | DrawMenuByState (menu_t *self) |
void | ProcessMenuItemsByType (menu_item_t *items, menu_type_t type) |
menu_t * | LoadMenu (object_t *object, char *g_str, GameState curr_state, GameState previous_state) |
menu_t * | FindMenuFromGameState (GameState curr_state) |
menu_t * | FindFreeMenu () |
menu_item_t * | FindMenuItem (menu_t *menu, char *item) |
int | StrToMenuType (char *str) |
Variables | |
menu_t * | gMenus = NULL |
int | gCurrentSelectedItem = 0 |
void DeselectItemByNum | ( | menu_t * | self, |
int | item | ||
) |
Deselect item by number.
[in,out] | self | If non-null, the class instance that this method operates on. |
item | The item number to deselect. |
Definition at line 25 of file menu.c.
References MENU_ITEM_STATE_NOT_SELECTED.
Referenced by UpdateVerticalMenu().
void DrawMenuByNum | ( | menu_t * | self | ) |
Definition at line 317 of file menu.c.
References DrawSprite(), gCurrentSelectedItem, gRedTexture, and gRenderer.
Referenced by LoadMenu().
void DrawMenuByState | ( | menu_t * | self | ) |
Definition at line 361 of file menu.c.
References DrawSprite(), gRedTexture, gRenderer, and MENU_ITEM_STATE_PICKED.
Referenced by LoadMenu().
menu_t* FindFreeMenu | ( | ) |
Searches for the first free menu slot in gMenus, used for loading new menus.
Definition at line 659 of file menu.c.
References gMenus, and MAX_MENUS.
Referenced by LoadMenu().
menu_t* FindMenuFromGameState | ( | GameState | curr_state | ) |
menu_item_t* FindMenuItem | ( | menu_t * | menu, |
char * | item | ||
) |
Searches for the first menu item, with name of str given.
[in,out] | menu | If non-null, the menu. |
[in,out] | item | If non-null, the item. |
Definition at line 679 of file menu.c.
References CountMem().
Referenced by LoadMenu().
int InitMenuSystem | ( | ) |
menu_t* LoadMenu | ( | object_t * | object, |
char * | g_str, | ||
GameState | curr_state, | ||
GameState | previous_state | ||
) |
Loads a menu.
[in,out] | object | If non-null, the object menu was parsed to. |
[in,out] | g_str | If non-null, the string. |
curr_state | State to assign the menu. | |
previous_state | State before this menu. |
Definition at line 478 of file menu.c.
References CountMem(), CountObjectChildren(), DrawMenuByNum(), DrawMenuByState(), FindFreeMenu(), FindMenuFromGameState(), FindMenuItem(), FindObject(), FindValue(), gSelectedPowerUps, GUESS, LoadSprite(), MENU_BACKGROUND, MENU_ITEM_EXTRA, MENU_ITEM_LINK, MENU_ITEM_MAX, MENU_ITEM_SPRITE, MENU_ITEM_STATE_NOT_SELECTED, MENU_ITEM_STATE_SELECTED, MENU_ITEM_TEXT, MENU_ITEMS, MENU_TYPE, MENU_TYPE_STR_CHOOSE, MENU_TYPE_STR_POWER, MENU_TYPE_STR_V, PLAYING, ProcessMenuItemsByType(), SPLASH, StrToGameState(), StrToMenuType(), UpdatePowerSelectMenu(), UpdatePowerUpMenu(), and UpdateVerticalMenu().
Referenced by LoadMenuData(), and UpdatePowerUpMenu().
void ProcessMenuItemsByType | ( | menu_item_t * | items, |
menu_type_t | type | ||
) |
Sets the positions of the menu items based on the type of layout.
[in,out] | items | If non-null, the items. |
type | The type. |
Definition at line 413 of file menu.c.
References CountMem(), gScreenHeight, gScreenWidth, LargestDivisor(), MENU_TYPE_CHOOSE, MENU_TYPE_GRID, MENU_TYPE_H, MENU_TYPE_POWER, MENU_TYPE_V, SCREEN_RES_H, SCREEN_RES_W, and SDL_SetRect().
Referenced by LoadMenu().
void SelectItemByNum | ( | menu_t * | self, |
int | item | ||
) |
Select item by number.
[in,out] | self | If non-null, the class instance that this method operates on. |
item | The item number to select. |
Definition at line 45 of file menu.c.
References MENU_ITEM_STATE_SELECTED.
Referenced by UpdateVerticalMenu().
int StrToMenuType | ( | char * | str | ) |
Converts a string into a menu type
Definition at line 697 of file menu.c.
References MENU_TYPE_CHOOSE, MENU_TYPE_GRID, MENU_TYPE_H, MENU_TYPE_NULL, MENU_TYPE_POWER, MENU_TYPE_STR_CHOOSE, MENU_TYPE_STR_GRID, MENU_TYPE_STR_H, MENU_TYPE_STR_POWER, MENU_TYPE_STR_V, and MENU_TYPE_V.
Referenced by LoadMenu().
void UpdatePowerSelectMenu | ( | menu_t * | self, |
SDL_GameControllerButton | button | ||
) |
Updates the power select menu, sets current powerup of the player.
[in,out] | self | If non-null, the class instance that this method operates on. |
button | The button. |
Definition at line 234 of file menu.c.
References CountMem(), FindPower(), gCurrentPowerUp, gCurrentPowerUpName, gGameState, gSelectedPowerUps, gUsedPowerUps, InitPlayer(), LoadSelectedLevel(), MENU_ITEM_STATE_NULL, and PLAYING.
Referenced by LoadMenu().
void UpdatePowerUpMenu | ( | menu_t * | self, |
SDL_GameControllerButton | button | ||
) |
Uses mSelectedItem. Updates the menu's selected item, and checks for number of power ups selected, to determine whether to switch game states.
[in,out] | self | If non-null, the class instance that this method operates on. |
button | The button. |
Definition at line 125 of file menu.c.
References CHOOSE, ConvertFileToUseable(), CountMem(), FindObject(), gGameData, gGameObject, gGameState, gLevelsPerGame, gPowerUps, gSelectedPowerUps, GUESS, gUsedPowerUps, JsmnToString(), LoadMenu(), MENU_ITEM_STATE_NOT_SELECTED, MENU_ITEM_STATE_PICKED, ParseToObject(), and SPLASH.
Referenced by LoadMenu().
void UpdateVerticalMenu | ( | menu_t * | self, |
SDL_GameControllerButton | button | ||
) |
Uses gSelectedItem. Updates input and state of menu items.
[in,out] | self | If non-null, the class instance that this method operates on. |
button | The button. |
Definition at line 65 of file menu.c.
References CountMem(), DeselectItemByNum(), gCurrentSelectedItem, gGameState, and SelectItemByNum().
Referenced by LoadMenu().
int gCurrentSelectedItem = 0 |
Definition at line 13 of file menu.c.
Referenced by DrawMenuByNum(), and UpdateVerticalMenu().
menu_t* gMenus = NULL |
Definition at line 12 of file menu.c.
Referenced by DrawChoose(), DrawGuess(), DrawStart(), FindFreeMenu(), FindMenuFromGameState(), InitMenuSystem(), LoadMenuData(), and Update().