Roguelike
 All Classes Namespaces Functions Variables Typedefs Friends Pages
Public Member Functions | Public Attributes | List of all members
Menu Class Referenceabstract

#include <menu.h>

Inheritance diagram for Menu:
AudioMenu EquipmentMenu EquipMenu EscapeMenu FontMenu InfoMenu InventoryMenu ItemMenu MainMenu StartMenu

Public Member Functions

bool out_of_bounds (int row)
 
 Menu (int _padding, Tile _border)
 
void move_selection (int direction)
 
virtual Menumake_selection ()=0
 
void add_item (string new_item)
 
bool should_exit ()
 
int get_selection ()
 
void toggle_exit ()
 
Screen get_screen ()
 
int get_id ()
 
int num_extra_lines ()
 
vector< string > get_extra_lines ()
 

Public Attributes

Gamegame
 
Screen next_screen
 
int selection
 
string title
 
Tile border
 
vector< string > options
 
bool exit
 
int id
 
int padding
 
vector< string > extra_lines
 

Detailed Description

The basis of the menuing system for the roguelike. Each different type of menu is going to be a subclass that overloads the make_selection() function to provide different functionality. See the documentation for make_selection for more detail.

Constructor & Destructor Documentation

Menu::Menu ( int  _padding,
Tile  _border 
)

The constructor for the menu.

Parameters
_paddingSets the padding for the menu.
_borderSets the border for the menu.

MAIN_MENU.CPP

This file is part of ROGUELIKETHING.

ROGUELIKETHING is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ROGUELIKETHING is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROGUELIKETHING. If not, see http://www.gnu.org/licenses/.

Member Function Documentation

void Menu::add_item ( string  new_item)

Adds an item to the options.

Parameters
new_itemItem to add to the menu.
vector< string > Menu::get_extra_lines ( )

Public accessor for extra_lines.

int Menu::get_id ( )

Public accessor for the id.

Screen Menu::get_screen ( )

Returns the screen to switch to upon exit.

int Menu::get_selection ( )

Public accessor for selection.

virtual Menu* Menu::make_selection ( )
pure virtual

The function that handles when a selection is made in the menu. This is the most important function. There are four possibilities:

  1. The selection just transitions to a new menu. The menu returned will be the new menu.
  2. The selection just performs a function and then returns to the same menu. In this case, "this" will be returned and nothing else will happen.
  3. The selection causes an exit of the menu screen. When this happens, "this" will be returned and should_exit will be toggled. On the next pass, the game_state will then transition to the next_screen.
  4. The function returns NULL, in which case the game is exited. There's no reason that 2 & 3 can't be combined.

Implemented in InfoMenu, FontMenu, AudioMenu, EscapeMenu, EquipMenu, ItemMenu, InventoryMenu, EquipmentMenu, MainMenu, and StartMenu.

void Menu::move_selection ( int  direction)

Changes the currently selected menu option.

Parameters
directionAlways +/- 1, determines whether the selection goes up or down.
int Menu::num_extra_lines ( )

Public accessor for number of extra_lines.

bool Menu::out_of_bounds ( int  row)

Checks whether or not a selection is out of the bounds of the menu.

Parameters
rowThe number to check.
Returns
True if the option is larger than the size of the list or smaller than 0.
bool Menu::should_exit ( )

PUblic accessor for exit.

void Menu::toggle_exit ( )

Flips the variable exit.

Member Data Documentation

Tile Menu::border

The tile which is used as a background for the menu. It occurs to me that this is actually a background, now a border.

Todo:
Make this an actual border.
bool Menu::exit

Whether or not the menu screen should be closed. This exits out of the entire menuing system, not just one menu.

vector<string> Menu::extra_lines

Anything extra to be displayed in a menu. This is pertinent if more information needs to be given by a menu ( as in the case of the InfoMenu).

Game* Menu::game

An instance of game which allows the menu to interact with most objects in the game. This is in the menu so that the menu is able to access information about almost everything (characters, items, chunks, etc.) so that accessing the menu actually does something instead of...well...nothing.

int Menu::id

A numerical id for the menu. Each type of menu has a different id.

Screen Menu::next_screen

The game state to switch to after closing the menu system. This usually becomes GAME_SCREEN, but not always. This refers to when you close the entire menuing system, not when you switch between two menus, as it will stay with the MENU_SCREEN.

vector<string> Menu::options

The possible options which can be chosen for the menu.

int Menu::padding

The distance between the menu text and the edge of the menu area.

int Menu::selection

The menu item which is currently selected (corresponds to an index in options).

string Menu::title

The title of the menu.


The documentation for this class was generated from the following files: