1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-05 18:59:41 +01:00

Finish language menu

This commit is contained in:
NyakoFox 2024-04-11 10:08:28 -03:00
parent 928b4240bb
commit 8f1bc82343
2 changed files with 37 additions and 17 deletions

View file

@ -7023,16 +7023,29 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
}
else
{
int button_x = 80;
int button_y = 32;
bool spawn_more_buttons = true;
int button_count = -1;
for (size_t i = 0; i < loc::languagelist.size(); i++)
{
int button_x = 0;
int button_y = 0;
bool spawn_buttons = false;
if (i >= (languagepage * 16))
{
spawn_buttons = true;
button_count++;
button_x = (button_count >= 8) ? 240 : 80;
button_y = 32 + 20 * (button_count % 8);
if (button_count >= 16)
{
spawn_buttons = false;
}
}
if (loc::languagelist[i].nativename.empty())
{
option(loc::languagelist[i].code.c_str());
if (spawn_more_buttons)
if (spawn_buttons)
{
int button_width = SDL_max(120, font::len(PR_1X, loc::languagelist[i].code.c_str()) + 16);
touch::create_menu_button(button_x - button_width / 2, button_y, button_width, 16, loc::languagelist[i].code.c_str(), i);
@ -7047,22 +7060,12 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
flags
);
if (spawn_more_buttons)
if (spawn_buttons)
{
int button_width = SDL_max(120, font::len(flags, loc::languagelist[i].nativename.c_str()) + 16);
touch::create_menu_button_flags(button_x - button_width / 2, button_y, button_width, 16, loc::languagelist[i].nativename.c_str(), i, flags);
}
}
button_y += 20;
if (button_y > 200 - 16)
{
button_y = 32;
button_x += 160;
if (button_x > 320 - 80)
{
spawn_more_buttons = false;
}
}
}
menuyoff = 70-(menuoptions.size()*10);

View file

@ -1230,17 +1230,26 @@ void menuactionpress(void)
// return
game.returnmenu();
map.nexttowercolour();
game.currentmenuoption = loc::languagelist_curlang;
}
else if (game.currentmenuoption == -2)
{
// go left a page (or wrap to end)
game.languagepage--;
game.languagepage = POS_MOD(game.languagepage - 1, (int) SDL_ceilf(loc::languagelist.size() / 16.0));
loc::loadlanguagelist();
loc::pre_title_lang_menu = false;
game.createmenu(Menu::language, true);
game.currentmenuoption = loc::languagelist_curlang;
map.nexttowercolour();
}
else if (game.currentmenuoption == -1)
{
// go right a page (or wrap to start)
game.languagepage++;
game.languagepage = POS_MOD(game.languagepage + 1, (int) SDL_ceilf(loc::languagelist.size() / 16.0));
loc::loadlanguagelist();
loc::pre_title_lang_menu = false;
game.createmenu(Menu::language, true);
game.currentmenuoption = loc::languagelist_curlang;
map.nexttowercolour();
}
else
@ -1274,6 +1283,14 @@ void menuactionpress(void)
game.returnmenu();
map.nexttowercolour();
}
else
{
// We need to respawn the buttons
loc::loadlanguagelist();
loc::pre_title_lang_menu = false;
game.createmenu(Menu::language, true);
game.currentmenuoption = loc::languagelist_curlang;
}
}
game.savestatsandsettings_menu();