Merge pull request #12797 from Gymnasiast/refactor/ellipsised-strings

Replace gfx_draw_string_clipped() calls with DrawTextEllipsised
This commit is contained in:
Michael Steenbeek 2020-09-10 18:48:52 +02:00 committed by GitHub
commit ce00ae5d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 205 additions and 231 deletions

View File

@ -358,14 +358,14 @@ static void widget_text_centred(rct_drawpixelinfo* dpi, rct_window* w, rct_widge
topLeft.y += widget->top;
auto stringId = widget->text;
void* formatArgs = gCommonFormatArgs;
auto ft = Formatter::Common();
if (widget->flags & WIDGET_FLAGS::TEXT_IS_STRING)
{
stringId = STR_STRING;
formatArgs = &widget->string;
ft.Add<utf8*>(widget->string);
}
gfx_draw_string_centred_clipped(
dpi, stringId, formatArgs, colour, { (topLeft.x + r + 1) / 2 - 1, topLeft.y }, widget->width() - 2);
DrawTextEllipsised(
dpi, { (topLeft.x + r + 1) / 2 - 1, topLeft.y }, widget->width() - 2, stringId, ft, colour, TextAlignment::CENTRE);
}
/**
@ -399,13 +399,13 @@ static void widget_text(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex w
t = w->windowPos.y + widget->top;
auto stringId = widget->text;
void* formatArgs = gCommonFormatArgs;
auto ft = Formatter::Common();
if (widget->flags & WIDGET_FLAGS::TEXT_IS_STRING)
{
stringId = STR_STRING;
formatArgs = &widget->string;
ft.Add<utf8*>(widget->string);
}
gfx_draw_string_left_clipped(dpi, stringId, formatArgs, colour, { l + 1, t }, r - l);
DrawTextEllipsised(dpi, { l + 1, t }, r - l, stringId, ft, colour);
}
/**
@ -556,7 +556,8 @@ static void widget_caption_draw(rct_drawpixelinfo* dpi, rct_window* w, rct_widge
width -= 10;
}
topLeft.x += width / 2;
gfx_draw_string_centred_clipped(dpi, widget->text, gCommonFormatArgs, COLOUR_WHITE | COLOUR_FLAG_OUTLINE, topLeft, width);
DrawTextEllipsised(
dpi, topLeft, width, widget->text, Formatter::Common(), COLOUR_WHITE | COLOUR_FLAG_OUTLINE, TextAlignment::CENTRE);
}
/**
@ -593,7 +594,7 @@ static void widget_closebox_draw(rct_drawpixelinfo* dpi, rct_window* w, rct_widg
if (widget_is_disabled(w, widgetIndex))
colour |= COLOUR_FLAG_INSET;
gfx_draw_string_centred_clipped(dpi, widget->text, gCommonFormatArgs, colour, topLeft, widget->width() - 2);
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();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(text);
gfx_draw_string_left_clipped(dpi, stringId, gCommonFormatArgs, COLOUR_BLACK, pos, size.width);
DrawTextEllipsised(dpi, pos, size.width, stringId, ft, COLOUR_BLACK);
}
std::optional<RowColumn> CustomListView::GetItemIndexAt(const ScreenCoordsXY& pos)

View File

@ -398,8 +398,8 @@ static void window_dropdown_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Draw item string
ScreenCoordsXY screenCoords = { w->windowPos.x + 2 + (cell_x * _dropdown_item_width),
w->windowPos.y + 2 + (cell_y * _dropdown_item_height) };
gfx_draw_string_left_clipped(
dpi, item, static_cast<void*>(&gDropdownItemsArgs[i]), colour, screenCoords, w->width - 5);
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_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
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 };
width = w->width - w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right - 6;
rct_string_id drawString = window_editor_inventions_list_prepare_name(researchItem, false);
gfx_draw_string_centred_clipped(dpi, drawString, gCommonFormatArgs, COLOUR_BLACK, screenPos, width);
auto [drawString, ft] = window_editor_inventions_list_prepare_name(researchItem, false);
DrawTextEllipsised(dpi, screenPos, width, drawString, ft, COLOUR_BLACK, TextAlignment::CENTRE);
screenPos.y += 15;
// 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)
{
rct_string_id drawString;
auto screenCoords = w->windowPos + ScreenCoordsXY{ 0, 2 };
drawString = window_editor_inventions_list_prepare_name(&_editorInventionsListDraggedItem, true);
gfx_draw_string_left(dpi, drawString, gCommonFormatArgs, COLOUR_BLACK | COLOUR_FLAG_OUTLINE, screenCoords);
auto [drawString, ft] = window_editor_inventions_list_prepare_name(&_editorInventionsListDraggedItem, true);
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 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);
}
return drawString;
return std::make_pair(drawString, ft);
}
#pragma endregion

View File

@ -951,7 +951,6 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
{
int32_t width;
rct_widget* widget;
rct_string_id stringId;
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];
if (widget->type != WWT_EMPTY)
{
stringId = _listSortType == RIDE_SORT_TYPE ? static_cast<rct_string_id>(_listSortDescending ? STR_DOWN : STR_UP)
: STR_NONE;
auto ft = Formatter::Common();
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 };
gfx_draw_string_left_clipped(dpi, STR_OBJECTS_SORT_TYPE, &stringId, w->colours[1], screenPos, widget->width());
DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_TYPE, ft, w->colours[1]);
}
widget = &w->widgets[WIDX_LIST_SORT_RIDE];
if (widget->type != WWT_EMPTY)
{
stringId = _listSortType == RIDE_SORT_RIDE ? static_cast<rct_string_id>(_listSortDescending ? STR_DOWN : STR_UP)
: STR_NONE;
auto ft = Formatter::Common();
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 };
gfx_draw_string_left_clipped(dpi, STR_OBJECTS_SORT_RIDE, &stringId, w->colours[1], screenPos, widget->width());
DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_RIDE, ft, w->colours[1]);
}
if (w->selected_list_item == -1 || _loadedObject == nullptr)
@ -1062,7 +1065,7 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(listItem->repositoryItem->Name.c_str());
gfx_draw_string_centred_clipped(dpi, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, screenPos, width);
DrawTextEllipsised(dpi, screenPos, width, STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK, TextAlignment::CENTRE);
}
// Draw description of object
@ -1085,14 +1088,14 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
// Draw ride type.
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);
}
screenPos.y += LIST_ROW_HEIGHT;
// 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);
screenPos.y += LIST_ROW_HEIGHT;
@ -1121,9 +1124,9 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
}
ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(authorsString.c_str());
gfx_draw_string_right_clipped(
dpi, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, { w->windowPos.x + w->width - 5, screenPos.y },
w->width - w->widgets[WIDX_LIST].right - 4);
DrawTextEllipsised(
dpi, { w->windowPos.x + w->width - 5, screenPos.y }, w->width - w->widgets[WIDX_LIST].right - 4,
STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK, TextAlignment::RIGHT);
}
}
/**
@ -1194,7 +1197,9 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi
// Draw ride type
rct_string_id rideTypeStringId = get_ride_type_string_id(listItem.repositoryItem);
safe_strcpy(buffer, language_get_string(rideTypeStringId), 256 - (buffer - bufferWithColour));
gfx_draw_string_left_clipped(dpi, STR_STRING, &bufferWithColour, colour, screenCoords, width_limit - 15);
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;
}
@ -1207,7 +1212,9 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi
*buffer = 0;
}
gfx_draw_string_left_clipped(dpi, STR_STRING, &bufferWithColour, colour, screenCoords, width_limit);
auto ft = Formatter::Common();
ft.Add<const char*>(gCommonStringFormatBuffer);
DrawTextEllipsised(dpi, screenCoords, width_limit, STR_STRING, ft, colour);
}
screenCoords.y += SCROLLABLE_ROW_HEIGHT;
}

View File

@ -923,7 +923,7 @@ static void window_editor_objective_options_main_paint(rct_window* w, rct_drawpi
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(parkName);
gfx_draw_string_left_clipped(dpi, STR_WINDOW_PARK_NAME, gCommonFormatArgs, COLOUR_BLACK, screenCoords, width);
DrawTextEllipsised(dpi, screenCoords, width, STR_WINDOW_PARK_NAME, ft, COLOUR_BLACK);
}
// Scenario name
@ -933,7 +933,7 @@ static void window_editor_objective_options_main_paint(rct_window* w, rct_drawpi
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(gS6Info.name);
gfx_draw_string_left_clipped(dpi, STR_WINDOW_SCENARIO_NAME, gCommonFormatArgs, COLOUR_BLACK, screenCoords, width);
DrawTextEllipsised(dpi, screenCoords, width, STR_WINDOW_SCENARIO_NAME, ft, COLOUR_BLACK);
// Scenario details label
screenCoords = w->windowPos + ScreenCoordsXY{ 8, w->widgets[WIDX_DETAILS].top };

View File

@ -1229,8 +1229,7 @@ static void window_finances_marketing_paint(rct_window* w, rct_drawpixelinfo* dp
}
// Advertisement
gfx_draw_string_left_clipped(
dpi, MarketingCampaignNames[i][1], gCommonFormatArgs, COLOUR_BLACK, screenCoords + ScreenCoordsXY{ 4, 0 }, 296);
DrawTextEllipsised(dpi, screenCoords + ScreenCoordsXY{ 4, 0 }, 296, MarketingCampaignNames[i][1], ft, COLOUR_BLACK);
// Duration
uint16_t weeksRemaining = campaign->WeeksLeft;

View File

@ -1126,7 +1126,7 @@ void window_guest_overview_paint(rct_window* w, rct_drawpixelinfo* dpi)
rct_widget* widget = &w->widgets[WIDX_ACTION_LBL];
auto screenPos = w->windowPos + ScreenCoordsXY{ widget->midX(), widget->top - 1 };
int32_t width = widget->width();
gfx_draw_string_centred_clipped(dpi, STR_BLACK_STRING, gCommonFormatArgs, COLOUR_BLACK, screenPos, width);
DrawTextEllipsised(dpi, screenPos, width, STR_BLACK_STRING, ft, COLOUR_BLACK, TextAlignment::CENTRE);
// Draw the marquee thought
widget = &w->widgets[WIDX_MARQUEE];
@ -1160,8 +1160,8 @@ void window_guest_overview_paint(rct_window* w, rct_drawpixelinfo* dpi)
}
screenPos.x = widget->width() - w->list_information_type;
peep_thought_set_format_args(&peep->Thoughts[i]);
gfx_draw_string_left(&dpi_marquee, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, { screenPos.x, 0 });
peep_thought_set_format_args(&peep->Thoughts[i], ft);
DrawTextBasic(&dpi_marquee, { screenPos.x, 0 }, STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK);
}
/**
@ -1774,7 +1774,7 @@ void window_guest_rides_paint(rct_window* w, rct_drawpixelinfo* dpi)
ride->FormatNameTo(ft);
}
}
gfx_draw_string_left_clipped(dpi, STR_FAVOURITE_RIDE, gCommonFormatArgs, COLOUR_BLACK, screenCoords, w->width - 14);
DrawTextEllipsised(dpi, screenCoords, w->width - 14, STR_FAVOURITE_RIDE, 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
- 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(
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 (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;
}
gfx_draw_string_left_clipped(dpi, format, _window_guest_list_filter_arguments.args, COLOUR_BLACK, screenCoords, 310);
{
Formatter ft(_window_guest_list_filter_arguments.args);
DrawTextEllipsised(dpi, screenCoords, 310, format, ft, COLOUR_BLACK);
}
// Number of guests (list items)
if (_window_guest_list_selected_tab == PAGE_INDIVIDUAL)
@ -782,7 +786,7 @@ static void window_guest_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
}
auto ft = Formatter::Common();
peep->FormatNameTo(ft);
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 0, y }, 113);
DrawTextEllipsised(dpi, { 0, y }, 113, format, ft, COLOUR_BLACK);
switch (_window_guest_list_selected_view)
{
@ -797,7 +801,7 @@ static void window_guest_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
// Action
ft = Formatter::Common();
peep->FormatActionTo(ft);
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 133, y }, 314);
DrawTextEllipsised(dpi, { 133, y }, 314, format, ft, COLOUR_BLACK);
break;
case VIEW_THOUGHTS:
// For each thought
@ -811,8 +815,8 @@ static void window_guest_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
if (thought->freshness > 5)
break;
peep_thought_set_format_args(&peep->Thoughts[j]);
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 118, y }, 329);
peep_thought_set_format_args(&peep->Thoughts[j], ft);
DrawTextEllipsised(dpi, { 118, y }, 329, format, ft, COLOUR_BLACK);
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);
// Draw action
std::memcpy(
gCommonFormatArgs, _window_guest_list_groups_arguments[i].args,
std::min(sizeof(gCommonFormatArgs), sizeof(_window_guest_list_groups_arguments[i].args)));
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 0, y }, 414);
Formatter ft(_window_guest_list_groups_arguments[i].args);
DrawTextEllipsised(dpi, { 0, y }, 414, format, ft, COLOUR_BLACK);
// Draw guest count
auto ft = Formatter::Common();
ft = Formatter::Common();
ft.Add<rct_string_id>(STR_GUESTS_COUNT_COMMA_SEP);
ft.Add<uint32_t>(numGuests);
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];
if (thought->freshness <= 5 && thought->type != PEEP_THOUGHT_TYPE_NONE)
{
std::memset(gCommonFormatArgs, 0, sizeof(gCommonFormatArgs));
peep_thought_set_format_args(thought);
std::memcpy(result.args, gCommonFormatArgs, std::min(sizeof(gCommonFormatArgs), sizeof(result.args)));
peep_thought_set_format_args(thought, ft);
}
break;
}

View File

@ -241,8 +241,7 @@ static void window_install_track_paint(rct_window* w, rct_drawpixelinfo* dpi)
if (!gTrackDesignSceneryToggle)
{
// Scenery not available
gfx_draw_string_centred_clipped(
dpi, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, nullptr, COLOUR_BLACK, screenPos, 368);
DrawTextEllipsised(dpi, screenPos, 308, STR_BLACK_STRING, Formatter::Common(), COLOUR_BLACK, TextAlignment::CENTRE);
screenPos.y -= LIST_ROW_HEIGHT;
}
}
@ -314,7 +313,7 @@ static void window_install_track_paint(rct_window* w, rct_drawpixelinfo* dpi)
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_RIDE_LENGTH_ENTRY);
ft.Add<uint16_t>(td6->ride_length);
gfx_draw_string_left_clipped(dpi, STR_TRACK_LIST_RIDE_LENGTH, gCommonFormatArgs, COLOUR_BLACK, screenPos, 214);
DrawTextEllipsised(dpi, screenPos, 214, STR_TRACK_LIST_RIDE_LENGTH, ft, COLOUR_BLACK);
screenPos.y += LIST_ROW_HEIGHT;
}

View File

@ -718,8 +718,7 @@ static void window_loadsave_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Draw path text
auto ft = Formatter::Common();
ft.Add<utf8*>(Platform::StrDecompToPrecomp(buffer));
gfx_draw_string_left_clipped(
dpi, STR_STRING, gCommonFormatArgs, COLOUR_BLACK, { w->windowPos.x + 4, w->windowPos.y + 20 }, w->width - 8);
DrawTextEllipsised(dpi, { w->windowPos.x + 4, w->windowPos.y + 20 }, w->width - 8, STR_STRING, ft, COLOUR_BLACK);
// Name button text
rct_string_id id = STR_NONE;
@ -784,7 +783,7 @@ static void window_loadsave_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
ft.Add<rct_string_id>(STR_STRING);
ft.Add<char*>(_listItems[i].name.c_str());
int32_t max_file_width = w->widgets[WIDX_SORT_NAME].width() - 10;
gfx_draw_string_left_clipped(dpi, stringId, gCommonFormatArgs, COLOUR_BLACK, { 10, y }, max_file_width);
DrawTextEllipsised(dpi, { 10, y }, max_file_width, stringId, ft, COLOUR_BLACK);
// Print formatted modified date, if this is a file
if (_listItems[i].type == TYPE_FILE)
@ -792,14 +791,12 @@ static void window_loadsave_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<char*>(_listItems[i].date_formatted.c_str());
gfx_draw_string_right_clipped(
dpi, stringId, gCommonFormatArgs, COLOUR_BLACK, { dateAnchor - DATE_TIME_GAP, y }, maxDateWidth);
DrawTextEllipsised(dpi, { dateAnchor - DATE_TIME_GAP, y }, maxDateWidth, stringId, ft, COLOUR_BLACK);
ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<char*>(_listItems[i].time_formatted.c_str());
gfx_draw_string_left_clipped(
dpi, stringId, gCommonFormatArgs, COLOUR_BLACK, { dateAnchor + DATE_TIME_GAP, y }, maxTimeWidth);
DrawTextEllipsised(dpi, { dateAnchor + DATE_TIME_GAP, y }, maxTimeWidth, stringId, ft, COLOUR_BLACK);
}
}
}

View File

@ -703,7 +703,7 @@ static void window_multiplayer_players_scrollpaint(rct_window* w, rct_drawpixeli
{
ft.Add<rct_string_id>(STR_ACTION_NA);
}
gfx_draw_string_left_clipped(dpi, STR_BLACK_STRING, gCommonFormatArgs, COLOUR_BLACK, { 256, screenCoords.y }, 100);
DrawTextEllipsised(dpi, { 256, screenCoords.y }, 100, STR_BLACK_STRING, ft, COLOUR_BLACK);
// Draw ping
lineCh = buffer;
@ -914,9 +914,9 @@ static void window_multiplayer_groups_paint(rct_window* w, rct_drawpixelinfo* dp
safe_strcpy(lineCh, network_get_group_name(group), sizeof(buffer) - (lineCh - buffer));
auto ft = Formatter::Common();
ft.Add<const char*>(buffer);
gfx_draw_string_centred_clipped(
dpi, STR_STRING, gCommonFormatArgs, COLOUR_BLACK, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top },
widget->width() - 8);
DrawTextEllipsised(
dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft,
COLOUR_BLACK, TextAlignment::CENTRE);
}
auto screenPos = w->windowPos
@ -941,9 +941,9 @@ static void window_multiplayer_groups_paint(rct_window* w, rct_drawpixelinfo* dp
safe_strcpy(lineCh, network_get_group_name(group), sizeof(buffer) - (lineCh - buffer));
auto ft = Formatter::Common();
ft.Add<const char*>(buffer);
gfx_draw_string_centred_clipped(
dpi, STR_STRING, gCommonFormatArgs, COLOUR_BLACK, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top },
widget->width() - 8);
DrawTextEllipsised(
dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft,
COLOUR_BLACK, TextAlignment::CENTRE);
}
}

View File

@ -925,8 +925,9 @@ static void window_new_ride_paint_ride_information(
if (availabilityString[0] != 0)
{
const char* drawString = availabilityString;
gfx_draw_string_left_clipped(
dpi, STR_AVAILABLE_VEHICLES, &drawString, COLOUR_BLACK, screenPos + ScreenCoordsXY{ 0, 39 }, WW - 2);
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)

View File

@ -566,8 +566,7 @@ static void window_object_load_error_paint(rct_window* w, rct_drawpixelinfo* dpi
ft = Formatter::Common();
ft.Add<rct_string_id>(STR_OBJECT_ERROR_WINDOW_FILE);
ft.Add<utf8*>(file_path.c_str());
gfx_draw_string_left_clipped(
dpi, STR_BLACK_STRING, gCommonFormatArgs, COLOUR_BLACK, { w->windowPos.x + 5, w->windowPos.y + 43 }, WW - 5);
DrawTextEllipsised(dpi, { w->windowPos.x + 5, w->windowPos.y + 43 }, WW - 5, STR_BLACK_STRING, ft, COLOUR_BLACK);
}
static void window_object_load_error_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)

View File

@ -2088,7 +2088,7 @@ static void window_options_paint(rct_window* w, rct_drawpixelinfo* dpi)
uint32_t padding = widgetHeight > lineHeight ? (widgetHeight - lineHeight) / 2 : 0;
ScreenCoordsXY screenCoords = { w->windowPos.x + pathWidget.left + 1,
w->windowPos.y + pathWidget.top + static_cast<int32_t>(padding) };
gfx_draw_string_left_clipped(dpi, STR_STRING, gCommonFormatArgs, w->colours[1], screenCoords, 277);
DrawTextEllipsised(dpi, screenCoords, 277, STR_STRING, ft, w->colours[1]);
break;
}
}

View File

@ -875,9 +875,9 @@ static void window_park_entrance_paint(rct_window* w, rct_drawpixelinfo* dpi)
ft.Add<rct_string_id>(park_is_open() ? STR_PARK_OPEN : STR_PARK_CLOSED);
labelWidget = &window_park_entrance_widgets[WIDX_STATUS];
gfx_draw_string_centred_clipped(
dpi, STR_BLACK_STRING, gCommonFormatArgs, COLOUR_BLACK,
w->windowPos + ScreenCoordsXY{ labelWidget->midX(), labelWidget->top }, labelWidget->width());
DrawTextEllipsised(
dpi, w->windowPos + ScreenCoordsXY{ labelWidget->midX(), labelWidget->top }, labelWidget->width(), STR_BLACK_STRING, ft,
COLOUR_BLACK, TextAlignment::CENTRE);
}
/**

View File

@ -377,9 +377,9 @@ void window_player_overview_paint(rct_window* w, rct_drawpixelinfo* dpi)
auto ft = Formatter::Common();
ft.Add<const char*>(buffer);
gfx_draw_string_centred_clipped(
dpi, STR_STRING, gCommonFormatArgs, COLOUR_BLACK, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top },
widget->width() - 8);
DrawTextEllipsised(
dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft,
COLOUR_BLACK, TextAlignment::CENTRE);
}
// Draw ping
@ -405,7 +405,7 @@ void window_player_overview_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
ft.Add<rct_string_id>(STR_ACTION_NA);
}
gfx_draw_string_centred_clipped(dpi, STR_LAST_ACTION_RAN, gCommonFormatArgs, COLOUR_BLACK, screenCoords, width);
DrawTextEllipsised(dpi, screenCoords, width, STR_LAST_ACTION_RAN, ft, COLOUR_BLACK);
if (w->viewport != nullptr && w->var_492 != -1)
{

View File

@ -2840,9 +2840,9 @@ static void window_ride_main_paint(rct_window* w, rct_drawpixelinfo* dpi)
ft = Formatter::Common();
widget = &window_ride_main_widgets[WIDX_STATUS];
rct_string_id rideStatus = window_ride_get_status(w, ft);
gfx_draw_string_centred_clipped(
dpi, rideStatus, gCommonFormatArgs, COLOUR_BLACK,
w->windowPos + ScreenCoordsXY{ (widget->left + widget->right) / 2, widget->top }, widget->width());
DrawTextEllipsised(
dpi, w->windowPos + ScreenCoordsXY{ (widget->left + widget->right) / 2, widget->top }, widget->width(), rideStatus, ft,
COLOUR_BLACK, TextAlignment::CENTRE);
}
#pragma endregion
@ -5027,8 +5027,8 @@ static void window_ride_colour_paint(rct_window* w, rct_drawpixelinfo* dpi)
}
}
gfx_draw_string_left_clipped(
dpi, STR_STATION_STYLE, gCommonFormatArgs, COLOUR_BLACK, { w->windowPos.x + 3, w->windowPos.y + 103 }, 97);
DrawTextEllipsised(
dpi, { w->windowPos.x + 3, w->windowPos.y + 103 }, 97, STR_STATION_STYLE, Formatter::Common(), COLOUR_BLACK);
}
}
@ -5765,7 +5765,7 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi
ft.Add<uint16_t>(0);
ft.Add<uint16_t>(0);
ft.Add<uint16_t>(0);
gfx_draw_string_left_clipped(dpi, STR_RIDE_TIME, gCommonFormatArgs, COLOUR_BLACK, screenCoords, 308);
DrawTextEllipsised(dpi, screenCoords, 308, STR_RIDE_TIME, ft, COLOUR_BLACK);
screenCoords.y += LIST_ROW_HEIGHT;
}
@ -5803,7 +5803,8 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi
ft.Add<uint16_t>(0);
ft.Add<uint16_t>(0);
ft.Add<uint16_t>(0);
gfx_draw_string_left_clipped(dpi, STR_RIDE_LENGTH, gCommonFormatArgs, COLOUR_BLACK, screenCoords, 308);
DrawTextEllipsised(dpi, screenCoords, 308, STR_RIDE_LENGTH, ft, COLOUR_BLACK);
screenCoords.y += LIST_ROW_HEIGHT;
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_G_FORCES))

View File

@ -609,7 +609,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
// Ride name
auto ft = Formatter::Common();
ride->FormatNameTo(ft);
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 0, y - 1 }, 159);
DrawTextEllipsised(dpi, { 0, y - 1 }, 159, format, ft, COLOUR_BLACK);
// Ride information
ft.Rewind();
@ -751,7 +751,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
ft.Rewind();
ft.Add<rct_string_id>(formatSecondary);
}
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 160, y - 1 }, 157);
DrawTextEllipsised(dpi, { 160, y - 1 }, 157, format, ft, COLOUR_BLACK);
y += SCROLLABLE_ROW_HEIGHT;
}
}

View File

@ -476,8 +476,9 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi)
auto screenPos = w->windowPos
+ ScreenCoordsXY{ window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4,
window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5 };
gfx_draw_string_centred_clipped(
dpi, STR_SCENARIO_LOCKED, nullptr, COLOUR_BLACK, screenPos + ScreenCoordsXY{ 85, 0 }, 170);
DrawTextEllipsised(
dpi, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_SCENARIO_LOCKED, Formatter::Common(), COLOUR_BLACK,
TextAlignment::CENTRE);
gfx_draw_string_left_wrapped(
dpi, nullptr, screenPos + ScreenCoordsXY{ 0, 15 }, 170, STR_SCENARIO_LOCKED_DESC, COLOUR_BLACK);
}
@ -505,8 +506,8 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi)
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(scenario->name);
gfx_draw_string_centred_clipped(
dpi, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, screenPos + ScreenCoordsXY{ 85, 0 }, 170);
DrawTextEllipsised(
dpi, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK, TextAlignment::CENTRE);
screenPos.y += 15;
// Scenario details

View File

@ -1188,9 +1188,8 @@ void window_scenery_paint(rct_window* w, rct_drawpixelinfo* dpi)
auto ft = Formatter::Common();
ft.Add<rct_string_id>(sceneryEntry != nullptr ? sceneryEntry->name : static_cast<rct_string_id>(STR_UNKNOWN_OBJECT_TYPE));
gfx_draw_string_left_clipped(
dpi, STR_BLACK_STRING, gCommonFormatArgs, COLOUR_BLACK, { w->windowPos.x + 3, w->windowPos.y + w->height - 13 },
w->width - 19);
DrawTextEllipsised(
dpi, { w->windowPos.x + 3, w->windowPos.y + w->height - 13 }, w->width - 19, STR_BLACK_STRING, ft, 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.
gfx_draw_string_left_clipped(
dpi, STR_STRING, &serverInfoToShow, colour, screenCoords + ScreenCoordsXY{ 0, 3 }, spaceAvailableForInfo);
auto ft = Formatter::Common();
ft.Add<const char*>(serverInfoToShow);
DrawTextEllipsised(dpi, screenCoords + ScreenCoordsXY{ 0, 3 }, spaceAvailableForInfo, STR_STRING, ft, colour);
int32_t right = width - 7 - SCROLLBAR_WIDTH;

View File

@ -373,7 +373,7 @@ static void window_shortcut_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_SHORTCUT_ENTRY_FORMAT);
ft.Add<rct_string_id>(ShortcutList[i].StringId);
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 0, y - 1 }, bindingOffset);
DrawTextEllipsised(dpi, { 0, y - 1 }, bindingOffset, format, ft, COLOUR_BLACK);
char keybinding[128];
keyboard_shortcuts_format_string(keybinding, 128, static_cast<int32_t>(ShortcutList[i].ShortcutId));
@ -384,7 +384,7 @@ static void window_shortcut_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<char*>(keybinding);
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { bindingOffset, y - 1 }, maxWidth);
DrawTextEllipsised(dpi, { bindingOffset, y - 1 }, maxWidth, format, ft, COLOUR_BLACK);
}
}
}

View File

@ -1000,7 +1000,7 @@ void window_staff_overview_paint(rct_window* w, rct_drawpixelinfo* dpi)
rct_widget* widget = &w->widgets[WIDX_BTM_LABEL];
auto screenPos = w->windowPos + ScreenCoordsXY{ widget->midX(), widget->top };
int32_t width = widget->width();
gfx_draw_string_centred_clipped(dpi, STR_BLACK_STRING, gCommonFormatArgs, COLOUR_BLACK, screenPos, width);
DrawTextEllipsised(dpi, screenPos, width, STR_BLACK_STRING, ft, COLOUR_BLACK, TextAlignment::CENTRE);
}
/**

View File

@ -715,11 +715,11 @@ void window_staff_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_
auto ft = Formatter::Common();
peep->FormatNameTo(ft);
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 0, y }, nameColumnSize);
DrawTextEllipsised(dpi, { 0, y }, nameColumnSize, format, ft, COLOUR_BLACK);
ft = Formatter::Common();
peep->FormatActionTo(ft);
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { actionOffset, y }, actionColumnSize);
DrawTextEllipsised(dpi, { actionOffset, y }, actionColumnSize, format, ft, COLOUR_BLACK);
// True if a patrol path is set for the worker
if (gStaffModes[peep->StaffId] == StaffMode::Patrol)

View File

@ -833,19 +833,22 @@ void window_themes_paint(rct_window* w, rct_drawpixelinfo* dpi)
if (_selected_tab == WINDOW_THEMES_TAB_SETTINGS)
{
size_t activeAvailableThemeIndex = theme_manager_get_active_available_theme_index();
const utf8* activeThemeName = theme_manager_get_available_theme_name(activeAvailableThemeIndex);
Formatter::Common().Add<const utf8*>(activeThemeName);
gfx_draw_string_left(
dpi, STR_THEMES_LABEL_CURRENT_THEME, nullptr, w->colours[1],
w->windowPos + ScreenCoordsXY{ 10, window_themes_widgets[WIDX_THEMES_PRESETS].top + 1 });
gfx_draw_string_left_clipped(
dpi, STR_STRING, gCommonFormatArgs, w->colours[1],
w->windowPos
+ ScreenCoordsXY{ window_themes_widgets[WIDX_THEMES_PRESETS].left + 1,
window_themes_widgets[WIDX_THEMES_PRESETS].top },
w->windowPos.x + window_themes_widgets[WIDX_THEMES_PRESETS_DROPDOWN].left
- window_themes_widgets[WIDX_THEMES_PRESETS].left - 4);
size_t activeAvailableThemeIndex = theme_manager_get_active_available_theme_index();
const utf8* activeThemeName = theme_manager_get_available_theme_name(activeAvailableThemeIndex);
auto ft = Formatter::Common();
ft.Add<const utf8*>(activeThemeName);
auto screenPos = w->windowPos
+ ScreenCoordsXY{ window_themes_widgets[WIDX_THEMES_PRESETS].left + 1,
window_themes_widgets[WIDX_THEMES_PRESETS].top };
auto width = w->windowPos.x + window_themes_widgets[WIDX_THEMES_PRESETS_DROPDOWN].left
- window_themes_widgets[WIDX_THEMES_PRESETS].left - 4;
DrawTextEllipsised(dpi, screenPos, width, STR_STRING, ft, w->colours[1]);
}
}

View File

@ -1722,33 +1722,33 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
rct_widget* widget;
if ((widget = &w->widgets[WIDX_COLUMN_TYPE])->type != WWT_EMPTY)
{
gfx_draw_string_left_clipped(
dpi, STR_TILE_INSPECTOR_ELEMENT_TYPE, gCommonFormatArgs, w->colours[1],
{ w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width());
DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_ELEMENT_TYPE, Formatter::Common(), w->colours[1]);
}
if ((widget = &w->widgets[WIDX_COLUMN_BASEHEIGHT])->type != WWT_EMPTY)
{
gfx_draw_string_left_clipped(
dpi, STR_TILE_INSPECTOR_BASE_HEIGHT_SHORT, gCommonFormatArgs, w->colours[1],
{ w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width());
DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_BASE_HEIGHT_SHORT, Formatter::Common(), w->colours[1]);
}
if ((widget = &w->widgets[WIDX_COLUMN_CLEARANCEHEIGHT])->type != WWT_EMPTY)
{
gfx_draw_string_left_clipped(
dpi, STR_TILE_INSPECTOR_CLEARANGE_HEIGHT_SHORT, gCommonFormatArgs, w->colours[1],
{ w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width());
DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_CLEARANGE_HEIGHT_SHORT, Formatter::Common(), w->colours[1]);
}
if ((widget = &w->widgets[WIDX_COLUMN_GHOSTFLAG])->type != WWT_EMPTY)
{
gfx_draw_string_left_clipped(
dpi, STR_TILE_INSPECTOR_FLAG_GHOST_SHORT, gCommonFormatArgs, w->colours[1],
{ w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width());
DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_FLAG_GHOST_SHORT, Formatter::Common(), w->colours[1]);
}
if ((widget = &w->widgets[WIDX_COLUMN_LASTFLAG])->type != WWT_EMPTY)
{
gfx_draw_string_left_clipped(
dpi, STR_TILE_INSPECTOR_FLAG_LAST_SHORT, gCommonFormatArgs, w->colours[1],
{ w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width());
DrawTextEllipsised(
dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(),
STR_TILE_INSPECTOR_FLAG_LAST_SHORT, Formatter::Common(), w->colours[1]);
}
ScreenCoordsXY screenCoords(w->windowPos.x, w->windowPos.y);
@ -2323,9 +2323,8 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo*
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<char*>(typeName);
gfx_draw_string_left_clipped(
dpi, stringFormat, gCommonFormatArgs, COLOUR_BLACK, screenCoords + ScreenCoordsXY{ COL_X_TYPE + 3, 0 },
COL_X_BH); // 3px padding
DrawTextEllipsised(
dpi, screenCoords + ScreenCoordsXY{ COL_X_TYPE + 3, 0 }, COL_X_BH, stringFormat, ft, COLOUR_BLACK); // 3px padding
// Base height
ft = Formatter::Common();

View File

@ -739,29 +739,30 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo*
dpi, STR_TITLE_COMMAND_EDITOR_COMMAND_LABEL, nullptr, w->colours[1], w->windowPos + ScreenCoordsXY{ WS, BY - 14 });
// Command dropdown name
gfx_draw_string_left_clipped(
dpi, command_info.nameStringId, nullptr, w->colours[1],
{ 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);
DrawTextEllipsised(
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,
Formatter::Common(), w->colours[1]);
// Label (e.g. "Location:")
gfx_draw_string_left(dpi, command_info.descStringId, nullptr, w->colours[1], w->windowPos + ScreenCoordsXY{ WS, BY2 - 14 });
if (command.Type == TITLE_SCRIPT_SPEED)
{
gfx_draw_string_left_clipped(
dpi, SpeedNames[command.Speed - 1], nullptr, w->colours[1],
{ 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);
DrawTextEllipsised(
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],
Formatter::Common(), w->colours[1]);
}
if (command.Type == TITLE_SCRIPT_FOLLOW)
{
uint8_t colour = COLOUR_BLACK;
rct_string_id spriteString = STR_TITLE_COMMAND_EDITOR_FORMAT_SPRITE_NAME;
auto ft = Formatter::Common();
if (command.SpriteIndex != SPRITE_INDEX_NULL)
{
window_draw_viewport(dpi, w);
Formatter::Common().Add<utf8*>(command.SpriteName);
ft.Add<utf8*>(command.SpriteName);
}
else
{
@ -772,37 +773,36 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo*
gfx_set_dirty_blocks(
{ { w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_VIEWPORT].left, w->widgets[WIDX_VIEWPORT].top } },
{ w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_VIEWPORT].right, w->widgets[WIDX_VIEWPORT].bottom } } });
gfx_draw_string_left_clipped(
dpi, spriteString, gCommonFormatArgs, colour,
{ w->windowPos.x + w->widgets[WIDX_VIEWPORT].left + 2, w->windowPos.y + w->widgets[WIDX_VIEWPORT].top + 1 },
w->widgets[WIDX_VIEWPORT].width() - 2);
DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_VIEWPORT].left + 2, w->windowPos.y + w->widgets[WIDX_VIEWPORT].top + 1 },
w->widgets[WIDX_VIEWPORT].width() - 2, spriteString, ft, colour);
}
else if (command.Type == TITLE_SCRIPT_LOAD)
{
if (command.SaveIndex == SAVE_INDEX_INVALID)
{
gfx_draw_string_left_clipped(
dpi, STR_TITLE_COMMAND_EDITOR_NO_SAVE_SELECTED, nullptr, w->colours[1],
{ 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);
DrawTextEllipsised(
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,
STR_TITLE_COMMAND_EDITOR_NO_SAVE_SELECTED, Formatter::Common(), w->colours[1]);
}
else
{
Formatter::Common().Add<utf8*>(_sequence->Saves[command.SaveIndex]);
gfx_draw_string_left_clipped(
dpi, STR_STRING, gCommonFormatArgs, w->colours[1],
{ 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);
auto ft = Formatter::Common();
ft.Add<utf8*>(_sequence->Saves[command.SaveIndex]);
DrawTextEllipsised(
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, STR_STRING, ft, w->colours[1]);
}
}
else if (command.Type == TITLE_SCRIPT_LOADSC)
{
if (command.Scenario[0] == '\0')
{
gfx_draw_string_left_clipped(
dpi, STR_TITLE_COMMAND_EDITOR_NO_SCENARIO_SELECTED, nullptr, w->colours[1],
{ 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);
DrawTextEllipsised(
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,
STR_TITLE_COMMAND_EDITOR_NO_SCENARIO_SELECTED, Formatter::Common(), w->colours[1]);
}
else
{
@ -817,11 +817,11 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo*
{
nameString = STR_TITLE_COMMAND_EDITOR_MISSING_SCENARIO;
}
Formatter::Common().Add<const char*>(name);
gfx_draw_string_left_clipped(
dpi, nameString, gCommonFormatArgs, w->colours[1],
{ 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);
auto ft = Formatter::Common();
ft.Add<const char*>(name);
DrawTextEllipsised(
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, nameString, ft, w->colours[1]);
}
}
}

View File

@ -831,17 +831,19 @@ static void window_title_editor_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
case WINDOW_TITLE_EDITOR_TAB_PRESETS:
{
auto ft = Formatter::Common();
ft.Add<const char*>(_sequenceName);
gfx_draw_string_left(
dpi, STR_TITLE_SEQUENCE, nullptr, w->colours[1],
w->windowPos + ScreenCoordsXY{ 10, window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].top + 1 });
gfx_draw_string_left_clipped(
dpi, STR_STRING, gCommonFormatArgs, w->colours[1],
{ w->windowPos.x + window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].left + 1,
w->windowPos.y + window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].top },
w->windowPos.x + window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS_DROPDOWN].left
- window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].left - 4);
auto ft = Formatter::Common();
ft.Add<const char*>(_sequenceName);
ScreenCoordsXY screenPos = { w->windowPos.x + window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].left + 1,
w->windowPos.y + window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].top };
auto width = w->windowPos.x + window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS_DROPDOWN].left
- window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].left - 4;
DrawTextEllipsised(dpi, screenPos, width, STR_STRING, ft, w->colours[1]);
break;
}
case WINDOW_TITLE_EDITOR_TAB_SAVES:

View File

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

View File

@ -744,16 +744,6 @@ void gfx_draw_string_centred(
void gfx_draw_string_right(
rct_drawpixelinfo* dpi, rct_string_id format, void* args, uint8_t colour, const ScreenCoordsXY& coords);
/** @deprecated */
void gfx_draw_string_left_clipped(
rct_drawpixelinfo* dpi, rct_string_id format, void* args, uint8_t colour, const ScreenCoordsXY& coords, int32_t width);
/** @deprecated */
void gfx_draw_string_centred_clipped(
rct_drawpixelinfo* dpi, rct_string_id format, void* args, uint8_t colour, const ScreenCoordsXY& coords, int32_t width);
/** @deprecated */
void gfx_draw_string_right_clipped(
rct_drawpixelinfo* dpi, rct_string_id format, void* args, uint8_t colour, const ScreenCoordsXY& coords, int32_t width);
int32_t gfx_draw_string_left_wrapped(
rct_drawpixelinfo* dpi, void* args, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, uint8_t colour);
int32_t gfx_draw_string_centred_wrapped(

View File

@ -132,9 +132,10 @@ void DrawTextBasic(
}
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)
{
const void* args = ft.GetStartBuf();
TextPaint textPaint = { colour, FONT_SPRITE_BASE_MEDIUM, underline, alignment };
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
@ -145,13 +146,6 @@ void DrawTextEllipsised(
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)
{
TextPaint textPaint = { colour, gCurrentFontSpriteBase, false, TextAlignment::LEFT };
@ -177,25 +171,6 @@ void gfx_draw_string_right(
DrawTextBasic(dpi, coords, format, args, colour, TextAlignment::RIGHT);
}
// Ellipsised
void gfx_draw_string_left_clipped(
rct_drawpixelinfo* dpi, rct_string_id format, void* args, uint8_t colour, const ScreenCoordsXY& coords, int32_t width)
{
DrawTextEllipsised(dpi, coords, width, format, args, colour, TextAlignment::LEFT);
}
void gfx_draw_string_centred_clipped(
rct_drawpixelinfo* dpi, rct_string_id format, void* args, uint8_t colour, const ScreenCoordsXY& coords, int32_t width)
{
DrawTextEllipsised(dpi, coords, width, format, args, colour, TextAlignment::CENTRE);
}
void gfx_draw_string_right_clipped(
rct_drawpixelinfo* dpi, rct_string_id format, void* args, uint8_t colour, const ScreenCoordsXY& coords, int32_t width)
{
DrawTextEllipsised(dpi, coords, width, format, args, colour, TextAlignment::RIGHT);
}
// Wrapping
int32_t gfx_draw_string_left_wrapped(
rct_drawpixelinfo* dpi, void* args, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, uint8_t colour)

View File

@ -52,13 +52,10 @@ public:
void DrawTextBasic(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const Formatter& ft, colour_t colour,
TextAlignment alignment, bool underline = false);
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, bool underline = false);
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, 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, bool underline = false);
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_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]);
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_days_in_queue();
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_large(Peep* peep);
void game_command_pickup_guest(