Coverage report for gui


src/
File: src/render/scenes/WinScene.cpp
Date: 2024-06-25 10:57:02
Lines:
0/27
0.0%
Functions:
0/3
0.0%
Branches:
0/34
0.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** zappy
4 ** File description:
5 ** WinScene
6 */
7
8 #include "WinScene.hpp"
9 #include "../core/Core.hpp"
10
11 WinScene::WinScene(Core *core)
12 {
13 _text.setFont(core->getFont());
14 _text.setCharacterSize(25);
15 _text.setFillColor(sf::Color::White);
16 _core = core;
17 _quitButton = std::make_shared<Button>(sf::Vector2f(100, 500), sf::Vector2f(100, 100), "Quit", _core->getFont());
18 _homeButton = std::make_shared<Button>(sf::Vector2f(100, 450), sf::Vector2f(100, 100), "Home", _core->getFont());
19 _homeButton->setCallBack(std::bind(&WinScene::getBackHome, this));
20 _win = std::make_shared<Sprite>("./assets/win.png");
21 _win->setScale(1.5f);
22 }
23
24 void WinScene::draw(sf::RenderWindow &window)
25 {
26 sf::Vector2f winSize = window.getView().getSize();
27 _quitButton->setPosition(sf::Vector2f(winSize.x / 2 - 150, winSize.y / 2 + 150));
28 _homeButton->setPosition(sf::Vector2f(winSize.x / 2 + 50, winSize.y / 2 + 150));
29 _quitButton->draw(window);
30 _homeButton->draw(window);
31 _text.setPosition(sf::Vector2f(winSize.x / 2 -_text.getGlobalBounds().width / 2
32 , winSize.y / 2 + 100));
33 _text.setString(_core->_winner + " won the game !");
34 _win->setPosition(sf::Vector2f(winSize.x / 2, winSize.y / 2 - 100));
35 window.draw(_text);
36 _win->draw(window);
37 }
38
39 void WinScene::getBackHome()
40 {
41 if (_core->_server.disconectFromServer() == true)
42 _core->_data.resetGame();
43 _core->_upperState = GameState::DEFAULT;
44 _core->_state = GameState::HOME;
45 }
46