Trabajando en las notificaciones

This commit is contained in:
2022-11-23 18:20:29 +01:00
parent a8b467290f
commit 1aac5b7719
6 changed files with 36 additions and 21 deletions

View File

@@ -364,7 +364,9 @@ void Screen::renderNotifications()
return; 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(); notify->render();
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
} }

View File

@@ -304,7 +304,7 @@ bool Director::saveConfig()
// Escribe en el fichero // Escribe en el fichero
file << "## VERSION\n"; file << "## VERSION\n";
file << "version=" + options->configVersion + "\n"; file << "configVersion=" + options->configVersion + "\n";
file << "\n## VISUAL OPTIONS\n"; file << "\n## VISUAL OPTIONS\n";
if (options->videoMode == 0) if (options->videoMode == 0)
@@ -1665,7 +1665,7 @@ void Director::runEnterID()
std::cout << "\n* SECTION: ENTER_ID" << std::endl; std::cout << "\n* SECTION: ENTER_ID" << std::endl;
} }
// loadResources(section); // loadResources(section);
enterID = new EnterID(renderer, screen, asset, options); enterID = new EnterID(renderer, screen, asset, options, section);
setSection(enterID->run()); setSection(enterID->run());
delete enterID; delete enterID;
resource->free(); resource->free();

View File

@@ -48,9 +48,9 @@ private:
struct options_t *options; // Variable con todas las opciones del programa struct options_t *options; // Variable con todas las opciones del programa
// Variables // Variables
section_t section; // Sección y subsección actual del programa;
JA_Music music; // Musica del titulo JA_Music music; // Musica del titulo
std::string executablePath; // Path del ejecutable 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 std::string systemFolder; // Carpeta del sistema donde guardar datos
// Crea e inicializa las opciones del programa // Crea e inicializa las opciones del programa

View File

@@ -5,7 +5,7 @@
#include <iostream> #include <iostream>
// Constructor // 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 // Copia la dirección de los objetos
this->renderer = renderer; this->renderer = renderer;
@@ -31,13 +31,22 @@ EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t
// Inicializa variables // Inicializa variables
counter = 0; counter = 0;
section.name = SECTION_PROG_ENTER_ID;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
pos = 0; pos = 0;
name[pos] = 0; name[pos] = 0;
maxLenght = 15; 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 // Escribe el texto en la textura
fillTexture(); fillTexture();
} }
@@ -92,7 +101,6 @@ void EnterID::checkEventHandler()
// Comprueba las teclas que se han pulsado // Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN)) 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) if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_A && eventHandler->key.keysym.scancode <= SDL_SCANCODE_Z)
{ // Si pulsa una letra { // Si pulsa una letra
if (pos < maxLenght) if (pos < maxLenght)
@@ -101,6 +109,7 @@ void EnterID::checkEventHandler()
name[pos] = 0; name[pos] = 0;
} }
} }
else if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_1 && eventHandler->key.keysym.scancode <= SDL_SCANCODE_9) else if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_1 && eventHandler->key.keysym.scancode <= SDL_SCANCODE_9)
{ // Si pulsa un número { // Si pulsa un número
if (pos < maxLenght) if (pos < maxLenght)
@@ -109,6 +118,7 @@ void EnterID::checkEventHandler()
name[pos] = 0; name[pos] = 0;
} }
} }
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_0) else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_0)
{ {
if (pos < maxLenght) if (pos < maxLenght)
@@ -117,6 +127,7 @@ void EnterID::checkEventHandler()
name[pos] = 0; name[pos] = 0;
} }
} }
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_BACKSPACE) else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_BACKSPACE)
{ {
if (pos > 0) if (pos > 0)
@@ -199,7 +210,7 @@ void EnterID::render()
// Escribe el jailerID // Escribe el jailerID
const std::string jailerID = (std::string)name + cursor; const std::string jailerID = (std::string)name + cursor;
const color_t color = stringToColor(options->palette, "white"); 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 // Vuelca el contenido del renderizador en pantalla
screen->blit(); screen->blit();
@@ -211,6 +222,8 @@ void EnterID::iniTexts()
texts.clear(); 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({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "red")}); texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "red")});
texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"YOU HAVE NOT SPECIFIED ANY ID", 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({"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({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"JAILER_ID:", stringToColor(options->palette, "red")}); texts.push_back({"JAILER_ID:", stringToColor(options->palette, "red")});
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")});
@@ -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")});
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 // Escribe el texto en la textura

View File

@@ -68,7 +68,7 @@ private:
public: public:
// Constructor // 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 // Destructor
~EnterID(); ~EnterID();

View File

@@ -82,7 +82,7 @@ void Logo::checkEventHandler()
} }
// Comprueba las teclas que se han pulsado // 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) switch (eventHandler->key.keysym.scancode)
{ {
@@ -125,6 +125,7 @@ void Logo::checkEventHandler()
break; break;
default: default:
section.subsection = SUBSECTION_LOGO_TO_TITLE;
endSection(); endSection();
break; break;
} }
@@ -317,12 +318,13 @@ void Logo::switchPalette()
// Termina la sección // Termina la sección
void Logo::endSection() void Logo::endSection()
{ {
if (options->online.enabled && options->online.jailerID == "") section.name = SECTION_PROG_ENTER_ID;
{ //if (options->online.enabled && options->online.jailerID == "")
section.name = SECTION_PROG_ENTER_ID; //{
} // section.name = SECTION_PROG_ENTER_ID;
else //}
{ //else
section.name = (section.subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE; //{
} // section.name = (section.subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE;
//}
} }