Unify calls to DrawTextBasic

This commit is contained in:
Gymnasiast 2021-02-27 14:32:13 +01:00
parent 13e7ec6e8e
commit 4d9c278ebc
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
14 changed files with 43 additions and 58 deletions

View File

@ -681,13 +681,13 @@ void CustomListView::PaintHeading(
{
auto ft = Formatter();
ft.Add<rct_string_id>(STR_UP);
DrawTextBasic(dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, COLOUR_BLACK, TextAlignment::RIGHT);
DrawTextBasic(dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT });
}
else if (sortOrder == ColumnSortOrder::Descending)
{
auto ft = Formatter();
ft.Add<rct_string_id>(STR_DOWN);
DrawTextBasic(dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, COLOUR_BLACK, TextAlignment::RIGHT);
DrawTextBasic(dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT });
}
}

View File

@ -629,15 +629,15 @@ public:
ft = Formatter();
ft.Add<int32_t>(_yearSpinnerValue);
DrawTextBasic(
&dpi, windowPos + ScreenCoordsXY{ X_RCOL, 198 }, STR_FORMAT_INTEGER, ft, colours[1], TextAlignment::RIGHT);
&dpi, windowPos + ScreenCoordsXY{ X_RCOL, 198 }, STR_FORMAT_INTEGER, ft, { colours[1], TextAlignment::RIGHT });
ft = Formatter();
ft.Add<int32_t>(actual_month);
DrawTextBasic(
&dpi, windowPos + ScreenCoordsXY{ X_RCOL, 219 }, STR_FORMAT_MONTH, ft, colours[1], TextAlignment::RIGHT);
&dpi, windowPos + ScreenCoordsXY{ X_RCOL, 219 }, STR_FORMAT_MONTH, ft, { colours[1], TextAlignment::RIGHT });
ft = Formatter();
ft.Add<int32_t>(_daySpinnerValue);
DrawTextBasic(
&dpi, windowPos + ScreenCoordsXY{ X_RCOL, 240 }, STR_FORMAT_INTEGER, ft, colours[1], TextAlignment::RIGHT);
&dpi, windowPos + ScreenCoordsXY{ X_RCOL, 240 }, STR_FORMAT_INTEGER, ft, { colours[1], TextAlignment::RIGHT });
}
else if (page == WINDOW_CHEATS_PAGE_MISC)
{
@ -653,7 +653,8 @@ public:
auto& widget = widgets[WIDX_PARK_RATING_SPINNER];
DrawTextBasic(
&dpi, windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 2 }, STR_FORMAT_INTEGER, ft, colours[1]);
&dpi, windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 2 }, STR_FORMAT_INTEGER, ft,
{ colours[1] });
}
{

View File

@ -757,7 +757,7 @@ static void window_editor_inventions_list_drag_paint(rct_window* w, rct_drawpixe
auto screenCoords = w->windowPos + ScreenCoordsXY{ 0, 2 };
auto [drawString, ft] = window_editor_inventions_list_prepare_name(&_editorInventionsListDraggedItem, true);
DrawTextBasic(dpi, screenCoords, drawString, ft, COLOUR_BLACK | COLOUR_FLAG_OUTLINE);
DrawTextBasic(dpi, screenCoords, drawString, ft, { COLOUR_BLACK | COLOUR_FLAG_OUTLINE });
}
static std::pair<rct_string_id, Formatter> window_editor_inventions_list_prepare_name(

View File

@ -1080,14 +1080,14 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
if (get_selected_object_type(w) == ObjectType::Ride)
{
auto stringId = get_ride_type_string_id(listItem->repositoryItem);
DrawTextBasic(dpi, screenPos, stringId, {}, COLOUR_WHITE, TextAlignment::RIGHT);
DrawTextBasic(dpi, screenPos, stringId, {}, { COLOUR_WHITE, TextAlignment::RIGHT });
}
screenPos.y += LIST_ROW_HEIGHT;
// Draw object source
auto stringId = object_manager_get_source_game_string(listItem->repositoryItem->GetFirstSourceGame());
DrawTextBasic(dpi, screenPos, stringId, {}, COLOUR_WHITE, TextAlignment::RIGHT);
DrawTextBasic(dpi, screenPos, stringId, {}, { COLOUR_WHITE, TextAlignment::RIGHT });
screenPos.y += LIST_ROW_HEIGHT;
// Draw object dat name
@ -1097,8 +1097,8 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(path);
DrawTextBasic(
dpi, { w->windowPos.x + w->width - 5, screenPos.y }, STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK,
TextAlignment::RIGHT);
dpi, { w->windowPos.x + w->width - 5, screenPos.y }, STR_WINDOW_COLOUR_2_STRINGID, ft,
{ COLOUR_BLACK, TextAlignment::RIGHT });
screenPos.y += LIST_ROW_HEIGHT;
}

