R-Type
R-Type project
UiText.hpp
1 /*
2 ** EPITECH PROJECT, 2022
3 ** gameEngine2
4 ** File description:
5 ** Text
6 */
7 
8 #ifndef UITEXT_HPP_
9 #define UITEXT_HPP_
10 
11 #include "Vectors.hpp"
12 #include "Colors.hpp"
13 
14 #include "Component.hpp"
15 
16 namespace KapEngine {
17 
18  class Component;
19 
20  namespace Tools {
21  class Color;
22  class Vector2;
23  }
24 }
25 
26 namespace KapEngine {
27 
28  namespace UI {
29 
30  class Text : public Component {
31  public:
32  Text(std::shared_ptr<GameObject> &go, std::string const& textContent = "");
33  ~Text();
34 
35  void setFont(std::string const& fontPath) {
36  PROFILER_FUNC_START();
37  _pathFont = fontPath;
38  PROFILER_FUNC_END();
39  }
40 
41  void setText(std::string const& text) {
42  PROFILER_FUNC_START();
43  _content = text;
44  PROFILER_FUNC_END();
45  }
46 
47  void setTextColor(Tools::Color const& color) {
48  PROFILER_FUNC_START();
49  _color = color;
50  PROFILER_FUNC_END();
51  }
52 
53  void setSpace(float space) {
54  PROFILER_FUNC_START();
55  _space = space;
56  PROFILER_FUNC_END();
57  }
58 
59  void setPoliceSize(float police) {
60  PROFILER_FUNC_START();
61  _police = police;
62  PROFILER_FUNC_END();
63  }
64 
65  std::string getFontPath() const {
66  PROFILER_FUNC_START();
67  PROFILER_FUNC_END();
68  return _pathFont;
69  }
70 
71  std::string getText() const {
72  return _content;
73  }
74 
75  Tools::Color getColor() const {
76  PROFILER_FUNC_START();
77  PROFILER_FUNC_END();
78  return _color;
79  }
80 
81  float getSpace() const {
82  PROFILER_FUNC_START();
83  PROFILER_FUNC_END();
84  return _space;
85  }
86 
87  float getPoliceSize() const {
88  PROFILER_FUNC_START();
89  PROFILER_FUNC_END();
90  return _police;
91  }
92 
93  void onAwake() override;
94  void onDisplay() override;
95  bool checkComponentValidity() override;
96 
97  Tools::Vector2 getCalculatedPos();
98  Tools::Vector2 getCalculatedScale();
99 
100  protected:
101  private:
102  float _space = 0.5f;
103  float _police = 15.0f;
104  Tools::Color _color;
105  std::string _content = "";
106  std::string _pathFont = "";
107  Tools::Vector2 _lastScale;
108  Tools::Vector2 _lastCompare;
109  Tools::Vector2 _lastPos;
110  Tools::Vector2 _lastScaleWant;
111  Tools::Vector2 _lastPosWant;
112  };
113 
114  }
115 
116 }
117 
118 #endif /* !UITEXT_HPP_ */
KapEngine::UI::Text::onAwake
void onAwake() override
call component awake
Definition: UiText.cpp:24
KapEngine::UI::Text
Definition: UiText.hpp:30
KapEngine::UI::Text::checkComponentValidity
bool checkComponentValidity() override
Check you component is runnable With this function you can add some conditions to make your component...
Definition: UiText.cpp:52
KapEngine::Component
Definition: Component.hpp:38
KapEngine::Tools::Vector2
Definition: Vectors.hpp:25
KapEngine::Tools::Color
Definition: Colors.hpp:22
KapEngine
main namespace
Definition: Component.hpp:17
KapEngine::UI::Text::onDisplay
void onDisplay() override
use to display some things this function is call after all updates fucntion
Definition: UiText.cpp:40