integrades mes clases amb ResourceHelper

mogudes les dades de la demo a resource.pack
This commit is contained in:
2025-08-19 13:08:37 +02:00
parent 8cfe28922c
commit 6bf8490776
9 changed files with 116 additions and 30 deletions

View File

@@ -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);