1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

Fix #11570 - create gfx_draw_string_centered() overload (#11760)

* Fix #11570 - create gfx_draw_string_centered() overload

I created the overload, updated all calls from the old function to the new and deleted the old one
This commit is contained in:
TomasZilinek
2020-05-17 20:29:56 +02:00
committed by GitHub
parent e87343f9c6
commit 277080de74
20 changed files with 171 additions and 161 deletions

View File

@@ -15,13 +15,12 @@
static void graph_draw_months_uint8_t(
rct_drawpixelinfo* dpi, const uint8_t* history, int32_t count, int32_t baseX, int32_t baseY)
{
int32_t i, x, y, yearOver32, currentMonth, currentDay;
int32_t i, yearOver32, currentMonth, currentDay;
currentMonth = date_get_month(gDateMonthsElapsed);
currentDay = gDateMonthTicks;
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
x = baseX;
y = baseY;
auto screenCoords = ScreenCoordsXY{ baseX, baseY };
for (i = count - 1; i >= 0; i--)
{
if (history[i] != 255 && yearOver32 % 4 == 0)
@@ -29,14 +28,15 @@ static void graph_draw_months_uint8_t(
// Draw month text
auto ft = Formatter::Common();
ft.Add<uint32_t>(DateGameShortMonthNames[date_get_month((yearOver32 / 4) + MONTH_COUNT)]);
gfx_draw_string_centred(dpi, STR_GRAPH_LABEL, x, y - 10, COLOUR_BLACK, gCommonFormatArgs);
gfx_draw_string_centred(
dpi, STR_GRAPH_LABEL, screenCoords - ScreenCoordsXY{ 0, 10 }, COLOUR_BLACK, gCommonFormatArgs);
// Draw month mark
gfx_fill_rect(dpi, x, y, x, y + 3, PALETTE_INDEX_10);
gfx_fill_rect(dpi, screenCoords.x, screenCoords.y, screenCoords.x, screenCoords.y + 3, PALETTE_INDEX_10);
}
yearOver32 = (yearOver32 + 1) % 32;
x += 6;
screenCoords.x += 6;
}
}
@@ -104,27 +104,26 @@ void graph_draw_uint8_t(rct_drawpixelinfo* dpi, uint8_t* history, int32_t count,
static void graph_draw_months_money32(
rct_drawpixelinfo* dpi, const money32* history, int32_t count, int32_t baseX, int32_t baseY)
{
int32_t i, x, y, yearOver32, currentMonth, currentDay;
int32_t i, yearOver32, currentMonth, currentDay;
currentMonth = date_get_month(gDateMonthsElapsed);
currentDay = gDateMonthTicks;
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
x = baseX;
y = baseY;
auto screenCoords = ScreenCoordsXY{ baseX, baseY };
for (i = count - 1; i >= 0; i--)
{
if (history[i] != MONEY32_UNDEFINED && yearOver32 % 4 == 0)
{
// Draw month text
int32_t monthFormat = DateGameShortMonthNames[date_get_month((yearOver32 / 4) + MONTH_COUNT)];
gfx_draw_string_centred(dpi, STR_GRAPH_LABEL, x, y - 10, COLOUR_BLACK, &monthFormat);
gfx_draw_string_centred(dpi, STR_GRAPH_LABEL, screenCoords - ScreenCoordsXY{ 0, 10 }, COLOUR_BLACK, &monthFormat);
// Draw month mark
gfx_fill_rect(dpi, x, y, x, y + 3, PALETTE_INDEX_10);
gfx_fill_rect(dpi, screenCoords.x, screenCoords.y, screenCoords.x, screenCoords.y + 3, PALETTE_INDEX_10);
}
yearOver32 = (yearOver32 + 1) % 32;
x += 6;
screenCoords.x += 6;
}
}
@@ -294,7 +293,7 @@ static void graph_draw_hovered_value(
}
gfx_draw_string_centred(
dpi, STR_FINANCES_SUMMARY_EXPENDITURE_VALUE, info.coords.x, info.coords.y - 16, COLOUR_BLACK, &info.money);
dpi, STR_FINANCES_SUMMARY_EXPENDITURE_VALUE, info.coords - ScreenCoordsXY{ 0, 16 }, COLOUR_BLACK, &info.money);
gfx_fill_rect(dpi, info.coords.x - 2, info.coords.y - 2, info.coords.x + 2, info.coords.y + 2, PALETTE_INDEX_10);
gfx_fill_rect(dpi, info.coords.x - 1, info.coords.y - 1, info.coords.x + 1, info.coords.y + 1, PALETTE_INDEX_21);