forked from jaildesigner-jailgames/jaildoctors_dilemma
unificats els resources en un namespace
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
#include <algorithm> // Para max
|
||||
#include <memory> // Para __shared_ptr_access, shared_ptr
|
||||
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "utils/utils.hpp" // Para Color
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "utils/utils.hpp" // Para Color
|
||||
|
||||
// [SINGLETON]
|
||||
Debug* Debug::debug = nullptr;
|
||||
@@ -27,7 +27,7 @@ auto Debug::get() -> Debug* {
|
||||
|
||||
// Dibuja en pantalla
|
||||
void Debug::render() {
|
||||
auto text = Resource::get()->getText("aseprite");
|
||||
auto text = Resource::Cache::get()->getText("aseprite");
|
||||
int y = y_;
|
||||
int w = 0;
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/input.hpp" // Para Input, InputAction
|
||||
#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_cache.hpp" // Para Resource
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
#include "core/resources/resource_list.hpp" // Para Asset, AssetType
|
||||
#include "core/resources/resource_loader.hpp" // Para ResourceLoader
|
||||
#include "core/system/debug.hpp" // Para Debug
|
||||
#include "game/gameplay/cheevos.hpp" // Para Cheevos
|
||||
@@ -69,7 +69,7 @@ Director::Director(std::vector<std::string> const& args) {
|
||||
|
||||
// 1. Initialize resource pack system (required, no fallback)
|
||||
std::cout << "Initializing resource pack: " << pack_path << '\n';
|
||||
if (!jdd::ResourceHelper::initializeResourceSystem(pack_path, false)) {
|
||||
if (!Resource::Helper::initializeResourceSystem(pack_path, false)) {
|
||||
std::cerr << "ERROR: Failed to load resources.pack (required in release builds)\n";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -92,8 +92,8 @@ Director::Director(std::vector<std::string> const& args) {
|
||||
// 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
|
||||
Resource::List::init(""); // Empty executable_path in release
|
||||
Resource::List::get()->loadFromString(assets_config, "", system_folder_); // Empty PREFIX for pack
|
||||
std::cout << "Asset system initialized from pack\n";
|
||||
|
||||
#else
|
||||
@@ -103,7 +103,7 @@ Director::Director(std::vector<std::string> const& args) {
|
||||
std::cout << "\n** DEVELOPMENT MODE: Filesystem-first initialization\n";
|
||||
|
||||
// 1. Initialize Asset system from filesystem
|
||||
Asset::init(executable_path_);
|
||||
Resource::List::init(executable_path_);
|
||||
|
||||
// 2. Load and verify assets from disk
|
||||
if (!setFileList()) {
|
||||
@@ -112,12 +112,12 @@ Director::Director(std::vector<std::string> const& args) {
|
||||
|
||||
// 3. Initialize resource pack system (optional, with fallback)
|
||||
std::cout << "Initializing resource pack (development mode): " << pack_path << '\n';
|
||||
Jdd::ResourceHelper::initializeResourceSystem(pack_path, true);
|
||||
Resource::Helper::initializeResourceSystem(pack_path, true);
|
||||
|
||||
#endif
|
||||
|
||||
// Carga las opciones desde un fichero
|
||||
Options::loadFromFile(Asset::get()->get("config.txt"));
|
||||
Options::loadFromFile(Resource::List::get()->get("config.txt"));
|
||||
|
||||
// Inicializa JailAudio
|
||||
Audio::init();
|
||||
@@ -126,7 +126,7 @@ Director::Director(std::vector<std::string> const& args) {
|
||||
Screen::init();
|
||||
|
||||
// Initialize resources (works for both release and development)
|
||||
Resource::init();
|
||||
Resource::Cache::init();
|
||||
Notifier::init("", "8bithud");
|
||||
Screen::get()->setNotificationsEnabled(true);
|
||||
|
||||
@@ -134,10 +134,10 @@ Director::Director(std::vector<std::string> const& args) {
|
||||
#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, Asset::get()->get("controllers.json"));
|
||||
Input::init(gamecontroller_db, Resource::List::get()->get("controllers.json"));
|
||||
#else
|
||||
// In development, use Asset as normal
|
||||
Input::init(Asset::get()->get("gamecontrollerdb.txt"), Asset::get()->get("controllers.json")); // Carga configuración de controles
|
||||
Input::init(Resource::List::get()->get("gamecontrollerdb.txt"), Resource::List::get()->get("controllers.json")); // Carga configuración de controles
|
||||
#endif
|
||||
|
||||
// Aplica las teclas configuradas desde Options
|
||||
@@ -150,24 +150,24 @@ Director::Director(std::vector<std::string> const& args) {
|
||||
std::string cheevos_path = system_folder_ + "/cheevos.bin";
|
||||
Cheevos::init(cheevos_path);
|
||||
#else
|
||||
Cheevos::init(Asset::get()->get("cheevos.bin"));
|
||||
Cheevos::init(Resource::List::get()->get("cheevos.bin"));
|
||||
#endif
|
||||
}
|
||||
|
||||
Director::~Director() {
|
||||
// Guarda las opciones a un fichero
|
||||
Options::saveToFile(Asset::get()->get("config.txt"));
|
||||
Options::saveToFile(Resource::List::get()->get("config.txt"));
|
||||
|
||||
// Destruye los singletones
|
||||
Cheevos::destroy();
|
||||
Debug::destroy();
|
||||
Input::destroy();
|
||||
Notifier::destroy();
|
||||
Resource::destroy();
|
||||
Jdd::ResourceHelper::shutdownResourceSystem(); // Shutdown resource pack system
|
||||
Resource::Cache::destroy();
|
||||
Resource::Helper::shutdownResourceSystem(); // Shutdown resource pack system
|
||||
Audio::destroy();
|
||||
Screen::destroy();
|
||||
Asset::destroy();
|
||||
Resource::List::destroy();
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
@@ -264,10 +264,10 @@ auto Director::setFileList() -> bool {
|
||||
std::string config_path = executable_path_ + PREFIX + "/config/assets.txt";
|
||||
|
||||
// Cargar todos los assets desde el archivo de configuración
|
||||
Asset::get()->loadFromFile(config_path, PREFIX, system_folder_);
|
||||
Resource::List::get()->loadFromFile(config_path, PREFIX, system_folder_);
|
||||
|
||||
// Verificar que todos los assets requeridos existen
|
||||
return Asset::get()->check();
|
||||
return Resource::List::get()->check();
|
||||
}
|
||||
|
||||
// Ejecuta la seccion de juego con el logo
|
||||
|
||||
Reference in New Issue
Block a user