mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
fix #2786: use gfx_draw_string_centred_wrapped which centres line by line
This commit is contained in:
@@ -335,24 +335,7 @@ void gfx_draw_string_right(rct_drawpixelinfo* dpi, int format, void* args, int c
|
||||
*/
|
||||
void gfx_draw_string_centred(rct_drawpixelinfo *dpi, int format, int x, int y, int colour, void *args)
|
||||
{
|
||||
char* buffer;
|
||||
int text_width;
|
||||
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
format_string(buffer, format, args);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 0xE0;
|
||||
|
||||
// Measure text width
|
||||
text_width = gfx_get_string_width(buffer);
|
||||
|
||||
// Draw the text centred
|
||||
if (text_width <= 0xFFFF && text_width >= 0) {
|
||||
x -= text_width / 2;
|
||||
gfx_draw_string(dpi, buffer, colour, x, y);
|
||||
} else {
|
||||
log_warning("improper text width %d for string %s", text_width, buffer);
|
||||
}
|
||||
gfx_draw_string_centred_wrapped(dpi, args, x, y, INT32_MAX, format, colour);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user