Compare commits
2 Commits
a2f1efd2a6
...
ec8209265a
| Author | SHA1 | Date | |
|---|---|---|---|
| ec8209265a | |||
| e963251fd9 |
BIN
data/notifications/notify.png
Normal file
BIN
data/notifications/notify.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 433 B |
BIN
data/notifications/notify.png:Zone.Identifier
Normal file
BIN
data/notifications/notify.png:Zone.Identifier
Normal file
Binary file not shown.
@@ -24,11 +24,11 @@ void Cheevos::init()
|
|||||||
c.completed = false;
|
c.completed = false;
|
||||||
|
|
||||||
c.id = 1;
|
c.id = 1;
|
||||||
c.caption = "SALTA";
|
c.caption = "JUMP";
|
||||||
cheevos.push_back(c);
|
cheevos.push_back(c);
|
||||||
|
|
||||||
c.id = 2;
|
c.id = 2;
|
||||||
c.caption = "OBTEN 3 ITEMS";
|
c.caption = "GET 3 ITEMS";
|
||||||
cheevos.push_back(c);
|
cheevos.push_back(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +59,6 @@ void Cheevos::unlockCheevo(int id)
|
|||||||
if (!cheevos[index].completed)
|
if (!cheevos[index].completed)
|
||||||
{
|
{
|
||||||
cheevos[index].completed = true;
|
cheevos[index].completed = true;
|
||||||
screen->showNotification(cheevos[index].caption);
|
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
|
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -13,8 +13,9 @@ Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textF
|
|||||||
waitTime = 300;
|
waitTime = 300;
|
||||||
|
|
||||||
// Crea objetos
|
// Crea objetos
|
||||||
texture = new Texture(renderer, bitmapFile);
|
iconTexture = new Texture(renderer, iconFile);
|
||||||
text = new Text(textFile, texture, renderer);
|
textTexture = new Texture(renderer, bitmapFile);
|
||||||
|
text = new Text(textFile, textTexture, renderer);
|
||||||
sound = JA_LoadSound(soundFile.c_str());
|
sound = JA_LoadSound(soundFile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +23,8 @@ Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textF
|
|||||||
Notify::~Notify()
|
Notify::~Notify()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete texture;
|
delete textTexture;
|
||||||
|
delete iconTexture;
|
||||||
delete text;
|
delete text;
|
||||||
JA_DeleteSound(sound);
|
JA_DeleteSound(sound);
|
||||||
|
|
||||||
@@ -124,12 +126,13 @@ void Notify::clearFinishedNotifications()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void Notify::showText(std::string text)
|
void Notify::showText(std::string text1, std::string text2)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
const int width = this->text->lenght(text) + (this->text->getCharacterSize() * 2);
|
const std::string txt = text1.length() > text2.length() ? text1 : text2;
|
||||||
const int height = this->text->getCharacterSize() * 2;
|
const int width = text->lenght(txt) + text->getCharacterSize() + 16 + 4;
|
||||||
const int padding = (this->text->getCharacterSize() / 2);
|
const int height = text->getCharacterSize() * 3;
|
||||||
|
const int padding = text->getCharacterSize() / 2;
|
||||||
|
|
||||||
// Posición horizontal
|
// Posición horizontal
|
||||||
int despH = 0;
|
int despH = 0;
|
||||||
@@ -178,7 +181,7 @@ void Notify::showText(std::string text)
|
|||||||
n.travelDist = travelDist;
|
n.travelDist = travelDist;
|
||||||
n.counter = 0;
|
n.counter = 0;
|
||||||
n.state = ns_rising;
|
n.state = ns_rising;
|
||||||
n.text = text;
|
n.text = text1;
|
||||||
if (options->notifications.posV == pos_top)
|
if (options->notifications.posV == pos_top)
|
||||||
{
|
{
|
||||||
n.rect = {despH, offset - travelDist, width, height};
|
n.rect = {despH, offset - travelDist, width, height};
|
||||||
@@ -188,15 +191,31 @@ void Notify::showText(std::string text)
|
|||||||
n.rect = {despH, offset + travelDist, width, height};
|
n.rect = {despH, offset + travelDist, width, height};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepara el sprite con el icono
|
||||||
|
Sprite *sp = new Sprite({0, 0, 16, 16}, iconTexture, renderer);
|
||||||
|
sp->setPos({padding, padding, 16, 16});
|
||||||
|
sp->setSpriteClip({16 * 2, 0, 16, 16});
|
||||||
|
|
||||||
// Crea la textura
|
// Crea la textura
|
||||||
n.texture = new Texture(renderer);
|
n.texture = new Texture(renderer);
|
||||||
n.texture->createBlank(renderer, width, height, SDL_TEXTUREACCESS_TARGET);
|
n.texture->createBlank(renderer, width, height, SDL_TEXTUREACCESS_TARGET);
|
||||||
n.texture->setAsRenderTarget(renderer);
|
n.texture->setAsRenderTarget(renderer);
|
||||||
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
sp->render();
|
||||||
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, padding, text, 1, {255, 255, 255}, 1, {0, 0, 0});
|
color_t color = {255, 255, 255};
|
||||||
|
if (text2 != "")
|
||||||
|
{ // Dos lineas de texto
|
||||||
|
text->writeColored(padding + 16 + 4, padding, text1, color);
|
||||||
|
text->writeColored(padding + 16 + 4, padding + text->getCharacterSize(), text2, color);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Una linea de texto
|
||||||
|
text->writeColored(padding + 16 + 4, (height / 2) - (text->getCharacterSize() / 2), text1, color);
|
||||||
|
}
|
||||||
SDL_SetRenderTarget(renderer, nullptr);
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
delete sp;
|
||||||
|
|
||||||
// Crea el sprite
|
// Crea el sprite
|
||||||
n.sprite = new Sprite(n.rect, n.texture, renderer);
|
n.sprite = new Sprite(n.rect, n.texture, renderer);
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ private:
|
|||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Texture *texture; // Textura para la fuente de las notificaciones
|
Texture *textTexture; // Textura para la fuente de las notificaciones
|
||||||
|
Texture *iconTexture; // Textura para los iconos de las notificaciones
|
||||||
Text *text; // Objeto para dibujar texto
|
Text *text; // Objeto para dibujar texto
|
||||||
options_t *options; // Variable con todas las opciones del programa
|
options_t *options; // Variable con todas las opciones del programa
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ private:
|
|||||||
color_t bgColor; // Color de fondo de las notificaciones
|
color_t bgColor; // Color de fondo de las notificaciones
|
||||||
int waitTime; // Tiempo que se ve la notificación
|
int waitTime; // Tiempo que se ve la notificación
|
||||||
std::vector<notification_t> notifications; // La lista de notificaciones activas
|
std::vector<notification_t> notifications; // La lista de notificaciones activas
|
||||||
JA_Sound_t* sound; // Sonido a reproducir cuando suena la notificación
|
JA_Sound_t *sound; // Sonido a reproducir cuando suena la notificación
|
||||||
|
|
||||||
// Elimina las notificaciones finalizadas
|
// Elimina las notificaciones finalizadas
|
||||||
void clearFinishedNotifications();
|
void clearFinishedNotifications();
|
||||||
@@ -70,13 +71,13 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
|
Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Notify();
|
~Notify();
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void showText(std::string text);
|
void showText(std::string text1 = "", std::string text2 = "");
|
||||||
|
|
||||||
// Indica si hay notificaciones activas
|
// Indica si hay notificaciones activas
|
||||||
bool active();
|
bool active();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
|||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
notify = new Notify(renderer, asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"), options);
|
notify = new Notify(renderer, asset->get("notify.png"), asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"), options);
|
||||||
|
|
||||||
gameCanvasWidth = options->gameWidth;
|
gameCanvasWidth = options->gameWidth;
|
||||||
gameCanvasHeight = options->gameHeight;
|
gameCanvasHeight = options->gameHeight;
|
||||||
@@ -370,9 +370,9 @@ void Screen::updateNotifier()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void Screen::showNotification(std::string text)
|
void Screen::showNotification(std::string text1, std::string text2)
|
||||||
{
|
{
|
||||||
notify->showText(text);
|
notify->showText(text1, text2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja las notificaciones
|
// Dibuja las notificaciones
|
||||||
@@ -383,9 +383,9 @@ void Screen::renderNotifications()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
|
// SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
|
||||||
notify->render();
|
notify->render();
|
||||||
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
// SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el tamaño de las notificaciones
|
// Establece el tamaño de las notificaciones
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public:
|
|||||||
void updateNotifier();
|
void updateNotifier();
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void showNotification(std::string text);
|
void showNotification(std::string text1 = "", std::string text2 = "");
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ void Director::initOptions()
|
|||||||
options->notifications.posV = pos_top;
|
options->notifications.posV = pos_top;
|
||||||
options->notifications.posH = pos_left;
|
options->notifications.posH = pos_left;
|
||||||
options->notifications.sound = true;
|
options->notifications.sound = true;
|
||||||
options->notifications.color = {64, 64, 64};
|
options->notifications.color = {48, 48, 48};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
@@ -1365,6 +1365,9 @@ bool Director::setFileList()
|
|||||||
asset->add(systemFolder + "/stats_buffer.csv", t_data, false, true);
|
asset->add(systemFolder + "/stats_buffer.csv", t_data, false, true);
|
||||||
asset->add(systemFolder + "/stats.csv", t_data, false, true);
|
asset->add(systemFolder + "/stats.csv", t_data, false, true);
|
||||||
|
|
||||||
|
// Notificaciones
|
||||||
|
asset->add(prefix + "/data/notifications/notify.png", t_bitmap);
|
||||||
|
|
||||||
// Habitaciones
|
// Habitaciones
|
||||||
asset->add(prefix + "/data/room/01.room", t_room);
|
asset->add(prefix + "/data/room/01.room", t_room);
|
||||||
asset->add(prefix + "/data/room/02.room", t_room);
|
asset->add(prefix + "/data/room/02.room", t_room);
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ void Game::checkEventHandler()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_F6:
|
case SDL_SCANCODE_F6:
|
||||||
screen->showNotification("MAMA MIRA! SIN MANOS!");
|
screen->showNotification("1234567890");
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user