#include <menu.h>
Public Member Functions | |
bool | out_of_bounds (int row) |
Menu (int _padding, Tile _border) | |
void | move_selection (int direction) |
virtual Menu * | make_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 | |
Game * | game |
Screen | next_screen |
int | selection |
string | title |
Tile | border |
vector< string > | options |
bool | exit |
int | id |
int | padding |
vector< string > | extra_lines |
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.
Menu::Menu | ( | int | _padding, |
Tile | _border | ||
) |
The constructor for the menu.
_padding | Sets the padding for the menu. |
_border | Sets 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/.
void Menu::add_item | ( | string | new_item | ) |
Adds an item to the options.
new_item | Item 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.
|
pure virtual |
The function that handles when a selection is made in the menu. This is the most important function. There are four possibilities:
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.
direction | Always +/- 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.
row | The number to check. |
bool Menu::should_exit | ( | ) |
PUblic accessor for exit.
void Menu::toggle_exit | ( | ) |
Flips the variable exit.
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.
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.