|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Scene for the main menu. More...
#include <MenuScene.hpp>
Classes | |
| struct | MenuEnemy |
Public Types | |
| using | ChangeStateFn = std::function< void(GameState)> |
| Type alias for a function that changes the game state. | |
Public Member Functions | |
| MenuScene (ecs::Registry &UiRegistry, ecs::Registry &worldRegistry, Settings &settings, TranslationManager &translationManager, NetworkSyncSystem &network, graphics::UiFactory &uiFactory, EntityBuilder &worldEntityBuilder, std::function< void(GameState)> changeState) | |
| Constructor for MenuScene. | |
| void | onEnter (void) override |
| Called when the scene is entered. | |
| void | onExit (void) override |
| Called when the scene is exited. | |
| void | handleEvent (const sf::Event &event) override |
| Handle an incoming event. | |
| void | update (float dt) override |
| Update the scene state. | |
Public Member Functions inherited from rtp::client::interfaces::IScene | |
| virtual | ~IScene (void)=default |
Private Member Functions | |
| void | updateWeaponDisplay () |
| Update weapon name and stats texts. | |
Private Attributes | |
| ecs::Registry & | _uiRegistry |
| Reference to the ECS registry. | |
| ecs::Registry & | _worldRegistry |
| Reference to the world ECS registry. | |
| Settings & | _settings |
| Reference to the application settings. | |
| TranslationManager & | _translationManager |
| Reference to the translation manager. | |
| NetworkSyncSystem & | _network |
| Reference to the client network. | |
| graphics::UiFactory & | _uiFactory |
| UI Factory for creating UI components. | |
| EntityBuilder & | _worldEntityBuilder |
| World entity builder for menu visuals. | |
| ChangeStateFn | _changeState |
| Function to change the game state. | |
| ecs::Entity | _menuMusicEntity |
| Entity for menu background music. | |
| std::vector< ecs::Entity > | _menuWorldEntities |
| Menu background entities. | |
| std::vector< MenuEnemy > | _menuEnemies |
| Moving enemies for menu decor. | |
| float | _menuTime {0.0f} |
| Menu animation timer. | |
| ecs::Entity | _weaponNameText |
| Entity for weapon name display. | |
| ecs::Entity | _weaponStatsText |
| Entity for weapon stats display. | |
Scene for the main menu.
This scene displays the main menu options such as Start Game, Settings, and Exit. It handles user interactions to navigate through the menu.
Definition at line 35 of file MenuScene.hpp.
| using rtp::client::scenes::MenuScene::ChangeStateFn = std::function<void(GameState)> |
Type alias for a function that changes the game state.
Definition at line 57 of file MenuScene.hpp.
| rtp::client::scenes::MenuScene::MenuScene | ( | ecs::Registry & | UiRegistry, |
| ecs::Registry & | worldRegistry, | ||
| Settings & | settings, | ||
| TranslationManager & | translationManager, | ||
| NetworkSyncSystem & | network, | ||
| graphics::UiFactory & | uiFactory, | ||
| EntityBuilder & | worldEntityBuilder, | ||
| std::function< void(GameState)> | changeState | ||
| ) |
Constructor for MenuScene.
| registry | Reference to the ECS registry |
| settings | Reference to the application settings |
| network | Reference to the client network |
| window | Reference to the SFML render window |
Definition at line 25 of file MenuScene.cpp.
|
overridevirtual |
Handle an incoming event.
| event | The event to handle. |
Implements rtp::client::interfaces::IScene.
Definition at line 408 of file MenuScene.cpp.
|
overridevirtual |
Called when the scene is entered.
Implements rtp::client::interfaces::IScene.
Definition at line 45 of file MenuScene.cpp.
References _changeState, _menuEnemies, _menuMusicEntity, _menuTime, _menuWorldEntities, _network, _settings, _translationManager, _uiFactory, _uiRegistry, _weaponNameText, _weaponStatsText, _worldEntityBuilder, rtp::ecs::Registry::add(), rtp::ecs::components::audio::AudioSource::audioPath, rtp::ecs::components::Beam, rtp::ecs::components::Boomerang, rtp::ecs::components::Classic, rtp::client::graphics::UiFactory::createButton(), rtp::client::EntityTemplate::createParrallaxLvl1_1(), rtp::client::EntityTemplate::createParrallaxLvl1_2(), rtp::client::graphics::UiFactory::createText(), rtp::ecs::components::audio::AudioSource::dirty, rtp::client::EntityTemplate::enemy_1(), rtp::client::EntityTemplate::enemy_2(), rtp::client::TranslationManager::get(), rtp::ecs::Registry::get(), rtp::client::Settings::getSelectedWeapon(), rtp::config::getWeaponDisplayName(), rtp::client::Settings::getWeaponName(), rtp::config::hasWeaponConfigs(), rtp::ecs::components::ui::Button::hoverColor, rtp::ecs::components::ui::Button::idleColor, rtp::log::info(), rtp::ecs::components::audio::AudioSource::isPlaying, rtp::client::Lobby, rtp::ecs::components::audio::AudioSource::loop, rtp::client::ModMenu, rtp::client::EntityTemplate::parallax, rtp::client::EntityTemplate::position, rtp::ecs::components::ui::Button::pressedColor, rtp::config::reloadWeaponConfigs(), rtp::client::NetworkSyncSystem::requestListRooms(), rtp::client::RoomWaiting, rtp::client::Settings::save(), rtp::client::EntityTemplate::scale, rtp::client::NetworkSyncSystem::sendSelectedWeapon(), rtp::client::Settings::setSelectedWeapon(), rtp::client::Settings, rtp::client::EntityBuilder::spawn(), rtp::ecs::Registry::spawn(), rtp::ecs::components::ParallaxLayer::textureWidth, rtp::ecs::components::Tracker, rtp::client::NetworkSyncSystem::tryStartSolo(), updateWeaponDisplay(), and rtp::ecs::components::audio::AudioSource::volume.
|
overridevirtual |
Called when the scene is exited.
Implements rtp::client::interfaces::IScene.
Definition at line 397 of file MenuScene.cpp.
References _menuEnemies, _menuWorldEntities, _worldEntityBuilder, rtp::log::info(), and rtp::client::EntityBuilder::kill().
|
overridevirtual |
Update the scene state.
| dt | Time delta since the last update. |
Implements rtp::client::interfaces::IScene.
Definition at line 417 of file MenuScene.cpp.
References _menuEnemies, _menuTime, _worldRegistry, rtp::ecs::Registry::get(), rtp::ecs::components::Transform::position, and rtp::Vec2< T >::x.
|
private |
Update weapon name and stats texts.
Definition at line 441 of file MenuScene.cpp.
References _settings, _uiRegistry, _weaponNameText, _weaponStatsText, rtp::ecs::Registry::get(), rtp::client::Settings::getSelectedWeapon(), rtp::config::getWeaponDef(), rtp::config::getWeaponDisplayName(), rtp::client::Settings::getWeaponName(), rtp::config::hasWeaponConfigs(), and rtp::log::warning().
Referenced by onEnter().
|
private |
Function to change the game state.
Definition at line 99 of file MenuScene.hpp.
Referenced by onEnter().
|
private |
Moving enemies for menu decor.
Definition at line 102 of file MenuScene.hpp.
|
private |
Entity for menu background music.
Definition at line 100 of file MenuScene.hpp.
Referenced by onEnter().
|
private |
Menu animation timer.
Definition at line 103 of file MenuScene.hpp.
|
private |
Menu background entities.
Definition at line 101 of file MenuScene.hpp.
|
private |
Reference to the client network.
Definition at line 96 of file MenuScene.hpp.
Referenced by onEnter().
|
private |
Reference to the application settings.
Definition at line 94 of file MenuScene.hpp.
Referenced by onEnter(), and updateWeaponDisplay().
|
private |
Reference to the translation manager.
Definition at line 95 of file MenuScene.hpp.
Referenced by onEnter().
|
private |
UI Factory for creating UI components.
Definition at line 97 of file MenuScene.hpp.
Referenced by onEnter().
|
private |
Reference to the ECS registry.
Definition at line 92 of file MenuScene.hpp.
Referenced by onEnter(), and updateWeaponDisplay().
|
private |
Entity for weapon name display.
Definition at line 104 of file MenuScene.hpp.
Referenced by onEnter(), and updateWeaponDisplay().
|
private |
Entity for weapon stats display.
Definition at line 105 of file MenuScene.hpp.
Referenced by onEnter(), and updateWeaponDisplay().
|
private |
World entity builder for menu visuals.
Definition at line 98 of file MenuScene.hpp.
|
private |
Reference to the world ECS registry.
Definition at line 93 of file MenuScene.hpp.
Referenced by update().