integrades mes clases amb ResourceHelper
mogudes les dades de la demo a resource.pack
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <string> // Para basic_string, allocator, string, operator==, operator+, char_traits
|
||||
|
||||
#include "lang.h" // Para getText
|
||||
#include "resource_helper.h" // Para ResourceHelper
|
||||
|
||||
// Variables
|
||||
Overrides overrides = Overrides();
|
||||
@@ -323,8 +324,17 @@ void printWithDots(const std::string &text1, const std::string &text2, const std
|
||||
auto loadDemoDataFromFile(const std::string &file_path) -> DemoData {
|
||||
DemoData dd;
|
||||
|
||||
// Indicador de éxito en la carga
|
||||
auto *file = SDL_IOFromFile(file_path.c_str(), "r+b");
|
||||
SDL_IOStream *file = nullptr;
|
||||
|
||||
// Intentar cargar desde ResourceHelper primero
|
||||
auto resource_data = ResourceHelper::loadFile(file_path);
|
||||
if (!resource_data.empty()) {
|
||||
file = SDL_IOFromConstMem(resource_data.data(), resource_data.size());
|
||||
} else {
|
||||
// Fallback a filesystem directo
|
||||
file = SDL_IOFromFile(file_path.c_str(), "r+b");
|
||||
}
|
||||
|
||||
if (file == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Fichero no encontrado %s", file_path.c_str());
|
||||
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
||||
|
||||
Reference in New Issue
Block a user