AGS: Fixed GUI textual controls not redrawn when translation changes

From upstream 618d2e38a118f47389aaf7e57972b2520b81fc1b
This commit is contained in:
Thierry Crozat 2022-06-21 22:29:21 +01:00
parent 4e9e0fcf15
commit 0c936b888d
3 changed files with 19 additions and 0 deletions

View File

@ -665,6 +665,7 @@ int Game_ChangeTranslation(const char *newFilename) {
if ((newFilename == nullptr) || (newFilename[0] == 0)) { // switch back to default translation
close_translation();
_GP(usetup).translation = "";
GUI::MarkForTranslationUpdate();
return 1;
}
@ -673,6 +674,7 @@ int Game_ChangeTranslation(const char *newFilename) {
return 0; // failed, kept previous translation
_GP(usetup).translation = newFilename;
GUI::MarkForTranslationUpdate();
return 1;
}

View File

@ -689,6 +689,21 @@ void MarkAllGUIForUpdate() {
}
}
void MarkForTranslationUpdate() {
for (auto &btn : _GP(guibuts)) {
if (btn.IsTranslated())
btn.MarkChanged();
}
for (auto &lbl : _GP(guilabels)) {
if (lbl.IsTranslated())
lbl.MarkChanged();
}
for (auto &list : _GP(guilist)) {
if (list.IsTranslated())
list.MarkChanged();
}
}
void MarkForFontUpdate(int font) {
for (auto &btn : _GP(guibuts)) {
if (btn.Font == font)

View File

@ -229,6 +229,8 @@ void DrawTextAlignedHor(Bitmap *ds, const char *text, int font, color_t text_col
// Mark all existing GUI for redraw
void MarkAllGUIForUpdate();
// Mark all translatable GUI controls for redraw
void MarkForTranslationUpdate();
// Mark all GUI which use the given font for redraw
void MarkForFontUpdate(int font);
// Mark labels that acts as special text placeholders for redraw