|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Main application class for the R-Type client. More...
#include <Application.hpp>
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. | |
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.
| 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.
|
private |
Change the current game state and active scene.
| newState | The new game state to switch to |
Definition at line 203 of file Application.cpp.
References _activeScene, _currentState, _scenes, _uiRegistry, _uiSystemManager, _worldRegistry, _worldSystemManager, rtp::ecs::Registry::add(), rtp::ecs::Registry::clear(), rtp::ecs::Registry::get(), rtp::ecs::SystemManager::getSystem(), rtp::log::info(), rtp::client::ModMenu, rtp::client::interfaces::IScene::onEnter(), rtp::client::interfaces::IScene::onExit(), rtp::client::Paused, rtp::client::Playing, rtp::client::AudioSystem::stopAllSounds(), and rtp::log::warning().
Referenced by initScenes().
|
private |
Initialize all application scenes.
Definition at line 153 of file Application.cpp.
References _scenes, _settings, _translations, _uiFactory, _uiRegistry, _worldEntityBuilder, _worldRegistry, _worldSystemManager, changeState(), rtp::client::CreateRoom, rtp::log::error(), rtp::client::GameOver, rtp::client::GamepadSettings, rtp::ecs::SystemManager::getSystem(), rtp::log::info(), rtp::client::KeyBindings, rtp::client::Lobby, rtp::client::Login, rtp::client::Menu, rtp::client::ModMenu, rtp::client::Paused, rtp::client::Playing, rtp::client::RoomWaiting, and rtp::client::Settings.
|
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().
|
private |
Initialize the game world systems.
Definition at line 107 of file Application.cpp.
References _settings, _uiRegistry, _uiSystemManager, _window, rtp::ecs::SystemManager::add(), rtp::client::Settings::getMasterVolume(), rtp::client::Settings::getMusicVolume(), rtp::client::Settings::getSfxVolume(), rtp::log::info(), and rtp::client::SpriteCustomizer::setRenderSystems().
|
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().
|
private |
Initialize the UI systems.
Definition at line 86 of file Application.cpp.
References _clientNetwork, _settings, _uiRegistry, _uiSystemManager, _window, _worldEntityBuilder, _worldRegistry, _worldSystemManager, rtp::ecs::SystemManager::add(), rtp::client::Settings::getMasterVolume(), rtp::client::Settings::getMusicVolume(), rtp::client::Settings::getSfxVolume(), rtp::ecs::SystemManager::getSystem(), rtp::log::info(), and rtp::client::SpriteCustomizer::setRenderSystems().
|
private |
Handle input events.
Definition at line 269 of file Application.cpp.
References _activeScene, _uiSystemManager, _window, rtp::ecs::SystemManager::getSystem(), and rtp::client::interfaces::IScene::handleEvent().
Referenced by run().
|
private |
Render the current scene.
Definition at line 333 of file Application.cpp.
References _currentState, _lastDt, _settings, _shaderLoaded, _uiSystemManager, _window, _worldSystemManager, rtp::client::Deuteranopia, rtp::client::Settings::getColorBlindMode(), rtp::ecs::SystemManager::getSystem(), rtp::client::None, rtp::client::Playing, rtp::client::Protanopia, rtp::client::Tritanopia, update(), rtp::client::UIConstants::WINDOW_HEIGHT, and rtp::client::UIConstants::WINDOW_WIDTH.
Referenced by 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().
|
private |
Setup callbacks for settings changes.
Definition at line 301 of file Application.cpp.
References _activeScene, _settings, _translations, _uiRegistry, _uiSystemManager, _worldSystemManager, rtp::ecs::Registry::clear(), rtp::ecs::SystemManager::getSystem(), rtp::log::info(), rtp::client::TranslationManager::loadLanguage(), rtp::client::interfaces::IScene::onEnter(), rtp::client::Settings::onLanguageChanged(), rtp::client::Settings::onMasterVolumeChanged(), rtp::client::Settings::onMusicVolumeChanged(), and rtp::client::Settings::onSfxVolumeChanged().
|
private |
Update the application state.
| delta | Time 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().
|
private |
Pointer to the currently active scene.
Definition at line 169 of file Application.hpp.
Referenced by changeState(), processInput(), setupSettingsCallbacks(), and update().
|
private |
Asset manager for textures and fonts.
Definition at line 183 of file Application.hpp.
|
private |
Client network manager.
Definition at line 188 of file Application.hpp.
Referenced by initWorldSystems().
|
private |
Shader for colorblind mode.
Definition at line 190 of file Application.hpp.
|
private |
Current game state.
Definition at line 194 of file Application.hpp.
Referenced by changeState(), and render().
|
private |
Last delta time value.
Definition at line 195 of file Application.hpp.
|
private |
Render texture for off-screen rendering.
Definition at line 191 of file Application.hpp.
|
private |
Map of game states to their corresponding scenes.
Definition at line 168 of file Application.hpp.
Referenced by changeState(), and initScenes().
|
private |
Application settings manager.
Definition at line 173 of file Application.hpp.
Referenced by initScenes(), initUiSystems(), initWorldSystems(), render(), and setupSettingsCallbacks().
|
private |
Flag indicating if the shader was loaded successfully.
Definition at line 192 of file Application.hpp.
Referenced by render().
|
private |
Translation manager for localization.
Definition at line 174 of file Application.hpp.
Referenced by initScenes(), and setupSettingsCallbacks().
|
private |
Entity builder for UI entities.
Definition at line 185 of file Application.hpp.
|
private |
UI Factory for creating UI components.
Definition at line 171 of file Application.hpp.
Referenced by initScenes().
|
private |
ECS registry for the UI.
Definition at line 179 of file Application.hpp.
Referenced by changeState(), initScenes(), initUiECS(), initUiSystems(), initWorldSystems(), and setupSettingsCallbacks().
|
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().
|
private |
SFML render window.
Definition at line 176 of file Application.hpp.
Referenced by initUiSystems(), initWorldSystems(), processInput(), render(), and run().
|
private |
Entity builder for world entities.
Definition at line 186 of file Application.hpp.
Referenced by initScenes(), and initWorldSystems().
|
private |
ECS registry for the game world.
Definition at line 178 of file Application.hpp.
Referenced by changeState(), initScenes(), initWorldECS(), and initWorldSystems().
|
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().