Remove const void* overload from DrawTextEllipsised()

This commit is contained in:
Gymnasiast 2020-08-28 22:33:36 +02:00
parent b788a099b5
commit d140dd72c6
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
19 changed files with 88 additions and 82 deletions

View File

@ -358,15 +358,14 @@ static void widget_text_centred(rct_drawpixelinfo* dpi, rct_window* w, rct_widge
topLeft.y += widget->top; topLeft.y += widget->top;
auto stringId = widget->text; auto stringId = widget->text;
void* formatArgs = gCommonFormatArgs; auto ft = Formatter::Common();
if (widget->flags & WIDGET_FLAGS::TEXT_IS_STRING) if (widget->flags & WIDGET_FLAGS::TEXT_IS_STRING)
{ {
stringId = STR_STRING; stringId = STR_STRING;
formatArgs = &widget->string; ft.Add<utf8*>(widget->string);
} }
DrawTextEllipsised( DrawTextEllipsised(
dpi, { (topLeft.x + r + 1) / 2 - 1, topLeft.y }, widget->width() - 2, stringId, formatArgs, colour, dpi, { (topLeft.x + r + 1) / 2 - 1, topLeft.y }, widget->width() - 2, stringId, ft, colour, TextAlignment::CENTRE);
TextAlignment::CENTRE);
} }
/** /**
@ -400,13 +399,13 @@ static void widget_text(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex w
t = w->windowPos.y + widget->top; t = w->windowPos.y + widget->top;
auto stringId = widget->text; auto stringId = widget->text;
void* formatArgs = gCommonFormatArgs; auto ft = Formatter::Common();
if (widget->flags & WIDGET_FLAGS::TEXT_IS_STRING) if (widget->flags & WIDGET_FLAGS::TEXT_IS_STRING)
{ {
stringId = STR_STRING; stringId = STR_STRING;
formatArgs = &widget->string; ft.Add<utf8*>(widget->string);
} }
DrawTextEllipsised(dpi, { l + 1, t }, r - l, stringId, formatArgs, colour); DrawTextEllipsised(dpi, { l + 1, t }, r - l, stringId, ft, colour);
} }
/** /**
@ -558,7 +557,7 @@ static void widget_caption_draw(rct_drawpixelinfo* dpi, rct_window* w, rct_widge
} }
topLeft.x += width / 2; topLeft.x += width / 2;
DrawTextEllipsised( DrawTextEllipsised(
dpi, topLeft, width, widget->text, gCommonFormatArgs, COLOUR_WHITE | COLOUR_FLAG_OUTLINE, TextAlignment::CENTRE); dpi, topLeft, width, widget->text, Formatter::Common(), COLOUR_WHITE | COLOUR_FLAG_OUTLINE, TextAlignment::CENTRE);
} }
/** /**
@ -595,7 +594,7 @@ static void widget_closebox_draw(rct_drawpixelinfo* dpi, rct_window* w, rct_widg
if (widget_is_disabled(w, widgetIndex)) if (widget_is_disabled(w, widgetIndex))
colour |= COLOUR_FLAG_INSET; colour |= COLOUR_FLAG_INSET;
DrawTextEllipsised(dpi, topLeft, widget->width() - 2, widget->text, gCommonFormatArgs, colour, TextAlignment::CENTRE); DrawTextEllipsised(dpi, topLeft, widget->width() - 2, widget->text, Formatter::Common(), colour, TextAlignment::CENTRE);
} }
/** /**

View File

@ -670,7 +670,7 @@ void CustomListView::PaintCell(
auto ft = Formatter::Common(); auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING); ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(text); ft.Add<const char*>(text);
DrawTextEllipsised(dpi, pos, size.width, stringId, gCommonFormatArgs, COLOUR_BLACK); DrawTextEllipsised(dpi, pos, size.width, stringId, ft, COLOUR_BLACK);
} }
std::optional<RowColumn> CustomListView::GetItemIndexAt(const ScreenCoordsXY& pos) std::optional<RowColumn> CustomListView::GetItemIndexAt(const ScreenCoordsXY& pos)

View File

@ -398,7 +398,8 @@ static void window_dropdown_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Draw item string // Draw item string
ScreenCoordsXY screenCoords = { w->windowPos.x + 2 + (cell_x * _dropdown_item_width), ScreenCoordsXY screenCoords = { w->windowPos.x + 2 + (cell_x * _dropdown_item_width),
w->windowPos.y + 2 + (cell_y * _dropdown_item_height) }; w->windowPos.y + 2 + (cell_y * _dropdown_item_height) };
DrawTextEllipsised(dpi, screenCoords, w->width - 5, item, static_cast<void*>(&gDropdownItemsArgs[i]), colour); Formatter ft(reinterpret_cast<uint8_t*>(&gDropdownItemsArgs[i]));
DrawTextEllipsised(dpi, screenCoords, w->width - 5, item, ft, colour);
} }
} }
} }

View File

@ -83,7 +83,7 @@ static void window_editor_inventions_list_drag_cursor(rct_window *w, rct_widgeti
static void window_editor_inventions_list_drag_moved(rct_window* w, const ScreenCoordsXY& screenCoords); static void window_editor_inventions_list_drag_moved(rct_window* w, const ScreenCoordsXY& screenCoords);
static void window_editor_inventions_list_drag_paint(rct_window *w, rct_drawpixelinfo *dpi); static void window_editor_inventions_list_drag_paint(rct_window *w, rct_drawpixelinfo *dpi);
static rct_string_id window_editor_inventions_list_prepare_name(const ResearchItem * researchItem, bool withGap); static std::pair<rct_string_id, Formatter> window_editor_inventions_list_prepare_name(const ResearchItem * researchItem, bool withGap);
// 0x0098177C // 0x0098177C
static rct_window_event_list window_editor_inventions_list_events = { static rct_window_event_list window_editor_inventions_list_events = {
@ -610,8 +610,8 @@ static void window_editor_inventions_list_paint(rct_window* w, rct_drawpixelinfo
screenPos = w->windowPos + ScreenCoordsXY{ widget->midX() + 1, widget->bottom + 3 }; screenPos = w->windowPos + ScreenCoordsXY{ widget->midX() + 1, widget->bottom + 3 };
width = w->width - w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right - 6; width = w->width - w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right - 6;
rct_string_id drawString = window_editor_inventions_list_prepare_name(researchItem, false); auto [drawString, ft] = window_editor_inventions_list_prepare_name(researchItem, false);
DrawTextEllipsised(dpi, screenPos, width, drawString, gCommonFormatArgs, COLOUR_BLACK, TextAlignment::CENTRE); DrawTextEllipsised(dpi, screenPos, width, drawString, ft, COLOUR_BLACK, TextAlignment::CENTRE);
screenPos.y += 15; screenPos.y += 15;
// Item category // Item category
@ -816,14 +816,14 @@ static void window_editor_inventions_list_drag_moved(rct_window* w, const Screen
*/ */
static void window_editor_inventions_list_drag_paint(rct_window* w, rct_drawpixelinfo* dpi) static void window_editor_inventions_list_drag_paint(rct_window* w, rct_drawpixelinfo* dpi)
{ {
rct_string_id drawString;
auto screenCoords = w->windowPos + ScreenCoordsXY{ 0, 2 }; auto screenCoords = w->windowPos + ScreenCoordsXY{ 0, 2 };
drawString = window_editor_inventions_list_prepare_name(&_editorInventionsListDraggedItem, true); auto [drawString, ft] = window_editor_inventions_list_prepare_name(&_editorInventionsListDraggedItem, true);
gfx_draw_string_left(dpi, drawString, gCommonFormatArgs, COLOUR_BLACK | COLOUR_FLAG_OUTLINE, screenCoords); DrawTextBasic(dpi, screenCoords, drawString, ft, COLOUR_BLACK | COLOUR_FLAG_OUTLINE);
} }
static rct_string_id window_editor_inventions_list_prepare_name(const ResearchItem* researchItem, bool withGap) static std::pair<rct_string_id, Formatter> window_editor_inventions_list_prepare_name(
const ResearchItem* researchItem, bool withGap)
{ {
rct_string_id drawString; rct_string_id drawString;
rct_string_id stringId = researchItem->GetName(); rct_string_id stringId = researchItem->GetName();
@ -843,7 +843,7 @@ static rct_string_id window_editor_inventions_list_prepare_name(const ResearchIt
ft.Add<rct_string_id>(stringId); ft.Add<rct_string_id>(stringId);
} }
return drawString; return std::make_pair(drawString, ft);
} }
#pragma endregion #pragma endregion

