Demo: añadidas notificaciones
This commit is contained in:
@@ -14,8 +14,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options)
|
||||
gameCanvasHeight = options->gameHeight;
|
||||
borderWidth = options->borderWidth * 2;
|
||||
borderHeight = options->borderHeight * 2;
|
||||
notificationLogicalWidth = gameCanvasWidth;
|
||||
notificationLogicalHeight = gameCanvasHeight;
|
||||
|
||||
iniFade();
|
||||
iniSpectrumFade();
|
||||
@@ -35,10 +33,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options)
|
||||
|
||||
// Establece el modo de video
|
||||
setVideoMode(options->videoMode);
|
||||
|
||||
// Inicializa variables
|
||||
notifyAdded = false;
|
||||
notifyActive = false;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -96,9 +90,6 @@ void Screen::setVideoMode(int videoMode)
|
||||
// Muestra el puntero
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
|
||||
// Esconde la ventana
|
||||
// SDL_HideWindow(window);
|
||||
|
||||
if (options->borderEnabled)
|
||||
{
|
||||
windowWidth = gameCanvasWidth + borderWidth;
|
||||
@@ -116,9 +107,6 @@ void Screen::setVideoMode(int videoMode)
|
||||
// Modifica el tamaño de la ventana
|
||||
SDL_SetWindowSize(window, windowWidth * options->windowSize, windowHeight * options->windowSize);
|
||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
|
||||
// Muestra la ventana
|
||||
// SDL_ShowWindow(window);
|
||||
}
|
||||
|
||||
// Si está activo el modo de pantalla completa añade el borde
|
||||
@@ -178,9 +166,6 @@ void Screen::setVideoMode(int videoMode)
|
||||
options->videoMode = videoMode;
|
||||
options->screen.windowWidth = windowWidth;
|
||||
options->screen.windowHeight = windowHeight;
|
||||
|
||||
// Establece el tamaño de las notificaciones
|
||||
setNotificationSize();
|
||||
}
|
||||
|
||||
// Camibia entre pantalla completa y ventana
|
||||
@@ -389,64 +374,34 @@ void Screen::renderFX()
|
||||
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()
|
||||
{
|
||||
if (notifyAdded)
|
||||
{
|
||||
notify->update();
|
||||
notifyActive = notify->active();
|
||||
}
|
||||
notify->update();
|
||||
}
|
||||
|
||||
// Muestra una notificación de texto por pantalla;
|
||||
void Screen::showNotification(std::string text1, std::string text2, int icon)
|
||||
{
|
||||
if (notifyAdded)
|
||||
{
|
||||
notify->showText(text1, text2, icon);
|
||||
}
|
||||
notify->showText(text1, text2, icon);
|
||||
}
|
||||
|
||||
// Dibuja las notificaciones
|
||||
void Screen::renderNotifications()
|
||||
{
|
||||
//if (notifyAdded)
|
||||
if (!notify->active())
|
||||
{
|
||||
if (!notifyActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
|
||||
notify->render();
|
||||
//SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
notify->render();
|
||||
}
|
||||
|
||||
// Establece el tamaño de las notificaciones
|
||||
void Screen::setNotificationSize()
|
||||
// Actualiza la lógica del objeto
|
||||
void Screen::update()
|
||||
{
|
||||
if (options->videoMode == 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
notificationLogicalWidth = windowWidth / 3;
|
||||
notificationLogicalHeight = windowHeight / 3;
|
||||
}
|
||||
updateNotifier();
|
||||
updateFX();
|
||||
}
|
||||
Reference in New Issue
Block a user