Skip to content

Commit

Permalink
Dynamically translate static texts
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Jan 5, 2020
1 parent 758fc04 commit 1acd179
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Source/gmenu.cpp
Expand Up @@ -192,7 +192,7 @@ void gmenu_draw_menu_item(TMenuItem *pItem, int y)
}
x = SCREEN_WIDTH / 2 - w / 2 + SCREEN_X;
light_table_index = (pItem->dwFlags & GMENU_ENABLED) ? 0 : 15;
gmenu_print_text(x, y, pItem->pszStr);
gmenu_print_text(x, y, _(pItem->pszStr));
if (pItem == sgpCurrItem) {
CelDraw(x - 54, y + 1, PentSpin_cel, PentSpin_frame, 48);
CelDraw(x + 4 + w, y + 1, PentSpin_cel, PentSpin_frame, 48);
Expand All @@ -218,7 +218,7 @@ int gmenu_get_lfont(TMenuItem *pItem)

if (pItem->dwFlags & GMENU_SLIDER)
return 490;
text = pItem->pszStr;
text = _(pItem->pszStr);
i = 0;
while (*text) {
c = gbFontTransTbl[(BYTE)*text++];
Expand Down
2 changes: 1 addition & 1 deletion SourceX/DiabloUI/button.cpp
Expand Up @@ -25,7 +25,7 @@ void RenderButton(UiButton *button)
SDL_Rect text_rect = button->rect;
if (!button->pressed)
--text_rect.y;
DrawTTF(button->text, text_rect, UIS_CENTER,
DrawTTF(_(button->text), text_rect, UIS_CENTER,
SDL_Color { 243, 243, 243, 0 }, SDL_Color { 0, 0, 0, 0 }, &button->render_cache);
}

Expand Down
3 changes: 3 additions & 0 deletions SourceX/DiabloUI/credits.cpp
Expand Up @@ -61,6 +61,9 @@ CachedLine PrepareLine(std::size_t index)
if (contents[0] == '\t')
++contents;

if (contents[0] != '\0')
contents = _(contents);

const SDL_Color shadow_color = { 0, 0, 0, 0 };
auto text = RenderText(contents, shadow_color);

Expand Down
8 changes: 4 additions & 4 deletions SourceX/DiabloUI/diabloui.cpp
Expand Up @@ -613,7 +613,7 @@ namespace {

void Render(UiText *ui_text)
{
DrawTTF(ui_text->text,
DrawTTF(_(ui_text->text),
ui_text->rect,
ui_text->flags,
ui_text->color,
Expand All @@ -623,7 +623,7 @@ void Render(UiText *ui_text)

void Render(const UiArtText &ui_art_text)
{
DrawArtStr(ui_art_text.text, ui_art_text.rect, ui_art_text.flags);
DrawArtStr(_(ui_art_text.text), ui_art_text.rect, ui_art_text.flags);
}

void Render(const UiImage &ui_image)
Expand All @@ -642,7 +642,7 @@ void Render(const UiImage &ui_image)

void Render(const UiArtTextButton &ui_button)
{
DrawArtStr(ui_button.text, ui_button.rect, ui_button.flags);
DrawArtStr(_(ui_button.text), ui_button.rect, ui_button.flags);
}

void Render(const UiList &ui_list)
Expand All @@ -652,7 +652,7 @@ void Render(const UiList &ui_list)
const auto &item = ui_list.items[i];
if (item.value == SelectedItem)
DrawSelector(rect);
DrawArtStr(item.text, rect, ui_list.flags);
DrawArtStr(_(item.text), rect, ui_list.flags);
}
}

Expand Down

0 comments on commit 1acd179

Please sign in to comment.