7#include "../json_helper.h"
8#include "../DataManager.h"
9#include "../system/system_utils.h"
25 SYSTEM_LOG <<
"AnimationBank: Failed to load file: " << filePath <<
"\n";
43 if (
j.contains(
"spritesheets") &&
j[
"spritesheets"].is_array())
45 for (
const auto&
sheetJson :
j[
"spritesheets"])
71 if (
sheet.texture ==
nullptr && !
sheet.path.empty())
82 if (
j.contains(
"animations") &&
j[
"animations"].is_array())
84 for (
const auto&
animJson :
j[
"animations"])
106 event.dataJson =
eventJson[
"data"].dump();
123 catch (
const std::exception&
e)
125 SYSTEM_LOG <<
"AnimationBank: Error parsing JSON: " <<
e.what() <<
"\n";
ComponentTypeID GetComponentTypeID_Static()
static DataManager & Get()
Sprite * GetTexture(const std::string &id) const
bool PreloadTexture(const std::string &id, const std::string &path, ResourceCategory category=ResourceCategory::System)
Animation * GetAnimation(const std::string &name)
std::unordered_map< std::string, Animation > m_animations
bool LoadFromFile(const std::string &filePath)
SpriteSheet * GetSpriteSheet(const std::string &id)
bool ParseJSON(const std::string &jsonContent)
std::string m_description
std::unordered_map< std::string, SpriteSheet > m_spritesheets
std::string GetString(const json &j, const std::string &key, const std::string &defaultValue="")
Safely get a string value from JSON.
bool LoadJsonFromFile(const std::string &filepath, json &j)
Load and parse a JSON file.
int GetInt(const json &j, const std::string &key, int defaultValue=0)
Safely get an integer value from JSON.
float GetFloat(const json &j, const std::string &key, float defaultValue=0.0f)
Safely get a float value from JSON.
bool GetBool(const json &j, const std::string &key, bool defaultValue=false)
Safely get a boolean value from JSON.