Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
Application.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** Air-Trap
4** File description:
5** Application
6*/
7
8#ifndef RTYPE_CLIENT_CORE_APPLICATION_HPP_
9 #define RTYPE_CLIENT_CORE_APPLICATION_HPP_
10
11#include <SFML/Graphics.hpp>
12#include <SFML/System.hpp>
13#include <memory>
14#include <optional>
15#include <vector>
16#include <string>
17#include <filesystem>
18#include <unordered_map>
19
20#include "Game/AssetManager.hpp"
24#include "Core/Settings.hpp"
25#include "RType/Logger.hpp"
26#include "UI/UiFactory.hpp"
27
28/* Components */
42
43/* Utils */
44#include "Utils/GameState.hpp"
45#include "Utils/KeyAction.hpp"
46#include "RType/Math/Vec2.hpp"
47
48/* Systems */
49#include "Systems/NetworkSyncSystem.hpp"
55#include "Systems/UISystem.hpp"
58
59/* ECS */
62
63/* Scenes */
64#include "Interfaces/IScene.hpp"
69#include "Scenes/LobbyScene.hpp"
70#include "Scenes/LoginScene.hpp"
71#include "Scenes/MenuScene.hpp"
73#include "Scenes/PauseScene.hpp"
77
82namespace rtp::client {
83
88 namespace UIConstants {
89 constexpr float WINDOW_WIDTH = 1280.0f;
90 constexpr float WINDOW_HEIGHT = 720.0f;
91 }
92
101 public:
105 Application(const std::string& serverIp, uint16_t serverPort);
106
110 void run(void);
111
112 private:
116 void initUiECS(void);
117
121 void initWorldECS(void);
122
126 void initUiSystems(void);
127
131 void initWorldSystems(void);
132
136 void initScenes(void);
137
142
143 private:
147 void processInput(void);
148
153 void update(sf::Time delta);
154
158 void render(void);
159
164 void changeState(GameState newState);
165
166 private:
167 std::unordered_map<GameState,
168 std::unique_ptr<interfaces::IScene>> _scenes;
176 sf::RenderWindow _window;
190 sf::Shader _colorblindShader;
191 sf::RenderTexture _renderTexture;
192 bool _shaderLoaded{false};
195 float _lastDt{0.0f};
196 };
197} // namespace rtp::client
198
199#endif /* !RTYPE_CLIENT_CORE_APPLICATION_HPP_ */
Logger declaration with support for multiple log levels.
Manager for ECS systems.
Declaration of the 2-dimensional vector class.
Main application class for the R-Type client.
ecs::Registry _worldRegistry
ECS registry for the game world.
bool _shaderLoaded
Flag indicating if the shader was loaded successfully.
float _lastDt
Last delta time value.
ecs::SystemManager _worldSystemManager
ECS system manager for the game world.
void initScenes(void)
Initialize all application scenes.
EntityBuilder _worldEntityBuilder
Entity builder for world entities.
std::unordered_map< GameState, std::unique_ptr< interfaces::IScene > > _scenes
Map of game states to their corresponding scenes.
void update(sf::Time delta)
Update the application state.
ecs::SystemManager _uiSystemManager
ECS system manager for the UI.
EntityBuilder _uiEntityBuilder
Entity builder for UI entities.
void setupSettingsCallbacks()
Setup callbacks for settings changes.
void processInput(void)
Handle input events.
ecs::Registry _uiRegistry
ECS registry for the UI.
sf::RenderTexture _renderTexture
Render texture for off-screen rendering.
ClientNetwork _clientNetwork
Client network manager.
graphics::UiFactory _uiFactory
UI Factory for creating UI components.
void changeState(GameState newState)
Change the current game state and active scene.
sf::Shader _colorblindShader
Shader for colorblind mode.
void initWorldECS(void)
Initialize the ECS and systems for the game world.
sf::RenderWindow _window
SFML render window.
void initUiSystems(void)
Initialize the game world systems.
Settings _settings
Application settings manager.
AssetManager _assetManager
Asset manager for textures and fonts.
void initUiECS(void)
Initialize the ECS and systems for the UI.
void initWorldSystems(void)
Initialize the UI systems.
void run(void)
Run the main application loop.
void render(void)
Render the current scene.
GameState _currentState
Current game state.
interfaces::IScene * _activeScene
Pointer to the currently active scene.
TranslationManager _translations
Translation manager for localization.
Manages loading and storage of graphical assets.
Manages game settings and preferences.
Definition Settings.hpp:67
Manages game translations for all UI elements.
Factory class for creating UI components in the ECS registry.
Definition UiFactory.hpp:72
Interface for different scenes in the client application.
Definition IScene.hpp:23
Constants related to the UI.
constexpr float WINDOW_WIDTH
Standard window width.
constexpr float WINDOW_HEIGHT
Standard window height.
R-Type client namespace.
@ NotInit
Uninitialized state.