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.
|
|
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.
|
|
void | draw (Window *window) |
| Draws the whole Menu on #window.
|
|
void | handleInput () |
| Makes the menu react to input, as seen on the global InputManager.
|
|
void | goNext () |
| Makes the menu select the next item.
|
|
void | goPrevious () |
| Makes the menu select the previous item.
|
|
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.
|
|
int | getInt (int id) |
| Returns the integer value of the item that has #id.
|
|
std::string | getString (int id) |
| Returns the string value of the item that has #id.
|
|
void | reset () |
| Makes the menu able to be selected again.
|
|
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::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.
◆ ~Menu()
◆ add()
◆ addBlank()
◆ currentID()
Returns the user-specified id of the selected item.
Definition at line 343 of file Menu.cpp.
◆ currentLabel()
std::string Menu::currentLabel |
( |
| ) |
|
Returns the label of the currently selected item.
Definition at line 336 of file Menu.cpp.
◆ draw()
void Menu::draw |
( |
Window * | window | ) |
|
Draws the whole Menu on #window.
Definition at line 95 of file Menu.cpp.
◆ getBool()
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.
◆ getInt()
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.
◆ getString()
std::string Menu::getString |
( |
int | id | ) |
|
◆ goFirst()
◆ goLast()
◆ goNext()
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.
◆ goPrevious()
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.
◆ goRandom()
◆ handleInput()
void Menu::handleInput |
( |
| ) |
|
Makes the menu react to input, as seen on the global InputManager.
Definition at line 183 of file Menu.cpp.
◆ removeByID()
void Menu::removeByID |
( |
int | id | ) |
|
Removes the menu item with #id.
Definition at line 47 of file Menu.cpp.
◆ removeByLabel()
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.
◆ reset()
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.
◆ willQuit()
Tells if the user selected an item that quits the menu.
Definition at line 330 of file Menu.cpp.
◆ current
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.
◆ currentIndex
unsigned int Menu::currentIndex |
|
protected |
Index of the currently selected item.
Definition at line 119 of file Menu.hpp.
◆ height
◆ item
Container of all the options inside the menu.
Definition at line 109 of file Menu.hpp.
◆ selected
Tells if the user selected an item (pressed Enter).
Definition at line 127 of file Menu.hpp.
◆ selectedItem
Specifies which item the user pressed Enter on.
Definition at line 130 of file Menu.hpp.
◆ width
The documentation for this class was generated from the following files: