R-Type  2
Doom but in better
Loading...
Searching...
No Matches
GUI::ECS::Systems::Window Class Reference

Manages an SFML-based graphical window and handles rendering of ECS components. More...

#include <Window.hpp>

Inheritance diagram for GUI::ECS::Systems::Window:
Inheritance graph
Collaboration diagram for GUI::ECS::Systems::Window:
Collaboration graph

Public Member Functions

 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.
 
 ~Window ()
 Destroys the Window object.
 
void setPosition (const std::pair< int, int > &position)
 Set the Position of the window.
 
void setIcon (const GUI::ECS::Components::ImageComponent &icon)
 Set the Icon of the window.
 
void setTitle (const std::string &title="R-Type")
 Set the Title of the window.
 
void clear (const GUI::ECS::Systems::Colour &color=GUI::ECS::Systems::Colour::Black)
 Clears the window with the specified color.
 
void display ()
 Displays the contents of the window on the screen.
 
bool isOpen () const
 Checks if the window is currently open.
 
void close ()
 Closes the window.
 
std::any pollEvent ()
 Polls for the next event in the window's event queue.
 
void setFramerateLimit (const unsigned int framerateLimit)
 Sets the frame rate limit of the window.
 
void setFullScreen (const bool fullScreen)
 Enables or disables fullscreen mode for the window.
 
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 call. It will dump them for itself and any of it's underlying classes.
 
const bool getFullScreen () const
 Retrieves the current fullscreen mode of the window.
 
const std::string getTitle () const
 Get the Title of the window.
 
const std::pair< int, int > getDimensions () const
 Get the Dimensions of the window.
 
const std::pair< int, int > getPosition () const
 Get the Position of the window.
 
void draw (const GUI::ECS::Components::TextComponent &text)
 Renders a text component to the window.
 
void draw (const GUI::ECS::Components::ShapeComponent &shape)
 Renders a shape component to the window.
 
void draw (const GUI::ECS::Components::ImageComponent &image)
 Renders an image component to the window.
 
void draw (const GUI::ECS::Components::SpriteComponent &sprite)
 Renders a sprite component to the window.
 
void draw (const GUI::ECS::Components::ButtonComponent &button)
 Renders a button component to the window.
 
- Public Member Functions inherited from GUI::ECS::EntityNode
 EntityNode (const size_t entityId=0)
 
virtual ~EntityNode ()=default
 
virtual size_t getEntityNodeId () const
 

Additional Inherited Members

- Protected Attributes inherited from GUI::ECS::EntityNode
size_t _entityID
 

Detailed Description

Manages an SFML-based graphical window and handles rendering of ECS components.

Definition at line 67 of file Window.hpp.

Constructor & Destructor Documentation

◆ Window()

GUI::ECS::Systems::Window::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.

Parameters
entityIdThe unique ID of the entity associated with this window.
windowWidthThe width of the window in pixels.
windowHeightThe height of the window in pixels.
windowNameThe title of the window.
frameRateLimitThe maximum frame rate for rendering.

Definition at line 16 of file Window.cpp.

◆ ~Window()

GUI::ECS::Systems::Window::~Window ( )

Destroys the Window object.

Definition at line 26 of file Window.cpp.

Member Function Documentation

◆ clear()

void GUI::ECS::Systems::Window::clear ( const GUI::ECS::Systems::Colour & color = GUI::ECS::Systems::Colour::Black)

Clears the window with the specified color.

Parameters
colorThe color to clear the window with. Defaults to black.

Definition at line 65 of file Window.cpp.

◆ close()

void GUI::ECS::Systems::Window::close ( )

Closes the window.

Definition at line 90 of file Window.cpp.

◆ display()

void GUI::ECS::Systems::Window::display ( )

Displays the contents of the window on the screen.

Definition at line 80 of file Window.cpp.

◆ draw() [1/5]

void GUI::ECS::Systems::Window::draw ( const GUI::ECS::Components::ButtonComponent & button)

Renders a button component to the window.

Parameters
buttonThe button component to render.

Definition at line 284 of file Window.cpp.

