Skip to content

Commit

Permalink
Fix: title positioning on HiDPI displays
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouke authored and michicc committed Sep 6, 2022
1 parent 2d2a5dd commit 18c210b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,17 @@ struct MainWindow : Window
this->DrawWidgets();
if (_game_mode == GM_MENU) {
static const SpriteID title_sprites[] = {SPR_OTTD_O, SPR_OTTD_P, SPR_OTTD_E, SPR_OTTD_N, SPR_OTTD_T, SPR_OTTD_T, SPR_OTTD_D};
static const uint LETTER_SPACING = 10;
int name_width = (lengthof(title_sprites) - 1) * LETTER_SPACING;
uint letter_spacing = ScaleGUITrad(10);
int name_width = (lengthof(title_sprites) - 1) * letter_spacing;

for (uint i = 0; i < lengthof(title_sprites); i++) {
name_width += GetSpriteSize(title_sprites[i]).width;
}
int off_x = (this->width - name_width) / 2;

for (uint i = 0; i < lengthof(title_sprites); i++) {
DrawSprite(title_sprites[i], PAL_NONE, off_x, 50);
off_x += GetSpriteSize(title_sprites[i]).width + LETTER_SPACING;
DrawSprite(title_sprites[i], PAL_NONE, off_x, ScaleGUITrad(50));
off_x += GetSpriteSize(title_sprites[i]).width + letter_spacing;
}
}
}
Expand Down

0 comments on commit 18c210b

Please sign in to comment.