TerryCavanagh / VVVVVV

The source code to VVVVVV! http://thelettervsixtim.es/
Other
6.94k stars 556 forks source link

Fix centering of game complete texts if level font != interface font #1073

Closed Daaaav closed 9 months ago

Daaaav commented 9 months ago

Changes:

Textboxes created with graphics.createtextboxflipme() use PR_FONT_LEVEL by default, but can be overridden with graphics.textboxprintflags() to, for example, set PR_FONT_INTERFACE. This happens for the textboxes on the Game Complete screen, which use interface text. The textboxes are centered by setting the X position to -1 though, which means they're solely centered based on the width of the first line, in the level font (because the font hasn't been changed to the interface font yet).

Normally, this isn't a problem, because in the main game (where the Game Complete screen usually appears), the level font is always equal to the interface font. However, in custom levels you can still get it (by calling gamestate 3500) and in that case some of the text may be misaligned. This change fixes that by adding graphics.textboxcenterx() to these textboxes.

As far as I can tell, these are the only textboxes that are centered by just x=-1 despite changing the font afterwards.

Before (showing a level using a Chinese level font in an English VVVVVV): misaligned

After: aligned properly

Legal Stuff:

By submitting this pull request, I confirm that...