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();
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);
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();
123 this->helpWindows->
run();
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));
146 mvwprintw(this->info->
win, 0, 9,
"%u", this->game->scores->highScore->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();
ScoreEntry * highScore
Maximum high score obtained for the current game.
bool showHelp
If it's showing the help screen.
WINDOW * win
Ncurses' internal data structure.
std::string level
On which level the user made this score.
A segment of the terminal screen (2D char matrix).
std::string getMetadata(std::string name)
Gets a meta information from this level.
Window * main
Layout's main Window, where all the others are inside.
Specific Window that shows Help and other info during Game.
Window * help
Contains the help screen.
Window * pause
Contains the pause menu.
void setTitle(std::string title, WindowTitlePosition position=Window::TOP_LEFT)
Sets a text that will appear at the top of the Window.
unsigned int points
How many points the user got.
Interface for how the things are shown on the screen.
ScoreEntry * currentScore
Current score for this level.
void print(std::string str, int x, int y, ColorPair pair=0)
Shows text #str at #x #y on the window with color #pair.
unsigned int speed
Under which game speed the score was made.
void run()
Updates and draws all tabs.
bool isPaused
If the game is paused.
ScoreFile * scores
All the current level's score.