Touch input menu

This commit is contained in:
NyakoFox 2024-04-09 18:04:31 -03:00
parent 59c74955ee
commit f061bfa66b
3 changed files with 48 additions and 19 deletions

View File

@ -6980,6 +6980,15 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
option(loc::gettext("return")); option(loc::gettext("return"));
menuyoff = 0; menuyoff = 0;
maxspacing = 15; 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; break;
case Menu::language: case Menu::language:
if (loc::languagelist.empty()) if (loc::languagelist.empty())

View File

@ -1184,7 +1184,7 @@ void menuactionpress(void)
} }
if (game.currentmenuoption == -1) if (game.currentmenuoption == -1)
{ {
// audio menu // touch input menu
music.playef(Sound_VIRIDIAN); music.playef(Sound_VIRIDIAN);
game.createmenu(Menu::touch_input, true); game.createmenu(Menu::touch_input, true);
map.nexttowercolour(); map.nexttowercolour();
@ -2039,6 +2039,18 @@ void menuactionpress(void)
case Menu::touch_input: case Menu::touch_input:
switch (game.currentmenuoption) 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: case 0:
music.playef(Sound_CRY); music.playef(Sound_CRY);
break; break;

View File

@ -801,27 +801,35 @@ static void menurender(void)
} }
case Menu::touch_input: 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("Touch Input"), tr, tg, tb);
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 touch input options."), tr, tg, tb);
font::print_wrap(PR_CEN, -1, 65, loc::gettext("Change the control style for touch input."), tr, tg, tb); }
break; else
case 1: {
// Display touch buttons! switch (game.currentmenuoption)
key.using_touch = true; {
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(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_wrap(PR_CEN, -1, 65, loc::gettext("Change the scale of the UI buttons."), tr, tg, tb);
char buffer[SCREEN_WIDTH_CHARS + 1]; char buffer[SCREEN_WIDTH_CHARS + 1];
float scale = (float)touch::scale / 10.0; float scale = (float) touch::scale / 10.0;
vformat_buf(buffer, sizeof(buffer), loc::gettext("Current scale: {scale}.{extra}x"), "scale:int, extra:int", vformat_buf(buffer, sizeof(buffer), loc::gettext("Current scale: {scale}.{extra}x"), "scale:int, extra:int",
(int) scale, (int)scale,
(int) ((float) ((float) scale - (int) scale) * 10) (int)((float)((float)scale - (int)scale) * 10)
); );
font::print(PR_CEN, -1, 75, buffer, tr, tg, tb); font::print(PR_CEN, -1, 75, buffer, tr, tg, tb);
break; break;
}
} }
} }
break; break;