View File

@ -951,7 +951,6 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
{ {
int32_t width; int32_t width;
rct_widget* widget; rct_widget* widget;
rct_string_id stringId;
window_draw_widgets(w, dpi); window_draw_widgets(w, dpi);
@ -1023,18 +1022,22 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
widget = &w->widgets[WIDX_LIST_SORT_TYPE]; widget = &w->widgets[WIDX_LIST_SORT_TYPE];
if (widget->type != WWT_EMPTY) if (widget->type != WWT_EMPTY)
{ {
stringId = _listSortType == RIDE_SORT_TYPE ? static_cast<rct_string_id>(_listSortDescending ? STR_DOWN : STR_UP) auto ft = Formatter::Common();
: STR_NONE; auto stringId = _listSortType == RIDE_SORT_TYPE ? static_cast<rct_string_id>(_listSortDescending ? STR_DOWN : STR_UP)
: STR_NONE;
ft.Add<rct_string_id>(stringId);
auto screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 }; auto screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 };
DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_TYPE, &stringId, w->colours[1]); DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_TYPE, ft, w->colours[1]);
} }
widget = &w->widgets[WIDX_LIST_SORT_RIDE]; widget = &w->widgets[WIDX_LIST_SORT_RIDE];
if (widget->type != WWT_EMPTY) if (widget->type != WWT_EMPTY)
{ {
stringId = _listSortType == RIDE_SORT_RIDE ? static_cast<rct_string_id>(_listSortDescending ? STR_DOWN : STR_UP) auto ft = Formatter::Common();
: STR_NONE; auto stringId = _listSortType == RIDE_SORT_RIDE ? static_cast<rct_string_id>(_listSortDescending ? STR_DOWN : STR_UP)
: STR_NONE;
ft.Add<rct_string_id>(stringId);
auto screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 }; auto screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 };
DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_RIDE, &stringId, w->colours[1]); DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_RIDE, ft, w->colours[1]);
} }
if (w->selected_list_item == -1 || _loadedObject == nullptr) if (w->selected_list_item == -1 || _loadedObject == nullptr)
@ -1085,14 +1088,14 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
// Draw ride type. // Draw ride type.
if (get_selected_object_type(w) == OBJECT_TYPE_RIDE) if (get_selected_object_type(w) == OBJECT_TYPE_RIDE)
{ {
stringId = get_ride_type_string_id(listItem->repositoryItem); auto stringId = get_ride_type_string_id(listItem->repositoryItem);
gfx_draw_string_right(dpi, stringId, nullptr, COLOUR_WHITE, screenPos); gfx_draw_string_right(dpi, stringId, nullptr, COLOUR_WHITE, screenPos);
} }
screenPos.y += LIST_ROW_HEIGHT; screenPos.y += LIST_ROW_HEIGHT;
// Draw object source // Draw object source
stringId = object_manager_get_source_game_string(listItem->repositoryItem->GetFirstSourceGame()); auto stringId = object_manager_get_source_game_string(listItem->repositoryItem->GetFirstSourceGame());
gfx_draw_string_right(dpi, stringId, nullptr, COLOUR_WHITE, screenPos); gfx_draw_string_right(dpi, stringId, nullptr, COLOUR_WHITE, screenPos);
screenPos.y += LIST_ROW_HEIGHT; screenPos.y += LIST_ROW_HEIGHT;
@ -1194,7 +1197,9 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi
// Draw ride type // Draw ride type
rct_string_id rideTypeStringId = get_ride_type_string_id(listItem.repositoryItem); rct_string_id rideTypeStringId = get_ride_type_string_id(listItem.repositoryItem);
safe_strcpy(buffer, language_get_string(rideTypeStringId), 256 - (buffer - bufferWithColour)); safe_strcpy(buffer, language_get_string(rideTypeStringId), 256 - (buffer - bufferWithColour));
DrawTextEllipsised(dpi, screenCoords, width_limit - 15, STR_STRING, &bufferWithColour, colour); auto ft = Formatter::Common();
ft.Add<const char*>(gCommonStringFormatBuffer);
DrawTextEllipsised(dpi, screenCoords, width_limit - 15, STR_STRING, ft, colour);
screenCoords.x = w->widgets[WIDX_LIST_SORT_RIDE].left - w->widgets[WIDX_LIST].left; screenCoords.x = w->widgets[WIDX_LIST_SORT_RIDE].left - w->widgets[WIDX_LIST].left;
} }
@ -1207,7 +1212,9 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi
*buffer = 0; *buffer = 0;
} }
DrawTextEllipsised(dpi, screenCoords, width_limit, STR_STRING, &bufferWithColour, colour); auto ft = Formatter::Common();
ft.Add<const char*>(gCommonStringFormatBuffer);
DrawTextEllipsised(dpi, screenCoords, width_limit, STR_STRING, ft, colour);
} }
screenCoords.y += SCROLLABLE_ROW_HEIGHT; screenCoords.y += SCROLLABLE_ROW_HEIGHT;
} }

