From bfb334bef0c6b2aaeb9da9c747ca16a04505f851 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 16 Mar 2025 13:24:33 +0100 Subject: [PATCH] style: eliminats uns fprintf --- source/credits.cpp | 16 +++++++++++++++- source/gif.cpp | 25 ++++++++++++------------- source/gif.h | 4 ++-- source/texture.cpp | 22 +++++++++++----------- 4 files changed, 40 insertions(+), 27 deletions(-) diff --git a/source/credits.cpp b/source/credits.cpp index dcc5aef..0d2f7a5 100644 --- a/source/credits.cpp +++ b/source/credits.cpp @@ -144,7 +144,6 @@ void Credits::checkInput() { // Comprueba si se ha pulsado cualquier botón (de los usados para jugar) if (Input::get()->checkAnyButtonPressed(INPUT_ALLOW_REPEAT)) - { if (mini_logo_on_position_) { @@ -163,6 +162,21 @@ void Credits::checkInput() want_to_pass_ = false; } + // Comprueba si se pulsa algun boton de disparo para acabar con el minilogo y empezar el fade + if (mini_logo_on_position_) + { + for (int i = 0; i < Input::get()->getNumControllers(); ++i) + { + // Salir + if (Input::get()->checkInput(InputType::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && + Input::get()->checkInput(InputType::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && + Input::get()->checkInput(InputType::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) + { + fading_ = true; + } + } + } + // Comprueba los inputs que se pueden introducir en cualquier sección del juego globalInputs::check(); } diff --git a/source/gif.cpp b/source/gif.cpp index c13e236..606683d 100644 --- a/source/gif.cpp +++ b/source/gif.cpp @@ -1,8 +1,8 @@ #include "gif.h" -#include // for fprintf, stderr -#include // for memcpy, size_t -#include // for runtime_error -#include // for allocator, char_traits, operator==, basic_string +#include // Para std::cout +#include // Para memcpy, size_t +#include // Para runtime_error +#include // Para allocator, char_traits, operator==, basic_string namespace GIF { @@ -52,7 +52,7 @@ namespace GIF { if (input_length <= 0) { - throw std::runtime_error("Unexpected end of input in uncompress"); + throw std::runtime_error("Unexpected end of input in decompress"); } bit = ((*input & mask) != 0) ? 1 : 0; mask <<= 1; @@ -89,7 +89,8 @@ namespace GIF { if (code > dictionary_ind) { - std::fprintf(stderr, "code = %.02x, but dictionary_ind = %d\n", code, dictionary_ind); + std::cerr << "code = " << std::hex << code + << ", but dictionary_ind = " << dictionary_ind << std::endl; throw std::runtime_error("LZW error: code exceeds dictionary_ind."); } @@ -124,7 +125,8 @@ namespace GIF // Verifica que 'code' sea un índice válido antes de usarlo. if (code < 0 || static_cast(code) >= dictionary.size()) { - std::fprintf(stderr, "Invalid LZW code %d, dictionary size %zu\n", code, dictionary.size()); + std::cerr << "Invalid LZW code " << code + << ", dictionary size " << dictionary.size() << std::endl; throw std::runtime_error("LZW error: invalid code encountered"); } @@ -136,8 +138,8 @@ namespace GIF out[dictionary[curCode].len - 1] = dictionary[curCode].byte; if (dictionary[curCode].prev == curCode) { - std::fprintf(stderr, "Internal error; self-reference detected.\n"); - throw std::runtime_error("Internal error in uncompress: self-reference"); + std::cerr << "Internal error; self-reference detected." << std::endl; + throw std::runtime_error("Internal error in decompress: self-reference"); } curCode = dictionary[curCode].prev; } @@ -226,9 +228,6 @@ namespace GIF w = screen_descriptor.width; h = screen_descriptor.height; - // Imprime para depuración - std::fprintf(stderr, "Screen Descriptor - Width: %d, Height: %d\n", w, h); - int color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1; std::vector global_color_table; if (screen_descriptor.fields & 0x80) @@ -300,7 +299,7 @@ namespace GIF } else { - std::fprintf(stderr, "Unrecognized block type %.02x\n", block_type); + std::cerr << "Unrecognized block type " << std::hex << static_cast(block_type) << std::endl; return std::vector{}; } block_type = *buffer++; diff --git a/source/gif.h b/source/gif.h index 54ceef6..2692da0 100644 --- a/source/gif.h +++ b/source/gif.h @@ -1,7 +1,7 @@ #pragma once -#include // for uint8_t, uint16_t, uint32_t -#include // for vector +#include // Para uint8_t, uint16_t, uint32_t +#include // Para vector namespace GIF { diff --git a/source/texture.cpp b/source/texture.cpp index af1aaca..006bf93 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -1,15 +1,15 @@ #include "texture.h" -#include // for SDL_GetError -#include // for SDL_CreateRGBSurfaceWithFormatFrom -#include // for uint32_t -#include // for memcpy, size_t -#include // for basic_ostream, operator<<, basic_ifstream -#include // for cerr, cout -#include // for runtime_error -#include // for char_traits, operator<<, operator+ -#include // for vector -#include "gif.h" // for Gif -#include "utils.h" // for getFileName, Color, printWithDots +#include // Para SDL_GetError +#include // Para SDL_CreateRGBSurfaceWithFormatFrom +#include // Para uint32_t +#include // Para memcpy, size_t +#include // Para basic_ostream, operator<<, basic_ifstream +#include // Para cerr, cout +#include // Para runtime_error +#include // Para char_traits, operator<<, operator+ +#include // Para vector +#include "gif.h" // Para Gif +#include "utils.h" // Para getFileName, Color, printWithDots #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" // Para stbi_failure_reason, stbi_image_free