View File

@ -530,7 +530,9 @@ static void window_finances_summary_paint(rct_window* w, rct_drawpixelinfo* dpi)
auto screenCoords = w->windowPos + ScreenCoordsXY{ 8, 51 };
// Expenditure / Income heading
DrawTextBasic(dpi, screenCoords, STR_FINANCES_SUMMARY_EXPENDITURE_INCOME, nullptr, COLOUR_BLACK, TextAlignment::LEFT, true);
DrawTextBasic(
dpi, screenCoords, STR_FINANCES_SUMMARY_EXPENDITURE_INCOME, {},
{ COLOUR_BLACK, TextUnderline::On, TextAlignment::LEFT });
screenCoords.y += 14;
// Expenditure / Income row labels
@ -618,8 +620,8 @@ static void window_finances_summary_scrollpaint(rct_window* w, rct_drawpixelinfo
ft.Add<uint16_t>(monthyear);
DrawTextBasic(
dpi, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, 0 },
monthyear == currentMonthYear ? STR_WINDOW_COLOUR_2_STRINGID : STR_BLACK_STRING, ft, COLOUR_BLACK,
TextAlignment::RIGHT, true);
monthyear == currentMonthYear ? STR_WINDOW_COLOUR_2_STRINGID : STR_BLACK_STRING, ft,
{ TextUnderline::On, TextAlignment::RIGHT });
screenCoords.y += 14;
// Month expenditures
@ -635,8 +637,7 @@ static void window_finances_summary_scrollpaint(rct_window* w, rct_drawpixelinfo
ft = Formatter();
ft.Add<money32>(expenditure);
DrawTextBasic(
dpi, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, 0 }, format, ft, COLOUR_BLACK,
TextAlignment::RIGHT);
dpi, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, 0 }, format, ft, { TextAlignment::RIGHT });
}
screenCoords.y += TABLE_CELL_HEIGHT;
}
@ -646,8 +647,7 @@ static void window_finances_summary_scrollpaint(rct_window* w, rct_drawpixelinfo
const rct_string_id format = profit >= 0 ? STR_FINANCES_SUMMARY_INCOME_VALUE : STR_FINANCES_SUMMARY_LOSS_VALUE;
ft = Formatter();
ft.Add<money32>(profit);
DrawTextBasic(
dpi, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, 0 }, format, ft, COLOUR_BLACK, TextAlignment::RIGHT);
DrawTextBasic(dpi, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, 0 }, format, ft, { TextAlignment::RIGHT });
gfx_fill_rect(
dpi, { screenCoords + ScreenCoordsXY{ 10, -2 }, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, -2 } },
@ -758,7 +758,7 @@ static void window_finances_financial_graph_paint(rct_window* w, rct_drawpixelin
money32 axisValue = axisBase << yAxisScale;
auto ft = Formatter();
ft.Add<money32>(axisValue);
DrawTextBasic(dpi, { x + 70, y }, STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE, ft, COLOUR_BLACK, TextAlignment::RIGHT);
DrawTextBasic(dpi, { x + 70, y }, STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE, ft, { TextAlignment::RIGHT });
gfx_fill_rect_inset(dpi, x + 70, y + 5, graphLeft + 482, y + 5, w->colours[2], INSET_RECT_FLAG_BORDER_INSET);
y += 39;
}
@ -863,7 +863,7 @@ static void window_finances_park_value_graph_paint(rct_window* w, rct_drawpixeli
money32 axisValue = axisBase << yAxisScale;
auto ft = Formatter();
ft.Add<money32>(axisValue);
DrawTextBasic(dpi, { x + 70, y }, STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE, ft, COLOUR_BLACK, TextAlignment::RIGHT);
DrawTextBasic(dpi, { x + 70, y }, STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE, ft, { TextAlignment::RIGHT });
gfx_fill_rect_inset(dpi, x + 70, y + 5, graphLeft + 482, y + 5, w->colours[2], INSET_RECT_FLAG_BORDER_INSET);
y += 39;
}
@ -969,8 +969,7 @@ static void window_finances_profit_graph_paint(rct_window* w, rct_drawpixelinfo*
auto ft = Formatter();
ft.Add<money32>(axisValue);
DrawTextBasic(
dpi, screenPos + ScreenCoordsXY{ 70, 0 }, STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE, ft, COLOUR_BLACK,
TextAlignment::RIGHT);
dpi, screenPos + ScreenCoordsXY{ 70, 0 }, STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE, ft, { TextAlignment::RIGHT });
gfx_fill_rect_inset(
dpi, screenPos.x + 70, screenPos.y + 5, graphLeft + 482, screenPos.y + 5, w->colours[2],
INSET_RECT_FLAG_BORDER_INSET);

