forked from jaildesigner-jailgames/jaildoctors_dilemma
migrant .ani a .yaml
This commit is contained in:
@@ -301,13 +301,11 @@ void Cache::loadAnimations() {
|
||||
for (const auto& l : list) {
|
||||
auto name = getFileName(l);
|
||||
|
||||
// Parsear YAML y almacenar datos pre-cargados
|
||||
std::shared_ptr<Surface> surface;
|
||||
float frame_width = 0.0F;
|
||||
float frame_height = 0.0F;
|
||||
auto animation_data = SurfaceAnimatedSprite::loadAnimationsFromYAML(l, surface, frame_width, frame_height);
|
||||
// Cargar bytes del archivo YAML sin parsear (carga lazy)
|
||||
auto yaml_bytes = Helper::loadFile(l);
|
||||
|
||||
animations_.emplace_back(name, animation_data, surface, frame_width, frame_height);
|
||||
animations_.emplace_back(name, yaml_bytes);
|
||||
printWithDots("Animation : ", name, "[ LOADED ]");
|
||||
updateLoadingProgress();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,19 +80,13 @@ struct ResourceText {
|
||||
|
||||
// Estructura para almacenar ficheros animaciones y su nombre
|
||||
struct ResourceAnimation {
|
||||
std::string name; // Nombre del fichero
|
||||
std::vector<SurfaceAnimatedSprite::AnimationData> animations; // Datos de animaciones parseadas desde YAML
|
||||
std::shared_ptr<Surface> surface; // Surface asociada al sprite sheet
|
||||
float frame_width{0.0F}; // Ancho de cada frame
|
||||
float frame_height{0.0F}; // Alto de cada frame
|
||||
std::string name; // Nombre del fichero
|
||||
std::vector<uint8_t> yaml_data; // Bytes del archivo YAML sin parsear
|
||||
|
||||
// Constructor
|
||||
ResourceAnimation(std::string name, std::vector<SurfaceAnimatedSprite::AnimationData> animations, std::shared_ptr<Surface> surface, float frame_width, float frame_height)
|
||||
ResourceAnimation(std::string name, std::vector<uint8_t> yaml_data)
|
||||
: name(std::move(name)),
|
||||
animations(std::move(animations)),
|
||||
surface(std::move(surface)),
|
||||
frame_width(frame_width),
|
||||
frame_height(frame_height) {}
|
||||
yaml_data(std::move(yaml_data)) {}
|
||||
};
|
||||
|
||||
// Estructura para almacenar ficheros con el mapa de tiles de una habitación y su nombre
|
||||
@@ -250,7 +244,7 @@ class Cache {
|
||||
// Obtiene el objeto de texto a partir de un nombre
|
||||
auto getText(const std::string& name) -> std::shared_ptr<Text>;
|
||||
|
||||
// Obtiene los datos de animación parseados a partir de un nombre
|
||||
// Obtiene los bytes YAML de animación a partir de un nombre (parsing lazy)
|
||||
auto getAnimationData(const std::string& name) -> const ResourceAnimation&;
|
||||
|
||||
// Obtiene el mapa de tiles a partir de un nombre
|
||||
|
||||
Reference in New Issue
Block a user