forked from jaildesigner-jailgames/jaildoctors_dilemma
unificats els resources en un namespace
This commit is contained in:
@@ -13,9 +13,9 @@
|
||||
#include "core/rendering/opengl/opengl_shader.hpp" // Para OpenGLShader
|
||||
#include "core/rendering/surface.hpp" // Para Surface, readPalFile
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#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 "game/options.hpp" // Para Options, options, OptionsVideo, Border
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
|
||||
@@ -41,7 +41,7 @@ auto Screen::get() -> Screen* {
|
||||
Screen::Screen()
|
||||
: window_width_(0),
|
||||
window_height_(0),
|
||||
palettes_(Asset::get()->getListByType(Asset::Type::PALETTE)) {
|
||||
palettes_(Resource::List::get()->getListByType(Resource::List::Type::PALETTE)) {
|
||||
// Arranca SDL VIDEO, crea la ventana y el renderizador
|
||||
initSDLVideo();
|
||||
if (Options::video.fullscreen) {
|
||||
@@ -274,8 +274,8 @@ void Screen::previousPalette() {
|
||||
|
||||
// Establece la paleta
|
||||
void Screen::setPalete() {
|
||||
game_surface_->loadPalette(Resource::get()->getPalette(palettes_.at(current_palette_)));
|
||||
border_surface_->loadPalette(Resource::get()->getPalette(palettes_.at(current_palette_)));
|
||||
game_surface_->loadPalette(Resource::Cache::get()->getPalette(palettes_.at(current_palette_)));
|
||||
border_surface_->loadPalette(Resource::Cache::get()->getPalette(palettes_.at(current_palette_)));
|
||||
|
||||
Options::video.palette = palettes_.at(current_palette_);
|
||||
|
||||
@@ -341,8 +341,8 @@ auto Screen::findPalette(const std::string& name) -> size_t {
|
||||
|
||||
// Muestra información por pantalla
|
||||
void Screen::renderInfo() {
|
||||
if (show_debug_info_ && (Resource::get() != nullptr)) {
|
||||
auto text = Resource::get()->getText("smb2");
|
||||
if (show_debug_info_ && (Resource::Cache::get() != nullptr)) {
|
||||
auto text = Resource::Cache::get()->getText("smb2");
|
||||
auto color = static_cast<Uint8>(PaletteColor::YELLOW);
|
||||
|
||||
// FPS
|
||||
@@ -397,7 +397,7 @@ auto Screen::getBorderSurface() -> std::shared_ptr<Surface> { return border_surf
|
||||
|
||||
auto loadData(const std::string& filepath) -> std::vector<uint8_t> {
|
||||
// Load using ResourceHelper (supports both filesystem and pack)
|
||||
return Jdd::ResourceHelper::loadFile(filepath);
|
||||
return Resource::Helper::loadFile(filepath);
|
||||
}
|
||||
|
||||
// Carga el contenido de los archivos GLSL
|
||||
@@ -406,12 +406,12 @@ void Screen::loadShaders() {
|
||||
// Detectar si necesitamos OpenGL ES (Raspberry Pi)
|
||||
// Intentar cargar versión ES primero si existe
|
||||
std::string vertex_file = "crtpi_vertex_es.glsl";
|
||||
auto data = loadData(Asset::get()->get(vertex_file));
|
||||
auto data = loadData(Resource::List::get()->get(vertex_file));
|
||||
|
||||
if (data.empty()) {
|
||||
// Si no existe versión ES, usar versión Desktop
|
||||
vertex_file = "crtpi_vertex.glsl";
|
||||
data = loadData(Asset::get()->get(vertex_file));
|
||||
data = loadData(Resource::List::get()->get(vertex_file));
|
||||
std::cout << "Usando shaders OpenGL Desktop 3.3\n";
|
||||
} else {
|
||||
std::cout << "Usando shaders OpenGL ES 3.0 (Raspberry Pi)\n";
|
||||
@@ -424,12 +424,12 @@ void Screen::loadShaders() {
|
||||
if (fragment_shader_source_.empty()) {
|
||||
// Intentar cargar versión ES primero si existe
|
||||
std::string fragment_file = "crtpi_fragment_es.glsl";
|
||||
auto data = loadData(Asset::get()->get(fragment_file));
|
||||
auto data = loadData(Resource::List::get()->get(fragment_file));
|
||||
|
||||
if (data.empty()) {
|
||||
// Si no existe versión ES, usar versión Desktop
|
||||
fragment_file = "crtpi_fragment.glsl";
|
||||
data = loadData(Asset::get()->get(fragment_file));
|
||||
data = loadData(Resource::List::get()->get(fragment_file));
|
||||
}
|
||||
|
||||
if (!data.empty()) {
|
||||
@@ -582,8 +582,8 @@ auto Screen::initSDLVideo() -> bool {
|
||||
// Crea el objeto de texto
|
||||
void Screen::createText() {
|
||||
// Carga la surface de la fuente directamente del archivo
|
||||
auto surface = std::make_shared<Surface>(Asset::get()->get("aseprite.gif"));
|
||||
auto surface = std::make_shared<Surface>(Resource::List::get()->get("aseprite.gif"));
|
||||
|
||||
// Crea el objeto de texto (el constructor de Text carga el archivo text_file internamente)
|
||||
text_ = std::make_shared<Text>(surface, Asset::get()->get("aseprite.txt"));
|
||||
text_ = std::make_shared<Text>(surface, Resource::List::get()->get("aseprite.txt"));
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
// Carga una paleta desde un archivo .gif
|
||||
auto loadPalette(const std::string& file_path) -> Palette {
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto buffer = Jdd::ResourceHelper::loadFile(file_path);
|
||||
auto buffer = Resource::Helper::loadFile(file_path);
|
||||
if (buffer.empty()) {
|
||||
throw std::runtime_error("Error opening file: " + file_path);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ auto readPalFile(const std::string& file_path) -> Palette {
|
||||
palette.fill(0); // Inicializar todo con 0 (transparente por defecto)
|
||||
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto file_data = Jdd::ResourceHelper::loadFile(file_path);
|
||||
auto file_data = Resource::Helper::loadFile(file_path);
|
||||
if (file_data.empty()) {
|
||||
throw std::runtime_error("No se pudo abrir el archivo .pal: " + file_path);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ Surface::Surface(const std::string& file_path)
|
||||
// Carga una superficie desde un archivo
|
||||
auto Surface::loadSurface(const std::string& file_path) -> SurfaceData {
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
std::vector<Uint8> buffer = Jdd::ResourceHelper::loadFile(file_path);
|
||||
std::vector<Uint8> buffer = Resource::Helper::loadFile(file_path);
|
||||
if (buffer.empty()) {
|
||||
std::cerr << "Error opening file: " << file_path << '\n';
|
||||
throw std::runtime_error("Error opening file");
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#include <utility>
|
||||
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
#include "utils/utils.hpp" // Para printWithDots
|
||||
|
||||
// Carga las animaciones en un vector(Animations) desde un fichero
|
||||
auto loadAnimationsFromFile(const std::string& file_path) -> Animations {
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto file_data = Jdd::ResourceHelper::loadFile(file_path);
|
||||
auto file_data = Resource::Helper::loadFile(file_path);
|
||||
if (file_data.empty()) {
|
||||
std::cerr << "Error: Fichero no encontrado " << file_path << '\n';
|
||||
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
||||
@@ -192,7 +192,7 @@ auto parseGlobalParameter(const std::string& line, std::shared_ptr<Surface>& sur
|
||||
|
||||
if (key == "tileSetFile") {
|
||||
std::string value = line.substr(pos + 1);
|
||||
surface = Resource::get()->getSurface(value);
|
||||
surface = Resource::Cache::get()->getSurface(value);
|
||||
return true;
|
||||
}
|
||||
if (key == "frame_width") {
|
||||
|
||||
@@ -28,7 +28,7 @@ auto loadTextFile(const std::string& file_path) -> std::shared_ptr<TextFile> {
|
||||
}
|
||||
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto file_data = Jdd::ResourceHelper::loadFile(file_path);
|
||||
auto file_data = Resource::Helper::loadFile(file_path);
|
||||
if (file_data.empty()) {
|
||||
std::cerr << "Error: Fichero no encontrado " << getFileName(file_path) << '\n';
|
||||
throw std::runtime_error("Fichero no encontrado: " + getFileName(file_path));
|
||||
|
||||
Reference in New Issue
Block a user