From 1aac5b7719e7469fc370d338cadb1cfa8f1d0cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Wed, 23 Nov 2022 18:20:29 +0100 Subject: [PATCH] Trabajando en las notificaciones --- source/common/screen.cpp | 4 +++- source/director.cpp | 4 ++-- source/director.h | 2 +- source/enter_id.cpp | 25 ++++++++++++++++++------- source/enter_id.h | 2 +- source/logo.cpp | 20 +++++++++++--------- 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/source/common/screen.cpp b/source/common/screen.cpp index b05f846..6c4f0e4 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -364,7 +364,9 @@ void Screen::renderNotifications() return; } - SDL_RenderSetLogicalSize(renderer, windowWidth * 2, windowHeight * 2); + // SDL_RenderSetLogicalSize(renderer, windowWidth * 2, windowHeight * 2); + const int mult = 1 + ((options->windowSize - 1) / 2); + SDL_RenderSetLogicalSize(renderer, windowWidth * mult, windowHeight * mult); notify->render(); SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); } \ No newline at end of file diff --git a/source/director.cpp b/source/director.cpp index d31e192..0b21269 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -304,7 +304,7 @@ bool Director::saveConfig() // Escribe en el fichero file << "## VERSION\n"; - file << "version=" + options->configVersion + "\n"; + file << "configVersion=" + options->configVersion + "\n"; file << "\n## VISUAL OPTIONS\n"; if (options->videoMode == 0) @@ -1665,7 +1665,7 @@ void Director::runEnterID() std::cout << "\n* SECTION: ENTER_ID" << std::endl; } // loadResources(section); - enterID = new EnterID(renderer, screen, asset, options); + enterID = new EnterID(renderer, screen, asset, options, section); setSection(enterID->run()); delete enterID; resource->free(); diff --git a/source/director.h b/source/director.h index 01713be..c86657c 100644 --- a/source/director.h +++ b/source/director.h @@ -48,9 +48,9 @@ private: struct options_t *options; // Variable con todas las opciones del programa // Variables + section_t section; // Sección y subsección actual del programa; JA_Music music; // Musica del titulo std::string executablePath; // Path del ejecutable - section_t section; // Sección y subsección actual del programa; std::string systemFolder; // Carpeta del sistema donde guardar datos // Crea e inicializa las opciones del programa diff --git a/source/enter_id.cpp b/source/enter_id.cpp index 357a910..1c68e03 100644 --- a/source/enter_id.cpp +++ b/source/enter_id.cpp @@ -5,7 +5,7 @@ #include // Constructor -EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options) +EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t section) { // Copia la dirección de los objetos this->renderer = renderer; @@ -31,13 +31,22 @@ EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t // Inicializa variables counter = 0; - section.name = SECTION_PROG_ENTER_ID; ticks = 0; ticksSpeed = 15; pos = 0; name[pos] = 0; maxLenght = 15; + if (options->online.enabled && options->online.jailerID == "") + { + this->section.name = SECTION_PROG_ENTER_ID; + this->section.subsection = section.subsection; + } + else + { + endSection(); + } + // Escribe el texto en la textura fillTexture(); } @@ -92,7 +101,6 @@ void EnterID::checkEventHandler() // Comprueba las teclas que se han pulsado if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN)) { - if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_A && eventHandler->key.keysym.scancode <= SDL_SCANCODE_Z) { // Si pulsa una letra if (pos < maxLenght) @@ -101,6 +109,7 @@ void EnterID::checkEventHandler() name[pos] = 0; } } + else if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_1 && eventHandler->key.keysym.scancode <= SDL_SCANCODE_9) { // Si pulsa un número if (pos < maxLenght) @@ -109,6 +118,7 @@ void EnterID::checkEventHandler() name[pos] = 0; } } + else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_0) { if (pos < maxLenght) @@ -117,6 +127,7 @@ void EnterID::checkEventHandler() name[pos] = 0; } } + else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_BACKSPACE) { if (pos > 0) @@ -199,7 +210,7 @@ void EnterID::render() // Escribe el jailerID const std::string jailerID = (std::string)name + cursor; const color_t color = stringToColor(options->palette, "white"); - text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 97, jailerID, 1, color); + text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, (16 * 8 + 1), jailerID, 1, color); // Vuelca el contenido del renderizador en pantalla screen->blit(); @@ -211,6 +222,8 @@ void EnterID::iniTexts() texts.clear(); texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")}); + texts.push_back({"", stringToColor(options->palette, "white")}); + texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "red")}); texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"YOU HAVE NOT SPECIFIED ANY ID", stringToColor(options->palette, "white")}); @@ -220,6 +233,7 @@ void EnterID::iniTexts() texts.push_back({"LEAVE BLANK FOR OFFLINE MODE", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")}); + texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"JAILER_ID:", stringToColor(options->palette, "red")}); texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")}); @@ -230,9 +244,6 @@ void EnterID::iniTexts() texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")}); - texts.push_back({"", stringToColor(options->palette, "white")}); - texts.push_back({"", stringToColor(options->palette, "white")}); - texts.push_back({"", stringToColor(options->palette, "white")}); } // Escribe el texto en la textura diff --git a/source/enter_id.h b/source/enter_id.h index 38fdcbf..3204463 100644 --- a/source/enter_id.h +++ b/source/enter_id.h @@ -68,7 +68,7 @@ private: public: // Constructor - EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options); + EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t section); // Destructor ~EnterID(); diff --git a/source/logo.cpp b/source/logo.cpp index 3693ee8..458ed8c 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -82,7 +82,7 @@ void Logo::checkEventHandler() } // Comprueba las teclas que se han pulsado - if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN)) + if ((eventHandler->type == SDL_KEYUP && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP)) { switch (eventHandler->key.keysym.scancode) { @@ -125,6 +125,7 @@ void Logo::checkEventHandler() break; default: + section.subsection = SUBSECTION_LOGO_TO_TITLE; endSection(); break; } @@ -317,12 +318,13 @@ void Logo::switchPalette() // Termina la sección void Logo::endSection() { - if (options->online.enabled && options->online.jailerID == "") - { - section.name = SECTION_PROG_ENTER_ID; - } - else - { - section.name = (section.subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE; - } + section.name = SECTION_PROG_ENTER_ID; + //if (options->online.enabled && options->online.jailerID == "") + //{ + // section.name = SECTION_PROG_ENTER_ID; + //} + //else + //{ + // section.name = (section.subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE; + //} } \ No newline at end of file