From dfc14da179dae9b926ad6d5e44db86aa017c1215 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 7 Jul 2024 22:48:00 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20la=20clase=20title=20no=20hac=C3=ADa=20f?= =?UTF-8?q?ade=20al=20pasar=20al=20modo=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/common/input.cpp | 9 +++++++++ source/common/input.h | 3 +++ source/define_buttons.cpp | 8 +++++--- source/director.cpp | 2 +- source/fade.cpp | 6 ++++++ source/title.cpp | 40 +++++++++++++++++++-------------------- 6 files changed, 44 insertions(+), 24 deletions(-) diff --git a/source/common/input.cpp b/source/common/input.cpp index 6521fb6..23117ce 100644 --- a/source/common/input.cpp +++ b/source/common/input.cpp @@ -484,4 +484,13 @@ inputs_e Input::to_inputs_e(std::string name) } return input_null; +} + +// Activa todos los inputs. Sirve para evitar inputs sin repeticiones pero que ya vienen pulsados cuando checkInput no estaba monitorizando +void Input::allActive(int index) +{ + for (int i = 0; i < (int)buttonInputs.size(); ++i) + { + gameControllerBindings[index][i].active = true; + } } \ No newline at end of file diff --git a/source/common/input.h b/source/common/input.h index 541d51c..06f9691 100644 --- a/source/common/input.h +++ b/source/common/input.h @@ -149,6 +149,9 @@ public: // Obtiene el indice a partir del nombre del mando int getIndexByName(std::string name); + + // Activa todos los inputs. Sirve para evitar inputs sin repeticiones pero que ya vienen pulsados cuando checkInput no estaba monitorizando + void allActive(int index); }; #endif diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index 7989d28..2843b34 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -69,9 +69,9 @@ void DefineButtons::render() { if (enabled) { - text->writeCentered(x, y - 20, "PLAYER " + std::to_string(indexController + 1)); - text->writeCentered(x, y - 10, controllerNames[indexController]); - text->writeCentered(x, y, buttons[indexButton].label); + text->writeCentered(x, y - 10, "PLAYER " + std::to_string(indexController + 1)); + text->writeCentered(x, y, controllerNames[indexController]); + text->writeCentered(x, y + 10, buttons[indexButton].label); } } @@ -143,6 +143,8 @@ void DefineButtons::incIndexButton() // Guarda los cambios en las opciones saveBindingsToOptions(); + //input->allActive(indexController); + // Reinicia variables indexButton = 0; indexController = 0; diff --git a/source/director.cpp b/source/director.cpp index 35df178..e5d761b 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -16,7 +16,7 @@ Director::Director(int argc, char *argv[]) { // Inicializa variables section = new section_t(); - section->name = SECTION_PROG_TITLE; + section->name = SECTION_PROG_LOGO; // Comprueba los parametros del programa checkProgramArguments(argc, argv); diff --git a/source/fade.cpp b/source/fade.cpp index 7f99372..1b1e7f2 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -206,6 +206,12 @@ void Fade::update() // Activa el fade void Fade::activate() { + // Si ya está habilitado, no hay que volverlo a activar + if (enabled) + { + return; + } + enabled = true; finished = false; counter = 0; diff --git a/source/title.cpp b/source/title.cpp index b9748b1..04ff1d9 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -91,6 +91,7 @@ void Title::update() // Actualiza el objeto 'background' background->update(); + // Actualiza el objeto 'defineButtons' defineButtons->update(); // Comprueba el fade y si se ha acabado @@ -133,29 +134,28 @@ void Title::update() // Sección 2 - La pantalla con el titulo, el fondo animado y la música else if (section->subsection == SUBSECTION_TITLE_2) { - if (counter < param->titleCounter) + // El contador solo sube si no estamos definiendo botones + if (!defineButtons->isEnabled()) { - // El contador solo sube si no estamos definiendo botones - if (!defineButtons->isEnabled()) - { - counter++; - } - - // Reproduce la música - if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED)) - { - JA_PlayMusic(music); - } - - // Actualiza el logo con el título del juego - gameLogo->update(); - - // Actualiza el mosaico de fondo - tiledbg->update(); + counter++; } - else if (counter >= param->titleCounter) + + // Reproduce la música + if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED)) { - section->name = SECTION_PROG_GAME_DEMO; + JA_PlayMusic(music); + } + + // Actualiza el logo con el título del juego + gameLogo->update(); + + // Actualiza el mosaico de fondo + tiledbg->update(); + + if (counter == param->titleCounter) + { + fade->activate(); + postFade = 3; } } }