List of selectable items.
More...
#include <Menu.hpp>
|
| Menu (int x, int y, int width, int height) |
| Creates a menu at #x and #y with #width and #height. More...
|
|
void | add (MenuItem *item) |
|
void | addBlank () |
|
void | removeByID (int id) |
| Removes the menu item with #id.
|
|
void | removeByLabel (std::string label) |
| Removes the menu item with #label. More...
|
|
void | draw (Window *window) |
| Draws the whole Menu on #window.
|
|
void | handleInput () |
| Makes the menu react to input, as seen on the global InputManager. More...
|
|
void | goNext () |
| Makes the menu select the next item. More...
|
|
void | goPrevious () |
| Makes the menu select the previous item. More...
|
|
void | goFirst () |
|
void | goLast () |
|
void | goRandom () |
|
bool | willQuit () |
| Tells if the user selected an item that quits the menu.
|
|
std::string | currentLabel () |
| Returns the label of the currently selected item.
|
|
int | currentID () |
| Returns the user-specified id of the selected item.
|
|
bool | getBool (int id) |
| Returns the bool internal value of item that has #id. More...
|
|
int | getInt (int id) |
| Returns the integer value of the item that has #id. More...
|
|
std::string | getString (int id) |
| Returns the string value of the item that has #id. More...
|
|
void | reset () |
| Makes the menu able to be selected again. More...
|
|
|
unsigned int | currentIndex |
| Index of the currently selected item.
|
|
int | x |
|
int | y |
|
int | width |
|
int | height |
|
bool | selected |
| Tells if the user selected an item (pressed Enter).
|
|
MenuItem * | selectedItem |
| Specifies which item the user pressed Enter on.
|
|
List of selectable items.
- Warning
- When adding items, make sure they're allocated dynamically! I mean POINTERS, damn it. Otherwise SEGFAULTS when trying to delete static stuff.
-
If you create a menu full of null elements (with #addBlank()), it'll probably get into an infinite loop when you call goNext() or goPrevious. I still have to find a way to fix this.
Definition at line 28 of file Menu.hpp.
Menu::Menu |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
width, |
|
|
int |
height |
|
) |
| |
Creates a menu at #x and #y with #width and #height.
It isn't attached to any specific Window, except when you call Menu::draw().
Definition at line 6 of file Menu.cpp.
bool Menu::getBool |
( |
int |
id | ) |
|
Returns the bool internal value of item that has #id.
- Note
- Meaning the item must be a MenuItemCheckbox.
Definition at line 350 of file Menu.cpp.
int Menu::getInt |
( |
int |
id | ) |
|
Returns the integer value of the item that has #id.
- Note
- Meaning the item must be a MenuItemNumberbox.
Definition at line 372 of file Menu.cpp.
std::string Menu::getString |
( |
int |
id | ) |
|
Makes the menu select the next item.
- Note
- This is a recursive function to guarantee we'll always point to a non-nil element.
Definition at line 226 of file Menu.cpp.
void Menu::goPrevious |
( |
| ) |
|
Makes the menu select the previous item.
- Note
- This is a recursive function to guarantee we'll always point to a non-nil element.
Definition at line 259 of file Menu.cpp.
void Menu::handleInput |
( |
| ) |
|
Makes the menu react to input, as seen on the global InputManager.
Definition at line 183 of file Menu.cpp.
void Menu::removeByLabel |
( |
std::string |
label | ) |
|
Removes the menu item with #label.
- Note
- It'll delete the first entry found with #label.
- Warning
- This is far more unreliable than #removeById(), provided you have unique IDs.
Definition at line 71 of file Menu.cpp.
Makes the menu able to be selected again.
When the user selects an item, willQuit() returns true. By calling this function, you make possible to select things again.
Definition at line 424 of file Menu.cpp.
Current item selected.
- Note
- It's public because we might want to change current item's attributes. Don't mess with the pointer itself!
Definition at line 115 of file Menu.hpp.
The documentation for this class was generated from the following files: