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

@@ -15,6 +15,7 @@
#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_helper.hpp" // Para ResourceHelper
#include "game/options.hpp" // Para Options, options, OptionsVideo, Border
#include "game/ui/notifier.hpp" // Para Notifier
@@ -385,21 +386,8 @@ auto Screen::getRendererSurface() -> std::shared_ptr<Surface> { return (*rendere
auto Screen::getBorderSurface() -> std::shared_ptr<Surface> { return border_surface_; }
auto loadData(const std::string& filepath) -> std::vector<uint8_t> {
// Fallback a filesystem
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
if (!file) {
return {};
}
std::streamsize file_size = file.tellg();
file.seekg(0, std::ios::beg);
std::vector<uint8_t> data(file_size);
if (!file.read(reinterpret_cast<char*>(data.data()), file_size)) {
return {};
}
return data;
// Load using ResourceHelper (supports both filesystem and pack)
return jdd::ResourceHelper::loadFile(filepath);
}
// Carga el contenido de los archivos GLSL

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;

View File

@@ -9,21 +9,27 @@
#include "core/rendering/surface.hpp" // Para Surface
#include "core/resources/resource.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 {
std::ifstream file(file_path);
if (!file) {
// Load file using ResourceHelper (supports both filesystem and pack)
auto file_data = jdd::ResourceHelper::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);
}
printWithDots("Animation : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
// Convert bytes to string and parse
std::string content(file_data.begin(), file_data.end());
std::istringstream stream(content);
std::vector<std::string> buffer;
std::string line;
while (std::getline(file, line)) {
while (std::getline(stream, line)) {
if (!line.empty()) {
buffer.push_back(line);
}

View File

@@ -5,11 +5,13 @@
#include <cstddef> // Para size_t
#include <fstream> // Para basic_ifstream, basic_istream, basic_ostream
#include <iostream> // Para cerr
#include <sstream> // Para istringstream
#include <stdexcept> // Para runtime_error
#include "core/rendering/screen.hpp" // Para Screen
#include "core/rendering/surface.hpp" // Para Surface
#include "core/rendering/surface_sprite.hpp" // Para SSprite
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
#include "utils/utils.hpp" // Para getFileName, stringToColor, printWithDots
// Llena una estructuta TextFile desde un fichero
@@ -25,46 +27,43 @@ auto loadTextFile(const std::string& file_path) -> std::shared_ptr<TextFile> {
tf->box_height = 0;
}
// Abre el fichero para leer los valores
std::ifstream file(file_path);
if (file.is_open() && file.good()) {
std::string buffer;
// Lee los dos primeros valores del fichero
std::getline(file, buffer);
std::getline(file, buffer);
tf->box_width = std::stoi(buffer);
std::getline(file, buffer);
std::getline(file, buffer);
tf->box_height = std::stoi(buffer);
// lee el resto de datos del fichero
auto index = 32;
auto line_read = 0;
while (std::getline(file, buffer)) {
// Almacena solo las lineas impares
if (line_read % 2 == 1) {
tf->offset[index++].w = std::stoi(buffer);
}
// Limpia el buffer
buffer.clear();
line_read++;
};
// Cierra el fichero
printWithDots("Text File : ", getFileName(file_path), "[ LOADED ]");
file.close();
}
// El fichero no se puede abrir
else {
// Load file using ResourceHelper (supports both filesystem and pack)
auto file_data = jdd::ResourceHelper::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));
}
// Convert bytes to string and parse
std::string content(file_data.begin(), file_data.end());
std::istringstream stream(content);
std::string buffer;
// Lee los dos primeros valores del fichero
std::getline(stream, buffer);
std::getline(stream, buffer);
tf->box_width = std::stoi(buffer);
std::getline(stream, buffer);
std::getline(stream, buffer);
tf->box_height = std::stoi(buffer);
// lee el resto de datos del fichero
auto index = 32;
auto line_read = 0;
while (std::getline(stream, buffer)) {
// Almacena solo las lineas impares
if (line_read % 2 == 1) {
tf->offset[index++].w = std::stoi(buffer);
}
// Limpia el buffer
buffer.clear();
line_read++;
};
printWithDots("Text File : ", getFileName(file_path), "[ LOADED ]");
// Establece las coordenadas para cada caracter ascii de la cadena y su ancho
for (int i = 32; i < 128; ++i) {
tf->offset[i].x = ((i - 32) % 15) * tf->box_width;