actualitzada la carpeta release a SDL3

migrat a resources.pack
This commit is contained in:
2025-10-31 22:58:37 +01:00
parent 70bfced50d
commit 8c6bea897c
513 changed files with 377587 additions and 29821 deletions

View File

@@ -16,6 +16,8 @@
#include "core/rendering/screen.hpp" // Para Screen
#include "core/resources/asset.hpp" // Para Asset, AssetType
#include "core/resources/resource.hpp" // Para Resource
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
#include "core/resources/resource_loader.hpp" // Para ResourceLoader
#include "core/system/debug.hpp" // Para Debug
#include "game/gameplay/cheevos.hpp" // Para Cheevos
#include "game/options.hpp" // Para Options, options, OptionsVideo
@@ -45,18 +47,75 @@ Director::Director(std::vector<std::string> const& args) {
// Comprueba los parametros del programa
executable_path_ = getPath(checkProgramArguments(args));
// Crea el objeto que controla los ficheros de recursos
Asset::init(executable_path_);
// Crea la carpeta del sistema donde guardar datos
createSystemFolder("jailgames");
createSystemFolder("jailgames/jaildoctors_dilemma");
// Si falta algún fichero no inicia el programa
// Determinar el prefijo de ruta según la plataforma
#ifdef MACOS_BUNDLE
const std::string PREFIX = "/../Resources";
#else
const std::string PREFIX;
#endif
// Preparar ruta al pack (en macOS bundle está en Contents/Resources/)
std::string pack_path = executable_path_ + PREFIX + "/resources.pack";
#ifdef RELEASE_BUILD
// ============================================================
// RELEASE BUILD: Pack-first architecture
// ============================================================
std::cout << "\n** RELEASE MODE: Pack-first initialization\n";
// 1. Initialize resource pack system (required, no fallback)
std::cout << "Initializing resource pack: " << pack_path << '\n';
if (!jdd::ResourceHelper::initializeResourceSystem(pack_path, false)) {
std::cerr << "ERROR: Failed to load resources.pack (required in release builds)\n";
exit(EXIT_FAILURE);
}
// 2. Validate pack integrity
std::cout << "Validating pack integrity..." << '\n';
if (!jdd::ResourceLoader::get().validatePack()) {
std::cerr << "ERROR: Pack validation failed\n";
exit(EXIT_FAILURE);
}
// 3. Load assets.txt from pack
std::cout << "Loading assets configuration from pack..." << '\n';
std::string assets_config = jdd::ResourceLoader::get().loadAssetsConfig();
if (assets_config.empty()) {
std::cerr << "ERROR: Failed to load assets.txt from pack\n";
exit(EXIT_FAILURE);
}
// 4. Initialize Asset system with config from pack
// NOTE: In release, don't use executable_path or PREFIX - paths in pack are relative
// Pass empty string to avoid issues when running from different directories
Asset::init(""); // Empty executable_path in release
Asset::get()->loadFromString(assets_config, "", system_folder_); // Empty PREFIX for pack
std::cout << "Asset system initialized from pack\n";
#else
// ============================================================
// DEVELOPMENT BUILD: Filesystem-first architecture
// ============================================================
std::cout << "\n** DEVELOPMENT MODE: Filesystem-first initialization\n";
// 1. Initialize Asset system from filesystem
Asset::init(executable_path_);
// 2. Load and verify assets from disk
if (!setFileList()) {
exit(EXIT_FAILURE);
}
// 3. Initialize resource pack system (optional, with fallback)
std::cout << "Initializing resource pack (development mode): " << pack_path << '\n';
jdd::ResourceHelper::initializeResourceSystem(pack_path, true);
#endif
// Carga las opciones desde un fichero
Options::loadFromFile(Asset::get()->get("config.txt"));
@@ -66,13 +125,32 @@ Director::Director(std::vector<std::string> const& args) {
// Crea los objetos
Screen::init();
SDL_HideCursor();
// Initialize resources (works for both release and development)
Resource::init();
Notifier::init("", "8bithud");
Screen::get()->setNotificationsEnabled(true);
// Special handling for gamecontrollerdb.txt - SDL needs filesystem path
#ifdef RELEASE_BUILD
// In release, construct the path manually (not from Asset which has empty executable_path)
std::string gamecontroller_db = executable_path_ + PREFIX + "/gamecontrollerdb.txt";
Input::init(gamecontroller_db);
#else
// In development, use Asset as normal
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
#endif
initInput();
Debug::init();
// Special handling for cheevos.bin - also needs filesystem path
#ifdef RELEASE_BUILD
std::string cheevos_path = system_folder_ + "/cheevos.bin";
Cheevos::init(cheevos_path);
#else
Cheevos::init(Asset::get()->get("cheevos.bin"));
#endif
}
Director::~Director() {
@@ -85,6 +163,7 @@ Director::~Director() {
Input::destroy();
Notifier::destroy();
Resource::destroy();
jdd::ResourceHelper::shutdownResourceSystem(); // Shutdown resource pack system
Audio::destroy();
Screen::destroy();
Asset::destroy();