From 706ad6f9c07eb77db9ad53ab5fdfac08654f1788 Mon Sep 17 00:00:00 2001 From: Sergio Valor Martinez Date: Wed, 23 Nov 2022 14:11:47 +0100 Subject: [PATCH] Trabajando en el escalado de las notificaciones --- source/common/notify.cpp | 2 +- source/director.cpp | 41 ++++++++-------------------------------- source/enter_id.cpp | 28 +++++++++++++++++++++++++-- source/enter_id.h | 3 +++ 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/source/common/notify.cpp b/source/common/notify.cpp index 651a2ab..4be6665 100644 --- a/source/common/notify.cpp +++ b/source/common/notify.cpp @@ -135,7 +135,7 @@ void Notify::showText(std::string text) SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255); SDL_RenderClear(renderer); n.texture->setBlendMode(SDL_BLENDMODE_BLEND); - this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, despV, text, 1, {255, 255, 255}, 2, {0, 0, 0}); + this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, despV, text, 1, {255, 255, 255}, 1, {0, 0, 0}); SDL_SetRenderTarget(renderer, nullptr); // Crea el sprite diff --git a/source/director.cpp b/source/director.cpp index 623e9d4..4a8d033 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -18,7 +18,7 @@ Director::Director(int argc, char *argv[]) section.subsection = SUBSECTION_LOGO_TO_INTRO; #ifdef DEBUG - section.name = SECTION_PROG_LOGO; + section.name = SECTION_PROG_GAME; #endif // Crea e inicializa las opciones del programa @@ -84,50 +84,25 @@ Director::~Director() // Inicializa los servicios online void Director::initOnline() { - //if (!options->online.enabled) - //{ - // return; - //} - - options->online.enabled = true; - - // Obten el Jailer ID if (options->online.jailerID == "") { // Jailer ID no definido - screen->showText("No ha especificado ningun Jailer ID"); - if (options->console) - { - std::cout << "No ha especificado ningun Jailer ID" << std::endl; - } + options->online.enabled = false; } else { // Jailer ID iniciado - // Establece el servidor y el puerto - jscore::init(options->online.server, options->online.port); + if (options->online.enabled) + { // Establece el servidor y el puerto + jscore::init(options->online.server, options->online.port); - // Obtiene la información online - if (jscore::initOnlineScore(options->online.gameID)) - { - screen->showText(options->online.jailerID + " ha iniciado sesion"); + const std::string caption = options->online.jailerID + " IS LOGGED IN"; + screen->showText(caption); if (options->console) { - std::cout << options->online.jailerID << " ha iniciado sesion" << std::endl; + std::cout << caption << std::endl; } } - else - { - screen->showText("Fallo al conectar a " + options->online.server); - if (options->console) - { - std::cout << "Fallo al conectar a " << options->online.server << std::endl; - } - - options->online.enabled = false; - - return; - } } } diff --git a/source/enter_id.cpp b/source/enter_id.cpp index 6042e2d..dbd4cea 100644 --- a/source/enter_id.cpp +++ b/source/enter_id.cpp @@ -1,4 +1,5 @@ #include "common/jail_audio.h" +#include "common/jscore.h" #include "const.h" #include "enter_id.h" #include @@ -118,6 +119,7 @@ void EnterID::checkEventHandler() else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_RETURN) { options->online.jailerID = (std::string)name; + initOnline(); section.name = SECTION_PROG_INTRO; break; } @@ -195,8 +197,7 @@ void EnterID::render() // Escribe el jailerID const std::string jailerID = (std::string)name + cursor; const color_t color = stringToColor(options->palette, "white"); - //text->writeCentered(GAMECANVAS_CENTER_X, 97, jailerID); - text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 97, jailerID,1,color); + text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 97, jailerID, 1, color); // Vuelca el contenido del renderizador en pantalla screen->blit(); @@ -262,4 +263,27 @@ void EnterID::switchPalette() { options->palette = options->palette == p_zxspectrum ? p_zxarne : p_zxspectrum; fillTexture(); +} + +// Inicializa los servicios online +void EnterID::initOnline() +{ + if (options->online.jailerID == "") + { // Jailer ID no definido + + options->online.enabled = false; + } + else + { // Jailer ID iniciado + + options->online.enabled = true; + jscore::init(options->online.server, options->online.port); + + const std::string caption = options->online.jailerID + " IS LOGGED IN"; + screen->showText(caption); + if (options->console) + { + std::cout << caption << std::endl; + } + } } \ No newline at end of file diff --git a/source/enter_id.h b/source/enter_id.h index ec6018f..4f85bc9 100644 --- a/source/enter_id.h +++ b/source/enter_id.h @@ -60,6 +60,9 @@ private: // Cambia la paleta void switchPalette(); + // Inicializa los servicios online + void initOnline(); + public: // Constructor EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options);