View File

@ -1016,7 +1016,7 @@ void window_guest_overview_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
auto ft = Formatter();
peep_thought_set_format_args(&peep->Thoughts[i], ft);
DrawTextBasic(&dpi_marquee, { screenPos.x, 0 }, STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK);
DrawTextBasic(&dpi_marquee, { screenPos.x, 0 }, STR_WINDOW_COLOUR_2_STRINGID, ft, {});
}
}

View File

@ -755,7 +755,7 @@ private:
ft = Formatter();
ft.Add<rct_string_id>(STR_GUESTS_COUNT_COMMA_SEP);
ft.Add<uint32_t>(group.NumGuests);
DrawTextBasic(&dpi, { 326, y }, format, ft, COLOUR_BLACK, TextAlignment::RIGHT);
DrawTextBasic(&dpi, { 326, y }, format, ft, { TextAlignment::RIGHT });
}
y += SUMMARISED_GUEST_ROW_HEIGHT;
index++;

View File

@ -954,7 +954,7 @@ static void window_new_ride_paint_ride_information(
ft = Formatter();
ft.Add<money32>(price);
DrawTextBasic(dpi, screenPos + ScreenCoordsXY{ width, 51 }, stringId, ft, COLOUR_BLACK, TextAlignment::RIGHT);
DrawTextBasic(dpi, screenPos + ScreenCoordsXY{ width, 51 }, stringId, ft, { TextAlignment::RIGHT });
}
}

View File

@ -916,7 +916,7 @@ static void window_park_rating_paint(rct_window* w, rct_drawpixelinfo* dpi)
uint32_t axisValue = i * 200;
auto ft = Formatter();
ft.Add<uint32_t>(axisValue);
DrawTextBasic(dpi, screenPos + ScreenCoordsXY{ 10, 0 }, STR_GRAPH_AXIS_LABEL, ft, COLOUR_BLACK, TextAlignment::RIGHT);
DrawTextBasic(dpi, screenPos + ScreenCoordsXY{ 10, 0 }, STR_GRAPH_AXIS_LABEL, ft, { TextAlignment::RIGHT });
gfx_fill_rect_inset(
dpi, { screenPos + ScreenCoordsXY{ 15, 5 }, screenPos + ScreenCoordsXY{ w->width - 32, 5 } }, w->colours[2],
INSET_RECT_FLAG_BORDER_INSET);
@ -1051,7 +1051,7 @@ static void window_park_guests_paint(rct_window* w, rct_drawpixelinfo* dpi)
uint32_t axisValue = i * 1000;
auto ft = Formatter();
ft.Add<uint32_t>(axisValue);
DrawTextBasic(dpi, screenPos + ScreenCoordsXY{ 10, 0 }, STR_GRAPH_AXIS_LABEL, ft, COLOUR_BLACK, TextAlignment::RIGHT);
DrawTextBasic(dpi, screenPos + ScreenCoordsXY{ 10, 0 }, STR_GRAPH_AXIS_LABEL, ft, { TextAlignment::RIGHT });
gfx_fill_rect_inset(
dpi, { screenPos + ScreenCoordsXY{ 15, 5 }, screenPos + ScreenCoordsXY{ w->width - 32, 5 } }, w->colours[2],
INSET_RECT_FLAG_BORDER_INSET);

View File

@ -1172,8 +1172,8 @@ void window_scenery_paint(rct_window* w, rct_drawpixelinfo* dpi)
// -14
DrawTextBasic(
dpi, w->windowPos + ScreenCoordsXY{ w->width - 0x1A, w->height - 13 }, STR_COST_LABEL, ft, COLOUR_BLACK,
TextAlignment::RIGHT);
dpi, w->windowPos + ScreenCoordsXY{ w->width - 0x1A, w->height - 13 }, STR_COST_LABEL, ft,
{ TextAlignment::RIGHT });
}
auto ft = Formatter();

View File

