Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::client::Application Class Reference

Main application class for the R-Type client. More...

#include <Application.hpp>

Collaboration diagram for rtp::client::Application:

Public Member Functions

 Application (const std::string &serverIp, uint16_t serverPort)
 Construct a new Application object.
 
void run (void)
 Run the main application loop.
 

Private Member Functions

void initUiECS (void)
 Initialize the ECS and systems for the UI.
 
void initWorldECS (void)
 Initialize the ECS and systems for the game world.
 
void initUiSystems (void)
 Initialize the game world systems.
 
void initWorldSystems (void)
 Initialize the UI systems.
 
void initScenes (void)
 Initialize all application scenes.
 
void setupSettingsCallbacks ()
 Setup callbacks for settings changes.
 
void processInput (void)
 Handle input events.
 
void update (sf::Time delta)
 Update the application state.
 
void render (void)
 Render the current scene.
 
void changeState (GameState newState)
 Change the current game state and active scene.
 

Private Attributes

std::unordered_map< GameState, std::unique_ptr< interfaces::IScene > > _scenes
 Map of game states to their corresponding scenes.
 
interfaces::IScene_activeScene = nullptr
 Pointer to the currently active scene.
 
graphics::UiFactory _uiFactory
 UI Factory for creating UI components.
 
Settings _settings
 Application settings manager.
 
TranslationManager _translations
 Translation manager for localization.
 
sf::RenderWindow _window
 SFML render window.
 
ecs::Registry _worldRegistry
 ECS registry for the game world.
 
ecs::Registry _uiRegistry
 ECS registry for the UI.
 
ecs::SystemManager _uiSystemManager
 ECS system manager for the UI.
 
ecs::SystemManager _worldSystemManager
 ECS system manager for the game world.
 
AssetManager _assetManager
 Asset manager for textures and fonts.
 
EntityBuilder _uiEntityBuilder
 Entity builder for UI entities.
 
EntityBuilder _worldEntityBuilder
 Entity builder for world entities.
 
ClientNetwork _clientNetwork
 Client network manager.
 
sf::Shader _colorblindShader
 Shader for colorblind mode.
 
sf::RenderTexture _renderTexture
 Render texture for off-screen rendering.
 
bool _shaderLoaded {false}
 Flag indicating if the shader was loaded successfully.
 
GameState _currentState {GameState::NotInit}
 Current game state.
 
float _lastDt {0.0f}
 Last delta time value.
 

Detailed Description

Main application class for the R-Type client.

This class manages the main application loop, including initialization of systems, scenes, and handling of game states.

This class initializes and runs the main application loop, handling window creation, ECS setup, and system management.

Definition at line 100 of file Application.hpp.

Constructor & Destructor Documentation

◆ Application()

rtp::client::Application::Application ( const std::string &  serverIp,
uint16_t  serverPort 
)

Construct a new Application object.

Definition at line 20 of file Application.cpp.

References rtp::client::UIConstants::WINDOW_HEIGHT, and rtp::client::UIConstants::WINDOW_WIDTH.

Member Function Documentation

◆ changeState()

◆ initScenes()

◆ initUiECS()

void rtp::client::Application::initUiECS ( void  )
private

Initialize the ECS and systems for the UI.

Definition at line 123 of file Application.cpp.

References _uiRegistry, rtp::log::info(), and rtp::ecs::Registry::subscribe().

◆ initUiSystems()

◆ initWorldECS()

void rtp::client::Application::initWorldECS ( void  )
private

Initialize the ECS and systems for the game world.

Definition at line 136 of file Application.cpp.

References _worldRegistry, rtp::log::info(), and rtp::ecs::Registry::subscribe().

◆ initWorldSystems()

◆ processInput()

void rtp::client::Application::processInput ( void  )
private

◆ render()

◆ run()

void rtp::client::Application::run ( void  )

Run the main application loop.

Definition at line 71 of file Application.cpp.

References _window, processInput(), render(), and update().

Referenced by main().

◆ setupSettingsCallbacks()

◆ update()

void rtp::client::Application::update ( sf::Time  delta)
private

Update the application state.

Parameters
deltaTime delta since the last update

Definition at line 286 of file Application.cpp.

References _activeScene, _lastDt, _uiSystemManager, _worldSystemManager, rtp::ecs::SystemManager::update(), and rtp::client::interfaces::IScene::update().

