encamina la resta de loads pel ResourceHelper i restaura SmartSprite::update
This commit is contained in:
@@ -5,9 +5,10 @@
|
||||
#include <iostream> // for cout
|
||||
#include <sstream>
|
||||
|
||||
#include "core/rendering/sprite.h" // for Sprite
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "utils/utils.h" // for color_t
|
||||
#include "core/rendering/sprite.h" // for Sprite
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/resources/resource_helper.h" // for loadFile (pack + filesystem fallback)
|
||||
#include "utils/utils.h" // for color_t
|
||||
|
||||
// Parser compartido: rellena un textFile_t desde cualquier istream
|
||||
static void parseTextFileStream(std::istream &rfile, textFile_t &tf) {
|
||||
@@ -38,30 +39,29 @@ static void computeTextFileOffsets(textFile_t &tf) {
|
||||
}
|
||||
}
|
||||
|
||||
// Llena una estructuta textFile_t desde un fichero
|
||||
// Llena una estructuta textFile_t desde un fichero (vía ResourceHelper: pack o filesystem)
|
||||
auto LoadTextFile(const std::string &file, bool verbose) -> textFile_t {
|
||||
textFile_t tf;
|
||||
tf.boxWidth = 0;
|
||||
tf.boxHeight = 0;
|
||||
for (auto &i : tf.offset) {
|
||||
i.x = 0;
|
||||
i.y = 0;
|
||||
i.w = 0;
|
||||
}
|
||||
|
||||
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
|
||||
std::ifstream rfile(file);
|
||||
if (rfile.is_open() && rfile.good()) {
|
||||
parseTextFileStream(rfile, tf);
|
||||
auto bytes = ResourceHelper::loadFile(file);
|
||||
if (bytes.empty()) {
|
||||
if (verbose) {
|
||||
std::cout << "Text loaded: " << filename.c_str() << '\n';
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << '\n';
|
||||
}
|
||||
} else if (verbose) {
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << '\n';
|
||||
textFile_t tf;
|
||||
tf.boxWidth = 0;
|
||||
tf.boxHeight = 0;
|
||||
for (auto &i : tf.offset) {
|
||||
i.x = 0;
|
||||
i.y = 0;
|
||||
i.w = 0;
|
||||
}
|
||||
computeTextFileOffsets(tf);
|
||||
return tf;
|
||||
}
|
||||
|
||||
computeTextFileOffsets(tf);
|
||||
return tf;
|
||||
if (verbose) {
|
||||
std::cout << "Text loaded: " << filename.c_str() << '\n';
|
||||
}
|
||||
return LoadTextFileFromMemory(bytes, verbose);
|
||||
}
|
||||
|
||||
// Llena una estructura textFile_t desde bytes en memoria
|
||||
|
||||
Reference in New Issue
Block a user