nsnake
Classic snake game for the terminal
MenuItem.cpp
1 #include <Interface/Menu/MenuItem.hpp>
2 #include <Config/Globals.hpp>
3 #include <Misc/Utils.hpp>
4 #include <Flow/InputManager.hpp>
5 
6 MenuItem::MenuItem(std::string label, int id):
7  type(MenuItem::ITEM),
8  label(label),
9  id(id)
10 { }
11 
12 void MenuItem::draw(Window* window, int x, int y, int width, bool hilite)
13 {
14  window->print(this->label.substr(0, width), x, y,
15  ((hilite) ?
16  Globals::Theme::hilite_text:
17  Globals::Theme::text));
18 }
20 { }
21 
A segment of the terminal screen (2D char matrix).
Definition: Window.hpp:16
Simplest type of item possible, with a label and user-defined id.
Definition: MenuItem.hpp:11
virtual void draw(Window *window, int x, int y, int width, bool hilite=false)
Shows this item at #x, #y with #width.
Definition: MenuItem.cpp:12
MenuItem(std::string label, int id)
Create a MenuItem, with user-defined id.
Definition: MenuItem.cpp:6
virtual void handleInput()
Makes the menu item react to input, as seen on the global InputManager.
Definition: MenuItem.cpp:19
std::string label
Text that will be shown on the screen.
Definition: MenuItem.hpp:54
void print(std::string str, int x, int y, ColorPair pair=0)
Shows text #str at #x #y on the window with color #pair.
Definition: Window.cpp:94