This commit is contained in:
2025-10-27 18:35:53 +01:00
parent b1dca32a5b
commit 3179a08dac
63 changed files with 686 additions and 693 deletions

View File

@@ -15,10 +15,10 @@ using Palette = std::array<Uint32, 256>;
using SubPalette = std::array<Uint8, 256>;
// Carga una paleta desde un archivo .gif
Palette loadPalette(const std::string& file_path);
auto loadPalette(const std::string& file_path) -> Palette;
// Carga una paleta desde un archivo .pal
Palette readPalFile(const std::string& file_path);
auto readPalFile(const std::string& file_path) -> Palette;
struct SurfaceData {
std::shared_ptr<Uint8[]> data; // Usa std::shared_ptr para gestión automática
@@ -47,11 +47,11 @@ struct SurfaceData {
SurfaceData(SurfaceData&& other) noexcept = default;
// Operador de movimiento
SurfaceData& operator=(SurfaceData&& other) noexcept = default;
auto operator=(SurfaceData&& other) noexcept -> SurfaceData& = default;
// Evita copias accidentales
SurfaceData(const SurfaceData&) = delete;
SurfaceData& operator=(const SurfaceData&) = delete;
auto operator=(const SurfaceData&) -> SurfaceData& = delete;
};
class Surface {
@@ -70,7 +70,7 @@ class Surface {
~Surface() = default;
// Carga una SurfaceData desde un archivo
static SurfaceData loadSurface(const std::string& file_path);
static auto loadSurface(const std::string& file_path) -> SurfaceData;
// Carga una paleta desde un archivo
void loadPalette(const std::string& file_path);
@@ -95,14 +95,14 @@ class Surface {
void copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FRect* src_rect, SDL_FRect* dest_rect);
// Realiza un efecto de fundido en las paletas
bool fadePalette();
bool fadeSubPalette(Uint32 delay = 0);
auto fadePalette() -> bool;
auto fadeSubPalette(Uint32 delay = 0) -> bool;
// Pone un pixel en la SurfaceData
void putPixel(int x, int y, Uint8 color);
// Obtiene el color de un pixel de la surface_data
Uint8 getPixel(int x, int y);
auto getPixel(int x, int y) -> Uint8;
// Dibuja un rectangulo relleno
void fillRect(const SDL_FRect* rect, Uint8 color);
@@ -114,15 +114,15 @@ class Surface {
void drawLine(float x1, float y1, float x2, float y2, Uint8 color);
// Metodos para gestionar surface_data_
std::shared_ptr<SurfaceData> getSurfaceData() const { return surface_data_; }
void setSurfaceData(std::shared_ptr<SurfaceData> new_data) { surface_data_ = new_data; }
[[nodiscard]] auto getSurfaceData() const -> std::shared_ptr<SurfaceData> { return surface_data_; }
void setSurfaceData(std::shared_ptr<SurfaceData> new_data) { surface_data_ = std::move(new_data); }
// Obtien ancho y alto
float getWidth() const { return surface_data_->width; }
float getHeight() const { return surface_data_->height; }
[[nodiscard]] auto getWidth() const -> float { return surface_data_->width; }
[[nodiscard]] auto getHeight() const -> float { return surface_data_->height; }
// Color transparente
Uint8 getTransparentColor() const { return transparent_color_; }
[[nodiscard]] auto getTransparentColor() const -> Uint8 { return transparent_color_; }
void setTransparentColor(Uint8 color = 255) { transparent_color_ = color; }
// Paleta