From c63298b555dc8bc6af6df6ce07e7f02aa340ff96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Tue, 29 Nov 2022 18:05:38 +0100 Subject: [PATCH] =?UTF-8?q?Posibilidad=20de=20escoger=20diferentes=20confi?= =?UTF-8?q?guraci=C3=B3nes=20prefijadas=20de=20teclas=20de=20control=20des?= =?UTF-8?q?de=20el=20fichero=20de=20configuraci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/room/34.tmx | 48 ++++++++++++++++---------------- source/common/utils.h | 9 ++++++ source/director.cpp | 65 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 89 insertions(+), 33 deletions(-) diff --git a/data/room/34.tmx b/data/room/34.tmx index 4726b4c..a9045d9 100644 --- a/data/room/34.tmx +++ b/data/room/34.tmx @@ -1,24 +1,24 @@ - - - - - -114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115, -116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,140,116, -140,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140, -116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,140,116, -140,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140, -116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,140,116, -140,0,0,0,0,0,0,0,0,0,0,114,115,114,115,114,115,114,115,0,0,0,0,0,0,0,0,0,0,377,116,140, -116,0,0,0,0,0,0,0,377,0,0,114,115,114,115,114,115,114,115,0,0,0,0,377,377,0,0,0,0,0,140,116, -140,0,0,0,0,0,0,0,0,377,0,0,0,114,115,114,115,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140, -116,0,0,0,377,377,377,0,0,0,0,0,0,115,114,115,114,0,0,0,0,0,377,377,377,377,0,0,0,0,140,116, -140,0,0,0,0,0,0,0,0,0,0,377,0,114,115,114,115,0,0,377,0,0,0,0,0,0,0,0,0,0,116,140, -116,0,0,0,0,0,0,0,0,0,0,0,0,115,114,115,114,0,0,0,0,0,0,0,0,0,431,432,114,115,140,116, -140,0,0,0,0,0,0,377,377,0,0,0,0,114,115,114,115,0,0,0,0,0,0,431,432,431,432,431,432,0,116,140, -0,0,0,0,0,0,0,0,0,0,0,0,377,115,114,115,114,0,0,377,0,0,0,0,0,0,0,0,0,0,140,116, -0,0,0,0,0,0,0,0,0,0,0,0,0,114,115,114,115,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140, -114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,0,0,114,115,114,115,114,115 - - - + + + + + +114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115, +116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,140,116, +140,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140, +116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,140,116, +140,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140, +116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,140,116, +140,0,0,0,0,0,0,0,0,0,0,114,115,114,115,114,115,114,115,0,0,0,0,0,0,0,0,0,0,377,116,140, +116,0,0,0,0,0,0,0,377,0,0,114,115,114,115,114,115,114,115,0,0,0,0,377,377,0,0,0,0,0,140,116, +140,0,0,0,0,0,0,0,0,377,0,0,0,114,115,114,115,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140, +116,0,0,0,377,377,377,0,0,0,0,0,0,115,114,115,114,0,0,0,0,0,377,377,377,377,0,0,0,0,140,116, +140,0,0,0,0,0,0,0,0,0,0,377,0,114,115,114,115,0,0,377,0,0,0,0,0,0,0,0,0,0,116,140, +116,0,0,0,0,0,0,0,0,0,0,0,0,115,114,115,114,0,0,0,0,0,0,0,0,0,431,432,114,115,140,116, +140,0,0,0,0,0,0,377,377,0,0,0,0,114,115,114,115,0,0,0,0,0,0,431,432,431,432,431,432,0,116,140, +0,0,0,0,0,0,0,0,0,0,0,0,377,115,114,115,114,0,0,377,0,0,0,0,0,0,0,0,0,0,140,116, +0,0,0,0,0,0,0,0,0,0,0,0,0,114,115,114,115,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140, +114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,0,0,114,115,114,115,114,115 + + + diff --git a/source/common/utils.h b/source/common/utils.h index 3253fb4..57e236f 100644 --- a/source/common/utils.h +++ b/source/common/utils.h @@ -64,6 +64,14 @@ enum not_pos_e pos_right }; +// Tipos de control de teclado +enum ctrl_schem_e +{ + ctrl_cursor, + ctrl_opqa, + ctrl_wasd +}; + // Estructura para las opciones de las notificaciones struct op_notification_t { @@ -136,6 +144,7 @@ struct options_t online_t online; // Datos del servicio online op_notification_t notifications; // Opciones relativas a las notificaciones; op_screen_t screen; // Opciones relativas a la clase screen + ctrl_schem_e keys; // Teclas usadas para jugar }; // Calcula el cuadrado de la distancia entre dos puntos diff --git a/source/director.cpp b/source/director.cpp index 56dde81..850c0b7 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -57,9 +57,6 @@ Director::Director(int argc, char *argv[]) screen->setBorderColor(borderColor); debug = new Debug(renderer, screen, asset); music = JA_LoadMusic(asset->get("title.ogg").c_str()); - - // Inicializa los servicios online - // initOnline(); } Director::~Director() @@ -112,10 +109,13 @@ void Director::initOptions() // Crea el puntero a la estructura de opciones options = new options_t; - // Version + // Version del archivo de configuración options->configVersion = "v1.06.1"; - // Opciones dee video + // Opciones de control + options->keys = ctrl_cursor; + + // Opciones de video options->gameWidth = GAMECANVAS_WIDTH; options->gameHeight = GAMECANVAS_HEIGHT; options->videoMode = 0; @@ -312,6 +312,21 @@ bool Director::saveConfig() file << "## VERSION\n"; file << "configVersion=" + options->configVersion + "\n"; + file << "\n## CONTROL OPTIONS\n"; + file << "## keys = CURSOR | OPQA | WASD\n"; + if (options->keys == ctrl_cursor) + { + file << "keys=CURSOR\n"; + } + else if (options->keys == ctrl_opqa) + { + file << "keys=OPQA\n"; + } + else if (options->keys == ctrl_wasd) + { + file << "keys=WASD\n"; + } + file << "\n## VISUAL OPTIONS\n"; if (options->videoMode == 0) { @@ -362,7 +377,7 @@ bool Director::saveConfig() { file << "notifications.posV=pos_bottom\n"; } - + file << "## notifications.posH = pos_left | pos_middle | pos_right\n"; if (options->notifications.posH == pos_left) { @@ -1009,6 +1024,22 @@ bool Director::setOptions(options_t *options, std::string var, std::string value options->configVersion = value; } + else if (var == "keys") + { + if (value == "OPQA") + { + options->keys = ctrl_opqa; + } + else if (value == "WASD") + { + options->keys = ctrl_wasd; + } + else + { + options->keys = ctrl_cursor; + } + } + else if (var == "videoMode") { if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP") @@ -1169,10 +1200,26 @@ void Director::initInput() input->discoverGameController(); // Asigna inputs a teclas - input->bindKey(INPUT_UP, SDL_SCANCODE_UP); + if (options->keys == ctrl_cursor) + { + input->bindKey(INPUT_UP, SDL_SCANCODE_UP); + input->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT); + input->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT); + } + else if (options->keys == ctrl_opqa) + { + input->bindKey(INPUT_UP, SDL_SCANCODE_Q); + input->bindKey(INPUT_LEFT, SDL_SCANCODE_O); + input->bindKey(INPUT_RIGHT, SDL_SCANCODE_P); + } + else if (options->keys == ctrl_wasd) + { + input->bindKey(INPUT_UP, SDL_SCANCODE_W); + input->bindKey(INPUT_LEFT, SDL_SCANCODE_A); + input->bindKey(INPUT_RIGHT, SDL_SCANCODE_D); + } + input->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN); - input->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT); - input->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT); input->bindKey(INPUT_ACCEPT, SDL_SCANCODE_RETURN); input->bindKey(INPUT_CANCEL, SDL_SCANCODE_ESCAPE); input->bindKey(INPUT_BUTTON_1, SDL_SCANCODE_SPACE);