diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index fd60bdd..bdab4fc 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -1,12 +1,12 @@ #include "define_buttons.h" -#include // for move -#include "input.h" // for Input, InputType -#include "lang.h" // for getText -#include "options.h" // for options -#include "param.h" // for param -#include "section.h" // for Name, Options, name, options -#include "text.h" // for Text -#include "utils.h" // for OptionsController, Options, Param, ParamGame +#include // for move +#include "input.h" // for Input, InputType +#include "lang.h" // for getText +#include "options.h" // for options +#include "param.h" // for param +#include "section.h" // for Name, Options, name, options +#include "text.h" // for Text +#include "utils.h" // for OptionsController, Options, Param, ParamGame // Constructor DefineButtons::DefineButtons(std::unique_ptr text_) @@ -106,7 +106,7 @@ void DefineButtons::checkInput() case SDL_QUIT: { section::name = section::Name::QUIT; - section::options = section::Options::QUIT_NORMAL; + section::options = section::Options::QUIT_WITH_KEYBOARD; break; } @@ -157,7 +157,7 @@ void DefineButtons::incIndexButton() // Guarda los cambios en las opciones saveBindingsToOptions(); - //input_->allActive(index_controller_); + // input_->allActive(index_controller_); // Reinicia variables index_button_ = 0; diff --git a/source/director.cpp b/source/director.cpp index 15be44d..4f935b5 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -134,6 +134,8 @@ Director::~Director() SDL_DestroyWindow(window_); SDL_Quit(); + + std::cout << "\nBye!" << std::endl; } // Asigna los botones y teclas al objeto Input @@ -658,19 +660,20 @@ int Director::run() #ifdef ARCADE // Comprueba si ha de apagar el sistema - if (section::options == section::Options::QUIT_SHUTDOWN) + if (section::options == section::Options::QUIT_WITH_CONTROLLER) shutdownSystem(); #endif - const auto return_code = (section::options == section::Options::QUIT_NORMAL) ? "keyboard" : "controller"; - std::cout << "\nGame end with " << return_code << std::endl; + const auto return_code = (section::options == section::Options::QUIT_WITH_KEYBOARD) ? "with keyboard" : (section::options == section::Options::QUIT_WITH_CONTROLLER) ? "with controller" + : "from event"; + std::cout << "\nGame end " << return_code << std::endl; #ifndef VERBOSE // Habilita de nuevo los std::cout std::cout.rdbuf(orig_buf); #endif - return (return_code == std::string("keyboard")) ? 0 : 1; + return (section::options == section::Options::QUIT_WITH_CONTROLLER) ? 1 : 0; } // Obtiene una fichero a partir de un lang::Code diff --git a/source/game.cpp b/source/game.cpp index dd27525..7ab7273 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -1970,6 +1970,7 @@ void Game::checkEvents() if (event.type == SDL_QUIT) { section::name = section::Name::QUIT; + section::options = section::Options::QUIT_FROM_EVENT; break; } diff --git a/source/global_inputs.cpp b/source/global_inputs.cpp index 0cec1bb..03e6146 100644 --- a/source/global_inputs.cpp +++ b/source/global_inputs.cpp @@ -69,7 +69,7 @@ namespace globalInputs // Comprueba si se sale con el teclado if (Input::get()->checkInput(InputType::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) { - quit(section::Options::QUIT_NORMAL); + quit(section::Options::QUIT_WITH_KEYBOARD); return; } @@ -107,7 +107,7 @@ namespace globalInputs // Comprueba si se sale con el mando if (Input::get()->checkModInput(InputType::SERVICE, InputType::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) { - quit(section::Options::QUIT_SHUTDOWN); + quit(section::Options::QUIT_WITH_CONTROLLER); return; } diff --git a/source/hiscore_table.cpp b/source/hiscore_table.cpp index 921d1c6..812a11b 100644 --- a/source/hiscore_table.cpp +++ b/source/hiscore_table.cpp @@ -188,6 +188,7 @@ void HiScoreTable::checkEvents() if (event.type == SDL_QUIT) { section::name = section::Name::QUIT; + section::options = section::Options::QUIT_FROM_EVENT; break; } diff --git a/source/input.cpp b/source/input.cpp index 23de730..06530ca 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -416,10 +416,9 @@ bool Input::discoverGameControllers() } } - { - std::cout << "\nChecking for game controllers...\n"; - std::cout << num_joysticks_ << " joysticks found, " << num_gamepads_ << " are gamepads\n"; - } + std::cout << "\n** LOOKING FOR GAME CONTROLLERS" << std::endl; + // std::cout << " " << num_joysticks_ << " joysticks found" << std::endl; + std::cout << "Gamepads found: " << num_gamepads_ << std::endl; if (num_gamepads_ > 0) { @@ -434,7 +433,7 @@ bool Input::discoverGameControllers() connected_controllers_.push_back(pad); const std::string name = SDL_GameControllerNameForIndex(i); { - std::cout << name << std::endl; + std::cout << "#" << i << ": " << name << std::endl; } controller_names_.push_back(name); } @@ -449,6 +448,8 @@ bool Input::discoverGameControllers() SDL_GameControllerEventState(SDL_ENABLE); } + std::cout << "\n** FINISHED LOOKING FOR GAME CONTROLLERS" << std::endl; + return found; } diff --git a/source/instructions.cpp b/source/instructions.cpp index 928cafd..04cea66 100644 --- a/source/instructions.cpp +++ b/source/instructions.cpp @@ -297,6 +297,7 @@ void Instructions::checkEvents() if (event.type == SDL_QUIT) { section::name = section::Name::QUIT; + section::options = section::Options::QUIT_FROM_EVENT; break; } diff --git a/source/intro.cpp b/source/intro.cpp index a44d6a8..34b2eea 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -170,6 +170,7 @@ void Intro::checkEvents() case SDL_QUIT: { section::name = section::Name::QUIT; + section::options = section::Options::QUIT_FROM_EVENT; break; } diff --git a/source/logo.cpp b/source/logo.cpp index 40e3164..0777ede 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -73,6 +73,7 @@ void Logo::checkEvents() if (event.type == SDL_QUIT) { section::name = section::Name::QUIT; + section::options = section::Options::QUIT_FROM_EVENT; break; } diff --git a/source/section.h b/source/section.h index 700395f..7c2d759 100644 --- a/source/section.h +++ b/source/section.h @@ -23,9 +23,10 @@ namespace section GAME_PLAY_2P = 1, TITLE_1 = 2, TITLE_2 = 3, - QUIT_NORMAL = 4, - QUIT_SHUTDOWN = 5, - NONE = 6, + QUIT_WITH_KEYBOARD = 4, + QUIT_WITH_CONTROLLER = 5, + QUIT_FROM_EVENT = 6, + NONE = 7, }; extern Name name; diff --git a/source/title.cpp b/source/title.cpp index f66f4e4..ddcd731 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -188,6 +188,7 @@ void Title::checkEvents() if (event.type == SDL_QUIT) { section::name = section::Name::QUIT; + section::options = section::Options::QUIT_FROM_EVENT; break; } diff --git a/source/utils.cpp b/source/utils.cpp index 6b52b70..f480744 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -197,7 +197,7 @@ void printWithDots(const std::string &text1, const std::string &text2, const std std::cout.setf(std::ios::left, std::ios::adjustfield); std::cout << text1; - std::cout.width(70 - text1.length() - text3.length()); + std::cout.width(50 - text1.length() - text3.length()); std::cout.fill('.'); std::cout << text2;