View File

@ -1160,8 +1160,8 @@ void window_guest_overview_paint(rct_window* w, rct_drawpixelinfo* dpi)
} }
screenPos.x = widget->width() - w->list_information_type; screenPos.x = widget->width() - w->list_information_type;
peep_thought_set_format_args(&peep->Thoughts[i]); peep_thought_set_format_args(&peep->Thoughts[i], ft);
gfx_draw_string_left(&dpi_marquee, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, { screenPos.x, 0 }); DrawTextBasic(&dpi_marquee, { screenPos.x, 0 }, STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK);
} }
/** /**
@ -1984,9 +1984,10 @@ void window_guest_thoughts_paint(rct_window* w, rct_drawpixelinfo* dpi)
int32_t width = window_guest_thoughts_widgets[WIDX_PAGE_BACKGROUND].right int32_t width = window_guest_thoughts_widgets[WIDX_PAGE_BACKGROUND].right
- window_guest_thoughts_widgets[WIDX_PAGE_BACKGROUND].left - 8; - window_guest_thoughts_widgets[WIDX_PAGE_BACKGROUND].left - 8;
peep_thought_set_format_args(thought); auto ft = Formatter::Common();
peep_thought_set_format_args(thought, ft);
screenCoords.y += gfx_draw_string_left_wrapped( screenCoords.y += gfx_draw_string_left_wrapped(
dpi, gCommonFormatArgs, screenCoords, width, STR_BLACK_STRING, COLOUR_BLACK); dpi, const_cast<unsigned char*>(ft.GetStartBuf()), screenCoords, width, STR_BLACK_STRING, COLOUR_BLACK);
// If this is the last visible line end drawing. // If this is the last visible line end drawing.
if (screenCoords.y > w->windowPos.y + window_guest_thoughts_widgets[WIDX_PAGE_BACKGROUND].bottom - 32) if (screenCoords.y > w->windowPos.y + window_guest_thoughts_widgets[WIDX_PAGE_BACKGROUND].bottom - 32)

View File

@ -724,7 +724,11 @@ static void window_guest_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
{ {
format = STR_ALL_GUESTS_SUMMARISED; format = STR_ALL_GUESTS_SUMMARISED;
} }
DrawTextEllipsised(dpi, screenCoords, 310, format, _window_guest_list_filter_arguments.args, COLOUR_BLACK);
{
Formatter ft(_window_guest_list_filter_arguments.args);
DrawTextEllipsised(dpi, screenCoords, 310, format, ft, COLOUR_BLACK);
}
// Number of guests (list items) // Number of guests (list items)
if (_window_guest_list_selected_tab == PAGE_INDIVIDUAL) if (_window_guest_list_selected_tab == PAGE_INDIVIDUAL)
@ -811,8 +815,8 @@ static void window_guest_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
if (thought->freshness > 5) if (thought->freshness > 5)
break; break;
peep_thought_set_format_args(&peep->Thoughts[j]); peep_thought_set_format_args(&peep->Thoughts[j], ft);
DrawTextEllipsised(dpi, { 118, y }, 329, format, gCommonFormatArgs, COLOUR_BLACK); DrawTextEllipsised(dpi, { 118, y }, 329, format, ft, COLOUR_BLACK);
break; break;
} }
break; break;
@ -854,13 +858,11 @@ static void window_guest_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
{ static_cast<int32_t>(j) * 8, y + 12 }, 0); { static_cast<int32_t>(j) * 8, y + 12 }, 0);
// Draw action // Draw action
std::memcpy( Formatter ft(_window_guest_list_groups_arguments[i].args);
gCommonFormatArgs, _window_guest_list_groups_arguments[i].args, DrawTextEllipsised(dpi, { 0, y }, 414, format, ft, COLOUR_BLACK);
std::min(sizeof(gCommonFormatArgs), sizeof(_window_guest_list_groups_arguments[i].args)));
DrawTextEllipsised(dpi, { 0, y }, 414, format, gCommonFormatArgs, COLOUR_BLACK);
// Draw guest count // Draw guest count
auto ft = Formatter::Common(); ft = Formatter::Common();
ft.Add<rct_string_id>(STR_GUESTS_COUNT_COMMA_SEP); ft.Add<rct_string_id>(STR_GUESTS_COUNT_COMMA_SEP);
ft.Add<uint32_t>(numGuests); ft.Add<uint32_t>(numGuests);
gfx_draw_string_right(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 326, y }); gfx_draw_string_right(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 326, y });
@ -926,9 +928,7 @@ static FilterArguments get_arguments_from_peep(const Peep* peep)
auto thought = &peep->Thoughts[0]; auto thought = &peep->Thoughts[0];
if (thought->freshness <= 5 && thought->type != PEEP_THOUGHT_TYPE_NONE) if (thought->freshness <= 5 && thought->type != PEEP_THOUGHT_TYPE_NONE)
{ {
std::memset(gCommonFormatArgs, 0, sizeof(gCommonFormatArgs)); peep_thought_set_format_args(thought, ft);
peep_thought_set_format_args(thought);
std::memcpy(result.args, gCommonFormatArgs, std::min(sizeof(gCommonFormatArgs), sizeof(result.args)));
} }
break; break;
} }

View File

@ -241,7 +241,7 @@ static void window_install_track_paint(rct_window* w, rct_drawpixelinfo* dpi)
if (!gTrackDesignSceneryToggle) if (!gTrackDesignSceneryToggle)
{ {
// Scenery not available // Scenery not available
DrawTextEllipsised(dpi, screenPos, 308, STR_BLACK_STRING, {}, COLOUR_BLACK, TextAlignment::CENTRE); DrawTextEllipsised(dpi, screenPos, 308, STR_BLACK_STRING, Formatter::Common(), COLOUR_BLACK, TextAlignment::CENTRE);
screenPos.y -= LIST_ROW_HEIGHT; screenPos.y -= LIST_ROW_HEIGHT;
} }
} }

View File

@ -925,7 +925,9 @@ static void window_new_ride_paint_ride_information(
if (availabilityString[0] != 0) if (availabilityString[0] != 0)
{ {
const char* drawString = availabilityString; const char* drawString = availabilityString;
DrawTextEllipsised(dpi, screenPos + ScreenCoordsXY{ 0, 39 }, WW - 2, STR_AVAILABLE_VEHICLES, &drawString, COLOUR_BLACK); ft = Formatter::Common();
ft.Add<const char*>(drawString);
DrawTextEllipsised(dpi, screenPos + ScreenCoordsXY{ 0, 39 }, WW - 2, STR_AVAILABLE_VEHICLES, ft, COLOUR_BLACK);
} }
if (item.Type != _lastTrackDesignCountRideType.Type || item.EntryIndex != _lastTrackDesignCountRideType.EntryIndex) if (item.Type != _lastTrackDesignCountRideType.Type || item.EntryIndex != _lastTrackDesignCountRideType.EntryIndex)

View File

@ -5027,7 +5027,8 @@ static void window_ride_colour_paint(rct_window* w, rct_drawpixelinfo* dpi)
} }
} }
DrawTextEllipsised(dpi, { w->windowPos.x + 3, w->windowPos.y + 103 }, 97, STR_STATION_STYLE, {}, COLOUR_BLACK); DrawTextEllipsised(
dpi, { w->windowPos.x + 3, w->windowPos.y + 103 }, 97, STR_STATION_STYLE, Formatter::Common(), COLOUR_BLACK);
} }
} }

View File

@ -477,7 +477,8 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi)
+ ScreenCoordsXY{ window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4, + ScreenCoordsXY{ window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4,
window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5 }; window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5 };
DrawTextEllipsised( DrawTextEllipsised(
dpi, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_SCENARIO_LOCKED, {}, COLOUR_BLACK, TextAlignment::CENTRE); dpi, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_SCENARIO_LOCKED, Formatter::Common(), COLOUR_BLACK,
TextAlignment::CENTRE);
gfx_draw_string_left_wrapped( gfx_draw_string_left_wrapped(
dpi, nullptr, screenPos + ScreenCoordsXY{ 0, 15 }, 170, STR_SCENARIO_LOCKED_DESC, COLOUR_BLACK); dpi, nullptr, screenPos + ScreenCoordsXY{ 0, 15 }, 170, STR_SCENARIO_LOCKED_DESC, COLOUR_BLACK);
} }

View File

@ -481,8 +481,9 @@ static void window_server_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi
} }
// Finally, draw the server information. // Finally, draw the server information.
DrawTextEllipsised( auto ft = Formatter::Common();
dpi, screenCoords + ScreenCoordsXY{ 0, 3 }, spaceAvailableForInfo, STR_STRING, &serverInfoToShow, colour); ft.Add<const char*>(serverInfoToShow);
DrawTextEllipsised(dpi, screenCoords + ScreenCoordsXY{ 0, 3 }, spaceAvailableForInfo, STR_STRING, ft, colour);
int32_t right = width - 7 - SCROLLBAR_WIDTH; int32_t right = width - 7 - SCROLLBAR_WIDTH;

View File

@ -1724,31 +1724,31 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
{ {
DrawTextEllipsised( DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_ELEMENT_TYPE, gCommonFormatArgs, w->colours[1]); STR_TILE_INSPECTOR_ELEMENT_TYPE, Formatter::Common(), w->colours[1]);
} }
if ((widget = &w->widgets[WIDX_COLUMN_BASEHEIGHT])->type != WWT_EMPTY) if ((widget = &w->widgets[WIDX_COLUMN_BASEHEIGHT])->type != WWT_EMPTY)
{ {
DrawTextEllipsised( DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_BASE_HEIGHT_SHORT, gCommonFormatArgs, w->colours[1]); STR_TILE_INSPECTOR_BASE_HEIGHT_SHORT, Formatter::Common(), w->colours[1]);
} }
if ((widget = &w->widgets[WIDX_COLUMN_CLEARANCEHEIGHT])->type != WWT_EMPTY) if ((widget = &w->widgets[WIDX_COLUMN_CLEARANCEHEIGHT])->type != WWT_EMPTY)
{ {
DrawTextEllipsised( DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_CLEARANGE_HEIGHT_SHORT, gCommonFormatArgs, w->colours[1]); STR_TILE_INSPECTOR_CLEARANGE_HEIGHT_SHORT, Formatter::Common(), w->colours[1]);
} }
if ((widget = &w->widgets[WIDX_COLUMN_GHOSTFLAG])->type != WWT_EMPTY) if ((widget = &w->widgets[WIDX_COLUMN_GHOSTFLAG])->type != WWT_EMPTY)
{ {
DrawTextEllipsised( DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_FLAG_GHOST_SHORT, gCommonFormatArgs, w->colours[1]); STR_TILE_INSPECTOR_FLAG_GHOST_SHORT, Formatter::Common(), w->colours[1]);
} }
if ((widget = &w->widgets[WIDX_COLUMN_LASTFLAG])->type != WWT_EMPTY) if ((widget = &w->widgets[WIDX_COLUMN_LASTFLAG])->type != WWT_EMPTY)
{ {
DrawTextEllipsised( DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_FLAG_LAST_SHORT, gCommonFormatArgs, w->colours[1]); STR_TILE_INSPECTOR_FLAG_LAST_SHORT, Formatter::Common(), w->colours[1]);
} }
ScreenCoordsXY screenCoords(w->windowPos.x, w->windowPos.y); ScreenCoordsXY screenCoords(w->windowPos.x, w->windowPos.y);

View File

@ -741,8 +741,8 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo*
// Command dropdown name // Command dropdown name
DrawTextEllipsised( DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_COMMAND].left + 1, w->windowPos.y + w->widgets[WIDX_COMMAND].top }, dpi, { w->windowPos.x + w->widgets[WIDX_COMMAND].left + 1, w->windowPos.y + w->widgets[WIDX_COMMAND].top },
w->widgets[WIDX_COMMAND_DROPDOWN].left - w->widgets[WIDX_COMMAND].left - 4, command_info.nameStringId, {}, w->widgets[WIDX_COMMAND_DROPDOWN].left - w->widgets[WIDX_COMMAND].left - 4, command_info.nameStringId,
w->colours[1]); Formatter::Common(), w->colours[1]);
// Label (e.g. "Location:") // Label (e.g. "Location:")
gfx_draw_string_left(dpi, command_info.descStringId, nullptr, w->colours[1], w->windowPos + ScreenCoordsXY{ WS, BY2 - 14 }); gfx_draw_string_left(dpi, command_info.descStringId, nullptr, w->colours[1], w->windowPos + ScreenCoordsXY{ WS, BY2 - 14 });
@ -751,8 +751,8 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo*
{ {
DrawTextEllipsised( DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top }, dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top },
w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, SpeedNames[command.Speed - 1], {}, w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, SpeedNames[command.Speed - 1],
w->colours[1]); Formatter::Common(), w->colours[1]);
} }
if (command.Type == TITLE_SCRIPT_FOLLOW) if (command.Type == TITLE_SCRIPT_FOLLOW)
{ {
@ -784,7 +784,7 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo*
DrawTextEllipsised( DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top }, dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top },
w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4,
STR_TITLE_COMMAND_EDITOR_NO_SAVE_SELECTED, {}, w->colours[1]); STR_TITLE_COMMAND_EDITOR_NO_SAVE_SELECTED, Formatter::Common(), w->colours[1]);
} }
else else
{ {
@ -802,7 +802,7 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo*
DrawTextEllipsised( DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top }, dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top },
w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4,
STR_TITLE_COMMAND_EDITOR_NO_SCENARIO_SELECTED, {}, w->colours[1]); STR_TITLE_COMMAND_EDITOR_NO_SCENARIO_SELECTED, Formatter::Common(), w->colours[1]);
} }
else else
{ {

View File

@ -558,7 +558,8 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
&& !(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) && !(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER))
{ {
// Vehicle design not available // Vehicle design not available
DrawTextEllipsised(dpi, screenPos, 368, STR_VEHICLE_DESIGN_UNAVAILABLE, {}, COLOUR_BLACK, TextAlignment::CENTRE); DrawTextEllipsised(
dpi, screenPos, 368, STR_VEHICLE_DESIGN_UNAVAILABLE, Formatter::Common(), COLOUR_BLACK, TextAlignment::CENTRE);
screenPos.y -= SCROLLABLE_ROW_HEIGHT; screenPos.y -= SCROLLABLE_ROW_HEIGHT;
} }
@ -568,14 +569,16 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
{ {
// Scenery not available // Scenery not available
DrawTextEllipsised( DrawTextEllipsised(
dpi, screenPos, 368, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, {}, COLOUR_BLACK, TextAlignment::CENTRE); dpi, screenPos, 368, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, Formatter::Common(), COLOUR_BLACK,
TextAlignment::CENTRE);
screenPos.y -= SCROLLABLE_ROW_HEIGHT; screenPos.y -= SCROLLABLE_ROW_HEIGHT;
} }
} }
// Track design name // Track design name
utf8* trackName = _trackDesigns[trackIndex].name; auto ft = Formatter::Common();
DrawTextEllipsised(dpi, screenPos, 368, STR_TRACK_PREVIEW_NAME_FORMAT, &trackName, COLOUR_BLACK, TextAlignment::CENTRE); ft.Add<utf8*>(_trackDesigns[trackIndex].name);
DrawTextEllipsised(dpi, screenPos, 368, STR_TRACK_PREVIEW_NAME_FORMAT, ft, COLOUR_BLACK, TextAlignment::CENTRE);
// Information // Information
screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->bottom + 2 }; screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->bottom + 2 };
@ -619,7 +622,7 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
} }
// Ride length // Ride length
auto ft = Formatter::Common(); ft = Formatter::Common();
ft.Add<rct_string_id>(STR_RIDE_LENGTH_ENTRY); ft.Add<rct_string_id>(STR_RIDE_LENGTH_ENTRY);
ft.Add<uint16_t>(_loadedTrackDesign->ride_length); ft.Add<uint16_t>(_loadedTrackDesign->ride_length);
DrawTextEllipsised(dpi, screenPos, 214, STR_TRACK_LIST_RIDE_LENGTH, ft, COLOUR_BLACK); DrawTextEllipsised(dpi, screenPos, 214, STR_TRACK_LIST_RIDE_LENGTH, ft, COLOUR_BLACK);
@ -681,7 +684,7 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
if (_loadedTrackDesign->space_required_x != 0xFF) if (_loadedTrackDesign->space_required_x != 0xFF)
{ {
// Space required // Space required
auto ft = Formatter::Common(); ft = Formatter::Common();
ft.Add<uint16_t>(_loadedTrackDesign->space_required_x); ft.Add<uint16_t>(_loadedTrackDesign->space_required_x);
ft.Add<uint16_t>(_loadedTrackDesign->space_required_y); ft.Add<uint16_t>(_loadedTrackDesign->space_required_y);
gfx_draw_string_left(dpi, STR_TRACK_LIST_SPACE_REQUIRED, gCommonFormatArgs, COLOUR_BLACK, screenPos); gfx_draw_string_left(dpi, STR_TRACK_LIST_SPACE_REQUIRED, gCommonFormatArgs, COLOUR_BLACK, screenPos);

View File

@ -132,9 +132,10 @@ void DrawTextBasic(
} }
void DrawTextEllipsised( void DrawTextEllipsised(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const void* args, rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const Formatter& ft,
colour_t colour, TextAlignment alignment, bool underline) colour_t colour, TextAlignment alignment, bool underline)
{ {
const void* args = ft.GetStartBuf();
TextPaint textPaint = { colour, FONT_SPRITE_BASE_MEDIUM, underline, alignment }; TextPaint textPaint = { colour, FONT_SPRITE_BASE_MEDIUM, underline, alignment };
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM; gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
@ -145,13 +146,6 @@ void DrawTextEllipsised(
DrawText(dpi, coords, textPaint, buffer); DrawText(dpi, coords, textPaint, buffer);
} }
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)
{
return DrawTextEllipsised(dpi, coords, width, format, ft.GetStartBuf(), colour, alignment, underline);
}
void gfx_draw_string(rct_drawpixelinfo* dpi, const_utf8string buffer, uint8_t colour, const ScreenCoordsXY& coords) void gfx_draw_string(rct_drawpixelinfo* dpi, const_utf8string buffer, uint8_t colour, const ScreenCoordsXY& coords)
{ {
TextPaint textPaint = { colour, gCurrentFontSpriteBase, false, TextAlignment::LEFT }; TextPaint textPaint = { colour, gCurrentFontSpriteBase, false, TextAlignment::LEFT };

View File

@ -59,6 +59,3 @@ void DrawTextBasic(
void DrawTextEllipsised( void DrawTextEllipsised(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const Formatter& ft, 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); 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 void* args,
colour_t colour, TextAlignment alignment = TextAlignment::LEFT, bool underline = false);

View File

@ -2004,9 +2004,8 @@ bool Peep::SetName(const std::string_view& value)
* argument_1 (esi & ebx) * argument_1 (esi & ebx)
* argument_2 (esi+2) * argument_2 (esi+2)
*/ */
void peep_thought_set_format_args(const rct_peep_thought* thought) void peep_thought_set_format_args(const rct_peep_thought* thought, Formatter& ft)
{ {
auto ft = Formatter::Common();
ft.Add<rct_string_id>(PeepThoughts[thought->type]); ft.Add<rct_string_id>(PeepThoughts[thought->type]);
PeepThoughtToActionFlag flags = PeepThoughtToActionMap[thought->type].flags; PeepThoughtToActionFlag flags = PeepThoughtToActionMap[thought->type].flags;

View File

@ -1039,7 +1039,7 @@ void peep_stop_crowd_noise();
void peep_update_crowd_noise(); void peep_update_crowd_noise();
void peep_update_days_in_queue(); void peep_update_days_in_queue();
void peep_applause(); void peep_applause();
void peep_thought_set_format_args(const rct_peep_thought* thought); void peep_thought_set_format_args(const rct_peep_thought* thought, Formatter& ft);
int32_t get_peep_face_sprite_small(Peep* peep); int32_t get_peep_face_sprite_small(Peep* peep);
int32_t get_peep_face_sprite_large(Peep* peep); int32_t get_peep_face_sprite_large(Peep* peep);
void game_command_pickup_guest( void game_command_pickup_guest(