Migrate 40 calls to set_format_arg()

This commit is contained in:
Gymnasiast 2020-06-03 00:40:47 +02:00
parent 2a8ab374d3
commit f640446d58
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
12 changed files with 72 additions and 40 deletions

View File

@ -1017,8 +1017,9 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
totalSelectable = 4;
set_format_arg(0, uint16_t, numSelected);
set_format_arg(2, uint16_t, totalSelectable);
auto ft = Formatter::Common();
ft.Add<uint16_t>(numSelected);
ft.Add<uint16_t>(totalSelectable);
gfx_draw_string_left(dpi, STR_OBJECT_SELECTION_SELECTION_SIZE, gCommonFormatArgs, COLOUR_BLACK, x, y);
}
@ -1065,16 +1066,18 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
x = w->windowPos.x + (widget->left + widget->right) / 2 + 1;
y = w->windowPos.y + widget->bottom + 3;
width = w->width - w->widgets[WIDX_LIST].right - 6;
set_format_arg(0, rct_string_id, STR_STRING);
set_format_arg(2, const char*, listItem->repositoryItem->Name.c_str());
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, x, y, width);
// Draw description of object
auto description = object_get_description(_loadedObject);
if (!description.empty())
{
set_format_arg(0, rct_string_id, STR_STRING);
set_format_arg(2, const char*, description.c_str());
ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(description.c_str());
x = w->windowPos.x + w->widgets[WIDX_LIST].right + 4;
y += 15;
@ -1101,8 +1104,9 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
// Draw object dat name
const char* path = path_get_filename(listItem->repositoryItem->Path.c_str());
set_format_arg(0, rct_string_id, STR_STRING);
set_format_arg(2, const char*, path);
ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<const char*>(path);
gfx_draw_string_right(dpi, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, w->windowPos.x + w->width - 5, y);
}

View File

@ -692,7 +692,8 @@ static void window_finances_summary_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Loan and interest rate
gfx_draw_string_left(dpi, STR_FINANCES_SUMMARY_LOAN, nullptr, COLOUR_BLACK, w->windowPos.x + 8, w->windowPos.y + 279);
set_format_arg(0, uint16_t, gBankLoanInterestRate);
auto ft = Formatter::Common();
ft.Add<uint16_t>(gBankLoanInterestRate);
gfx_draw_string_left(
dpi, STR_FINANCES_SUMMARY_AT_X_PER_YEAR, gCommonFormatArgs, COLOUR_BLACK, w->windowPos.x + 167, w->windowPos.y + 279);
@ -704,7 +705,8 @@ static void window_finances_summary_paint(rct_window* w, rct_drawpixelinfo* dpi)
if (gScenarioObjectiveType == OBJECTIVE_MONTHLY_FOOD_INCOME)
{
money32 lastMonthProfit = finance_get_last_month_shop_profit();
set_format_arg(0, money32, lastMonthProfit);
ft = Formatter::Common();
ft.Add<money32>(lastMonthProfit);
gfx_draw_string_left(
dpi, STR_LAST_MONTH_PROFIT_FROM_FOOD_DRINK_MERCHANDISE_SALES_LABEL, gCommonFormatArgs, COLOUR_BLACK,
w->windowPos.x + 280, w->windowPos.y + 279);

View File

@ -1697,7 +1697,8 @@ void window_guest_rides_paint(rct_window* w, rct_drawpixelinfo* dpi)
y = w->windowPos.y + window_guest_rides_widgets[WIDX_PAGE_BACKGROUND].bottom - 12;
set_format_arg(0, rct_string_id, STR_PEEP_FAVOURITE_RIDE_NOT_AVAILABLE);
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_PEEP_FAVOURITE_RIDE_NOT_AVAILABLE);
if (peep->FavouriteRide != RIDE_ID_NULL)
{
auto ride = get_ride(peep->FavouriteRide);
@ -1778,25 +1779,29 @@ void window_guest_finance_paint(rct_window* w, rct_drawpixelinfo* dpi)
int32_t y = w->windowPos.y + window_guest_finance_widgets[WIDX_PAGE_BACKGROUND].top + 4;
// Cash in pocket
set_format_arg(0, money32, peep->cash_in_pocket);
auto ft = Formatter::Common();
ft.Add<money32>(peep->cash_in_pocket);
gfx_draw_string_left(dpi, STR_GUEST_STAT_CASH_IN_POCKET, gCommonFormatArgs, COLOUR_BLACK, x, y);
// Cash spent
y += LIST_ROW_HEIGHT;
set_format_arg(0, money32, peep->cash_spent);
ft = Formatter::Common();
ft.Add<money32>(peep->cash_spent);
gfx_draw_string_left(dpi, STR_GUEST_STAT_CASH_SPENT, gCommonFormatArgs, COLOUR_BLACK, x, y);
y += LIST_ROW_HEIGHT * 2;
gfx_fill_rect_inset(dpi, x, y - 6, x + 179, y - 5, w->colours[1], INSET_RECT_FLAG_BORDER_INSET);
// Paid to enter
set_format_arg(0, money32, peep->PaidToEnter);
ft = Formatter::Common();
ft.Add<money32>(peep->PaidToEnter);
gfx_draw_string_left(dpi, STR_GUEST_EXPENSES_ENTRANCE_FEE, gCommonFormatArgs, COLOUR_BLACK, x, y);
// Paid on rides
y += LIST_ROW_HEIGHT;
set_format_arg(0, money32, peep->PaidOnRides);
set_format_arg(4, uint16_t, peep->no_of_rides);
ft = Formatter::Common();
ft.Add<money32>(peep->PaidOnRides);
ft.Add<uint16_t>(peep->no_of_rides);
if (peep->no_of_rides != 1)
{
gfx_draw_string_left(dpi, STR_GUEST_EXPENSES_RIDE_PLURAL, gCommonFormatArgs, COLOUR_BLACK, x, y);
@ -1808,8 +1813,9 @@ void window_guest_finance_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Paid on food
y += LIST_ROW_HEIGHT;
set_format_arg(0, money32, peep->PaidOnFood);
set_format_arg(4, uint16_t, peep->AmountOfFood);
ft = Formatter::Common();
ft.Add<money32>(peep->PaidOnFood);
ft.Add<uint16_t>(peep->AmountOfFood);
if (peep->AmountOfFood != 1)
{
gfx_draw_string_left(dpi, STR_GUEST_EXPENSES_FOOD_PLURAL, gCommonFormatArgs, COLOUR_BLACK, x, y);
@ -1821,8 +1827,9 @@ void window_guest_finance_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Paid on drinks
y += LIST_ROW_HEIGHT;
set_format_arg(0, money32, peep->paid_on_drink);
set_format_arg(4, uint16_t, peep->AmountOfDrinks);
ft = Formatter::Common();
ft.Add<money32>(peep->paid_on_drink);
ft.Add<uint16_t>(peep->AmountOfDrinks);
if (peep->AmountOfDrinks != 1)
{
gfx_draw_string_left(dpi, STR_GUEST_EXPENSES_DRINK_PLURAL, gCommonFormatArgs, COLOUR_BLACK, x, y);
@ -1834,8 +1841,9 @@ void window_guest_finance_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Paid on souvenirs
y += LIST_ROW_HEIGHT;
set_format_arg(0, money32, peep->PaidOnSouvenirs);
set_format_arg(4, uint16_t, peep->AmountOfSouvenirs);
ft = Formatter::Common();
ft.Add<money32>(peep->PaidOnSouvenirs);
ft.Add<uint16_t>(peep->AmountOfSouvenirs);
if (peep->AmountOfSouvenirs != 1)
{
gfx_draw_string_left(dpi, STR_GUEST_EXPENSES_SOUVENIR_PLURAL, gCommonFormatArgs, COLOUR_BLACK, x, y);
@ -2083,7 +2091,8 @@ void window_guest_debug_paint(rct_window* w, rct_drawpixelinfo* dpi)
auto screenCoords = ScreenCoordsXY{ w->windowPos.x + window_guest_debug_widgets[WIDX_PAGE_BACKGROUND].left + 4,
w->windowPos.y + window_guest_debug_widgets[WIDX_PAGE_BACKGROUND].top + 4 };
{
set_format_arg(0, uint32_t, peep->sprite_index);
auto ft = Formatter::Common();
ft.Add<uint32_t>(peep->sprite_index);
gfx_draw_string_left(dpi, STR_PEEP_DEBUG_SPRITE_INDEX, gCommonFormatArgs, 0, screenCoords.x, screenCoords.y);
}
screenCoords.y += LIST_ROW_HEIGHT;

View File

@ -725,7 +725,8 @@ static void window_guest_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
x = w->windowPos.x + 4;
y = w->windowPos.y + window_guest_list_widgets[WIDX_GUEST_LIST].bottom + 2;
set_format_arg(0, int32_t, static_cast<int32_t>(GuestList.size()));
auto ft = Formatter::Common();
ft.Add<int32_t>(static_cast<int32_t>(GuestList.size()));
gfx_draw_string_left(
dpi, (GuestList.size() == 1 ? STR_FORMAT_NUM_GUESTS_SINGULAR : STR_FORMAT_NUM_GUESTS_PLURAL), gCommonFormatArgs,
COLOUR_BLACK, x, y);
@ -846,8 +847,9 @@ static void window_guest_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 0, y }, 414);
// Draw guest count
set_format_arg(0, rct_string_id, STR_GUESTS_COUNT_COMMA_SEP);
set_format_arg(2, uint32_t, numGuests);
auto 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);
}
y += SUMMARISED_GUEST_ROW_HEIGHT;

View File

@ -716,7 +716,8 @@ static void window_loadsave_paint(rct_window* w, rct_drawpixelinfo* dpi)
safe_strcpy(ch, _shortenedDirectory, sizeof(buffer) - (ch - buffer));
// Draw path text
set_format_arg(0, uintptr_t, Platform::StrDecompToPrecomp(buffer));
auto ft = Formatter::Common();
ft.Add<uintptr_t>(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);
@ -1236,8 +1237,9 @@ static void window_overwrite_prompt_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
window_draw_widgets(w, dpi);
set_format_arg(0, rct_string_id, STR_STRING);
set_format_arg(2, char*, _window_overwrite_prompt_name);
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_STRING);
ft.Add<char*>(_window_overwrite_prompt_name);
ScreenCoordsXY stringCoords(w->windowPos.x + w->width / 2, w->windowPos.y + (w->height / 2) - 3);
gfx_draw_string_centred_wrapped(

View File

@ -979,7 +979,9 @@ static void window_map_show_default_scenario_editor_buttons(rct_window* w)
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
w->widgets[WIDX_MAP_GENERATOR].type = WWT_BUTTON;
set_format_arg(2, uint16_t, gMapSize - 2);
auto ft = Formatter::Common();
ft.Increment(2);
ft.Add<uint16_t>(gMapSize - 2);
}
static void window_map_inputsize_land(rct_window* w)

View File

@ -432,7 +432,9 @@ static void window_maze_construction_invalidate(rct_window* w)
}
else
{
set_format_arg(4, rct_string_id, STR_NONE);
auto ft = Formatter::Common();
ft.Increment(4);
ft.Add<rct_string_id>(STR_NONE);
}
}

View File

@ -284,8 +284,9 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32
dpi, -1, y, 383, y + itemHeight - 1, w->colours[1], (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_GREY));
// Date text
set_format_arg(0, rct_string_id, DateDayNames[newsItem->Day - 1]);
set_format_arg(2, rct_string_id, DateGameMonthNames[date_get_month(newsItem->MonthYear)]);
auto ft = Formatter::Common();
ft.Add<rct_string_id>(DateDayNames[newsItem->Day - 1]);
ft.Add<rct_string_id>(DateGameMonthNames[date_get_month(newsItem->MonthYear)]);
gfx_draw_string_left(dpi, STR_NEWS_DATE_FORMAT, gCommonFormatArgs, COLOUR_WHITE, 2, y);
// Item text

View File

@ -558,13 +558,15 @@ static void window_object_load_error_paint(rct_window* w, rct_drawpixelinfo* dpi
window_draw_widgets(w, dpi);
// Draw explanatory message
set_format_arg(0, rct_string_id, STR_OBJECT_ERROR_WINDOW_EXPLANATION);
auto ft = Formatter::Common();
ft.Add<rct_string_id>(STR_OBJECT_ERROR_WINDOW_EXPLANATION);
gfx_draw_string_left_wrapped(
dpi, gCommonFormatArgs, { w->windowPos.x + 5, w->windowPos.y + 18 }, WW - 10, STR_BLACK_STRING, COLOUR_BLACK);
// Draw file name
set_format_arg(0, rct_string_id, STR_OBJECT_ERROR_WINDOW_FILE);
set_format_arg(2, utf8*, file_path.c_str());
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);
}

View File

@ -2069,7 +2069,8 @@ static void window_options_paint(rct_window* w, rct_drawpixelinfo* dpi)
w->windowPos.x + w->widgets[WIDX_AUTOSAVE_AMOUNT].left + 1,
w->windowPos.y + w->widgets[WIDX_AUTOSAVE_AMOUNT].top + 1);
set_format_arg(0, uintptr_t, Platform::StrDecompToPrecomp(gConfigGeneral.rct1_path));
auto ft = Formatter::Common();
ft.Add<uintptr_t>(Platform::StrDecompToPrecomp(gConfigGeneral.rct1_path));
rct_widget pathWidget = window_options_advanced_widgets[WIDX_PATH_TO_RCT1_BUTTON];
@ -2118,7 +2119,8 @@ static void window_options_tooltip(rct_window* w, rct_widgetindex widgetIndex, r
}
else
{
set_format_arg(0, uintptr_t, reinterpret_cast<uintptr_t>(gConfigGeneral.rct1_path));
auto ft = Formatter::Common();
ft.Add<uintptr_t>(reinterpret_cast<uintptr_t>(gConfigGeneral.rct1_path));
}
}
}

View File

@ -1627,7 +1627,8 @@ static void window_park_objective_paint(rct_window* w, rct_drawpixelinfo* dpi)
else
{
// Objective completed
set_format_arg(0, money32, gScenarioCompletedCompanyValue);
ft = Formatter::Common();
ft.Add<money32>(gScenarioCompletedCompanyValue);
gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, { x, y }, 222, STR_OBJECTIVE_ACHIEVED, COLOUR_BLACK);
}
}

View File

@ -832,7 +832,9 @@ static void window_title_editor_paint(rct_window* w, rct_drawpixelinfo* dpi)
switch (w->selected_tab)
{
case WINDOW_TITLE_EDITOR_TAB_PRESETS:
set_format_arg(0, uintptr_t, _sequenceName);
{
auto ft = Formatter::Common();
ft.Add<const char*>(_sequenceName);
gfx_draw_string_left(
dpi, STR_TITLE_SEQUENCE, nullptr, w->colours[1], w->windowPos.x + 10,
w->windowPos.y + window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].top + 1);
@ -843,6 +845,7 @@ static void window_title_editor_paint(rct_window* w, rct_drawpixelinfo* dpi)
w->windowPos.x + window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS_DROPDOWN].left
- window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].left - 4);
break;
}
case WINDOW_TITLE_EDITOR_TAB_SAVES:
break;
case WINDOW_TITLE_EDITOR_TAB_SCRIPT: