nsnake
Classic snake game for the terminal
Main Page
Namespaces
Classes
Files
File List
src
Interface
Menu
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
}
19
void
MenuItem::handleInput
()
20
{ }
21
Window
A segment of the terminal screen (2D char matrix).
Definition:
Window.hpp:16
MenuItem
Simplest type of item possible, with a label and user-defined id.
Definition:
MenuItem.hpp:11
MenuItem::draw
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::MenuItem
MenuItem(std::string label, int id)
Create a MenuItem, with user-defined id.
Definition:
MenuItem.cpp:6
MenuItem::handleInput
virtual void handleInput()
Makes the menu item react to input, as seen on the global InputManager.
Definition:
MenuItem.cpp:19
MenuItem::label
std::string label
Text that will be shown on the screen.
Definition:
MenuItem.hpp:54
Window::print
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
Generated on Wed Aug 24 2016 02:49:12 for nsnake by
1.8.11