From ec8209265aa73c5ca3bdd520b28776d8e474d447 Mon Sep 17 00:00:00 2001 From: Sergio Valor Martinez Date: Thu, 29 Dec 2022 10:19:11 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1adidos=20iconos=20a=20las=20notificacion?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/notifications/notify.png | Bin 0 -> 433 bytes data/notifications/notify.png:Zone.Identifier | Bin 0 -> 27 bytes source/cheevos.cpp | 4 +-- source/common/notify.cpp | 26 ++++++++++++------ source/common/notify.h | 5 ++-- source/common/screen.cpp | 6 ++-- source/director.cpp | 3 ++ 7 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 data/notifications/notify.png create mode 100644 data/notifications/notify.png:Zone.Identifier diff --git a/data/notifications/notify.png b/data/notifications/notify.png new file mode 100644 index 0000000000000000000000000000000000000000..de802f80c36e9ebe72ba5a81ad5e2119b25795e9 GIT binary patch literal 433 zcmeAS@N?(olHy`uVBq!ia0vp^3qY8I4M=vMPuB%fjKx9jP7LeL$-D%zvproLLn`LH zy%o*ZtRTYbV0iccw3pL)GoLPGjXrs1z9zr0pI#`Zw_A_lvg?X16SA!jt$+SpO1}Ho zz7O)UT#h$>J-cdl#JyUFrdAS$>i985_ literal 0 HcmV?d00001 diff --git a/source/cheevos.cpp b/source/cheevos.cpp index 356497c..7d1f590 100644 --- a/source/cheevos.cpp +++ b/source/cheevos.cpp @@ -24,11 +24,11 @@ void Cheevos::init() c.completed = false; c.id = 1; - c.caption = "SALTA"; + c.caption = "JUMP"; cheevos.push_back(c); c.id = 2; - c.caption = "OBTEN 3 ITEMS"; + c.caption = "GET 3 ITEMS"; cheevos.push_back(c); } diff --git a/source/common/notify.cpp b/source/common/notify.cpp index d74c8f8..07290fd 100644 --- a/source/common/notify.cpp +++ b/source/common/notify.cpp @@ -4,7 +4,7 @@ #include // 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 this->renderer = renderer; @@ -13,8 +13,9 @@ Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textF waitTime = 300; // Crea objetos - texture = new Texture(renderer, bitmapFile); - text = new Text(textFile, texture, renderer); + iconTexture = new Texture(renderer, iconFile); + textTexture = new Texture(renderer, bitmapFile); + text = new Text(textFile, textTexture, renderer); sound = JA_LoadSound(soundFile.c_str()); } @@ -22,7 +23,8 @@ Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textF Notify::~Notify() { // Libera la memoria de los objetos - delete texture; + delete textTexture; + delete iconTexture; delete text; JA_DeleteSound(sound); @@ -128,7 +130,7 @@ void Notify::showText(std::string text1, std::string text2) { // Inicializa variables const std::string txt = text1.length() > text2.length() ? text1 : text2; - const int width = text->lenght(txt) + text->getCharacterSize(); + const int width = text->lenght(txt) + text->getCharacterSize() + 16 + 4; const int height = text->getCharacterSize() * 3; const int padding = text->getCharacterSize() / 2; @@ -189,23 +191,31 @@ void Notify::showText(std::string text1, std::string text2) 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 n.texture = new Texture(renderer); n.texture->createBlank(renderer, width, height, SDL_TEXTUREACCESS_TARGET); n.texture->setAsRenderTarget(renderer); SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255); SDL_RenderClear(renderer); + sp->render(); n.texture->setBlendMode(SDL_BLENDMODE_BLEND); + color_t color = {255, 255, 255}; if (text2 != "") { // Dos lineas de texto - text->writeDX(TXT_STROKE, padding, padding, text1, 1, {255, 255, 255}, 1, {0, 0, 0}); - text->writeDX(TXT_STROKE, padding, padding + text->getCharacterSize() + 1, text2, 1, {255, 255, 255}, 1, {0, 0, 0}); + text->writeColored(padding + 16 + 4, padding, text1, color); + text->writeColored(padding + 16 + 4, padding + text->getCharacterSize(), text2, color); } else { // Una linea de texto - text->writeDX(TXT_STROKE, padding, (height / 2) - (text->getCharacterSize() / 2), text1, 1, {255, 255, 255}, 1, {0, 0, 0}); + text->writeColored(padding + 16 + 4, (height / 2) - (text->getCharacterSize() / 2), text1, color); } SDL_SetRenderTarget(renderer, nullptr); + delete sp; // Crea el sprite n.sprite = new Sprite(n.rect, n.texture, renderer); diff --git a/source/common/notify.h b/source/common/notify.h index 78f3e70..886e016 100644 --- a/source/common/notify.h +++ b/source/common/notify.h @@ -49,7 +49,8 @@ private: // Objetos y punteros 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 options_t *options; // Variable con todas las opciones del programa @@ -70,7 +71,7 @@ public: void update(); // 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 ~Notify(); diff --git a/source/common/screen.cpp b/source/common/screen.cpp index e863294..74b264c 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -12,7 +12,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options this->asset = asset; // 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; gameCanvasHeight = options->gameHeight; @@ -383,9 +383,9 @@ void Screen::renderNotifications() return; } - SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight); + // SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight); notify->render(); - SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); + // SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); } // Establece el tamaƱo de las notificaciones diff --git a/source/director.cpp b/source/director.cpp index 77d8b46..fe29979 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -1365,6 +1365,9 @@ bool Director::setFileList() asset->add(systemFolder + "/stats_buffer.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 asset->add(prefix + "/data/room/01.room", t_room); asset->add(prefix + "/data/room/02.room", t_room);