RType
TextComponent.hpp
Go to the documentation of this file.
1 /*
2 ** EPITECH PROJECT, 2023
3 ** R-type
4 ** File description:
5 ** R-type
6 */
7 
8 #pragma once
9 
10 #include "Components/AComponent.hpp"
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 class TextComponent : public AComponent
16 {
17  public:
18 
19  /**
20  * @brief Construct a new Text Component:: Text Component object
21  *
22  * @param core
23  * @param socket
24  */
25  explicit TextComponent(ClientCore *core, std::shared_ptr<ClientSocket> socket);
26 
27 
28  /**
29  * @brief display the text
30  *
31  * @param window
32  */
33  void display(sf::RenderWindow &window) override;
34 
35  /**
36  * @brief action
37  */
38  void action() override;
39 
40  /**
41  * @brief setText, set the text
42  *
43  * @param text
44  */
45  void setText(std::string text);
46 
47  /**
48  * @brief setFont, set the font
49  *
50  * @param font
51  */
52  void setFont(const sf::Font &font);
53 
54  /**
55  * @brief setPosition, set the position
56  *
57  * @param position
58  */
59  void setPosition(sf::Vector2f position);
60 
61  /**
62  * @brief setColor, set the color
63  *
64  * @param color
65  */
66  void setColor(sf::Color color);
67 
68  /**
69  * @brief setSize, set the size
70  *
71  * @param size
72  */
73  void setSize(unsigned int size);
74 
75  /**
76  * @brief handleEvent
77  *
78  * @param event
79  * @param window
80  */
81  void handleEvent(const sf::Event &event, sf::RenderWindow &window) override;
82 
83  private:
84  std::string _text;
85  sf::Font _font;
86  sf::Text _sfText;
87  sf::Vector2f _position;
88  sf::Color _color;
89  unsigned int _size{};
90 
91  std::vector<std::unique_ptr<IComponent>> _subComponents;
92  std::vector<std::unique_ptr<IComponent>> _actionTargets;
93  std::shared_ptr<ClientSocket> _socket;
94 };