diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index 3131eed..82fa680 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -1,5 +1,5 @@ #include "define_buttons.h" -#include "input.h" // Para Input, InputType +#include "input.h" // Para Input, InputAction #include "lang.h" // Para getText #include "options.h" // Para OptionsController, Options, options #include "param.h" // Para Param, param, ParamGame, ParamTitle @@ -135,9 +135,9 @@ bool DefineButtons::checkButtonNotInUse(SDL_GameControllerButton button) void DefineButtons::clearButtons() { buttons_.clear(); - buttons_.emplace_back(lang::getText(95), InputType::FIRE_LEFT, SDL_CONTROLLER_BUTTON_INVALID); - buttons_.emplace_back(lang::getText(96), InputType::FIRE_CENTER, SDL_CONTROLLER_BUTTON_INVALID); - buttons_.emplace_back(lang::getText(97), InputType::FIRE_RIGHT, SDL_CONTROLLER_BUTTON_INVALID); - buttons_.emplace_back(lang::getText(98), InputType::START, SDL_CONTROLLER_BUTTON_INVALID); - buttons_.emplace_back(lang::getText(99), InputType::SERVICE, SDL_CONTROLLER_BUTTON_INVALID); + buttons_.emplace_back(lang::getText(95), InputAction::FIRE_LEFT, SDL_CONTROLLER_BUTTON_INVALID); + buttons_.emplace_back(lang::getText(96), InputAction::FIRE_CENTER, SDL_CONTROLLER_BUTTON_INVALID); + buttons_.emplace_back(lang::getText(97), InputAction::FIRE_RIGHT, SDL_CONTROLLER_BUTTON_INVALID); + buttons_.emplace_back(lang::getText(98), InputAction::START, SDL_CONTROLLER_BUTTON_INVALID); + buttons_.emplace_back(lang::getText(99), InputAction::SERVICE, SDL_CONTROLLER_BUTTON_INVALID); } \ No newline at end of file diff --git a/source/define_buttons.h b/source/define_buttons.h index f8e2288..62bd975 100644 --- a/source/define_buttons.h +++ b/source/define_buttons.h @@ -8,16 +8,16 @@ #include // Para vector class Input; // lines 8-8 class Text; // lines 9-9 -enum class InputType : int; // lines 10-10 +enum class InputAction : int; // lines 10-10 struct DefineButtonsButton { std::string label; // Texto en pantalla para el botón - InputType input; // Input asociado + InputAction input; // Input asociado SDL_GameControllerButton button; // Botón del mando correspondiente // Constructor - DefineButtonsButton(const std::string &lbl, InputType inp, SDL_GameControllerButton btn) + DefineButtonsButton(const std::string &lbl, InputAction inp, SDL_GameControllerButton btn) : label(lbl), input(inp), button(btn) {} }; diff --git a/source/director.cpp b/source/director.cpp index 9eb7e6d..df4b373 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -27,7 +27,7 @@ #include "dbgtxt.h" // Para dbg_init #include "game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_... #include "hiscore_table.h" // Para HiScoreTable -#include "input.h" // Para Input, InputType +#include "input.h" // Para Input, InputAction #include "instructions.h" // Para Instructions #include "intro.h" // Para Intro #include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundV... @@ -167,58 +167,58 @@ void Director::loadScoreFile() void Director::bindInputs() { // Teclado - Movimiento del jugador - Input::get()->bindKey(InputType::UP, SDL_SCANCODE_UP); - Input::get()->bindKey(InputType::DOWN, SDL_SCANCODE_DOWN); - Input::get()->bindKey(InputType::LEFT, SDL_SCANCODE_LEFT); - Input::get()->bindKey(InputType::RIGHT, SDL_SCANCODE_RIGHT); + Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_UP); + Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_DOWN); + Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_LEFT); + Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_RIGHT); - Input::get()->bindKey(InputType::FIRE_LEFT, SDL_SCANCODE_Q); - Input::get()->bindKey(InputType::FIRE_CENTER, SDL_SCANCODE_W); - Input::get()->bindKey(InputType::FIRE_RIGHT, SDL_SCANCODE_E); + Input::get()->bindKey(InputAction::FIRE_LEFT, SDL_SCANCODE_Q); + Input::get()->bindKey(InputAction::FIRE_CENTER, SDL_SCANCODE_W); + Input::get()->bindKey(InputAction::FIRE_RIGHT, SDL_SCANCODE_E); - Input::get()->bindKey(InputType::START, SDL_SCANCODE_RETURN); + Input::get()->bindKey(InputAction::START, SDL_SCANCODE_RETURN); // Teclado - Control del programa - Input::get()->bindKey(InputType::SERVICE, SDL_SCANCODE_0); - Input::get()->bindKey(InputType::EXIT, SDL_SCANCODE_ESCAPE); - Input::get()->bindKey(InputType::PAUSE, SDL_SCANCODE_P); + Input::get()->bindKey(InputAction::SERVICE, SDL_SCANCODE_0); + Input::get()->bindKey(InputAction::EXIT, SDL_SCANCODE_ESCAPE); + Input::get()->bindKey(InputAction::PAUSE, SDL_SCANCODE_P); - Input::get()->bindKey(InputType::WINDOW_DEC_SIZE, SDL_SCANCODE_F1); - Input::get()->bindKey(InputType::WINDOW_INC_SIZE, SDL_SCANCODE_F2); - Input::get()->bindKey(InputType::WINDOW_FULLSCREEN, SDL_SCANCODE_F3); - Input::get()->bindKey(InputType::VIDEO_SHADERS, SDL_SCANCODE_F4); - Input::get()->bindKey(InputType::VIDEO_INTEGER_SCALE, SDL_SCANCODE_F5); - - Input::get()->bindKey(InputType::MUTE, SDL_SCANCODE_F6); - Input::get()->bindKey(InputType::AUTO_FIRE, SDL_SCANCODE_F7); - Input::get()->bindKey(InputType::CHANGE_LANG, SDL_SCANCODE_F8); - - Input::get()->bindKey(InputType::RESET, SDL_SCANCODE_F10); - - Input::get()->bindKey(InputType::SHOWINFO, SDL_SCANCODE_F12); + Input::get()->bindKey(InputAction::WINDOW_DEC_SIZE, SDL_SCANCODE_F1); + Input::get()->bindKey(InputAction::WINDOW_INC_SIZE, SDL_SCANCODE_F2); + Input::get()->bindKey(InputAction::WINDOW_FULLSCREEN, SDL_SCANCODE_F3); + Input::get()->bindKey(InputAction::VIDEO_SHADERS, SDL_SCANCODE_F4); + Input::get()->bindKey(InputAction::VIDEO_INTEGER_SCALE, SDL_SCANCODE_F5); + + Input::get()->bindKey(InputAction::MUTE, SDL_SCANCODE_F6); + Input::get()->bindKey(InputAction::AUTO_FIRE, SDL_SCANCODE_F7); + Input::get()->bindKey(InputAction::CHANGE_LANG, SDL_SCANCODE_F8); + + Input::get()->bindKey(InputAction::RESET, SDL_SCANCODE_F10); + + Input::get()->bindKey(InputAction::SHOW_INFO, SDL_SCANCODE_F12); // Asigna botones a inputs - const int num_gamepads = Input::get()->getNumControllers(); - for (int i = 0; i < num_gamepads; ++i) + const int NUM_GAMEPADS = Input::get()->getNumControllers(); + for (int i = 0; i < NUM_GAMEPADS; ++i) { // Mando - Movimiento del jugador - Input::get()->bindGameControllerButton(i, InputType::UP, SDL_CONTROLLER_BUTTON_DPAD_UP); - Input::get()->bindGameControllerButton(i, InputType::DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN); - Input::get()->bindGameControllerButton(i, InputType::LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT); - Input::get()->bindGameControllerButton(i, InputType::RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); + Input::get()->bindGameControllerButton(i, InputAction::UP, SDL_CONTROLLER_BUTTON_DPAD_UP); + Input::get()->bindGameControllerButton(i, InputAction::DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN); + Input::get()->bindGameControllerButton(i, InputAction::LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT); + Input::get()->bindGameControllerButton(i, InputAction::RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); - Input::get()->bindGameControllerButton(i, InputType::FIRE_LEFT, SDL_CONTROLLER_BUTTON_X); - Input::get()->bindGameControllerButton(i, InputType::FIRE_CENTER, SDL_CONTROLLER_BUTTON_Y); - Input::get()->bindGameControllerButton(i, InputType::FIRE_RIGHT, SDL_CONTROLLER_BUTTON_B); + Input::get()->bindGameControllerButton(i, InputAction::FIRE_LEFT, SDL_CONTROLLER_BUTTON_X); + Input::get()->bindGameControllerButton(i, InputAction::FIRE_CENTER, SDL_CONTROLLER_BUTTON_Y); + Input::get()->bindGameControllerButton(i, InputAction::FIRE_RIGHT, SDL_CONTROLLER_BUTTON_B); - Input::get()->bindGameControllerButton(i, InputType::START, SDL_CONTROLLER_BUTTON_START); + Input::get()->bindGameControllerButton(i, InputAction::START, SDL_CONTROLLER_BUTTON_START); // Mando - Control del programa - Input::get()->bindGameControllerButton(i, InputType::SERVICE, SDL_CONTROLLER_BUTTON_BACK); + Input::get()->bindGameControllerButton(i, InputAction::SERVICE, SDL_CONTROLLER_BUTTON_BACK); } // Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso - const size_t max_controllers = std::min(2, num_gamepads); + const size_t max_controllers = std::min(2, NUM_GAMEPADS); for (size_t i = 0; i < max_controllers; ++i) { for (auto &controller : options.controllers) @@ -234,16 +234,16 @@ void Director::bindInputs() } // Asigna botones a inputs desde otros inputs - for (int i = 0; i < num_gamepads; ++i) + for (int i = 0; i < NUM_GAMEPADS; ++i) { - Input::get()->bindGameControllerButton(i, InputType::EXIT, InputType::START); - Input::get()->bindGameControllerButton(i, InputType::RESET, InputType::FIRE_CENTER); - Input::get()->bindGameControllerButton(i, InputType::PAUSE, InputType::FIRE_RIGHT); - Input::get()->bindGameControllerButton(i, InputType::VIDEO_SHADERS, InputType::FIRE_LEFT); - Input::get()->bindGameControllerButton(i, InputType::MUTE, InputType::LEFT); - Input::get()->bindGameControllerButton(i, InputType::SHOWINFO, InputType::RIGHT); - Input::get()->bindGameControllerButton(i, InputType::CONFIG, InputType::DOWN); - Input::get()->bindGameControllerButton(i, InputType::SWAP_CONTROLLERS, InputType::UP); + Input::get()->bindGameControllerButton(i, InputAction::EXIT, InputAction::START); + Input::get()->bindGameControllerButton(i, InputAction::RESET, InputAction::FIRE_CENTER); + Input::get()->bindGameControllerButton(i, InputAction::PAUSE, InputAction::FIRE_RIGHT); + Input::get()->bindGameControllerButton(i, InputAction::VIDEO_SHADERS, InputAction::FIRE_LEFT); + Input::get()->bindGameControllerButton(i, InputAction::MUTE, InputAction::LEFT); + Input::get()->bindGameControllerButton(i, InputAction::SHOW_INFO, InputAction::RIGHT); + Input::get()->bindGameControllerButton(i, InputAction::CONFIG, InputAction::DOWN); + Input::get()->bindGameControllerButton(i, InputAction::SWAP_CONTROLLERS, InputAction::UP); } // Guarda las asignaciones de botones en las opciones de los dos primeros mandos diff --git a/source/game.cpp b/source/game.cpp index ddf7eb0..8ab89be 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -17,7 +17,7 @@ #include "fade.h" // Para Fade, FadeType, FadeMode #include "global_events.h" // Para check #include "global_inputs.h" // Para check, update -#include "input.h" // Para InputType, Input, INPUT_DO_NOT_ALL... +#include "input.h" // Para InputAction, Input, INPUT_DO_NOT_ALL... #include "item.h" // Para Item, ItemType #include "jail_audio.h" // Para JA_PlaySound, JA_GetMusicState #include "lang.h" // Para getText @@ -1365,8 +1365,8 @@ void Game::checkPauseInput() // Comprueba los mandos for (int i = 0; i < input_->getNumControllers(); ++i) { - if (input_->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && - input_->checkInput(InputType::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) + if (input_->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && + input_->checkInput(InputAction::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) { pause(!paused_); return; @@ -1374,7 +1374,7 @@ void Game::checkPauseInput() } // Comprueba el teclado - if (input_->checkInput(InputType::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (input_->checkInput(InputAction::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { pause(!paused_); return; @@ -1410,15 +1410,15 @@ void Game::handleDemoPlayerInput(const std::shared_ptr &player, int inde if (demoData.left == 1) { - player->setInput(InputType::LEFT); + player->setInput(InputAction::LEFT); } else if (demoData.right == 1) { - player->setInput(InputType::RIGHT); + player->setInput(InputAction::RIGHT); } else if (demoData.no_input == 1) { - player->setInput(InputType::NONE); + player->setInput(InputAction::NONE); } if (demoData.fire == 1) @@ -1440,8 +1440,8 @@ void Game::handleFireInput(const std::shared_ptr &player, BulletType bul { if (player->canFire()) { - player->setInput(bulletType == BulletType::UP ? InputType::FIRE_CENTER : bulletType == BulletType::LEFT ? InputType::FIRE_LEFT - : InputType::FIRE_RIGHT); + player->setInput(bulletType == BulletType::UP ? InputAction::FIRE_CENTER : bulletType == BulletType::LEFT ? InputAction::FIRE_LEFT + : InputAction::FIRE_RIGHT); createBullet(player->getPosX() + (player->getWidth() / 2) - 6, player->getPosY() + (player->getHeight() / 2), bulletType, player->isPowerUp(), player->getId()); JA_PlaySound(Resource::get()->getSound("bullet.wav")); @@ -1481,23 +1481,23 @@ void Game::handleNormalPlayerInput(const std::shared_ptr &player) const auto &controller = options.controllers.at(player->getController()); const bool autofire = player->isPowerUp() || options.game.autofire; - if (input_->checkInput(InputType::LEFT, INPUT_ALLOW_REPEAT, controller.type, controller.index)) + if (input_->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, controller.type, controller.index)) { - player->setInput(InputType::LEFT); + player->setInput(InputAction::LEFT); #ifdef RECORDING demo_.keys.left = 1; #endif } - else if (input_->checkInput(InputType::RIGHT, INPUT_ALLOW_REPEAT, controller.type, controller.index)) + else if (input_->checkInput(InputAction::RIGHT, INPUT_ALLOW_REPEAT, controller.type, controller.index)) { - player->setInput(InputType::RIGHT); + player->setInput(InputAction::RIGHT); #ifdef RECORDING demo_.keys.right = 1; #endif } else { - player->setInput(InputType::NONE); + player->setInput(InputAction::NONE); #ifdef RECORDING demo_.keys.no_input = 1; #endif @@ -1509,21 +1509,21 @@ void Game::handleNormalPlayerInput(const std::shared_ptr &player) // Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado. void Game::handleFireInputs(const std::shared_ptr &player, bool autofire, int controllerIndex) { - if (input_->checkInput(InputType::FIRE_CENTER, autofire, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + if (input_->checkInput(InputAction::FIRE_CENTER, autofire, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { handleFireInput(player, BulletType::UP); #ifdef RECORDING demo_.keys.fire = 1; #endif } - else if (input_->checkInput(InputType::FIRE_LEFT, autofire, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + else if (input_->checkInput(InputAction::FIRE_LEFT, autofire, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { handleFireInput(player, BulletType::LEFT); #ifdef RECORDING demo_.keys.fire_left = 1; #endif } - else if (input_->checkInput(InputType::FIRE_RIGHT, autofire, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + else if (input_->checkInput(InputAction::FIRE_RIGHT, autofire, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { handleFireInput(player, BulletType::RIGHT); #ifdef RECORDING @@ -1536,16 +1536,16 @@ void Game::handleFireInputs(const std::shared_ptr &player, bool autofire void Game::handlePlayerContinue(const std::shared_ptr &player) { const auto controllerIndex = player->getController(); - if (input_->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { player->setPlayingState(PlayerState::PLAYING); player->addCredit(); } // Disminuye el contador de continuación si se presiona cualquier botón de disparo. - if (input_->checkInput(InputType::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) || - input_->checkInput(InputType::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) || - input_->checkInput(InputType::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) || + input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) || + input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { if (player->getContinueCounter() < 7) { @@ -1558,9 +1558,9 @@ void Game::handlePlayerContinue(const std::shared_ptr &player) void Game::handleNameInput(const std::shared_ptr &player) { const auto controllerIndex = player->getController(); - if (input_->checkInput(InputType::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) || - input_->checkInput(InputType::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) || - input_->checkInput(InputType::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) || + input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) || + input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { if (player->isShowingName()) { @@ -1568,30 +1568,30 @@ void Game::handleNameInput(const std::shared_ptr &player) } else if (player->getEnterNamePositionOverflow()) { - player->setInput(InputType::START); + player->setInput(InputAction::START); addScoreToScoreBoard(player); player->setPlayingState(PlayerState::SHOWING_NAME); } else { - player->setInput(InputType::RIGHT); + player->setInput(InputAction::RIGHT); } } - else if (input_->checkInput(InputType::UP, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + else if (input_->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { - player->setInput(InputType::UP); + player->setInput(InputAction::UP); } - else if (input_->checkInput(InputType::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + else if (input_->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { - player->setInput(InputType::DOWN); + player->setInput(InputAction::DOWN); } - else if (input_->checkInput(InputType::LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + else if (input_->checkInput(InputAction::LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { - player->setInput(InputType::LEFT); + player->setInput(InputAction::LEFT); } - else if (input_->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) + else if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index)) { - player->setInput(InputType::START); + player->setInput(InputAction::START); addScoreToScoreBoard(player); player->setPlayingState(PlayerState::SHOWING_NAME); } diff --git a/source/global_inputs.cpp b/source/global_inputs.cpp index 7261dba..c6b15a3 100644 --- a/source/global_inputs.cpp +++ b/source/global_inputs.cpp @@ -4,7 +4,7 @@ #include // Para operator+, string, to_string, basic_string #include // Para vector #include "asset.h" // Para Asset -#include "input.h" // Para Input, InputDeviceToUse, InputType, INP... +#include "input.h" // Para Input, InputDeviceToUse, InputAction, INP... #include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundVolume #include "lang.h" // Para getText, Code, getNextLangCode, loadFro... #include "notifier.h" // Para Notifier @@ -178,7 +178,7 @@ namespace globalInputs // Teclado { // Comprueba el teclado para cambiar entre pantalla completa y ventana - if (Input::get()->checkInput(InputType::WINDOW_FULLSCREEN, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::WINDOW_FULLSCREEN, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { Screen::get()->toggleVideoMode(); const std::string mode = options.video.mode == ScreenVideoMode::WINDOW ? lang::getText(132) : lang::getText(133); @@ -187,7 +187,7 @@ namespace globalInputs } // Comprueba el teclado para decrementar el tamaño de la ventana - if (Input::get()->checkInput(InputType::WINDOW_DEC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::WINDOW_DEC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { if (Screen::get()->decWindowZoom()) { @@ -197,7 +197,7 @@ namespace globalInputs } // Comprueba el teclado para incrementar el tamaño de la ventana - if (Input::get()->checkInput(InputType::WINDOW_INC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::WINDOW_INC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { if (Screen::get()->incWindowZoom()) { @@ -207,7 +207,7 @@ namespace globalInputs } // Salir - if (Input::get()->checkInput(InputType::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { quit(section::Options::QUIT_WITH_KEYBOARD); return; @@ -221,41 +221,41 @@ namespace globalInputs } // Reset - if (Input::get()->checkInput(InputType::RESET, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::RESET, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { reset(); return; } // Audio - if (Input::get()->checkInput(InputType::MUTE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::MUTE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { toggleAudio(); return; } // Autofire - if (Input::get()->checkInput(InputType::AUTO_FIRE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::AUTO_FIRE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { toggleFireMode(); return; } // Idioma - if (Input::get()->checkInput(InputType::CHANGE_LANG, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::CHANGE_LANG, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { changeLang(); return; } // Shaders - if (Input::get()->checkInput(InputType::VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { toggleShaders(); return; } - if (Input::get()->checkInput(InputType::VIDEO_INTEGER_SCALE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::VIDEO_INTEGER_SCALE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { toggleintegerScale(); return; @@ -263,14 +263,14 @@ namespace globalInputs #ifdef DEBUG // Comprueba el teclado para mostrar la información de debug - if (Input::get()->checkInput(InputType::SHOWINFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::SHOW_INFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { Screen::get()->toggleDebugInfo(); return; } #endif // OnScreenHelp - if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) + if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) { service_pressed = true; return; @@ -282,47 +282,47 @@ namespace globalInputs for (int i = 0; i < Input::get()->getNumControllers(); ++i) { // Salir - if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && - Input::get()->checkInput(InputType::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) + if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && + Input::get()->checkInput(InputAction::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) { quit(section::Options::QUIT_WITH_CONTROLLER); return; } // Reset - if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && - Input::get()->checkInput(InputType::RESET, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) + if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && + Input::get()->checkInput(InputAction::RESET, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) { reset(); return; } // Audio - if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && - Input::get()->checkInput(InputType::MUTE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) + if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && + Input::get()->checkInput(InputAction::MUTE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) { toggleAudio(); return; } // Shaders - if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && - Input::get()->checkInput(InputType::VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) + if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && + Input::get()->checkInput(InputAction::VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) { toggleShaders(); return; } #ifdef DEBUG // Debug Info - if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && - Input::get()->checkInput(InputType::SHOWINFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) + if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) && + Input::get()->checkInput(InputAction::SHOW_INFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) { Screen::get()->toggleDebugInfo(); return; } #endif // OnScreenHelp - if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) + if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) { service_pressed = true; return; diff --git a/source/input.cpp b/source/input.cpp index f61a770..d3cd523 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -38,21 +38,21 @@ Input::Input(const std::string &game_controller_db_path) discoverGameControllers(); // Inicializa los vectores - key_bindings_.resize(static_cast(InputType::NUMBER_OF_INPUTS), KeyBindings()); - controller_bindings_.resize(num_gamepads_, std::vector(static_cast(InputType::NUMBER_OF_INPUTS), ControllerBindings())); + key_bindings_.resize(static_cast(InputAction::SIZE), KeyBindings()); + controller_bindings_.resize(num_gamepads_, std::vector(static_cast(InputAction::SIZE), ControllerBindings())); // Listado de los inputs para jugar que utilizan botones, ni palancas ni crucetas - button_inputs_ = {InputType::FIRE_LEFT, InputType::FIRE_CENTER, InputType::FIRE_RIGHT, InputType::START}; + button_inputs_ = {InputAction::FIRE_LEFT, InputAction::FIRE_CENTER, InputAction::FIRE_RIGHT, InputAction::START}; } // Asigna inputs a teclas -void Input::bindKey(InputType input, SDL_Scancode code) +void Input::bindKey(InputAction input, SDL_Scancode code) { key_bindings_.at(static_cast(input)).scancode = code; } // Asigna inputs a botones del mando -void Input::bindGameControllerButton(int controller_index, InputType input, SDL_GameControllerButton button) +void Input::bindGameControllerButton(int controller_index, InputAction input, SDL_GameControllerButton button) { if (controller_index < num_gamepads_) { @@ -61,7 +61,7 @@ void Input::bindGameControllerButton(int controller_index, InputType input, SDL_ } // Asigna inputs a botones del mando -void Input::bindGameControllerButton(int controller_index, InputType input_target, InputType input_source) +void Input::bindGameControllerButton(int controller_index, InputAction input_target, InputAction input_source) { if (controller_index < num_gamepads_) { @@ -70,7 +70,7 @@ void Input::bindGameControllerButton(int controller_index, InputType input_targe } // Comprueba si un input esta activo -bool Input::checkInput(InputType input, bool repeat, InputDeviceToUse device, int controller_index) +bool Input::checkInput(InputAction input, bool repeat, InputDeviceToUse device, int controller_index) { bool success_keyboard = false; bool success_controller = false; @@ -190,7 +190,7 @@ bool Input::checkAnyInput(InputDeviceToUse device, int controller_index) int Input::checkAnyButtonPressed(bool repeat) { // Si está pulsado el botón de servicio, ningún botón se puede considerar pulsado - if (checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::ANY)) + if (checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::ANY)) { return 0; } @@ -335,7 +335,7 @@ void Input::printBindings(InputDeviceToUse device, int controller_index) const } // Obtiene el SDL_GameControllerButton asignado a un input -SDL_GameControllerButton Input::getControllerBinding(int controller_index, InputType input) const +SDL_GameControllerButton Input::getControllerBinding(int controller_index, InputAction input) const { return controller_bindings_[controller_index][static_cast(input)].button; } @@ -347,42 +347,42 @@ int Input::getIndexByName(const std::string &name) const return it != controller_names_.end() ? std::distance(controller_names_.begin(), it) : -1; } -// Convierte un InputType a std::string -std::string Input::to_string(InputType input) const +// Convierte un InputAction a std::string +std::string Input::to_string(InputAction input) const { switch (input) { - case InputType::FIRE_LEFT: + case InputAction::FIRE_LEFT: return "input_fire_left"; - case InputType::FIRE_CENTER: + case InputAction::FIRE_CENTER: return "input_fire_center"; - case InputType::FIRE_RIGHT: + case InputAction::FIRE_RIGHT: return "input_fire_right"; - case InputType::START: + case InputAction::START: return "input_start"; - case InputType::SERVICE: + case InputAction::SERVICE: return "input_service"; default: return ""; } } -// Convierte un std::string a InputType -InputType Input::to_inputs_e(const std::string &name) const +// Convierte un std::string a InputAction +InputAction Input::to_inputs_e(const std::string &name) const { - static const std::unordered_map inputMap = { - {"input_fire_left", InputType::FIRE_LEFT}, - {"input_fire_center", InputType::FIRE_CENTER}, - {"input_fire_right", InputType::FIRE_RIGHT}, - {"input_start", InputType::START}, - {"input_service", InputType::SERVICE}}; + static const std::unordered_map inputMap = { + {"input_fire_left", InputAction::FIRE_LEFT}, + {"input_fire_center", InputAction::FIRE_CENTER}, + {"input_fire_right", InputAction::FIRE_RIGHT}, + {"input_start", InputAction::START}, + {"input_service", InputAction::SERVICE}}; auto it = inputMap.find(name); - return it != inputMap.end() ? it->second : InputType::NONE; + return it != inputMap.end() ? it->second : InputAction::NONE; } // Comprueba el eje del mando -bool Input::checkAxisInput(InputType input, int controller_index, bool repeat) +bool Input::checkAxisInput(InputAction input, int controller_index, bool repeat) { // Umbral para considerar el eje como activo const Sint16 threshold = 30000; @@ -390,16 +390,16 @@ bool Input::checkAxisInput(InputType input, int controller_index, bool repeat) switch (input) { - case InputType::LEFT: + case InputAction::LEFT: axis_active_now = SDL_GameControllerGetAxis(connected_controllers_[controller_index], SDL_CONTROLLER_AXIS_LEFTX) < -threshold; break; - case InputType::RIGHT: + case InputAction::RIGHT: axis_active_now = SDL_GameControllerGetAxis(connected_controllers_[controller_index], SDL_CONTROLLER_AXIS_LEFTX) > threshold; break; - case InputType::UP: + case InputAction::UP: axis_active_now = SDL_GameControllerGetAxis(connected_controllers_[controller_index], SDL_CONTROLLER_AXIS_LEFTY) < -threshold; break; - case InputType::DOWN: + case InputAction::DOWN: axis_active_now = SDL_GameControllerGetAxis(connected_controllers_[controller_index], SDL_CONTROLLER_AXIS_LEFTY) > threshold; break; default: diff --git a/source/input.h b/source/input.h index e6fb790..15a5f23 100644 --- a/source/input.h +++ b/source/input.h @@ -16,7 +16,7 @@ device contiene el tipo de dispositivo a comprobar: InputDeviceToUse::ANY mirará tanto el teclado como el PRIMER controlador */ -enum class InputType : int +enum class InputAction : int { // Inputs de movimiento UP, @@ -42,14 +42,14 @@ enum class InputType : int RESET, MUTE, CHANGE_LANG, - SHOWINFO, + SHOW_INFO, CONFIG, SWAP_CONTROLLERS, AUTO_FIRE, // Input obligatorio NONE, - NUMBER_OF_INPUTS, + SIZE, }; constexpr bool INPUT_ALLOW_REPEAT = true; @@ -95,13 +95,13 @@ private: std::vector key_bindings_; // Vector con las teclas asociadas a los inputs predefinidos std::vector> controller_bindings_; // Vector con los botones asociadas a los inputs predefinidos para cada mando std::vector controller_names_; // Vector con los nombres de los mandos - std::vector button_inputs_; // Inputs asignados al jugador y a botones, excluyendo direcciones + std::vector button_inputs_; // Inputs asignados al jugador y a botones, excluyendo direcciones int num_joysticks_ = 0; // Número de joysticks conectados int num_gamepads_ = 0; // Número de mandos conectados std::string game_controller_db_path_; // Ruta al archivo gamecontrollerdb.txt // Comprueba el eje del mando - bool checkAxisInput(InputType input, int controller_index, bool repeat); + bool checkAxisInput(InputAction input, int controller_index, bool repeat); // Constructor explicit Input(const std::string &game_controller_db_path); @@ -120,14 +120,14 @@ public: static Input *get(); // Asigna inputs a teclas - void bindKey(InputType input, SDL_Scancode code); + void bindKey(InputAction input, SDL_Scancode code); // Asigna inputs a botones del mando - void bindGameControllerButton(int controller_index, InputType input, SDL_GameControllerButton button); - void bindGameControllerButton(int controller_index, InputType inputTarget, InputType inputSource); + void bindGameControllerButton(int controller_index, InputAction input, SDL_GameControllerButton button); + void bindGameControllerButton(int controller_index, InputAction inputTarget, InputAction inputSource); // Comprueba si un input esta activo - bool checkInput(InputType input, bool repeat = true, InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0); + bool checkInput(InputAction input, bool repeat = true, InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0); // Comprueba si hay almenos un input activo bool checkAnyInput(InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0); @@ -154,13 +154,13 @@ public: void printBindings(InputDeviceToUse device = InputDeviceToUse::KEYBOARD, int controller_index = 0) const; // Obtiene el SDL_GameControllerButton asignado a un input - SDL_GameControllerButton getControllerBinding(int controller_index, InputType input) const; + SDL_GameControllerButton getControllerBinding(int controller_index, InputAction input) const; - // Convierte un InputType a std::string - std::string to_string(InputType input) const; + // Convierte un InputAction a std::string + std::string to_string(InputAction input) const; - // Convierte un std::string a InputType - InputType to_inputs_e(const std::string &name) const; + // Convierte un std::string a InputAction + InputAction to_inputs_e(const std::string &name) const; // Obtiene el indice a partir del nombre del mando int getIndexByName(const std::string &name) const; diff --git a/source/options.h b/source/options.h index feea2a9..9976dc0 100644 --- a/source/options.h +++ b/source/options.h @@ -4,7 +4,7 @@ #include // Para Uint32 #include // Para string #include // Para vector -#include "input.h" // Para InputType, InputDeviceToUse +#include "input.h" // Para InputAction, InputDeviceToUse #include "manage_hiscore_table.h" // Para HiScoreEntry enum class ScreenFilter : int; // lines 8-8 enum class ScreenVideoMode : Uint32; // lines 9-9 @@ -87,13 +87,13 @@ struct OptionsController InputDeviceToUse type; // Indica si se utilizará teclado o mando o ambos std::string name; // Nombre del dispositivo bool plugged; // Indica si el mando se encuentra conectado - std::vector inputs; // Listado de inputs + std::vector inputs; // Listado de inputs std::vector buttons; // Listado de botones asignados a cada input // Constructor por defecto OptionsController() : index(-1), player_id(-1), type(InputDeviceToUse::CONTROLLER), name(""), plugged(false), - inputs{InputType::FIRE_LEFT, InputType::FIRE_CENTER, InputType::FIRE_RIGHT, InputType::START, InputType::SERVICE}, + inputs{InputAction::FIRE_LEFT, InputAction::FIRE_CENTER, InputAction::FIRE_RIGHT, InputAction::START, InputAction::SERVICE}, buttons{SDL_CONTROLLER_BUTTON_X, SDL_CONTROLLER_BUTTON_Y, SDL_CONTROLLER_BUTTON_B, SDL_CONTROLLER_BUTTON_START, SDL_CONTROLLER_BUTTON_BACK} {} }; diff --git a/source/player.cpp b/source/player.cpp index b7c7394..a7a8346 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -4,7 +4,7 @@ #include // Para rand #include // Para clamp, max, min #include "animated_sprite.h" // Para AnimatedSprite -#include "input.h" // Para InputType +#include "input.h" // Para InputAction #include "param.h" // Para Param, ParamGame, param #include "scoreboard.h" // Para Scoreboard, ScoreboardMode #include "texture.h" // Para Texture @@ -70,7 +70,7 @@ void Player::init() } // Actua en consecuencia de la entrada recibida -void Player::setInput(InputType input) +void Player::setInput(InputAction input) { switch (playing_state_) { @@ -91,33 +91,33 @@ void Player::setInput(InputType input) } // Procesa inputs para cuando está jugando -void Player::setInputPlaying(InputType input) +void Player::setInputPlaying(InputAction input) { switch (input) { - case InputType::LEFT: + case InputAction::LEFT: { vel_x_ = -BASE_SPEED_; setWalkingState(PlayerState::WALKING_LEFT); break; } - case InputType::RIGHT: + case InputAction::RIGHT: { vel_x_ = BASE_SPEED_; setWalkingState(PlayerState::WALKING_RIGHT); break; } - case InputType::FIRE_CENTER: + case InputAction::FIRE_CENTER: { setFiringState(PlayerState::FIRING_UP); break; } - case InputType::FIRE_LEFT: + case InputAction::FIRE_LEFT: { setFiringState(PlayerState::FIRING_LEFT); break; } - case InputType::FIRE_RIGHT: + case InputAction::FIRE_RIGHT: { setFiringState(PlayerState::FIRING_RIGHT); break; @@ -132,23 +132,23 @@ void Player::setInputPlaying(InputType input) } // Procesa inputs para cuando está introduciendo el nombre -void Player::setInputEnteringName(InputType input) +void Player::setInputEnteringName(InputAction input) { switch (input) { - case InputType::LEFT: + case InputAction::LEFT: enter_name_->decPosition(); break; - case InputType::RIGHT: + case InputAction::RIGHT: enter_name_->incPosition(); break; - case InputType::UP: + case InputAction::UP: enter_name_->incIndex(); break; - case InputType::DOWN: + case InputAction::DOWN: enter_name_->decIndex(); break; - case InputType::START: + case InputAction::START: last_enter_name_ = getRecordName(); if (last_enter_name_.empty()) { @@ -227,10 +227,10 @@ void Player::move() switch (id_) { case 1: - setInputPlaying(InputType::LEFT); + setInputPlaying(InputAction::LEFT); break; case 2: - setInputPlaying(InputType::RIGHT); + setInputPlaying(InputAction::RIGHT); break; default: break; @@ -258,7 +258,7 @@ void Player::move() switch (id_) { case 1: - setInputPlaying(InputType::RIGHT); + setInputPlaying(InputAction::RIGHT); pos_x_ += vel_x_; if (pos_x_ > default_pos_x_) { @@ -268,7 +268,7 @@ void Player::move() } break; case 2: - setInputPlaying(InputType::LEFT); + setInputPlaying(InputAction::LEFT); pos_x_ += vel_x_; if (pos_x_ < default_pos_x_) { @@ -288,7 +288,7 @@ void Player::move() pos_x_ += vel_x_ / 2.0f; if (vel_x_ > 0) { - // setInputPlaying(InputType::RIGHT); + // setInputPlaying(InputAction::RIGHT); if (pos_x_ > param.game.game_area.rect.w - WIDTH_) { pos_x_ = param.game.game_area.rect.w - WIDTH_; @@ -297,7 +297,7 @@ void Player::move() } else { - // setInputPlaying(InputType::LEFT); + // setInputPlaying(InputAction::LEFT); if (pos_x_ < param.game.game_area.rect.x) { pos_x_ = param.game.game_area.rect.x; diff --git a/source/player.h b/source/player.h index bfa8aee..e83eeb1 100644 --- a/source/player.h +++ b/source/player.h @@ -11,7 +11,7 @@ #include "options.h" // Para Options, OptionsGame, options #include "utils.h" // Para Circle class Texture; // lines 13-13 -enum class InputType : int; // lines 14-14 +enum class InputAction : int; // lines 14-14 enum class ScoreboardMode; // lines 15-15 // Estados del jugador @@ -152,13 +152,13 @@ public: void setPlayerTextures(const std::vector> &texture); // Actua en consecuencia de la entrada recibida - void setInput(InputType input); + void setInput(InputAction input); // Procesa inputs para cuando está jugando - void setInputPlaying(InputType input); + void setInputPlaying(InputAction input); // Procesa inputs para cuando está introduciendo el nombre - void setInputEnteringName(InputType input); + void setInputEnteringName(InputAction input); // Mueve el jugador a la posición y animación que le corresponde void move(); @@ -238,7 +238,7 @@ public: int getScoreBoardPanel() const { return scoreboard_panel_; } int getWidth() const { return WIDTH_; } PlayerState getPlayingState() const { return playing_state_; } - const std::string& getName() const { return name_; } + const std::string &getName() const { return name_; } bool get1CC() const { return game_completed_ && credits_used_ == 1; } bool getEnterNamePositionOverflow() const { return enter_name_->getPositionOverflow(); } diff --git a/source/screen.cpp b/source/screen.cpp index bafe6ed..4766a0b 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -88,10 +88,10 @@ void Screen::renderScreen() } // Establece el modo de video -void Screen::setVideoMode(ScreenVideoMode video_mode) +void Screen::setVideoMode(ScreenVideoMode mode) { // Actualiza las opciones - options.video.mode = video_mode; + options.video.mode = mode; // Configura el modo de pantalla Uint32 flags = SDL_GetWindowFlags(window_); @@ -316,17 +316,17 @@ void Screen::loadShaders() { const std::string GLSL_FILE = param.game.game_area.rect.h == 256 ? "crtpi_256.glsl" : "crtpi_240.glsl"; std::ifstream f(Asset::get()->get(GLSL_FILE).c_str()); - shaderSource = std::string((std::istreambuf_iterator(f)), std::istreambuf_iterator()); + shader_source_ = std::string((std::istreambuf_iterator(f)), std::istreambuf_iterator()); } // Inicializa los shaders void Screen::initShaders() { - if (shaderSource.empty()) + if (shader_source_.empty()) { loadShaders(); } - shader::init(window_, game_canvas_, shaderSource); + shader::init(window_, game_canvas_, shader_source_); } // Calcula el tamaño de la ventana diff --git a/source/screen.h b/source/screen.h index 3bdfb51..419ca7e 100644 --- a/source/screen.h +++ b/source/screen.h @@ -44,7 +44,7 @@ private: int fps_counter_ = 0; // Contador de frames por segundo int fps_ = 0; // Frames calculados en el último segundo std::string info_resolution_; // Texto con la informacion de la pantalla - std::string shaderSource; // Almacenar el contenido del archivo GLSL + std::string shader_source_; // Almacena el contenido del archivo GLSL #ifdef DEBUG bool show_debug_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla @@ -162,7 +162,7 @@ public: void render(); // Establece el modo de video - void setVideoMode(ScreenVideoMode video_mode = options.video.mode); + void setVideoMode(ScreenVideoMode mode = options.video.mode); // Cambia entre pantalla completa y ventana void toggleVideoMode(); diff --git a/source/title.cpp b/source/title.cpp index 1093819..3c48474 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -9,7 +9,7 @@ #include "fade.h" // Para Fade, FadeType #include "game_logo.h" // Para GameLogo #include "global_inputs.h" // Para check, update -#include "input.h" // Para Input, InputType, INPUT_DO_NOT_ALLOW_R... +#include "input.h" // Para Input, InputAction, INPUT_DO_NOT_ALLOW_R... #include "jail_audio.h" // Para JA_GetMusicState, JA_FadeOutMusic, JA_... #include "lang.h" // Para getText #include "global_events.h" // Para handleEvent @@ -198,8 +198,8 @@ void Title::checkInput() for (const auto &controller : options.controllers) { // START - if (Input::get()->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index) && - !Input::get()->checkInput(InputType::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index)) + if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index) && + !Input::get()->checkInput(InputAction::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index)) { if ((state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP) && !fade_->isEnabled()) { @@ -224,16 +224,16 @@ void Title::checkInput() } // SWAP_CONTROLLERS - if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) && - Input::get()->checkInput(InputType::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index)) + if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) && + Input::get()->checkInput(InputAction::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index)) { swapControllers(); return; } // CONFIG - if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) && - Input::get()->checkInput(InputType::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index)) + if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) && + Input::get()->checkInput(InputAction::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index)) { define_buttons_->enable(controller.index); return;