1 #include <Interface/LayoutGame.hpp> 2 #include <Config/Globals.hpp> 3 #include <Misc/Utils.hpp> 5 LayoutGame::LayoutGame(
Game* game,
int width,
int height):
17 LayoutGame::~LayoutGame()
21 void LayoutGame::windowsInit()
23 Layout::windowsInit();
26 if (this->game->currentScore->level.empty())
29 this->
main->
setTitle(
"Level " + this->game->board->getMetadata(
"name"), Window::TOP_RIGHT);
36 this->
main->getH() - 3);
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);
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");
76 void 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();
90 void 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();
114 menu->
draw(this->pause);
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 * win
Ncurses' internal data structure.
A segment of the terminal screen (2D char matrix).
Window * main
Layout's main Window, where all the others are inside.
Specific Window that shows Help and other info during Game.
void setTitle(std::string title, WindowTitlePosition position=Window::TOP_LEFT)
Sets a text that will appear at the top of the Window.
Interface for how the things are shown on the screen.
void print(std::string str, int x, int y, ColorPair pair=0)
Shows text #str at #x #y on the window with color #pair.