1#include <Interface/LayoutGame.hpp>
2#include <Config/Globals.hpp>
3#include <Misc/Utils.hpp>
5LayoutGame::LayoutGame(
Game* game,
int width,
int height):
17LayoutGame::~LayoutGame()
21void LayoutGame::windowsInit()
23 Layout::windowsInit();
24 this->
main->setTitle(
"nsnake " VERSION);
26 if (this->game->currentScore->level.empty())
27 this->
main->setTitle(
"Arcade Mode", Window::TOP_RIGHT);
29 this->
main->setTitle(
"Level " + this->game->board->getMetadata(
"name"), Window::TOP_RIGHT);
32 this->gamewin =
new Window(this->
main,
36 this->
main->getH() - 3);
38 this->info =
new Window(this->
main,
40 this->
main->getH() - 2,
46 this->
main->getW() / 4,
47 this->main->getH() / 2 - 1,
48 this->main->getW() / 2,
51 if (Globals::Screen::show_borders)
53 this->
pause->borders(Globals::Screen::fancy_borders ?
54 Window::BORDER_FANCY :
55 Window::BORDER_REGULAR);
57 this->
pause->setTitle(
"Paused");
61 this->
main->getW() / 4,
62 this->main->getH() / 4,
63 this->main->getW() / 2,
64 this->main->getH() / 2);
66 if (Globals::Screen::show_borders)
68 this->
help->borders(Globals::Screen::fancy_borders ?
69 Window::BORDER_FANCY :
70 Window::BORDER_REGULAR);
72 this->
help->setTitle(
"Help");
74 this->helpWindows =
new WindowGameHelp();
76void LayoutGame::windowsExit()
78 SAFE_DELETE(this->gamewin);
79 SAFE_DELETE(this->info);
80 SAFE_DELETE(this->
pause);
81 SAFE_DELETE(this->
help);
82 SAFE_DELETE(this->boardwin);
83 SAFE_DELETE(this->helpWindows);
86 this->
main->refresh();
88 Layout::windowsExit();
90void LayoutGame::draw(
Menu* menu)
99 int x = this->gamewin->getW()/2 - this->game->board->getW()/2;
100 int y = this->gamewin->getH()/2 - this->game->board->getH()/2;
101 int w = this->game->board->getW();
102 int h = this->game->board->getH();
104 boardwin =
new Window(this->gamewin, x, y, w, h);
111 if (this->game->isPaused && this->game->showPauseMenu)
113 this->
pause->clear();
115 this->
pause->refresh();
121 if (this->game->showHelp)
123 this->helpWindows->run();
124 this->game->showHelp =
false;
134 this->info->print(
"a", 0, 0, 0);
136 ColorPair hilite = Globals::Theme::hilite_text;
138 this->info->print(
"Hi-Score", 0, 0, hilite);
139 this->info->print(
"Score", this->info->getW()/3, 0, hilite);
140 this->info->print(
"Speed", this->info->getW()/3 * 2, 0, hilite);
143 wattrset(this->info->win, COLOR_PAIR(0));
145 if (this->game->scores->highScore)
146 mvwprintw(this->info->win, 0, 9,
"%u", this->game->scores->highScore->points);
148 mvwprintw(this->info->win, 0, this->info->getW()/3 + 6,
"%u", this->game->currentScore->points);
149 mvwprintw(this->info->win, 0, this->info->getW()/3 * 2 + 6,
"%d", this->game->currentScore->speed);
179 this->gamewin->clear();
181 this->game->board->draw(boardwin);
182 this->game->player->draw(boardwin);
183 this->game->fruits->draw(boardwin);
185 this->gamewin->refresh();
186 this->info->refresh();
187 this->
main->refresh();
Window * help
Contains the help screen.
Window * pause
Contains the pause menu.
Interface for how the things are shown on the screen.
Window * main
Layout's main Window, where all the others are inside.