diff --git a/source/common/input.h b/source/common/input.h index 073a9cb..d08aa2f 100644 --- a/source/common/input.h +++ b/source/common/input.h @@ -7,24 +7,6 @@ #ifndef INPUT_H #define INPUT_H -#define INPUT_NULL 0 -#define INPUT_UP 1 -#define INPUT_DOWN 2 -#define INPUT_LEFT 3 -#define INPUT_RIGHT 4 -#define INPUT_ACCEPT 5 -#define INPUT_CANCEL 6 -#define INPUT_BUTTON_1 7 -#define INPUT_BUTTON_2 8 -#define INPUT_BUTTON_3 9 -#define INPUT_BUTTON_4 10 -#define INPUT_BUTTON_5 11 -#define INPUT_BUTTON_6 12 -#define INPUT_BUTTON_7 13 -#define INPUT_BUTTON_8 14 -#define INPUT_BUTTON_PAUSE 15 -#define INPUT_BUTTON_ESCAPE 16 - enum inputs_e { // Inputs obligatorios @@ -40,15 +22,12 @@ enum inputs_e // Inputs personalizados input_jump, - input_switch_music, - input_video_mode, - input_swap_palette, - input_window_size_1, - input_window_size_2, - input_window_size_3, - input_window_size_4, - input_change_windows_size, + input_window_fullscreen, + input_window_inc_size, + input_window_dec_size, input_toggle_border, + input_switch_music, + input_swap_palette, // Input obligatorio input_number_of_inputs diff --git a/source/common/menu.cpp b/source/common/menu.cpp index e44cab8..f29f8ac 100644 --- a/source/common/menu.cpp +++ b/source/common/menu.cpp @@ -850,7 +850,7 @@ void Menu::setDefaultActionWhenCancel(int item) // Gestiona la entrada de teclado y mando durante el menu void Menu::checkInput() { - if (input->checkInput(INPUT_UP, REPEAT_FALSE)) + if (input->checkInput(input_up, REPEAT_FALSE)) { if (decreaseSelectorIndex()) { @@ -861,7 +861,7 @@ void Menu::checkInput() } } - if (input->checkInput(INPUT_DOWN, REPEAT_FALSE)) + if (input->checkInput(input_down, REPEAT_FALSE)) { if (increaseSelectorIndex()) { @@ -872,7 +872,7 @@ void Menu::checkInput() } } - if (input->checkInput(INPUT_ACCEPT, REPEAT_FALSE)) + if (input->checkInput(input_accept, REPEAT_FALSE)) { itemSelected = selector.index; if (soundAccept) @@ -881,7 +881,7 @@ void Menu::checkInput() } } - if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE)) + if (input->checkInput(input_cancel, REPEAT_FALSE)) { itemSelected = defaultActionWhenCancel; if (soundCancel) diff --git a/source/common/screen.cpp b/source/common/screen.cpp index 1ba2352..49d6b99 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -164,7 +164,7 @@ void Screen::setVideoMode(int videoMode) dest.x = dest.y = 0; } } - + // Modifica el tamaño del renderizador SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); @@ -191,6 +191,22 @@ void Screen::setWindowSize(int size) setVideoMode(0); } +// Reduce el tamaño de la ventana +void Screen::decWindowSize() +{ + --options->windowSize; + options->windowSize = std::max(options->windowSize, 1); + setVideoMode(0); +} + +// Aumenta el tamaño de la ventana +void Screen::incWindowSize() +{ + ++options->windowSize; + options->windowSize = std::min(options->windowSize, 4); + setVideoMode(0); +} + // Cambia el color del borde void Screen::setBorderColor(color_t color) { diff --git a/source/common/screen.h b/source/common/screen.h index 9a05e5d..8842d65 100644 --- a/source/common/screen.h +++ b/source/common/screen.h @@ -95,6 +95,12 @@ public: // Cambia el tamaño de la ventana void setWindowSize(int size); + // Reduce el tamaño de la ventana + void decWindowSize(); + + // Aumenta el tamaño de la ventana + void incWindowSize(); + // Cambia el color del borde void setBorderColor(color_t color); diff --git a/source/credits.cpp b/source/credits.cpp index 7fb2e63..7ad6ff9 100644 --- a/source/credits.cpp +++ b/source/credits.cpp @@ -96,29 +96,19 @@ void Credits::checkInput() screen->switchBorder(); } - else if (input->checkInput(input_video_mode, REPEAT_FALSE)) + else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); } - else if (input->checkInput(input_window_size_1, REPEAT_FALSE)) + else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) { - screen->setWindowSize(1); + screen->decWindowSize(); } - else if (input->checkInput(input_window_size_2, REPEAT_FALSE)) + else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) { - screen->setWindowSize(2); - } - - else if (input->checkInput(input_window_size_3, REPEAT_FALSE)) - { - screen->setWindowSize(3); - } - - else if (input->checkInput(input_window_size_4, REPEAT_FALSE)) - { - screen->setWindowSize(4); + screen->incWindowSize(); } else if (input->checkInput(input_swap_palette, REPEAT_FALSE)) diff --git a/source/demo.cpp b/source/demo.cpp index a31ecc3..6986d4c 100644 --- a/source/demo.cpp +++ b/source/demo.cpp @@ -91,33 +91,21 @@ void Demo::checkInput() reLoadTextures(); } - else if (input->checkInput(input_video_mode, REPEAT_FALSE)) + else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); reLoadTextures(); } - else if (input->checkInput(input_window_size_1, REPEAT_FALSE)) + else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) { - screen->setWindowSize(1); + screen->decWindowSize(); reLoadTextures(); } - else if (input->checkInput(input_window_size_2, REPEAT_FALSE)) + else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) { - screen->setWindowSize(2); - reLoadTextures(); - } - - else if (input->checkInput(input_window_size_3, REPEAT_FALSE)) - { - screen->setWindowSize(3); - reLoadTextures(); - } - - else if (input->checkInput(input_window_size_4, REPEAT_FALSE)) - { - screen->setWindowSize(4); + screen->incWindowSize(); reLoadTextures(); } diff --git a/source/director.cpp b/source/director.cpp index 69a154b..da21c0f 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -1234,13 +1234,11 @@ void Director::initInput() input->bindKey(input_cancel, SDL_SCANCODE_ESCAPE); input->bindKey(input_pause, SDL_SCANCODE_H); input->bindKey(input_exit, SDL_SCANCODE_ESCAPE); - input->bindKey(input_window_size_1, SDL_SCANCODE_F1); - input->bindKey(input_window_size_2, SDL_SCANCODE_F2); - input->bindKey(input_window_size_3, SDL_SCANCODE_F3); - input->bindKey(input_window_size_4, SDL_SCANCODE_F4); + input->bindKey(input_window_dec_size, SDL_SCANCODE_F1); + input->bindKey(input_window_inc_size, SDL_SCANCODE_F2); + input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3); input->bindKey(input_swap_palette, SDL_SCANCODE_F5); input->bindKey(input_switch_music, SDL_SCANCODE_M); - input->bindKey(input_video_mode, SDL_SCANCODE_F); input->bindKey(input_toggle_border, SDL_SCANCODE_B); // Mando - Movimiento diff --git a/source/ending.cpp b/source/ending.cpp index 335e6bf..5ee50ed 100644 --- a/source/ending.cpp +++ b/source/ending.cpp @@ -176,29 +176,19 @@ void Ending::checkInput() screen->switchBorder(); } - else if (input->checkInput(input_video_mode, REPEAT_FALSE)) + else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); } - else if (input->checkInput(input_window_size_1, REPEAT_FALSE)) + else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) { - screen->setWindowSize(1); + screen->decWindowSize(); } - else if (input->checkInput(input_window_size_2, REPEAT_FALSE)) + else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) { - screen->setWindowSize(2); - } - - else if (input->checkInput(input_window_size_3, REPEAT_FALSE)) - { - screen->setWindowSize(3); - } - - else if (input->checkInput(input_window_size_4, REPEAT_FALSE)) - { - screen->setWindowSize(4); + screen->incWindowSize(); } else if (input->checkInput(input_swap_palette, REPEAT_FALSE)) diff --git a/source/ending2.cpp b/source/ending2.cpp index 26340e3..95cdb85 100644 --- a/source/ending2.cpp +++ b/source/ending2.cpp @@ -210,29 +210,19 @@ void Ending2::checkInput() screen->switchBorder(); } - else if (input->checkInput(input_video_mode, REPEAT_FALSE)) + else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); } - else if (input->checkInput(input_window_size_1, REPEAT_FALSE)) + else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) { - screen->setWindowSize(1); + screen->decWindowSize(); } - else if (input->checkInput(input_window_size_2, REPEAT_FALSE)) + else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) { - screen->setWindowSize(2); - } - - else if (input->checkInput(input_window_size_3, REPEAT_FALSE)) - { - screen->setWindowSize(3); - } - - else if (input->checkInput(input_window_size_4, REPEAT_FALSE)) - { - screen->setWindowSize(4); + screen->incWindowSize(); } else if (input->checkInput(input_swap_palette, REPEAT_FALSE)) diff --git a/source/game.cpp b/source/game.cpp index 3015e0d..517ec77 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -208,33 +208,21 @@ void Game::checkInput() reLoadTextures(); } - else if (input->checkInput(input_video_mode, REPEAT_FALSE)) + else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); reLoadTextures(); } - else if (input->checkInput(input_window_size_1, REPEAT_FALSE)) + else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) { - screen->setWindowSize(1); + screen->decWindowSize(); reLoadTextures(); } - else if (input->checkInput(input_window_size_2, REPEAT_FALSE)) + else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) { - screen->setWindowSize(2); - reLoadTextures(); - } - - else if (input->checkInput(input_window_size_3, REPEAT_FALSE)) - { - screen->setWindowSize(3); - reLoadTextures(); - } - - else if (input->checkInput(input_window_size_4, REPEAT_FALSE)) - { - screen->setWindowSize(4); + screen->incWindowSize(); reLoadTextures(); } diff --git a/source/game_over.cpp b/source/game_over.cpp index 6e9112e..952e5cc 100644 --- a/source/game_over.cpp +++ b/source/game_over.cpp @@ -147,29 +147,19 @@ void GameOver::checkInput() screen->switchBorder(); } - else if (input->checkInput(input_video_mode, REPEAT_FALSE)) + else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); } - else if (input->checkInput(input_window_size_1, REPEAT_FALSE)) + else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) { - screen->setWindowSize(1); + screen->decWindowSize(); } - else if (input->checkInput(input_window_size_2, REPEAT_FALSE)) + else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) { - screen->setWindowSize(2); - } - - else if (input->checkInput(input_window_size_3, REPEAT_FALSE)) - { - screen->setWindowSize(3); - } - - else if (input->checkInput(input_window_size_4, REPEAT_FALSE)) - { - screen->setWindowSize(4); + screen->incWindowSize(); } else if (input->checkInput(input_swap_palette, REPEAT_FALSE)) diff --git a/source/intro.cpp b/source/intro.cpp index db466e8..a7878a7 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -104,29 +104,19 @@ void Intro::checkInput() screen->switchBorder(); } - else if (input->checkInput(input_video_mode, REPEAT_FALSE)) + else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); } - else if (input->checkInput(input_window_size_1, REPEAT_FALSE)) + else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) { - screen->setWindowSize(1); + screen->decWindowSize(); } - else if (input->checkInput(input_window_size_2, REPEAT_FALSE)) + else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) { - screen->setWindowSize(2); - } - - else if (input->checkInput(input_window_size_3, REPEAT_FALSE)) - { - screen->setWindowSize(3); - } - - else if (input->checkInput(input_window_size_4, REPEAT_FALSE)) - { - screen->setWindowSize(4); + screen->incWindowSize(); } else if (input->checkInput(input_swap_palette, REPEAT_FALSE)) diff --git a/source/logo.cpp b/source/logo.cpp index f8c1ede..e2df901 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -98,29 +98,19 @@ void Logo::checkInput() screen->switchBorder(); } - else if (input->checkInput(input_video_mode, REPEAT_FALSE)) + else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); } - else if (input->checkInput(input_window_size_1, REPEAT_FALSE)) + else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) { - screen->setWindowSize(1); + screen->decWindowSize(); } - else if (input->checkInput(input_window_size_2, REPEAT_FALSE)) + else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) { - screen->setWindowSize(2); - } - - else if (input->checkInput(input_window_size_3, REPEAT_FALSE)) - { - screen->setWindowSize(3); - } - - else if (input->checkInput(input_window_size_4, REPEAT_FALSE)) - { - screen->setWindowSize(4); + screen->incWindowSize(); } else if (input->checkInput(input_swap_palette, REPEAT_FALSE)) diff --git a/source/title.cpp b/source/title.cpp index 1615457..80a260f 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -106,33 +106,21 @@ void Title::checkInput() resource->reLoadTextures(); } - else if (input->checkInput(input_video_mode, REPEAT_FALSE)) + else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); resource->reLoadTextures(); } - else if (input->checkInput(input_window_size_1, REPEAT_FALSE)) + else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) { - screen->setWindowSize(1); + screen->decWindowSize(); resource->reLoadTextures(); } - else if (input->checkInput(input_window_size_2, REPEAT_FALSE)) + else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) { - screen->setWindowSize(2); - resource->reLoadTextures(); - } - - else if (input->checkInput(input_window_size_3, REPEAT_FALSE)) - { - screen->setWindowSize(3); - resource->reLoadTextures(); - } - - else if (input->checkInput(input_window_size_4, REPEAT_FALSE)) - { - screen->setWindowSize(4); + screen->incWindowSize(); resource->reLoadTextures(); }