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,24 +16,16 @@
#include "core/rendering/gif.hpp" // Para Gif
#include "core/rendering/screen.hpp" // Para Screen
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
// Carga una paleta desde un archivo .gif
auto loadPalette(const std::string& file_path) -> Palette {
// Abrir el archivo en modo binario
std::ifstream file(file_path, std::ios::binary | std::ios::ate);
if (!file.is_open()) {
// Load file using ResourceHelper (supports both filesystem and pack)
auto buffer = jdd::ResourceHelper::loadFile(file_path);
if (buffer.empty()) {
throw std::runtime_error("Error opening file: " + file_path);
}
// Obtener el tamaño del archivo y leerlo en un buffer
std::streamsize size = file.tellg();
file.seekg(0, std::ios::beg);
std::vector<Uint8> buffer(size);
if (!file.read(reinterpret_cast<char*>(buffer.data()), size)) {
throw std::runtime_error("Error reading file: " + file_path);
}
// Cargar la paleta usando los datos del buffer
std::vector<uint32_t> pal = GIF::Gif::loadPalette(buffer.data());
if (pal.empty()) {
@@ -55,16 +47,21 @@ auto readPalFile(const std::string& file_path) -> Palette {
Palette palette{};
palette.fill(0); // Inicializar todo con 0 (transparente por defecto)
std::ifstream file(file_path);
if (!file.is_open()) {
throw std::runtime_error("No se pudo abrir el archivo .pal");
// Load file using ResourceHelper (supports both filesystem and pack)
auto file_data = jdd::ResourceHelper::loadFile(file_path);
if (file_data.empty()) {
throw std::runtime_error("No se pudo abrir el archivo .pal: " + file_path);
}
// Convert bytes to string for parsing
std::string content(file_data.begin(), file_data.end());
std::istringstream stream(content);
std::string line;
int line_number = 0;
int color_index = 0;
while (std::getline(file, line)) {
while (std::getline(stream, line)) {
++line_number;
// Ignorar las tres primeras líneas del archivo
@@ -89,7 +86,7 @@ auto readPalFile(const std::string& file_path) -> Palette {
}
}
file.close();
printWithDots("Palette : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
return palette;
}
@@ -108,24 +105,13 @@ Surface::Surface(const std::string& file_path)
// Carga una superficie desde un archivo
auto Surface::loadSurface(const std::string& file_path) -> SurfaceData {
// Abrir el archivo usando std::ifstream para manejo automático del recurso
std::ifstream file(file_path, std::ios::binary | std::ios::ate);
if (!file.is_open()) {
// Load file using ResourceHelper (supports both filesystem and pack)
std::vector<Uint8> buffer = jdd::ResourceHelper::loadFile(file_path);
if (buffer.empty()) {
std::cerr << "Error opening file: " << file_path << '\n';
throw std::runtime_error("Error opening file");
}
// Obtener el tamaño del archivo
std::streamsize size = file.tellg();
file.seekg(0, std::ios::beg);
// Leer el contenido del archivo en un buffer
std::vector<Uint8> buffer(size);
if (!file.read(reinterpret_cast<char*>(buffer.data()), size)) {
std::cerr << "Error reading file: " << file_path << '\n';
throw std::runtime_error("Error reading file");
}
// Crear un objeto Gif y llamar a la función loadGif
Uint16 w = 0;
Uint16 h = 0;