migrant .ani a .yaml

This commit is contained in:
2025-11-17 13:08:38 +01:00
parent 3c4092df5e
commit 6a6cc22b21
72 changed files with 47 additions and 1050 deletions
+11 -4
View File
@@ -148,12 +148,12 @@ auto Cache::getText(const std::string& name) -> std::shared_ptr<Text> {
throw std::runtime_error("Texto no encontrado: " + name);
}
// Obtiene la animación a partir de un nombre
auto Cache::getAnimations(const std::string& name) -> SurfaceAnimatedSprite::Animations& {
// Obtiene los datos de animación parseados a partir de un nombre
auto Cache::getAnimationData(const std::string& name) -> const ResourceAnimation& {
auto it = std::ranges::find_if(animations_, [&name](const auto& a) { return a.name == name; });
if (it != animations_.end()) {
return it->animation;
return *it;
}
std::cerr << "Error: Animación no encontrada " << name << '\n';
@@ -300,7 +300,14 @@ void Cache::loadAnimations() {
for (const auto& l : list) {
auto name = getFileName(l);
animations_.emplace_back(name, SurfaceAnimatedSprite::loadAnimationsFromFile(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);
animations_.emplace_back(name, animation_data, surface, frame_width, frame_height);
updateLoadingProgress();
}
}