nsnake
Classic snake game for the terminal
Main Page
Namespaces
Classes
Files
File List
src
Interface
Menu
Menu.hpp
1
#ifndef MENU_H_DEFINED
2
#define MENU_H_DEFINED
3
4
#include <Interface/Window.hpp>
5
#include <Interface/Menu/MenuItem.hpp>
6
#include <Interface/Menu/MenuItemLabel.hpp>
7
#include <Interface/Menu/MenuItemCheckbox.hpp>
8
#include <Interface/Menu/MenuItemNumberbox.hpp>
9
#include <Interface/Menu/MenuItemTextbox.hpp>
10
#include <Interface/Menu/MenuItemTextlist.hpp>
11
12
#include <vector>
13
#include <string>
14
28
class
Menu
29
{
30
public
:
35
Menu
(
int
x,
int
y,
int
width,
int
height);
36
37
virtual
~
Menu
();
38
39
void
add(
MenuItem
*
item
);
40
void
addBlank();
41
43
void
removeByID
(
int
id
);
44
52
void
removeByLabel
(std::string label);
53
55
void
draw
(
Window
* window);
56
59
void
handleInput
();
60
64
void
goNext
();
65
69
void
goPrevious
();
70
71
void
goFirst();
72
void
goLast();
73
void
goRandom();
74
76
bool
willQuit
();
77
79
std::string
currentLabel
();
80
82
int
currentID
();
83
86
bool
getBool
(
int
id
);
87
90
int
getInt
(
int
id
);
91
95
std::string
getString
(
int
id
);
96
103
void
reset
();
104
105
// FIXME: create an iterator so I dont need to expose
106
// this vector
107
109
std::vector<MenuItem*>
item
;
110
115
MenuItem
*
current
;
116
117
protected
:
119
unsigned
int
currentIndex
;
120
121
int
x;
122
int
y;
123
int
width;
124
int
height;
125
127
bool
selected
;
128
130
MenuItem
*
selectedItem
;
131
};
132
133
#endif //MENU_H_DEFINED
134
Menu::handleInput
void handleInput()
Makes the menu react to input, as seen on the global InputManager.
Definition:
Menu.cpp:183
Menu::reset
void reset()
Makes the menu able to be selected again.
Definition:
Menu.cpp:424
Menu::selectedItem
MenuItem * selectedItem
Specifies which item the user pressed Enter on.
Definition:
Menu.hpp:130
Menu::goNext
void goNext()
Makes the menu select the next item.
Definition:
Menu.cpp:226
Window
A segment of the terminal screen (2D char matrix).
Definition:
Window.hpp:16
Menu::current
MenuItem * current
Current item selected.
Definition:
Menu.hpp:115
Menu::currentLabel
std::string currentLabel()
Returns the label of the currently selected item.
Definition:
Menu.cpp:336
Menu::getString
std::string getString(int id)
Returns the string value of the item that has #id.
Definition:
Menu.cpp:394
Menu::removeByID
void removeByID(int id)
Removes the menu item with #id.
Definition:
Menu.cpp:47
Menu::getBool
bool getBool(int id)
Returns the bool internal value of item that has #id.
Definition:
Menu.cpp:350
Menu::getInt
int getInt(int id)
Returns the integer value of the item that has #id.
Definition:
Menu.cpp:372
Menu::Menu
Menu(int x, int y, int width, int height)
Creates a menu at #x and #y with #width and #height.
Definition:
Menu.cpp:6
Menu::goPrevious
void goPrevious()
Makes the menu select the previous item.
Definition:
Menu.cpp:259
Menu::willQuit
bool willQuit()
Tells if the user selected an item that quits the menu.
Definition:
Menu.cpp:330
Menu::draw
void draw(Window *window)
Draws the whole Menu on #window.
Definition:
Menu.cpp:95
Menu::currentIndex
unsigned int currentIndex
Index of the currently selected item.
Definition:
Menu.hpp:119
Menu::item
std::vector< MenuItem * > item
Container of all the options inside the menu.
Definition:
Menu.hpp:109
Menu::selected
bool selected
Tells if the user selected an item (pressed Enter).
Definition:
Menu.hpp:127
MenuItem
Simplest type of item possible, with a label and user-defined id.
Definition:
MenuItem.hpp:11
Menu
List of selectable items.
Definition:
Menu.hpp:28
Menu::removeByLabel
void removeByLabel(std::string label)
Removes the menu item with #label.
Definition:
Menu.cpp:71
Menu::currentID
int currentID()
Returns the user-specified id of the selected item.
Definition:
Menu.cpp:343
Generated on Wed Aug 24 2016 02:49:12 for nsnake by
1.8.11