1 #include <Interface/WindowGameHelp.hpp> 2 #include <Interface/Layout.hpp> 3 #include <Interface/Colors.hpp> 4 #include <Config/Globals.hpp> 5 #include <Flow/InputManager.hpp> 6 #include <Misc/Utils.hpp> 8 WindowGameHelp::WindowGameHelp()
16 this->main =
new Window(windowx,
21 if (Globals::Screen::show_borders)
23 this->main->borders(Globals::Screen::fancy_borders ?
24 Window::BORDER_FANCY :
25 Window::BORDER_REGULAR);
31 win =
new Window(this->main, 0, 0, WINDOW_FILL, WINDOW_FILL);
32 this->windows.push_back(win);
34 win =
new Window(this->main, 0, 0, WINDOW_FILL, WINDOW_FILL);
35 this->windows.push_back(win);
39 int activatedIndex = 0;
45 this->windows[activatedIndex]->clear();
47 this->main->
print(((activatedIndex == 0) ?
52 ((activatedIndex == 0) ?
53 Globals::Theme::textbox :
54 Globals::Theme::hilite_text));
56 this->main->
print(((activatedIndex == 1) ?
61 ((activatedIndex == 1) ?
62 Globals::Theme::textbox :
63 Globals::Theme::hilite_text));
67 Colors::pairActivate(this->main->
win, Globals::Theme::text);
70 if (activatedIndex == 0)
72 this->windows[0]->print(
"In-game controls:\n",
74 Globals::Theme::hilite_text);
76 this->windows[0]->print(Utils::String::split(
"Move up\n" 84 Globals::Theme::hilite_text);
86 this->windows[0]->print(Utils::String::split(InputManager::keyToString(InputManager::getBind(
"up")) +
"\n" +
87 InputManager::keyToString(InputManager::getBind(
"down")) +
"\n" +
88 InputManager::keyToString(InputManager::getBind(
"left")) +
"\n" +
89 InputManager::keyToString(InputManager::getBind(
"right")) +
"\n" +
90 InputManager::keyToString(InputManager::getBind(
"pause")) +
"\n" +
91 InputManager::keyToString(InputManager::getBind(
"quit")) +
"\n" +
92 InputManager::keyToString(InputManager::getBind(
"help")),
'\n'),
94 Globals::Theme::text);
96 this->windows[0]->print(
"Menu controls:\n",
98 Globals::Theme::hilite_text);
100 this->windows[0]->print(Utils::String::split(
"First item\n" 103 Globals::Theme::hilite_text);
105 this->windows[0]->print(Utils::String::split(
"page up\n" 108 Globals::Theme::text);
110 this->windows[0]->print(Utils::String::split(
" Settings and scores are stored at:\n" 111 " `~/.local/share/nsnake/`",
'\n'),
113 Globals::Theme::text);
117 else if (activatedIndex == 1)
119 this->windows[1]->print(Utils::String::split(
" _ __ _ __ _ ____ \n" 120 "| |\\ | ( (` | |\\ | / /\\ | |_/ | |_ \n" 121 "|_| \\| _)_) |_| \\| /_/--\\ |_| \\ |_|__",
'\n'),
122 0, 0, Colors::pair(COLOR_BLUE, COLOR_DEFAULT,
true));
124 this->windows[1]->print(
" v" VERSION
" (built " DATE
")",
126 Colors::pair(COLOR_GREEN, COLOR_DEFAULT,
true));
128 this->windows[1]->print(Utils::String::split(
"Try `nsnake --help` and `man nsnake`\n" 130 "Game made by Alexandre Dantas,\n" 131 "contact him at <eu@alexdantas.net>\n" 132 "Thanks for playing this game :)\n" 135 " http://nsnake.alexdantas.net/\n" 137 " https://github.com/alexdantas/nsnake/",
'\n'),
138 0, 5, Globals::Theme::text);
141 this->windows[activatedIndex]->refresh();
142 this->main->refresh();
146 InputManager::update();
148 if (InputManager::isPressed(
"left") ||
149 InputManager::isPressed(KEY_LEFT))
152 if (activatedIndex < 0)
155 else if (InputManager::isPressed(
"right") ||
156 InputManager::isPressed(KEY_RIGHT))
159 if (activatedIndex > 1)
162 else if (InputManager::isPressed(
"quit") ||
163 InputManager::isPressed(KEY_ENTER) ||
164 InputManager::isPressed(
'\n'))
WINDOW * win
Ncurses' internal data structure.
A segment of the terminal screen (2D char matrix).
static int screenWidth
Full width of the terminal right now.
void print(std::string str, int x, int y, ColorPair pair=0)
Shows text #str at #x #y on the window with color #pair.
static int screenHeight
Full height of the terminal right now.
void run()
Updates and draws all tabs.