@ -1758,11 +1758,12 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
auto tileCoords = TileCoordsXY{ windowTileInspectorToolMap };
auto ft = Formatter();
ft.Add<int32_t>(tileCoords.x);
DrawTextBasic(dpi, screenCoords + ScreenCoordsXY{ 43, 24 }, STR_FORMAT_INTEGER, ft, COLOUR_WHITE, TextAlignment::RIGHT);
DrawTextBasic(
dpi, screenCoords + ScreenCoordsXY{ 43, 24 }, STR_FORMAT_INTEGER, ft, { COLOUR_WHITE, TextAlignment::RIGHT });
ft = Formatter();
ft.Add<int32_t>(tileCoords.y);
DrawTextBasic(
dpi, screenCoords + ScreenCoordsXY{ 113, 24 }, STR_FORMAT_INTEGER, ft, COLOUR_WHITE, TextAlignment::RIGHT);
dpi, screenCoords + ScreenCoordsXY{ 113, 24 }, STR_FORMAT_INTEGER, ft, { COLOUR_WHITE, TextAlignment::RIGHT });
}
else
{

View File

@ -904,7 +904,7 @@ static void window_top_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
DrawTextBasic(
dpi, screenPos + ScreenCoordsXY{ 26, 2 }, STR_OVERLAY_CLEARANCE_CHECKS_DISABLED, {},
COLOUR_DARK_ORANGE | COLOUR_FLAG_OUTLINE, TextAlignment::RIGHT);
{ COLOUR_DARK_ORANGE | COLOUR_FLAG_OUTLINE, TextAlignment::RIGHT });
}
}
@ -983,8 +983,8 @@ static void window_top_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi)
ft.Add<int32_t>(network_get_num_players());
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
DrawTextBasic(
dpi, screenPos + ScreenCoordsXY{ 23, 1 }, STR_COMMA16, ft, COLOUR_WHITE | COLOUR_FLAG_OUTLINE,
TextAlignment::RIGHT);
dpi, screenPos + ScreenCoordsXY{ 23, 1 }, STR_COMMA16, ft,
{ COLOUR_WHITE | COLOUR_FLAG_OUTLINE, TextAlignment::RIGHT });
}
}

View File

@ -129,21 +129,6 @@ void DrawTextBasic(
DrawTextBasic(dpi, coords, format, ft.Data(), textPaint);
}
void DrawTextBasic(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const void* args, colour_t colour,
TextAlignment alignment, bool underline)
{
TextPaint textPaint = { colour, FontSpriteBase::MEDIUM, underline ? TextUnderline::On : TextUnderline::Off, alignment };
DrawTextBasic(dpi, coords, format, args, textPaint);
}
void DrawTextBasic(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const Formatter& ft, colour_t colour,
TextAlignment alignment, bool underline)
{
DrawTextBasic(dpi, coords, format, ft.Data(), colour, alignment, underline);
}
void DrawTextEllipsised(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const Formatter& ft,
colour_t colour, TextAlignment alignment, bool underline)
@ -175,13 +160,13 @@ void gfx_draw_string_no_formatting(
void gfx_draw_string_left(
rct_drawpixelinfo* dpi, rct_string_id format, void* args, uint8_t colour, const ScreenCoordsXY& coords)
{
DrawTextBasic(dpi, coords, format, args, colour, TextAlignment::LEFT);
DrawTextBasic(dpi, coords, format, args, { colour, TextAlignment::LEFT });
}
void gfx_draw_string_centred(
rct_drawpixelinfo* dpi, rct_string_id format, const ScreenCoordsXY& coords, uint8_t colour, const void* args)
{
DrawTextBasic(dpi, coords, format, args, colour, TextAlignment::CENTRE);
DrawTextBasic(dpi, coords, format, args, { colour, TextAlignment::CENTRE });
}
// Wrapping

View File

@ -37,7 +37,7 @@ struct TextPaint
TextUnderline UnderlineText = TextUnderline::Off;
TextAlignment Alignment = TextAlignment::LEFT;
explicit TextPaint()
TextPaint()
{
}
TextPaint(colour_t colour)
@ -83,6 +83,11 @@ struct TextPaint
, Alignment(alignment)
{
}
TextPaint(TextUnderline underlineText, TextAlignment alignment)
: UnderlineText(underlineText)
, Alignment(alignment)
{
}
TextPaint(colour_t colour, FontSpriteBase spriteBase, TextUnderline underlineText)
: Colour(colour)
@ -142,12 +147,6 @@ void DrawTextBasic(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const Formatter& ft, TextPaint textPaint);
void DrawTextBasic(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const void* args, TextPaint textPaint);
void DrawTextBasic(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const Formatter& ft, colour_t colour,
TextAlignment alignment = TextAlignment::LEFT, bool underline = false);
void DrawTextBasic(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const void* args, colour_t colour,
TextAlignment alignment = TextAlignment::LEFT, bool underline = false);
void DrawTextEllipsised(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const Formatter& ft,
colour_t colour, TextAlignment alignment = TextAlignment::LEFT, bool underline = false);