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

@@ -11,6 +11,7 @@
#include "difficulty.h" // Para Difficulty
#include "external/json.hpp" // Para basic_json, iteration_proxy_value, oper...
#include "options.h" // Para SettingsOpt...
#include "resource_helper.h" // Para ResourceHelper
using json = nlohmann::json;
@@ -27,14 +28,24 @@ std::vector<Language> languages = {
auto loadFromFile(const std::string &file_path) -> bool {
texts.clear();
std::ifstream rfile(file_path);
if (!rfile.is_open()) {
return false;
}
// Intentar cargar desde ResourceHelper primero
auto resource_data = ResourceHelper::loadFile(file_path);
try {
json j;
rfile >> j;
if (!resource_data.empty()) {
// Cargar desde datos del pack
std::string content(resource_data.begin(), resource_data.end());
j = json::parse(content);
} else {
// Fallback a filesystem directo
std::ifstream rfile(file_path);
if (!rfile.is_open()) {
return false;
}
rfile >> j;
}
for (const auto &el : j.items()) {
texts[el.key()] = el.value();