From f061bfa66bfa155cff462ab64561810302d27b5e Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Tue, 9 Apr 2024 18:04:31 -0300 Subject: [PATCH] Touch input menu --- desktop_version/src/Game.cpp | 9 +++++++ desktop_version/src/Input.cpp | 14 ++++++++++- desktop_version/src/Render.cpp | 44 ++++++++++++++++++++-------------- 3 files changed, 48 insertions(+), 19 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 35fa64e3..5f91fe4d 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6980,6 +6980,15 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) option(loc::gettext("return")); menuyoff = 0; maxspacing = 15; + + auto_buttons = false; + + touch::create_slider_button((320 - 160) / 2, 120 + 32, 160, 48, loc::gettext("ui scale"), &touch::scale, 5, 20); + + touch::create_menu_button(46 - 16, 200, 76, 26, loc::gettext("previous"), -2); + touch::create_menu_button(122, 200, 76, 26, loc::gettext("return"), 2); + touch::create_menu_button(198 + 16, 200, 76, 26, loc::gettext("next"), -1); + break; case Menu::language: if (loc::languagelist.empty()) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 4730b902..fa51fd96 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1184,7 +1184,7 @@ void menuactionpress(void) } if (game.currentmenuoption == -1) { - // audio menu + // touch input menu music.playef(Sound_VIRIDIAN); game.createmenu(Menu::touch_input, true); map.nexttowercolour(); @@ -2039,6 +2039,18 @@ void menuactionpress(void) case Menu::touch_input: switch (game.currentmenuoption) { + case -2: + // audio menu + music.playef(Sound_VIRIDIAN); + game.createmenu(Menu::audiooptions, true); + map.nexttowercolour(); + break; + case -1: + // accessibility menu + music.playef(Sound_VIRIDIAN); + game.createmenu(Menu::accessibility, true); + map.nexttowercolour(); + break; case 0: music.playef(Sound_CRY); break; diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index d0bd2370..044f450b 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -801,27 +801,35 @@ static void menurender(void) } case Menu::touch_input: { - switch (game.currentmenuoption) + if (key.using_touch) { - case 0: // Control style - font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Control Style"), tr, tg, tb); - font::print_wrap(PR_CEN, -1, 65, loc::gettext("Change the control style for touch input."), tr, tg, tb); - break; - case 1: - // Display touch buttons! - key.using_touch = true; + font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Touch Input"), tr, tg, tb); + font::print_wrap(PR_CEN, -1, 65, loc::gettext("Change touch input options."), tr, tg, tb); + } + else + { + switch (game.currentmenuoption) + { + case 0: // Control style + font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Control Style"), tr, tg, tb); + font::print_wrap(PR_CEN, -1, 65, loc::gettext("Change the control style for touch input."), tr, tg, tb); + break; + case 1: + // Display touch buttons! + key.using_touch = true; - font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("UI Scale"), tr, tg, tb); - font::print_wrap(PR_CEN, -1, 65, loc::gettext("Change the scale of the UI buttons."), tr, tg, tb); + font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("UI Scale"), tr, tg, tb); + font::print_wrap(PR_CEN, -1, 65, loc::gettext("Change the scale of the UI buttons."), tr, tg, tb); - char buffer[SCREEN_WIDTH_CHARS + 1]; - float scale = (float)touch::scale / 10.0; - vformat_buf(buffer, sizeof(buffer), loc::gettext("Current scale: {scale}.{extra}x"), "scale:int, extra:int", - (int) scale, - (int) ((float) ((float) scale - (int) scale) * 10) - ); - font::print(PR_CEN, -1, 75, buffer, tr, tg, tb); - break; + char buffer[SCREEN_WIDTH_CHARS + 1]; + float scale = (float) touch::scale / 10.0; + vformat_buf(buffer, sizeof(buffer), loc::gettext("Current scale: {scale}.{extra}x"), "scale:int, extra:int", + (int)scale, + (int)((float)((float)scale - (int)scale) * 10) + ); + font::print(PR_CEN, -1, 75, buffer, tr, tg, tb); + break; + } } } break;