21 : _window(sf::VideoMode(
25 , _uiSystemManager(_uiRegistry)
26 , _worldSystemManager(_worldRegistry)
27 , _uiEntityBuilder(_uiRegistry)
28 , _worldEntityBuilder(_worldRegistry)
29 , _clientNetwork(serverIp, serverPort)
31 _window.setFramerateLimit(60);
33 _translations.loadLanguage(_settings.getLanguage());
35 setupSettingsCallbacks();
37 if (!_colorblindShader.loadFromFile(
"assets/shaders/colorblind.frag",
38 sf::Shader::Type::Fragment)) {
39 log::warning(
"Failed to load colorblind shader, running "
40 "without colorblind support");
41 _shaderLoaded =
false;
44 log::info(
"Colorblind shader loaded successfully");
47 if (!_renderTexture.resize(
48 {static_cast<unsigned int>(UIConstants::WINDOW_WIDTH),
49 static_cast<unsigned int>(UIConstants::WINDOW_HEIGHT)})) {
58 _clientNetwork.start();
59 }
catch (
const std::exception& e) {
60 throw std::runtime_error(
61 std::string(
"Failed to start client network: ") + e.what());
75 sf::Time deltaTime = clock.restart();
104 log::info(
"OK: World systems initialized");
133 log::info(
"OK: UI ECS initialized with components");
150 log::info(
"OK: World ECS initialized with components");
195 }
catch (
const std::exception& e) {
196 log::error(
"Failed to get NetworkSyncSystem: {}", e.what());
205 log::info(
"Changing state from {} to {}",
207 static_cast<int>(newState));
225 std::vector<ecs::Entity> audioSourcesToKeep;
226 std::vector<ecs::components::audio::AudioSource> audioSourceData;
230 auto& sources = audioSources.value().get();
231 for (
const auto& entity : sources.entities()) {
232 audioSourcesToKeep.push_back(entity);
233 audioSourceData.push_back(sources[entity]);
239 for (
size_t i = 0; i < audioSourcesToKeep.size(); ++i) {
251 log::info(
"Clearing texture caches to apply sprite changes");
256 auto it =
_scenes.find(newState);
261 log::warning(
"No scene found for state {}, cannot change state",
262 static_cast<int>(newState));
271 while (
auto eventOpt =
_window.pollEvent()) {
272 const sf::Event&
event = *eventOpt;
274 if (event.is<sf::Event::Closed>()) {
304 log::info(
"Master volume changed to: {:.2f}", volume);
310 log::info(
"Music volume changed to: {:.2f}", volume);
316 log::info(
"SFX volume changed to: {:.2f}", volume);
322 log::info(
"Language changed to: {}",
static_cast<int>(lang));
335 _window.clear(sf::Color::Black);
341 overlay.setPosition({0.0f, 0.0f});
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.
void setupSettingsCallbacks()
Setup callbacks for settings changes.
void processInput(void)
Handle input events.
ecs::Registry _uiRegistry
ECS registry for the UI.
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.
void initWorldECS(void)
Initialize the ECS and systems for the game world.
Application(const std::string &serverIp, uint16_t serverPort)
Construct a new Application object.
sf::RenderWindow _window
SFML render window.
void initUiSystems(void)
Initialize the game world systems.
Settings _settings
Application settings manager.
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.
System responsible for handling audio playback (music, SFX, ambient)
void stopAllSounds()
Stop all currently playing sounds.
System to handle network-related operations on the client side.
void onLanguageChanged(LanguageCallback callback)
float getMusicVolume() const
ColorBlindMode getColorBlindMode() const
void onSfxVolumeChanged(VolumeCallback callback)
float getMasterVolume() const
void onMusicVolumeChanged(VolumeCallback callback)
float getSfxVolume() const
void onMasterVolumeChanged(VolumeCallback callback)
System responsible for managing shield visual effects.
static void setRenderSystems(void *worldRenderSystem, void *uiRenderSystem)
Set render system pointers for cache clearing Called internally by Application during initialization.
bool loadLanguage(Language language)
Load translations for a specific language.
System responsible for handling menu interactions.
virtual void onEnter(void)=0
Called when the scene is entered.
virtual void handleEvent(const sf::Event &)=0
Handle an incoming event.
virtual void onExit(void)=0
Called when the scene is exited.
virtual void update(float dt)=0
Update the scene state.
auto subscribe(this Self &self) -> std::expected< std::reference_wrapper< ConstLike< Self, SparseArray< T > > >, rtp::Error >
void clear(void) noexcept
auto add(Entity entity, Args &&...args) -> std::expected< std::reference_wrapper< T >, rtp::Error >
auto get(this const Self &self) -> std::expected< std::reference_wrapper< ConstLike< Self, SparseArray< T > > >, rtp::Error >
File : Network.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue.hajjar-llauquen@epit...
constexpr float WINDOW_WIDTH
Standard window width.
constexpr float WINDOW_HEIGHT
Standard window height.
@ RoomWaiting
Room waiting state.
@ GameOver
Game over state.
@ CreateRoom
Create room state.
@ Login
Login screen state.
@ GamepadSettings
Gamepad settings configuration state.
@ KeyBindings
Key bindings configuration state.
@ Playing
In-game playing state.
@ Paused
Game paused state.
@ Settings
Settings menu state.
Language
Supported languages.
void error(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an error message.
void warning(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log a warning message.
void info(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an informational message.
Component representing an animation.
Component indicating that an entity can be controlled by a player.
Component representing a network identifier for an entity.
Tag component indicating that an entity should loop its position when it exits the screen (infinite s...
Component for visual shield effect displayed around the player.
Component representing a sprite.
Component representing a 2D velocity.
Component for entities that emit continuous sound (music, loops, ambient)
Component for triggering one-time sound effects (SFX)
Component for dropdown menu selection.
Component for a draggable slider control.
Component for displaying a sprite preview in the UI.
Component representing text to render.