22 : _spriteMappingPath(
"config/client/sprite_mappings.json")
38 log::warning(
"Sprite mappings file exists but is empty or invalid");
44 }
catch (
const std::exception& e) {
45 log::error(
"Failed to load sprite mappings: {}", e.what());
78 const std::string& defaultPath,
79 int& outLeft,
int& outTop,
80 int& outWidth,
int& outHeight)
const
88 log::debug(
"SpriteCustomizer: Using custom sprite '{}' with original dimensions {}x{}",
89 entityName, outWidth, outHeight);
114 log::info(
"SpriteCustomizer: Cleared world render system texture cache");
120 log::info(
"SpriteCustomizer: Cleared UI render system texture cache");
122 }
catch (
const std::exception& e) {
123 log::error(
"SpriteCustomizer: Error clearing texture caches: {}", e.what());
Logger declaration with support for multiple log levels.
Singleton class to manage custom sprite mappings globally.
std::filesystem::path _spriteMappingPath
static void clearTextureCaches()
Clear all texture caches in render systems This should be called when sprites are modified to ensure ...
void reloadMappings()
Reload sprite mappings (useful after modifications) This clears the cache and reloads from disk.
bool loadMappings()
Load sprite mappings from config file.
std::unordered_map< std::string, std::string > _customSpriteMappings
static void setRenderSystems(void *worldRenderSystem, void *uiRenderSystem)
Set render system pointers for cache clearing Called internally by Application during initialization.
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)
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.
static SpriteCustomizer & getInstance()
Get the singleton instance.
static void * s_worldRenderSystem
static void * s_uiRenderSystem
std::unordered_map< std::string, std::string > loadSpriteMappings(const std::string &filepath="config/client/sprite_mappings.json")
Load sprite mappings from a JSON file.
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.
void debug(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log a debug message.