Pasaeta de include-what-you-use
Acabada de perfilar la classe PathSprite Menjeades declaracions de utils.h als fitxers que toca
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
#include "notifier.h"
|
||||
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
|
||||
#include <string> // para string
|
||||
#include "jail_audio.h" // para JA_DeleteSound, JA_LoadSound, JA_Pla...
|
||||
#include "param.h" // para param
|
||||
#include "resource.h" // para Resource
|
||||
#include "screen.h" // para Screen
|
||||
#include "sprite.h" // para Sprite
|
||||
#include "text.h" // para Text
|
||||
#include "texture.h" // para Texture
|
||||
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
|
||||
#include <string> // Para string
|
||||
#include "jail_audio.h" // Para JA_DeleteSound, JA_LoadSound, JA_Pla...
|
||||
#include "param.h" // Para Param, param, ParamNotification, Par...
|
||||
#include "screen.h" // Para Screen
|
||||
#include "sprite.h" // Para Sprite
|
||||
#include "text.h" // Para Text
|
||||
#include "texture.h" // Para Texture
|
||||
|
||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||
Notifier *Notifier::notifier_ = nullptr;
|
||||
@@ -34,35 +33,25 @@ Notifier *Notifier::get()
|
||||
// Constructor
|
||||
Notifier::Notifier(std::string icon_file, std::shared_ptr<Text> text, const std::string &sound_file)
|
||||
: renderer_(Screen::get()->getRenderer()),
|
||||
icon_texture_(!icon_file.empty() ? std::make_unique<Texture>(renderer_, icon_file) : nullptr),
|
||||
text_(text),
|
||||
bg_color_(param.notification.color),
|
||||
wait_time_(150),
|
||||
stack_(false),
|
||||
sound_(JA_LoadSound(sound_file.c_str()))
|
||||
{
|
||||
// Inicializa variables
|
||||
has_icons_ = !icon_file.empty();
|
||||
|
||||
// Crea objetos
|
||||
icon_texture_ = has_icons_ ? std::make_unique<Texture>(renderer_, icon_file) : nullptr;
|
||||
}
|
||||
has_icons_(!icon_file.empty()),
|
||||
sound_(JA_LoadSound(sound_file.c_str())) {}
|
||||
|
||||
// Destructor
|
||||
Notifier::~Notifier()
|
||||
{
|
||||
// Libera la memoria de los objetos
|
||||
JA_DeleteSound(sound_);
|
||||
|
||||
notifications_.clear();
|
||||
}
|
||||
|
||||
// Dibuja las notificaciones por pantalla
|
||||
void Notifier::render()
|
||||
{
|
||||
for (int i = (int)notifications_.size() - 1; i >= 0; --i)
|
||||
{
|
||||
notifications_[i].sprite->render();
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el estado de las notificaiones
|
||||
|
||||
Reference in New Issue
Block a user