Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** zappy |
4 |
|
|
** File description: |
5 |
|
|
** WorldUi |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef WORLDUI_HPP_ |
9 |
|
|
#define WORLDUI_HPP_ |
10 |
|
|
|
11 |
|
|
#include "../../IScene.hpp" |
12 |
|
|
#include "../../../ui/AdvancedButton.hpp" |
13 |
|
|
#include <vector> |
14 |
|
|
#include <memory> |
15 |
|
|
#include "../../../sprites/Sprite.hpp" |
16 |
|
|
|
17 |
|
|
class World; |
18 |
|
|
|
19 |
|
|
class WorldUi : public IScene { |
20 |
|
|
public: |
21 |
|
|
enum panelState { |
22 |
|
|
TROPHY, |
23 |
|
|
FLAG, |
24 |
|
|
TRANTORIAN, |
25 |
|
|
NONE |
26 |
|
|
}; |
27 |
|
✗ |
WorldUi(World *world) |
28 |
|
✗ |
{ |
29 |
|
✗ |
_world = world; |
30 |
|
✗ |
_layer1.push_back(std::make_shared<AdvancedButton>("./assets/flags/trophyButton.png", sf::Vector2f(0, 16*4 * 0), sf::Vector2f(16, 16), 4)); |
31 |
|
✗ |
_layer1.push_back(std::make_shared<AdvancedButton>("./assets/flags/flagButton.png", sf::Vector2f(0, 16*4 * 1), sf::Vector2f(16, 16), 4)); |
32 |
|
✗ |
_layer1.push_back(std::make_shared<AdvancedButton>("./assets/flags/trantorianButton.png", sf::Vector2f(0, 16*4 * 2), sf::Vector2f(16, 16), 4)); |
33 |
|
✗ |
_layer2["closeButton"] = std::make_shared<AdvancedButton>("./assets/flags/closeButton.png", sf::Vector2f(16 * 4 *7, 0), sf::Vector2f(16, 16), 4); |
34 |
|
✗ |
_layer2["prevButton"] = std::make_shared<AdvancedButton>("./assets/flags/prevButton.png", sf::Vector2f(16 * 4 + 8, 32), sf::Vector2f(16, 16), 4); |
35 |
|
✗ |
_layer2["nextButton"] = std::make_shared<AdvancedButton>("./assets/flags/nextButton.png", sf::Vector2f(16 * 4 * 6 - 8, 32), sf::Vector2f(16, 16), 4); |
36 |
|
✗ |
_layer2["lookButton"] = std::make_shared<AdvancedButton>("./assets/flags/lookButton.png", sf::Vector2f(16 * 4 * 6 - 8, 96), sf::Vector2f(16, 16), 4); |
37 |
|
✗ |
_sprites["inventory"] = std::make_shared<Sprite>("./assets/inventory.png"); |
38 |
|
✗ |
_sprites["food"] = std::make_shared<Sprite>("./assets/ressources/food.png"); |
39 |
|
✗ |
_sprites["trantorian"] = std::make_shared<Sprite>("./assets/trantorian.png"); |
40 |
|
✗ |
_sprites["trophyPanel"] = std::make_shared<Sprite>("./assets/flags/trophyPanel.png"); |
41 |
|
✗ |
_sprites["trophyPanel"]->setPosition(sf::Vector2f(16 * 4, 0)); |
42 |
|
✗ |
_sprites["trophyPanel"]->resetOrigin(); |
43 |
|
✗ |
_sprites["trophyPanel"]->setScale(4); |
44 |
|
✗ |
_sprites["trantorianPanel"] = std::make_shared<Sprite>("./assets/flags/trantorianPanel.png"); |
45 |
|
✗ |
_sprites["trantorianPanel"]->setPosition(sf::Vector2f(16 * 4, 0)); |
46 |
|
✗ |
_sprites["trantorianPanel"]->resetOrigin(); |
47 |
|
✗ |
_sprites["trantorianPanel"]->setScale(4); |
48 |
|
✗ |
_sprites["flagPanel"] = std::make_shared<Sprite>("./assets/flags/flagPanel.png"); |
49 |
|
✗ |
_sprites["flagPanel"]->setPosition(sf::Vector2f(16 * 4, 0)); |
50 |
|
✗ |
_sprites["flagPanel"]->resetOrigin(); |
51 |
|
✗ |
_sprites["flagPanel"]->setScale(4); |
52 |
|
✗ |
_sprites["bousolle"] = std::make_shared<Sprite>("./assets/bousolle.png"); |
53 |
|
✗ |
_sprites["bousolle"]->setScale(0.5); |
54 |
|
✗ |
_font.loadFromFile("assets/BadComic-Regular.ttf"); |
55 |
|
✗ |
_inventoryText = sf::Text("", _font, 25); |
56 |
|
✗ |
} |
57 |
|
✗ |
~WorldUi() {} |
58 |
|
|
|
59 |
|
|
void init() override; |
60 |
|
|
bool update(sf::Event event, sf::RenderWindow &window) override; |
61 |
|
|
void update(float fElapsedTime) override; |
62 |
|
|
void draw(sf::RenderWindow &window) override; |
63 |
|
|
|
64 |
|
|
void drawInventoryTile(int nb, sf::RenderWindow &window, std::string name); |
65 |
|
|
void drawRanking(sf::RenderWindow &window); |
66 |
|
|
void drawTeam(sf::RenderWindow &window); |
67 |
|
|
void drawTrantorian(sf::RenderWindow &window); |
68 |
|
|
|
69 |
|
|
void drawTileInventory(sf::RenderWindow &window); |
70 |
|
|
void drawPlayerInventory(sf::RenderWindow &window); |
71 |
|
|
|
72 |
|
✗ |
panelState getPanelState() { return _panelState; } |
73 |
|
|
int _idPlayer = 0; |
74 |
|
|
int _idTeam = 0; |
75 |
|
|
|
76 |
|
|
protected: |
77 |
|
|
private: |
78 |
|
|
World *_world; |
79 |
|
|
std::vector<std::shared_ptr<AdvancedButton>> _layer1; |
80 |
|
|
std::map<std::string, std::shared_ptr<AdvancedButton>> _layer2; |
81 |
|
|
std::map<std::string, std::shared_ptr<Sprite>> _sprites; |
82 |
|
|
sf::Text _inventoryText; |
83 |
|
|
panelState _panelState = NONE; |
84 |
|
|
sf::Font _font; |
85 |
|
|
|
86 |
|
|
}; |
87 |
|
|
|
88 |
|
|
#endif /* !WORLDUI_HPP_ */ |
89 |
|
|
|