summaryrefslogtreecommitdiff
path: root/src/View/MainWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/View/MainWindow.cpp')
-rw-r--r--src/View/MainWindow.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/View/MainWindow.cpp b/src/View/MainWindow.cpp
index ea4346d..3a61068 100644
--- a/src/View/MainWindow.cpp
+++ b/src/View/MainWindow.cpp
@@ -13,17 +13,14 @@ MainWindow::MainWindow(int width, int height, std::string title):
m_gridSize(0,0),
m_gridPosition(),
m_spaceBetweenCell(15),
+ m_skinName("original"),
m_font()
{
//Set windows size
m_windowSize=RenderWindow::getSize();
-
- m_gridPosition=sf::Vector2u(0,200);
-
-
- //Load font
- m_font.loadFromFile("./src/skin/original/Pragmatica-Medium.ttf");
+ //Set default grid position
+ m_gridPosition=sf::Vector2u(0,200);
//Define original skin:
m_skin.push_back(sf::Color(250,248,239)); //Background MainWindow
@@ -54,6 +51,9 @@ MainWindow::MainWindow(int width, int height, std::string title):
//Skin for other number
m_skin.push_back(sf::Color(60,58,50)); //More than 2048
+ //Load font
+ m_font.loadFromFile("./bin/fonts/Pragmatica-Medium.ttf");
+ m_skin=skin::loadSkin(m_skinName);
}
@@ -140,7 +140,7 @@ void MainWindow::drawCell(int x, int y, int value){
text.setFont(m_font);
text.setStyle(sf::Text::Bold);
text.setCharacterSize(fontSize);
- text.setString(valueString);
+ text.setString(valueString);
if(value==2 || value==4)
text.setColor(m_skin.at(3));
else
@@ -173,7 +173,7 @@ sf::Color MainWindow::getCellColor(int value){
}
void MainWindow::drawGameOver(int gridX, int gridY){
-
+
sf::RectangleShape gridShape(sf::Vector2f(m_gridSize.x,m_gridSize.y));
gridShape.setFillColor(m_skin.at(6));
gridShape.setPosition(gridX,gridY);
@@ -187,14 +187,14 @@ void MainWindow::drawATH(Stats stats){
int titleY=m_gridPosition.y-190;
- //==================== Draw title ====================
+ //==================== Draw title ====================
sf::Text text;
text.setFont(m_font);
text.setStyle(sf::Text::Bold);
text.setCharacterSize(80);
text.setColor(m_skin.at(3));
text.setPosition(titleX,titleY);
- text.setString("2048");
+ text.setString("2048");
RenderWindow::draw(text);
@@ -221,7 +221,7 @@ void MainWindow::drawATH(Stats stats){
RenderWindow::draw(text);
//==================== Draw score ====================
-
+
int scoreX=bestScoreX-bestScoreSizeX-5;
int scoreY=bestScoreY;
int scoreSizeX=bestScoreSizeX;
@@ -253,3 +253,4 @@ void MainWindow::drawGame(std::vector<std::vector<int> > grid, bool gameIsOver,
this->drawGrid(grid,gameIsOver);
this->drawATH(stats);
}
+