Referenced by render(), and run().

Member Data Documentation

◆ _activeScene

interfaces::IScene* rtp::client::Application::_activeScene = nullptr
private

Pointer to the currently active scene.

Definition at line 169 of file Application.hpp.

Referenced by changeState(), processInput(), setupSettingsCallbacks(), and update().

◆ _assetManager

AssetManager rtp::client::Application::_assetManager
private

Asset manager for textures and fonts.

Definition at line 183 of file Application.hpp.

◆ _clientNetwork

ClientNetwork rtp::client::Application::_clientNetwork
private

Client network manager.

Definition at line 188 of file Application.hpp.

Referenced by initWorldSystems().

◆ _colorblindShader

sf::Shader rtp::client::Application::_colorblindShader
private

Shader for colorblind mode.

Definition at line 190 of file Application.hpp.

◆ _currentState

GameState rtp::client::Application::_currentState {GameState::NotInit}
private

Current game state.

Definition at line 194 of file Application.hpp.

Referenced by changeState(), and render().

◆ _lastDt

float rtp::client::Application::_lastDt {0.0f}
private

Last delta time value.

Definition at line 195 of file Application.hpp.

Referenced by render(), and update().

◆ _renderTexture

sf::RenderTexture rtp::client::Application::_renderTexture
private

Render texture for off-screen rendering.

Definition at line 191 of file Application.hpp.

◆ _scenes

std::unordered_map<GameState, std::unique_ptr<interfaces::IScene> > rtp::client::Application::_scenes
private

Map of game states to their corresponding scenes.

Definition at line 168 of file Application.hpp.

Referenced by changeState(), and initScenes().

◆ _settings

Settings rtp::client::Application::_settings
private

Application settings manager.

Definition at line 173 of file Application.hpp.

Referenced by initScenes(), initUiSystems(), initWorldSystems(), render(), and setupSettingsCallbacks().

◆ _shaderLoaded

bool rtp::client::Application::_shaderLoaded {false}
private

Flag indicating if the shader was loaded successfully.

Definition at line 192 of file Application.hpp.

Referenced by render().

◆ _translations

TranslationManager rtp::client::Application::_translations
private

Translation manager for localization.

Definition at line 174 of file Application.hpp.

Referenced by initScenes(), and setupSettingsCallbacks().

◆ _uiEntityBuilder

EntityBuilder rtp::client::Application::_uiEntityBuilder
private

Entity builder for UI entities.

Definition at line 185 of file Application.hpp.

◆ _uiFactory

graphics::UiFactory rtp::client::Application::_uiFactory
private

UI Factory for creating UI components.

Definition at line 171 of file Application.hpp.

Referenced by initScenes().

◆ _uiRegistry

ecs::Registry rtp::client::Application::_uiRegistry
private

ECS registry for the UI.

Definition at line 179 of file Application.hpp.

Referenced by changeState(), initScenes(), initUiECS(), initUiSystems(), initWorldSystems(), and setupSettingsCallbacks().

◆ _uiSystemManager

ecs::SystemManager rtp::client::Application::_uiSystemManager
private

ECS system manager for the UI.

Definition at line 180 of file Application.hpp.

Referenced by changeState(), initUiSystems(), initWorldSystems(), processInput(), render(), setupSettingsCallbacks(), and update().

◆ _window

sf::RenderWindow rtp::client::Application::_window
private

SFML render window.

Definition at line 176 of file Application.hpp.

Referenced by initUiSystems(), initWorldSystems(), processInput(), render(), and run().

◆ _worldEntityBuilder

EntityBuilder rtp::client::Application::_worldEntityBuilder
private

Entity builder for world entities.

Definition at line 186 of file Application.hpp.

Referenced by initScenes(), and initWorldSystems().

◆ _worldRegistry

ecs::Registry rtp::client::Application::_worldRegistry
private

ECS registry for the game world.

Definition at line 178 of file Application.hpp.

Referenced by changeState(), initScenes(), initWorldECS(), and initWorldSystems().

◆ _worldSystemManager

ecs::SystemManager rtp::client::Application::_worldSystemManager
private

ECS system manager for the game world.

Definition at line 181 of file Application.hpp.

Referenced by changeState(), initScenes(), initWorldSystems(), render(), setupSettingsCallbacks(), and update().


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