encamina la resta de loads pel ResourceHelper i restaura SmartSprite::update
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
#include <iostream> // for cout
|
||||
#include <sstream> // for basic_stringstream
|
||||
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/resources/resource_helper.h" // for loadFile (pack + filesystem fallback)
|
||||
|
||||
// Parser compartido: lee un istream con el formato .ani
|
||||
static auto parseAnimationStream(std::istream &file, Texture *texture, const std::string &filename, bool verbose) -> animatedSprite_t {
|
||||
@@ -96,11 +97,11 @@ static auto parseAnimationStream(std::istream &file, Texture *texture, const std
|
||||
return as;
|
||||
}
|
||||
|
||||
// Carga la animación desde un fichero
|
||||
// Carga la animación desde un fichero (vía ResourceHelper: pack si està inicialitzat, filesystem si no)
|
||||
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose) -> animatedSprite_t {
|
||||
const std::string filename = filePath.substr(filePath.find_last_of("\\/") + 1);
|
||||
std::ifstream file(filePath);
|
||||
if (!file.good()) {
|
||||
auto bytes = ResourceHelper::loadFile(filePath);
|
||||
if (bytes.empty()) {
|
||||
if (verbose) {
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << '\n';
|
||||
}
|
||||
@@ -108,7 +109,7 @@ auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool v
|
||||
as.texture = texture;
|
||||
return as;
|
||||
}
|
||||
return parseAnimationStream(file, texture, filename, verbose);
|
||||
return loadAnimationFromMemory(texture, bytes, filename, verbose);
|
||||
}
|
||||
|
||||
// Carga la animación desde bytes en memoria
|
||||
|
||||
Reference in New Issue
Block a user