forked from jaildesigner-jailgames/jaildoctors_dilemma
Optimizado el calculo del tamaño de las notificaciones
This commit is contained in:
@@ -18,6 +18,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
||||
gameCanvasHeight = options->gameHeight;
|
||||
borderWidth = options->gameWidth * options->borderSize;
|
||||
borderHeight = options->gameHeight * options->borderSize;
|
||||
notificationLogicalWidth = gameCanvasWidth;
|
||||
notificationLogicalHeight = gameCanvasHeight;
|
||||
|
||||
iniFade();
|
||||
iniSpectrumFade();
|
||||
@@ -84,6 +86,7 @@ void Screen::blit()
|
||||
// Establece el modo de video
|
||||
void Screen::setVideoMode(int videoMode)
|
||||
{
|
||||
// Muestra el puntero
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
|
||||
// Aplica el modo de video
|
||||
@@ -114,6 +117,7 @@ void Screen::setVideoMode(int videoMode)
|
||||
// Si está activo el modo de pantalla completa añade el borde
|
||||
else if (videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP)
|
||||
{
|
||||
// Oculta el puntero
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
// Obten el alto y el ancho de la ventana
|
||||
@@ -165,6 +169,9 @@ void Screen::setVideoMode(int videoMode)
|
||||
|
||||
// Actualiza el valor de la variable
|
||||
options->videoMode = videoMode;
|
||||
|
||||
// Establece el tamaño de las notificaciones
|
||||
setNotificationSize();
|
||||
}
|
||||
|
||||
// Camibia entre pantalla completa y ventana
|
||||
@@ -368,17 +375,31 @@ void Screen::renderNotifications()
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_RenderSetLogicalSize(renderer, windowWidth * 2, windowHeight * 2);
|
||||
if (options->windowSize == 3)
|
||||
SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
|
||||
notify->render();
|
||||
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||
}
|
||||
|
||||
// Establece el tamaño de las notificaciones
|
||||
void Screen::setNotificationSize()
|
||||
{
|
||||
if (options->videoMode == 0)
|
||||
{
|
||||
SDL_RenderSetLogicalSize(renderer, (windowWidth * 3) / 2, (windowHeight * 3) / 2);
|
||||
if (options->windowSize == 3)
|
||||
{
|
||||
notificationLogicalWidth = (windowWidth * 3) / 2;
|
||||
notificationLogicalHeight = (windowHeight * 3) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
notificationLogicalWidth = windowWidth * 2;
|
||||
notificationLogicalHeight = windowHeight * 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (options->videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP)
|
||||
{
|
||||
SDL_RenderSetLogicalSize(renderer, windowWidth / 3, windowHeight / 3);
|
||||
notificationLogicalWidth = windowWidth / 3;
|
||||
notificationLogicalHeight = windowHeight / 3;
|
||||
}
|
||||
|
||||
notify->render();
|
||||
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||
}
|
||||
@@ -24,15 +24,17 @@ private:
|
||||
Notify *notify; // Dibuja notificaciones por pantalla
|
||||
|
||||
// Variables
|
||||
int windowWidth; // Ancho de la pantalla o ventana
|
||||
int windowHeight; // Alto de la pantalla o ventana
|
||||
int gameCanvasWidth; // Resolución interna del juego. Es el ancho de la textura donde se dibuja el juego
|
||||
int gameCanvasHeight; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
|
||||
int borderWidth; // Anchura del borde
|
||||
int borderHeight; // Anltura del borde
|
||||
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
||||
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||
bool notifyActive; // Indica si hay notificaciones activas
|
||||
int windowWidth; // Ancho de la pantalla o ventana
|
||||
int windowHeight; // Alto de la pantalla o ventana
|
||||
int gameCanvasWidth; // Resolución interna del juego. Es el ancho de la textura donde se dibuja el juego
|
||||
int gameCanvasHeight; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
|
||||
int borderWidth; // Anchura del borde
|
||||
int borderHeight; // Anltura del borde
|
||||
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
||||
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||
bool notifyActive; // Indica si hay notificaciones activas
|
||||
int notificationLogicalWidth; // Ancho lógico de las notificaciones en relación al tamaño de pantalla
|
||||
int notificationLogicalHeight; // Alto lógico de las notificaciones en relación al tamaño de pantalla
|
||||
|
||||
// Variables - Efectos
|
||||
bool fade; // Indica si esta activo el efecto de fade
|
||||
@@ -64,6 +66,9 @@ private:
|
||||
// Dibuja las notificaciones
|
||||
void renderNotifications();
|
||||
|
||||
// Establece el tamaño de las notificaciones
|
||||
void setNotificationSize();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options_t *options);
|
||||
|
||||
Reference in New Issue
Block a user