From df4e351b30ad449c23c7b48ab0d9c3ffcaccc57b Mon Sep 17 00:00:00 2001 From: Dav999-v Date: Sun, 15 Jan 2023 04:06:31 +0100 Subject: [PATCH] Use languages' fonts for options on language screen --- desktop_version/src/Font.h | 1 + desktop_version/src/Game.cpp | 2 +- desktop_version/src/Game.h | 4 +++- desktop_version/src/Graphics.cpp | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/desktop_version/src/Font.h b/desktop_version/src/Font.h index 6b1fb59a..3f00a040 100644 --- a/desktop_version/src/Font.h +++ b/desktop_version/src/Font.h @@ -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) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 44144f02..fc4eb30a 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -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); diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 7a789441..72f2f60c 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -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 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); } diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index ba63a23f..592939cb 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -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); } }