diff --git a/source/loading_screen.cpp b/source/loading_screen.cpp index c77ba08..80658cf 100644 --- a/source/loading_screen.cpp +++ b/source/loading_screen.cpp @@ -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) diff --git a/source/screen.cpp b/source/screen.cpp index b593ff5..85b964c 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -3,7 +3,7 @@ #include // Para SDL_DISABLE, SDL_ENABLE #include // Para SDL_ShowCursor #include // Para SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORM... -#include // Para SDL_GetTicks +#include // Para SDL_GetTicks #include // Para toupper #include // Para max, min, transform #include // 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); } -} \ No newline at end of file +} + +// 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 Screen::getRendererSurface() { return (*renderer_surface_); } +std::shared_ptr Screen::getBorderSurface() { return border_surface_; } \ No newline at end of file diff --git a/source/screen.h b/source/screen.h index 3d806aa..fb57801 100644 --- a/source/screen.h +++ b/source/screen.h @@ -10,7 +10,7 @@ #include // Para string #include // 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 = nullptr); - // Getters - SDL_Renderer *getRenderer() { return renderer_; } - std::shared_ptr getRendererSurface() { return (*renderer_surface_); } - std::shared_ptr 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 getRendererSurface(); + std::shared_ptr getBorderSurface(); }; \ No newline at end of file