1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-29 01:35:06 +01:00

Close #11561: Use ScreenCoordsXY in gfx_draw_string()

* Fix #11572 create gfx_draw_string() overload

created the overload and changed all calls of the old function to the new (using const ScreenCoordsXY&)

...
This commit is contained in:
TomasZilinek
2020-05-10 14:49:15 +02:00
committed by GitHub
parent 783494df68
commit 9fde6a74c3
23 changed files with 219 additions and 191 deletions

View File

@@ -251,7 +251,7 @@ void gfx_draw_string_left_centred(
char* buffer = gCommonStringFormatBuffer;
format_string(buffer, 256, format, args);
int32_t height = string_get_height_raw(buffer);
gfx_draw_string(dpi, buffer, colour, x, y - (height / 2));
gfx_draw_string(dpi, buffer, colour, { x, y - (height / 2) });
}
/**
@@ -311,14 +311,16 @@ static void colour_char_window(uint8_t colour, const uint16_t* current_font_flag
*/
void draw_string_centred_raw(rct_drawpixelinfo* dpi, int32_t x, int32_t y, int32_t numLines, char* text)
{
ScreenCoordsXY screenCoords(dpi->x, dpi->y);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gfx_draw_string(dpi, (char*)"", COLOUR_BLACK, dpi->x, dpi->y);
gfx_draw_string(dpi, (char*)"", COLOUR_BLACK, screenCoords);
screenCoords.y = y;
gCurrentFontFlags = 0;
for (int32_t i = 0; i <= numLines; i++)
{
int32_t width = gfx_get_string_width(text);
gfx_draw_string(dpi, text, TEXT_COLOUR_254, x - (width / 2), y);
gfx_draw_string(dpi, text, TEXT_COLOUR_254, screenCoords - ScreenCoordsXY{ width / 2, 0 });
const utf8* ch = text;
const utf8* nextCh = nullptr;
@@ -329,7 +331,7 @@ void draw_string_centred_raw(rct_drawpixelinfo* dpi, int32_t x, int32_t y, int32
}
text = const_cast<char*>(ch + 1);
y += font_get_line_height(gCurrentFontSpriteBase);
screenCoords.y += font_get_line_height(gCurrentFontSpriteBase);
}
}
@@ -424,9 +426,10 @@ void gfx_draw_string_centred_wrapped_partial(
{
int32_t numLines, fontSpriteBase, lineHeight, lineY;
utf8* buffer = gCommonStringFormatBuffer;
ScreenCoordsXY screenCoords(dpi->x, dpi->y);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gfx_draw_string(dpi, (char*)"", colour, dpi->x, dpi->y);
gfx_draw_string(dpi, (char*)"", colour, screenCoords);
format_string(buffer, 256, format, args);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
@@ -459,7 +462,8 @@ void gfx_draw_string_centred_wrapped_partial(
ch = nextCh;
}
gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, x - halfWidth, lineY);
screenCoords = { x - halfWidth, lineY };
gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, screenCoords);
if (numCharactersDrawn > numCharactersToDraw)
{