arreglos d'estil en Screen

This commit is contained in:
2025-03-20 08:22:25 +01:00
parent 0de6117ca0
commit 7aae9fb5e6
3 changed files with 54 additions and 45 deletions

View File

@@ -214,7 +214,7 @@ void LoadingScreen::run()
// Limpia la pantalla
Screen::get()->start();
Screen::get()->clear();
Screen::get()->clearRenderer();
Screen::get()->render();
while (options.section.section == Section::LOADING_SCREEN)

View File

@@ -3,7 +3,7 @@
#include <SDL2/SDL_events.h> // Para SDL_DISABLE, SDL_ENABLE
#include <SDL2/SDL_mouse.h> // Para SDL_ShowCursor
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORM...
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <ctype.h> // Para toupper
#include <algorithm> // Para max, min, transform
#include <fstream> // Para basic_ostream, operator<<, endl, basic_...
@@ -129,16 +129,13 @@ Screen::~Screen()
SDL_DestroyTexture(shaders_texture_);
}
// Limpia la pantalla
void Screen::clear(Color color)
// Limpia el renderer
void Screen::clearRenderer(Color color)
{
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer_);
}
// Limpia la pantalla
void Screen::clearSurface(Uint8 index) { game_surface_->clear(index); }
// Prepara para empezar a dibujar en la textura de juego
void Screen::start()
{
@@ -162,10 +159,10 @@ void Screen::render()
}
// Establece el modo de video
void Screen::setVideoMode(int video_mode)
void Screen::setVideoMode(int mode)
{
// Actualiza las opciones
options.video.mode = video_mode;
options.video.mode = mode;
// Mostrar u ocultar el cursor según el modo
SDL_ShowCursor(options.video.mode == 0 ? SDL_ENABLE : SDL_DISABLE);
@@ -232,18 +229,6 @@ void Screen::setBorderColor(Uint8 color)
border_surface_->clear(border_color_);
}
// Cambia el tipo de mezcla
void Screen::setBlendMode(SDL_BlendMode blendMode) { SDL_SetRenderDrawBlendMode(renderer_, blendMode); }
// Establece el tamaño del borde
void Screen::setBorderWidth(int s) { options.video.border.width = s; }
// Establece el tamaño del borde
void Screen::setBorderHeight(int s) { options.video.border.height = s; }
// Establece si se ha de ver el borde en el modo ventana
void Screen::setBorderEnabled(bool value) { options.video.border.enabled = value; }
// Cambia entre borde visible y no visible
void Screen::toggleBorder()
{
@@ -276,12 +261,6 @@ void Screen::update()
Mouse::updateCursorVisibility();
}
// Muestra la ventana
void Screen::show() { SDL_ShowWindow(window_); }
// Oculta la ventana
void Screen::hide() { SDL_HideWindow(window_); }
// Calcula el tamaño de la ventana
void Screen::adjustWindowSize()
{
@@ -508,3 +487,32 @@ void Screen::renderInfo()
text->writeColored(0, 0, info_resolution_, color);
}
}
// Limpia la game_surface_
void Screen::clearSurface(Uint8 index) { game_surface_->clear(index); }
// Establece el tamaño del borde
void Screen::setBorderWidth(int width) { options.video.border.width = width; }
// Establece el tamaño del borde
void Screen::setBorderHeight(int height) { options.video.border.height = height; }
// Establece si se ha de ver el borde en el modo ventana
void Screen::setBorderEnabled(bool value) { options.video.border.enabled = value; }
// Muestra la ventana
void Screen::show() { SDL_ShowWindow(window_); }
// Oculta la ventana
void Screen::hide() { SDL_HideWindow(window_); }
// Establece la visibilidad de las notificaciones
void Screen::setNotificationsEnabled(bool value) { notifications_enabled_ = value; }
// Activa / desactiva la información de debug
void Screen::toggleDebugInfo() { show_debug_info_ = !show_debug_info_; }
// Getters
SDL_Renderer *Screen::getRenderer() { return renderer_; }
std::shared_ptr<Surface> Screen::getRendererSurface() { return (*renderer_surface_); }
std::shared_ptr<Surface> Screen::getBorderSurface() { return border_surface_; }

View File

@@ -10,7 +10,7 @@
#include <string> // Para string
#include <vector> // Para vector
#include "utils.h" // Para Color
class Surface;
struct Surface;
// Tipos de filtro
enum class ScreenFilter : Uint32
@@ -136,9 +136,11 @@ public:
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
static Screen *get();
// Limpia la pantalla
void clear(Color color = {0x00, 0x00, 0x00});
void clearSurface(Uint8 index = 0);
// Limpia el renderer
void clearRenderer(Color color = {0x00, 0x00, 0x00});
// Limpia la game_surface_
void clearSurface(Uint8 index);
// Prepara para empezar a dibujar en la textura de juego
void start();
@@ -150,7 +152,7 @@ public:
void update();
// Establece el modo de video
void setVideoMode(int videoMode);
void setVideoMode(int mode);
// Camibia entre pantalla completa y ventana
void toggleVideoMode();
@@ -164,12 +166,11 @@ public:
// Cambia el color del borde
void setBorderColor(Uint8 color);
// Cambia el tipo de mezcla
void setBlendMode(SDL_BlendMode blendMode);
// Establece el tamaño del borde
void setBorderWidth(int width);
// Establece el tamaño del borde
void setBorderWidth(int s);
void setBorderHeight(int s);
void setBorderHeight(int height);
// Establece si se ha de ver el borde en el modo ventana
void setBorderEnabled(bool value);
@@ -192,11 +193,6 @@ public:
// Establece el renderizador para las surfaces
void setRendererSurface(std::shared_ptr<Surface> surface = nullptr);
// Getters
SDL_Renderer *getRenderer() { return renderer_; }
std::shared_ptr<Surface> getRendererSurface() { return (*renderer_surface_); }
std::shared_ptr<Surface> getBorderSurface() { return border_surface_; }
// Cambia la paleta
void nextPalette();
void previousPalette();
@@ -205,8 +201,13 @@ public:
void setPalete();
// Establece la visibilidad de las notificaciones
void setNotificationsEnabled(bool value) { notifications_enabled_ = value; }
void setNotificationsEnabled(bool value);
// Activa / desactiva la información de debug
void toggleDebugInfo() { show_debug_info_ = !show_debug_info_; }
// Activa o desactiva la información de debug
void toggleDebugInfo();
// Getters
SDL_Renderer *getRenderer();
std::shared_ptr<Surface> getRendererSurface();
std::shared_ptr<Surface> getBorderSurface();
};