acabat amb resource.pack

This commit is contained in:
2026-04-16 16:21:44 +02:00
parent b2d5f5af61
commit 4244bcaea3
11 changed files with 55 additions and 167 deletions

View File

@@ -19,6 +19,7 @@
#include "core/rendering/menu.hpp"
#include "core/rendering/overlay.hpp"
#include "core/rendering/screen.hpp"
#include "core/resources/resource_helper.hpp"
#include "core/system/director.hpp"
#include "game/options.hpp"
@@ -32,10 +33,27 @@ SDL_AppResult SDL_AppInit(void** /*appstate*/, int /*argc*/, char* /*argv*/[]) {
// SDL_GetBasePath() detecta automàticament si estem dins d'un .app bundle
// (retorna Contents/Resources/) o en un executable normal (carpeta del binari).
const char* base_path = SDL_GetBasePath();
std::string resource_pack_path;
if (base_path) {
const std::string data_path = std::string(base_path) + "data/";
file_setresourcefolder(data_path.c_str());
resource_pack_path = std::string(base_path) + "resource.pack";
} else {
resource_pack_path = "resource.pack";
}
// Sistema de recursos: prova el pack i cau a fitxers solts dins data/.
// Release natiu exigix el pack (sense fallback); Debug i WASM mantenen
// el fallback actiu per a desenvolupament i per al build amb MEMFS.
#if defined(NDEBUG) && !defined(__EMSCRIPTEN__)
const bool enable_fallback = false;
#else
const bool enable_fallback = true;
#endif
if (!ResourceHelper::initializeResourceSystem(resource_pack_path, enable_fallback)) {
return SDL_APP_FAILURE;
}
Options::setConfigFile(std::string(file_getconfigfolder()) + "config.yaml");
Options::loadFromFile();
@@ -102,4 +120,5 @@ void SDL_AppQuit(void* /*appstate*/, SDL_AppResult /*result*/) {
JD8_Quit();
Screen::destroy();
JG_Finalize();
ResourceHelper::shutdownResourceSystem();
}