1 #include <Display/WindowGameHelp.hpp> 2 #include <Engine/Graphics/Layout.hpp> 3 #include <Engine/Graphics/Colors.hpp> 4 #include <Engine/EngineGlobals.hpp> 5 #include <Engine/InputManager.hpp> 6 #include <Engine/Helpers/Utils.hpp> 8 WindowGameHelp::WindowGameHelp()
13 int windowx = Layout::screenWidth/2 - width/2;
14 int windowy = Layout::screenHeight/2 - height/2;
16 this->main =
new Window(windowx, windowy, width, height);
21 win =
new Window(this->main, 0, 0, WINDOW_FILL, WINDOW_FILL);
22 win->borders(Window::BORDER_NONE);
24 this->windows.push_back(win);
26 win =
new Window(this->main, 0, 0, WINDOW_FILL, WINDOW_FILL);
27 win->borders(Window::BORDER_NONE);
28 this->windows.push_back(win);
32 int activatedIndex = 0;
38 this->windows[activatedIndex]->clear();
40 this->main->print(((activatedIndex == 0) ?
45 ((activatedIndex == 0) ?
46 EngineGlobals::Theme::textbox :
47 EngineGlobals::Theme::hilite_text));
49 this->main->print(((activatedIndex == 1) ?
54 ((activatedIndex == 1) ?
55 EngineGlobals::Theme::textbox :
56 EngineGlobals::Theme::hilite_text));
63 this->main->print(
"", 0, 0, EngineGlobals::Theme::text);
66 if (activatedIndex == 0)
68 this->windows[0]->print(
"In-game controls:\n",
70 EngineGlobals::Theme::hilite_text);
72 this->windows[0]->print(Utils::String::split(
"Move up\n" 80 EngineGlobals::Theme::hilite_text);
82 this->windows[0]->print(Utils::String::split(InputManager::keyToString(InputManager::getBind(
"up")) +
"\n" +
83 InputManager::keyToString(InputManager::getBind(
"down")) +
"\n" +
84 InputManager::keyToString(InputManager::getBind(
"left")) +
"\n" +
85 InputManager::keyToString(InputManager::getBind(
"right")) +
"\n" +
86 InputManager::keyToString(InputManager::getBind(
"pause")) +
"\n" +
87 InputManager::keyToString(InputManager::getBind(
"quit")) +
"\n" +
88 InputManager::keyToString(InputManager::getBind(
"help")),
'\n'),
90 EngineGlobals::Theme::text);
92 this->windows[0]->print(
"Menu controls:\n",
94 EngineGlobals::Theme::hilite_text);
96 this->windows[0]->print(Utils::String::split(
"First item\n" 99 EngineGlobals::Theme::hilite_text);
101 this->windows[0]->print(Utils::String::split(
"page up\n" 104 EngineGlobals::Theme::text);
106 this->windows[0]->print(Utils::String::split(
" Settings and scores are stored at:\n" 107 " `~/.local/share/nsnake/`",
'\n'),
109 EngineGlobals::Theme::text);
113 else if (activatedIndex == 1)
115 this->windows[1]->print(Utils::String::split(
" _ __ _ __ _ ____ \n" 116 "| |\\ | ( (` | |\\ | / /\\ | |_/ | |_ \n" 117 "|_| \\| _)_) |_| \\| /_/--\\ |_| \\ |_|__",
'\n'),
118 0, 0, Colors::pair(
"blue",
"default",
true));
120 this->windows[1]->print(
" v" VERSION
" (built " DATE
")",
122 Colors::pair(
"green",
"default",
true));
124 this->windows[1]->print(Utils::String::split(
"Try `nsnake --help` and `man nsnake`\n" 126 "Game made by Alexandre Dantas,\n" 127 "contact him at <eu@alexdantas.net>\n" 128 "Thanks for playing this game :)\n" 131 " http://nsnake.alexdantas.net/\n" 133 " https://github.com/alexdantas/nsnake/",
'\n'),
134 0, 5, EngineGlobals::Theme::text);
137 this->windows[activatedIndex]->refresh();
138 this->main->refresh();
142 InputManager::update();
144 if (InputManager::isPressed(
"left") ||
145 InputManager::isPressed(KEY_LEFT))
148 if (activatedIndex < 0)
151 else if (InputManager::isPressed(
"right") ||
152 InputManager::isPressed(KEY_RIGHT))
155 if (activatedIndex > 1)
158 else if (InputManager::isPressed(
"quit") ||
159 InputManager::isPressed(KEY_ENTER) ||
160 InputManager::isPressed(
'\n'))
void run()
Updates and draws all tabs.