Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
ModMenuScene.hpp
Go to the documentation of this file.
1
8#ifndef RTYPE_CLIENT_SCENES_MODMENUSCENE_HPP_
9 #define RTYPE_CLIENT_SCENES_MODMENUSCENE_HPP_
10
11 #include "Interfaces/IScene.hpp"
12 #include "RType/ECS/Registry.hpp"
13 #include "UI/UiFactory.hpp"
14 #include "Utils/GameState.hpp"
16 #include "Core/Settings.hpp"
17 #include <SFML/Graphics.hpp>
18 #include <memory>
19 #include <functional>
20 #include <filesystem>
21 #include <map>
22
23namespace rtp::client {
24 namespace scenes {
25
31 std::string name;
32 std::string texturePath;
34 int rectTop;
37 };
38
44 std::string name;
45 std::vector<EntitySpriteInfo> entities;
46 };
47
56 {
57 public:
66 ModMenuScene(ecs::Registry& UiRegistry,
67 Settings& settings,
68 TranslationManager& translationManager,
69 graphics::UiFactory& uiFactory,
70 std::function<void(GameState)> changeState);
71
75 using ChangeStateFn = std::function<void(GameState)>;
76
80 void onEnter(void) override;
81
85 void onExit(void) override;
86
91 void handleEvent(const sf::Event& event) override;
92
97 void update(float dt) override;
98
99 private:
106 std::filesystem::path _customSpritesPath;
107 std::filesystem::path _spriteMappingPath;
108 std::vector<EntityCategory> _categories;
112 // Sprite display
113 std::map<std::string, sf::Texture> _loadedTextures;
115 // Custom sprite mappings: entity key -> custom sprite path
116 std::unordered_map<std::string, std::string> _customSpriteMappings;
117
122
127
131 void showCategoryList();
132
137 void showEntityCodex(size_t categoryIndex);
138
144 sf::Texture* loadTexture(const std::string& texturePath);
145
150 std::string openFileDialog();
151
155 void saveSpriteMappings();
156
160 void loadSpriteMappings();
161
167 void applyCustomSprite(const EntitySpriteInfo& entity, const std::string& categoryName);
168
176 sf::Image resizeImage(const sf::Image& sourceImage, unsigned int targetWidth, unsigned int targetHeight);
177
183 std::string getEntityKey(const EntitySpriteInfo& entity) const;
184 };
185 } // namespace scenes
186} // namespace rtp::client
187
188#endif // RTYPE_CLIENT_SCENES_MODMENUSCENE_HPP_
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
Scene for customizing game sprites.
bool _showingCategoryList
True if showing category list, false if showing entity codex.
std::filesystem::path _customSpritesPath
Path to custom sprites directory.
std::filesystem::path _spriteMappingPath
Path to sprite mapping config file.
std::map< std::string, sf::Texture > _loadedTextures
Cache of loaded textures.
void initializeModDirectory()
Initialize the custom sprites directory.
sf::Image resizeImage(const sf::Image &sourceImage, unsigned int targetWidth, unsigned int targetHeight)
Resize an image to match target dimensions.
size_t _selectedCategoryIndex
Currently selected category index.
ecs::Registry & _uiRegistry
Reference to the ECS registry.
void loadEntityCategories()
Load all entity categories and their sprites.
void applyCustomSprite(const EntitySpriteInfo &entity, const std::string &categoryName)
Apply a custom sprite to an entity.
sf::Texture * loadTexture(const std::string &texturePath)
Load a texture if not already loaded.
TranslationManager & _translationManager
Reference to the translation manager.
void update(float dt) override
Update the scene state.
Settings & _settings
Reference to the application settings.
std::vector< EntityCategory > _categories
Available entity categories with their sprites.
void handleEvent(const sf::Event &event) override
Handle an incoming event.
std::unordered_map< std::string, std::string > _customSpriteMappings
ChangeStateFn _changeState
Function to change the game state.
graphics::UiFactory & _uiFactory
UI Factory for creating UI components.
void onEnter(void) override
Called when the scene is entered.
void showEntityCodex(size_t categoryIndex)
Show the entity codex for a specific category.
std::string openFileDialog()
Open file dialog to select a custom sprite.
std::string getEntityKey(const EntitySpriteInfo &entity) const
Get the unique key for an entity.
void onExit(void) override
Called when the scene is exited.
std::function< void(GameState)> ChangeStateFn
Type alias for a function that changes the game state.
void saveSpriteMappings()
Save custom sprite mappings to config file.
void showCategoryList()
Show the main category selection screen.
void loadSpriteMappings()
Load custom sprite mappings from config file.
R-Type client namespace.
Category of entities with their sprites.
std::vector< EntitySpriteInfo > entities
List of entities in this category.
std::string name
Category name.
Information about an entity's sprite for the mod menu.
int rectLeft
Left position in sprite sheet.
std::string texturePath
Path to the texture.
int rectHeight
Height of the sprite.
int rectTop
Top position in sprite sheet.
std::string name
Display name of the entity.