R-Type
R-Type project
UiFactory.hpp
1 /*
2 ** EPITECH PROJECT, 2022
3 ** gameEngine2
4 ** File description:
5 ** Factory
6 */
7 
8 #ifndef UI_FACTORY_HPP_
9 #define UI_FACTORY_HPP_
10 
11 #include "Factory.hpp"
12 #include "GameObject.hpp"
13 #include "UiImage.hpp"
14 #include "UiText.hpp"
15 #include "UiCanvas.hpp"
16 
17 namespace KapEngine {
18  class Factory;
19  class GameObject;
20 
21  namespace UI {
22  class Image;
23  class Text;
24  class Canvas;
25  }
26 
27 }
28 
29 namespace KapEngine {
30 
36  namespace UI {
37 
38  class UiFactory {
39  public:
40 
41  //create canvas
42  static std::shared_ptr<GameObject> createCanvas(SceneManagement::Scene &scene, std::string const& name = "Canvas") {
43  PROFILER_FUNC_START();
44  auto result = Factory::createEmptyGameObject(scene, name);
45 
46  auto canvasComp = std::make_shared<Canvas>(result);
47  result->addComponent(canvasComp);
48 
49  PROFILER_FUNC_END();
50  return result;
51  }
52 
53  //create image
54  static std::shared_ptr<GameObject> createImage(SceneManagement::Scene &scene, std::string const& name = "Image", std::string const& pathImage = "", Tools::Rectangle const& rect = {0, 0, 0, 0}) {
55  PROFILER_FUNC_START();
56  auto result = Factory::createEmptyGameObject(scene, name);
57  std::shared_ptr<Image> imgComponent = std::make_shared<Image>(result);
58  result->addComponent(imgComponent);
59 
60  imgComponent->setPathSprite(pathImage);
61  imgComponent->setRectangle(rect);
62 
63  PROFILER_FUNC_END();
64  return result;
65  }
66 
67  //create text
68  static std::shared_ptr<GameObject> createText(SceneManagement::Scene &scene, std::string const& name = "Text") {
69  PROFILER_FUNC_START();
70  auto result = Factory::createEmptyGameObject(scene, name);
71  std::shared_ptr<Text> txtComponent = std::make_shared<Text>(result);
72  result->addComponent(txtComponent);
73 
74  PROFILER_FUNC_END();
75  return result;
76  }
77 
78  };
79 
80  }
81 
82 }
83 
84 #endif /* !UI_FACTORY_HPP_ */
KapEngine::UI::UiFactory
Definition: UiFactory.hpp:38
KapEngine
main namespace
Definition: Component.hpp:17
KapEngine::Tools::Rectangle
Definition: Rectangle.hpp:23
KapEngine::SceneManagement::Scene
Definition: Scene.hpp:37