◆ draw() [2/5]

void GUI::ECS::Systems::Window::draw ( const GUI::ECS::Components::ImageComponent & image)

Renders an image component to the window.

Parameters
imageThe image component to render.

Definition at line 238 of file Window.cpp.

◆ draw() [3/5]

void GUI::ECS::Systems::Window::draw ( const GUI::ECS::Components::ShapeComponent & shape)

Renders a shape component to the window.

Parameters
shapeThe shape component to render.

Definition at line 182 of file Window.cpp.

◆ draw() [4/5]

void GUI::ECS::Systems::Window::draw ( const GUI::ECS::Components::SpriteComponent & sprite)

Renders a sprite component to the window.

Parameters
spriteThe sprite component to render.

Definition at line 261 of file Window.cpp.

◆ draw() [5/5]

void GUI::ECS::Systems::Window::draw ( const GUI::ECS::Components::TextComponent & text)

Renders a text component to the window.

Parameters
textThe text component to render.

Definition at line 167 of file Window.cpp.

◆ getDimensions()

const std::pair< int, int > GUI::ECS::Systems::Window::getDimensions ( ) const

Get the Dimensions of the window.

Returns
const std::pair<int, int> of the window dimensions (width,height) in pixels

Definition at line 137 of file Window.cpp.

◆ getFullScreen()

const bool GUI::ECS::Systems::Window::getFullScreen ( ) const

Retrieves the current fullscreen mode of the window.

Returns
true if fullscreen mode is enabled, false otherwise.

Definition at line 127 of file Window.cpp.

◆ getInfo()

const std::string GUI::ECS::Systems::Window::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 call. It will dump them for itself and any of it's underlying classes.

Parameters
indentThe level to which the class should be indented in the dump.
Returns
const std::string The formatted output.

Definition at line 149 of file Window.cpp.

◆ getPosition()

const std::pair< int, int > GUI::ECS::Systems::Window::getPosition ( ) const

Get the Position of the window.

Returns
const std::pair<int, int> of the window position (x, y) in pixels

Definition at line 143 of file Window.cpp.

◆ getTitle()

const std::string GUI::ECS::Systems::Window::getTitle ( ) const

Get the Title of the window.

Returns
const std::string

Definition at line 132 of file Window.cpp.

◆ isOpen()

bool GUI::ECS::Systems::Window::isOpen ( ) const

Checks if the window is currently open.

Returns
true if the window is open, false otherwise.

Definition at line 85 of file Window.cpp.

◆ pollEvent()

std::any GUI::ECS::Systems::Window::pollEvent ( )

Polls for the next event in the window's event queue.

Returns
A std::any containing the event, or an empty value if no event is available.

Definition at line 95 of file Window.cpp.

◆ setFramerateLimit()

void GUI::ECS::Systems::Window::setFramerateLimit ( const unsigned int framerateLimit)

Sets the frame rate limit of the window.

Parameters
framerateLimitThe maximum number of frames per second.

Definition at line 107 of file Window.cpp.

◆ setFullScreen()

void GUI::ECS::Systems::Window::setFullScreen ( const bool fullScreen)

Enables or disables fullscreen mode for the window.

Parameters
fullScreenWhether to enable fullscreen mode.

Definition at line 112 of file Window.cpp.

◆ setIcon()

void GUI::ECS::Systems::Window::setIcon ( const GUI::ECS::Components::ImageComponent & icon)

Set the Icon of the window.

Parameters
iconA GUI::ECS::Components::ImageComponent of the window icon to be set.

Definition at line 35 of file Window.cpp.

◆ setPosition()

void GUI::ECS::Systems::Window::setPosition ( const std::pair< int, int > & position)

Set the Position of the window.

Parameters
positionan std::pair<int, int> of the window position (x, y).

Definition at line 28 of file Window.cpp.

◆ setTitle()

void GUI::ECS::Systems::Window::setTitle ( const std::string & title = "R-Type")

Set the Title of the window.

Parameters
title

Definition at line 57 of file Window.cpp.


The documentation for this class was generated from the following files: