nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
MenuItemLabel.cpp
1#include <Interface/Menu/MenuItemLabel.hpp>
2#include <Config/Globals.hpp>
3
4MenuItemLabel::MenuItemLabel(std::string label, int id, std::string rightLabel):
5 MenuItem(label, id),
6 rightLabel(rightLabel)
7{
8 this->type = MenuItem::LABEL;
9}
10
11void MenuItemLabel::draw(Window* window, int x, int y, int width, bool hilite)
12{
13 unsigned int rightLabelSize = this->rightLabel.size();
14
15 MenuItem::draw(window, x, y, width - rightLabelSize - 1, hilite);
16
17 window->print(this->rightLabel,
18 x + width - rightLabelSize,
19 y,
20 ((hilite) ?
21 Globals::Theme::hilite_text:
22 Globals::Theme::text));
23}
24
27
28void MenuItemLabel::set(std::string str)
29{
30 this->rightLabel = str;
31}
32
A segment of the terminal screen (2D char matrix).
Definition Window.hpp:17
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
void handleInput()
Makes the menu item react to input, as seen on the global InputManager.
void draw(Window *window, int x, int y, int width, bool hilite=false)
Shows this item at #x, #y with #width.
Simplest type of item possible, with a label and user-defined id.
Definition MenuItem.hpp:12
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