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

@@ -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()
{
@@ -507,4 +486,33 @@ void Screen::renderInfo()
// Resolution
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_; }