|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Singleton class to manage custom sprite mappings globally. More...
#include <SpriteCustomizer.hpp>
Public Member Functions | |
| bool | loadMappings () |
| Load sprite mappings from config file. | |
| void | reloadMappings () |
| Reload sprite mappings (useful after modifications) This clears the cache and reloads from disk. | |
| bool | hasCustomSprite (const std::string &entityName) const |
| Check if an entity has a custom sprite. | |
| std::string | getSpritePath (const std::string &entityName, const std::string &defaultPath) const |
| Get the custom sprite path for an entity. | |
| std::string | getSpriteInfo (const std::string &entityName, const std::string &defaultPath, int &outLeft, int &outTop, int &outWidth, int &outHeight) const |
| Get custom sprite info (path and coordinates for full sprite) | |
Static Public Member Functions | |
| static SpriteCustomizer & | getInstance () |
| Get the singleton instance. | |
| static void | clearTextureCaches () |
| Clear all texture caches in render systems This should be called when sprites are modified to ensure that cached textures are reloaded with the new sprites. | |
| static void | setRenderSystems (void *worldRenderSystem, void *uiRenderSystem) |
| Set render system pointers for cache clearing Called internally by Application during initialization. | |
Private Member Functions | |
| SpriteCustomizer () | |
| ~SpriteCustomizer ()=default | |
| SpriteCustomizer (const SpriteCustomizer &)=delete | |
| SpriteCustomizer & | operator= (const SpriteCustomizer &)=delete |
| SpriteCustomizer (SpriteCustomizer &&)=delete | |
| SpriteCustomizer & | operator= (SpriteCustomizer &&)=delete |
Private Attributes | |
| std::filesystem::path | _spriteMappingPath |
| std::unordered_map< std::string, std::string > | _customSpriteMappings |
Singleton class to manage custom sprite mappings globally.
This class allows the game to check if an entity has a custom sprite and provides the path to that custom sprite if it exists.
Definition at line 25 of file SpriteCustomizer.hpp.
|
private |
Definition at line 21 of file SpriteCustomizer.cpp.
References loadMappings().
|
privatedefault |
|
privatedelete |
|
privatedelete |
|
static |
Clear all texture caches in render systems This should be called when sprites are modified to ensure that cached textures are reloaded with the new sprites.
Definition at line 108 of file SpriteCustomizer.cpp.
References rtp::client::RenderSystem::clearTextureCache(), rtp::client::systems::UIRenderSystem::clearTextureCache(), rtp::log::error(), rtp::log::info(), rtp::client::s_uiRenderSystem, and rtp::client::s_worldRenderSystem.
Referenced by rtp::client::scenes::ModMenuScene::applyCustomSprite(), and rtp::client::scenes::ModMenuScene::showEntityCodex().
|
static |
Get the singleton instance.
Definition at line 15 of file SpriteCustomizer.cpp.
Referenced by rtp::client::scenes::ModMenuScene::applyCustomSprite(), rtp::client::scenes::ModMenuScene::handleEvent(), rtp::client::scenes::ModMenuScene::showCategoryList(), rtp::client::scenes::ModMenuScene::showEntityCodex(), and rtp::client::EntityBuilder::spawn().
| std::string rtp::client::SpriteCustomizer::getSpriteInfo | ( | const std::string & | entityName, |
| const std::string & | defaultPath, | ||
| int & | outLeft, | ||
| int & | outTop, | ||
| int & | outWidth, | ||
| int & | outHeight | ||
| ) | const |
Get custom sprite info (path and coordinates for full sprite)
| entityName | Name of the entity |
| defaultPath | Default sprite path |
| outLeft | Output rect left position (set to 0 if custom sprite) |
| outTop | Output rect top position (set to 0 if custom sprite) |
| outWidth | Output width (set to texture width if custom sprite) |
| outHeight | Output height (set to texture height if custom sprite) |
Definition at line 77 of file SpriteCustomizer.cpp.
References _customSpriteMappings, and rtp::log::debug().
| std::string rtp::client::SpriteCustomizer::getSpritePath | ( | const std::string & | entityName, |
| const std::string & | defaultPath | ||
| ) | const |
Get the custom sprite path for an entity.
| entityName | Name of the entity |
| defaultPath | Default sprite path (returned if no custom sprite exists) |
Definition at line 68 of file SpriteCustomizer.cpp.
References _customSpriteMappings.
| bool rtp::client::SpriteCustomizer::hasCustomSprite | ( | const std::string & | entityName | ) | const |
Check if an entity has a custom sprite.
| entityName | Name of the entity |
Definition at line 57 of file SpriteCustomizer.cpp.
References _customSpriteMappings.
| bool rtp::client::SpriteCustomizer::loadMappings | ( | ) |
Load sprite mappings from config file.
Definition at line 27 of file SpriteCustomizer.cpp.
References _customSpriteMappings, _spriteMappingPath, rtp::log::error(), rtp::log::info(), rtp::config::loadSpriteMappings(), and rtp::log::warning().
Referenced by SpriteCustomizer(), and reloadMappings().
|
privatedelete |
|
privatedelete |
| void rtp::client::SpriteCustomizer::reloadMappings | ( | ) |
Reload sprite mappings (useful after modifications) This clears the cache and reloads from disk.
Definition at line 50 of file SpriteCustomizer.cpp.
References _customSpriteMappings, rtp::log::info(), and loadMappings().
Referenced by rtp::client::scenes::ModMenuScene::applyCustomSprite(), rtp::client::scenes::ModMenuScene::handleEvent(), rtp::client::scenes::ModMenuScene::showCategoryList(), and rtp::client::scenes::ModMenuScene::showEntityCodex().
|
static |
Set render system pointers for cache clearing Called internally by Application during initialization.
| worldRenderSystem | Pointer to world render system |
| uiRenderSystem | Pointer to UI render system |
Definition at line 102 of file SpriteCustomizer.cpp.
References rtp::client::s_uiRenderSystem, and rtp::client::s_worldRenderSystem.
Referenced by rtp::client::Application::initUiSystems(), and rtp::client::Application::initWorldSystems().
|
private |
Definition at line 101 of file SpriteCustomizer.hpp.
Referenced by getSpriteInfo(), getSpritePath(), hasCustomSprite(), loadMappings(), and reloadMappings().
|
private |
Definition at line 100 of file SpriteCustomizer.hpp.
Referenced by loadMappings().