1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-02 19:13:31 +02:00

Use languages' fonts for options on language screen

This commit is contained in:
Dav999-v 2023-01-15 04:06:31 +01:00 committed by Misa Elizabeth Kai
parent 5dad6b38be
commit df4e351b30
4 changed files with 8 additions and 5 deletions

View File

@ -92,6 +92,7 @@ struct PrintFlags
#define PR_FONT_INTERFACE (0 << 3) /* default, use interface font */
#define PR_FONT_LEVEL (1 << 3) /* use level-specific font (room names, cutscene dialogue, etc) */
#define PR_FONT_8X8 (2 << 3) /* use 8x8 font no matter what */
#define PR_FONT_IDX(idx) ((SDL_clamp(idx, 0, 28) + 3) << 3) /* use given font index */
#define PR_AB_IS_BRI (1 << 16)
#define PR_ALPHA(value) /* use this alpha value 0-255 (incompatible with PR_COLORGLYPH_BRI) */\
((~SDL_clamp((int)(value), 0, 255) & 0xff) << 8)

View File

@ -6477,7 +6477,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
if (loc::languagelist[i].nativename.empty())
option(loc::languagelist[i].code.c_str());
else
option(loc::languagelist[i].nativename.c_str());
option(loc::languagelist[i].nativename.c_str(), true, PR_FONT_IDX(loc::languagelist[i].font_idx));
}
menuyoff = 70-(menuoptions.size()*10);

View File

@ -28,6 +28,7 @@ struct MenuOption
{
char text[MENU_TEXT_BYTES];
bool active;
uint32_t print_flags;
};
//Menu IDs
@ -309,11 +310,12 @@ public:
int menuspacing;
std::vector<MenuStackFrame> menustack;
void inline option(const char* text, bool active = true)
void inline option(const char* text, bool active = true, uint32_t print_flags = 0)
{
MenuOption menuoption;
SDL_strlcpy(menuoption.text, text, sizeof(menuoption.text));
menuoption.active = active;
menuoption.print_flags = print_flags;
menuoptions.push_back(menuoption);
}

View File

@ -1552,7 +1552,7 @@ void Graphics::drawmenu(int cr, int cg, int cb, enum Menu::MenuName menu)
int x, y;
if (language_screen)
{
int name_len = len(opt.text);
int name_len = font::len(opt.print_flags, opt.text);
x = (i < twocol_voptions ? 80 : 240) - name_len/2;
y = 36 + (i % twocol_voptions)*12;
}
@ -1612,14 +1612,14 @@ void Graphics::drawmenu(int cr, int cg, int cb, enum Menu::MenuName menu)
vformat_buf(buffer, sizeof(buffer), loc::get_langmeta()->menu_select.c_str(), "label:str", opt_text.c_str());
// Account for brackets
x -= (len(buffer)-len(opt_text))/2;
x -= (font::len(opt.print_flags, buffer)-font::len(opt.print_flags, opt_text))/2;
}
else
{
SDL_strlcpy(buffer, loc::remove_toupper_escape_chars(opt.text).c_str(), sizeof(buffer));
}
Print(x, y, buffer, fr, fg, fb);
font::print(opt.print_flags, x, y, buffer, fr, fg, fb);
}
}