R-Type  2
Doom but in better
Loading...
Searching...
No Matches
Window.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** Window.hpp
6*/
7
14#pragma once
15
16#include <any>
17#include <string>
18#include <cstring>
19#include <SFML/Graphics/Image.hpp>
20#include <SFML/Graphics/RenderWindow.hpp>
21
22#include "Log.hpp"
23#include "LogMacros.hpp"
24#include "Utilities.hpp"
28
29namespace GUI
30{
31 namespace ECS
32 {
33 namespace Components
34 {
38 class TextComponent;
39
43 class ShapeComponent;
44
48 class ButtonComponent;
49
53 class SpriteComponent;
54
58 class ImageComponent;
59 }
60
61 namespace Systems
62 {
67 class Window : public EntityNode {
68 public:
78 Window(const std::uint32_t entityId = 0, const std::uint32_t windowWidth = 800, const std::uint32_t windowHeight = 600, const std::string &windowName = "R-Type", unsigned int frameRateLimit = 60);
79
83 ~Window();
84
90 void setPosition(const std::pair<int, int> &position);
91
98
99
105 void setTitle(const std::string &title = "R-Type");
106
113
117 void display();
118
124 bool isOpen() const;
125
129 void close();
130
136 std::any pollEvent();
137
143 void setFramerateLimit(const unsigned int framerateLimit);
149 void setFullScreen(const bool fullScreen);
150
159 const std::string getInfo(const unsigned int indent = 0) const;
160
166 const bool getFullScreen() const;
167
173 const std::string getTitle() const;
174
180 const std::pair<int, int> getDimensions() const;
181
187 const std::pair<int, int> getPosition() const;
188
219
220
221 private:
222 bool _fullScreen;
223 std::string _windowName;
224 sf::RenderWindow _sfWindow;
225 std::uint32_t _windowWidth;
226 std::uint32_t _windowHeight;
227 sf::VideoMode _desktopMode = sf::VideoMode::getDesktopMode();
228 };
229
238 std::ostream &operator<<(std::ostream &os, const Window &item);
239 }
240 }
241}
This is the file that links the EntityNode children.
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
Manages button functionalities, including appearance, position, and callbacks.
Represents an image component in the GUI ECS system.
Manages shapes and their associated properties in the ECS framework.
Represents a drawable and interactive sprite in the ECS system.
A class that represents a text component in the GUI system. It manages font, size,...
A class for representing and manipulating colors using RGBA components. Inherits from EntityNode to a...
Definition Colour.hpp:37
static const Colour Black
Definition Colour.hpp:969
Manages an SFML-based graphical window and handles rendering of ECS components.
Definition Window.hpp:67
void setPosition(const std::pair< int, int > &position)
Set the Position of the window.
Definition Window.cpp:28
void close()
Closes the window.
Definition Window.cpp:90
Window(const std::uint32_t entityId=0, const std::uint32_t windowWidth=800, const std::uint32_t windowHeight=600, const std::string &windowName="R-Type", unsigned int frameRateLimit=60)
Constructs a new Window object.
Definition Window.cpp:16
~Window()
Destroys the Window object.
Definition Window.cpp:26
void setTitle(const std::string &title="R-Type")
Set the Title of the window.
Definition Window.cpp:57
void draw(const GUI::ECS::Components::TextComponent &text)
Renders a text component to the window.
Definition Window.cpp:167
void display()
Displays the contents of the window on the screen.
Definition Window.cpp:80
const bool getFullScreen() const
Retrieves the current fullscreen mode of the window.
Definition Window.cpp:127
void setFullScreen(const bool fullScreen)
Enables or disables fullscreen mode for the window.
Definition Window.cpp:112
void setIcon(const GUI::ECS::Components::ImageComponent &icon)
Set the Icon of the window.
Definition Window.cpp:35
const std::string getInfo(const unsigned int indent=0) const
This is a function meant for debugging purposes It will dump the current state of the variables upon ...
Definition Window.cpp:149
void clear(const GUI::ECS::Systems::Colour &color=GUI::ECS::Systems::Colour::Black)
Clears the window with the specified color.
Definition Window.cpp:65
void setFramerateLimit(const unsigned int framerateLimit)
Sets the frame rate limit of the window.
Definition Window.cpp:107
bool isOpen() const
Checks if the window is currently open.
Definition Window.cpp:85
const std::pair< int, int > getPosition() const
Get the Position of the window.
Definition Window.cpp:143
const std::string getTitle() const
Get the Title of the window.
Definition Window.cpp:132
std::any pollEvent()
Polls for the next event in the window's event queue.
Definition Window.cpp:95
const std::pair< int, int > getDimensions() const
Get the Dimensions of the window.
Definition Window.cpp:137
This is the file that links the Components children.
std::ostream & operator<<(std::ostream &os, const Clock &item)
Outputs the clock's info to a stream.
Definition Clock.cpp:73