corregida la llista de inicialització en clang-format
creat Balloon::Config per a inicialitzar globos
This commit is contained in:
@@ -12,11 +12,11 @@
|
||||
#include <utility>
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "color.h" // Para getFileName, Color, printWithDots
|
||||
#include "external/gif.h" // Para Gif
|
||||
#include "stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_alpha
|
||||
#include "utils.h"
|
||||
#include "color.h" // Para getFileName, Color, printWithDots
|
||||
#include "external/gif.h" // Para Gif
|
||||
#include "resource_helper.h" // Para ResourceHelper
|
||||
#include "stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_alpha
|
||||
#include "utils.h"
|
||||
|
||||
// Constructor
|
||||
Texture::Texture(SDL_Renderer *renderer, std::string path)
|
||||
@@ -66,18 +66,18 @@ auto Texture::loadFromFile(const std::string &file_path) -> bool {
|
||||
int height;
|
||||
int orig_format;
|
||||
unsigned char *data = nullptr;
|
||||
|
||||
|
||||
// Intentar cargar desde ResourceHelper primero
|
||||
auto resource_data = ResourceHelper::loadFile(file_path);
|
||||
if (!resource_data.empty()) {
|
||||
data = stbi_load_from_memory(resource_data.data(), resource_data.size(), &width, &height, &orig_format, req_format);
|
||||
}
|
||||
|
||||
|
||||
// Fallback a filesystem directo
|
||||
if (data == nullptr) {
|
||||
data = stbi_load(file_path.c_str(), &width, &height, &orig_format, req_format);
|
||||
}
|
||||
|
||||
|
||||
if (data == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Fichero no encontrado %s", getFileName(file_path).c_str());
|
||||
throw std::runtime_error("Fichero no encontrado: " + getFileName(file_path));
|
||||
@@ -226,7 +226,7 @@ auto Texture::loadSurface(const std::string &file_path) -> std::shared_ptr<Surfa
|
||||
unloadSurface();
|
||||
|
||||
std::vector<Uint8> buffer;
|
||||
|
||||
|
||||
// Intentar cargar desde ResourceHelper primero
|
||||
auto resource_data = ResourceHelper::loadFile(file_path);
|
||||
if (!resource_data.empty()) {
|
||||
@@ -305,7 +305,7 @@ auto Texture::loadPaletteFromFile(const std::string &file_path) -> Palette {
|
||||
Palette palette;
|
||||
|
||||
std::vector<Uint8> buffer;
|
||||
|
||||
|
||||
// Intentar cargar desde ResourceHelper primero
|
||||
auto resource_data = ResourceHelper::loadFile(file_path);
|
||||
if (!resource_data.empty()) {
|
||||
@@ -328,7 +328,7 @@ auto Texture::loadPaletteFromFile(const std::string &file_path) -> Palette {
|
||||
throw std::runtime_error("Error al leer el fichero: " + file_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printWithDots("Palette : ", getFileName(file_path), "[ LOADED ]");
|
||||
|
||||
// Usar la nueva función loadPalette, que devuelve un vector<uint32_t>
|
||||
@@ -380,13 +380,13 @@ auto Texture::readPalFile(const std::string &file_path) -> Palette {
|
||||
auto resource_data = ResourceHelper::loadFile(file_path);
|
||||
std::istringstream stream;
|
||||
bool using_resource_data = false;
|
||||
|
||||
|
||||
if (!resource_data.empty()) {
|
||||
std::string content(resource_data.begin(), resource_data.end());
|
||||
stream.str(content);
|
||||
using_resource_data = true;
|
||||
}
|
||||
|
||||
|
||||
// Fallback a archivo directo
|
||||
std::ifstream file;
|
||||
if (!using_resource_data) {
|
||||
@@ -395,8 +395,8 @@ auto Texture::readPalFile(const std::string &file_path) -> Palette {
|
||||
throw std::runtime_error("No se pudo abrir el archivo .pal");
|
||||
}
|
||||
}
|
||||
|
||||
std::istream& input_stream = using_resource_data ? stream : static_cast<std::istream&>(file);
|
||||
|
||||
std::istream &input_stream = using_resource_data ? stream : static_cast<std::istream &>(file);
|
||||
|
||||
std::string line;
|
||||
int line_number = 0;
|
||||
|
||||
Reference in New Issue
Block a user