Demo: añadida la clase screen
This commit is contained in:
@@ -3,16 +3,12 @@
|
||||
#include <iostream>
|
||||
|
||||
// Constructor
|
||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options_t *options)
|
||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options)
|
||||
{
|
||||
// Inicializa variables
|
||||
this->window = window;
|
||||
this->renderer = renderer;
|
||||
this->options = options;
|
||||
this->asset = asset;
|
||||
|
||||
// Crea los objetos
|
||||
notify = new Notify(renderer, asset->get("notify.png"), asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"), options);
|
||||
|
||||
gameCanvasWidth = options->gameWidth;
|
||||
gameCanvasHeight = options->gameHeight;
|
||||
@@ -41,13 +37,17 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
||||
setVideoMode(options->videoMode);
|
||||
|
||||
// Inicializa variables
|
||||
notifyAdded = false;
|
||||
notifyActive = false;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Screen::~Screen()
|
||||
{
|
||||
delete notify;
|
||||
if (notify != nullptr)
|
||||
{
|
||||
delete notify;
|
||||
}
|
||||
SDL_DestroyTexture(gameCanvas);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ void Screen::setVideoMode(int videoMode)
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
|
||||
// Esconde la ventana
|
||||
//SDL_HideWindow(window);
|
||||
// SDL_HideWindow(window);
|
||||
|
||||
if (options->borderEnabled)
|
||||
{
|
||||
@@ -118,7 +118,7 @@ void Screen::setVideoMode(int videoMode)
|
||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
|
||||
// Muestra la ventana
|
||||
//SDL_ShowWindow(window);
|
||||
// SDL_ShowWindow(window);
|
||||
}
|
||||
|
||||
// Si está activo el modo de pantalla completa añade el borde
|
||||
@@ -385,30 +385,46 @@ void Screen::renderFX()
|
||||
renderSpectrumFade();
|
||||
}
|
||||
|
||||
// Añade un notificador a la pantalla
|
||||
void Screen::addNotifier(string iconsFile, string bitmapFontFile, string offsetFontFile, string soundFile)
|
||||
{
|
||||
notify = new Notify(renderer, iconsFile, bitmapFontFile, offsetFontFile, soundFile, options);
|
||||
notifyAdded = true;
|
||||
}
|
||||
|
||||
// Actualiza el notificador
|
||||
void Screen::updateNotifier()
|
||||
{
|
||||
notify->update();
|
||||
notifyActive = notify->active();
|
||||
if (notifyAdded)
|
||||
{
|
||||
notify->update();
|
||||
notifyActive = notify->active();
|
||||
}
|
||||
}
|
||||
|
||||
// Muestra una notificación de texto por pantalla;
|
||||
void Screen::showNotification(std::string text1, std::string text2, int icon)
|
||||
{
|
||||
notify->showText(text1, text2, icon);
|
||||
if (notifyAdded)
|
||||
{
|
||||
notify->showText(text1, text2, icon);
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja las notificaciones
|
||||
void Screen::renderNotifications()
|
||||
{
|
||||
if (!notifyActive)
|
||||
if (notifyAdded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!notifyActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
|
||||
notify->render();
|
||||
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||
SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
|
||||
notify->render();
|
||||
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el tamaño de las notificaciones
|
||||
|
||||
Reference in New Issue
Block a user