1
0
Fork 0

Codechange: Use parameterised GetString() in network-related windows. (#13635)

pull/13641/head
Peter Nelson 2025-02-22 13:16:47 +00:00 committed by GitHub
parent 847fbe3348
commit 2b80812922
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 82 additions and 118 deletions

View File

@ -725,9 +725,9 @@ int GetStringHeight(StringID str, int maxw)
* @param maxw maximum string width
* @return number of lines of string when it is drawn
*/
int GetStringLineCount(StringID str, int maxw)
int GetStringLineCount(std::string_view str, int maxw)
{
Layouter layout(GetString(str), maxw);
Layouter layout(str, maxw);
return (uint)layout.size();
}

View File

@ -138,7 +138,7 @@ uint GetStringListWidth(std::span<const StringID> list, FontSize fontsize = FS_N
Dimension GetStringListBoundingBox(std::span<const StringID> list, FontSize fontsize = FS_NORMAL);
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize = FS_NORMAL);
int GetStringHeight(StringID str, int maxw);
int GetStringLineCount(StringID str, int maxw);
int GetStringLineCount(std::string_view str, int maxw);
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion);
Dimension GetStringMultiLineBoundingBox(std::string_view str, const Dimension &suggestion);
void LoadStringWidthTable(bool monospace = false);

View File

@ -217,8 +217,7 @@ void NetworkDrawChatMessage()
int string_height = 0;
for (auto &cmsg : _chatmsg_list) {
if (!show_all && cmsg.remove_time < now) continue;
SetDParamStr(0, cmsg.message);
string_height += GetStringLineCount(STR_JUST_RAW_STRING, width - 1) * GetCharacterHeight(FS_NORMAL) + NETWORK_CHAT_LINE_SPACING;
string_height += GetStringLineCount(GetString(STR_JUST_RAW_STRING, cmsg.message), width - 1) * GetCharacterHeight(FS_NORMAL) + NETWORK_CHAT_LINE_SPACING;
}
string_height = std::min<uint>(string_height, MAX_CHAT_MESSAGES * (GetCharacterHeight(FS_NORMAL) + NETWORK_CHAT_LINE_SPACING));

View File

@ -119,15 +119,14 @@ void BaseNetworkContentDownloadStatusWindow::Close([[maybe_unused]] int data)
void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize)
{
switch (widget) {
case WID_NCDS_PROGRESS_BAR:
SetDParamMaxDigits(0, 8);
SetDParamMaxDigits(1, 8);
SetDParamMaxDigits(2, 8);
size = GetStringBoundingBox(STR_CONTENT_DOWNLOAD_PROGRESS_SIZE);
case WID_NCDS_PROGRESS_BAR: {
auto max_value = GetParamMaxDigits(8);
size = GetStringBoundingBox(GetString(STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, max_value, max_value, max_value));
/* We need some spacing for the 'border' */
size.height += WidgetDimensions::scaled.frametext.Horizontal();
size.width += WidgetDimensions::scaled.frametext.Vertical();
break;
}
case WID_NCDS_PROGRESS_TEXT:
size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
@ -143,28 +142,23 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, WidgetID
DrawFrameRect(r, COLOUR_GREY, {FrameFlag::BorderOnly, FrameFlag::Lowered});
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
DrawFrameRect(ir.WithWidth((uint64_t)ir.Width() * this->downloaded_bytes / this->total_bytes, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
SetDParam(0, this->downloaded_bytes);
SetDParam(1, this->total_bytes);
SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes);
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)),
GetString(STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, this->downloaded_bytes, this->total_bytes, this->downloaded_bytes * 100LL / this->total_bytes),
TC_FROMSTRING, SA_HOR_CENTER);
break;
}
case WID_NCDS_PROGRESS_TEXT: {
StringID str;
case WID_NCDS_PROGRESS_TEXT:
if (this->downloaded_bytes == this->total_bytes) {
str = STR_CONTENT_DOWNLOAD_COMPLETE;
DrawStringMultiLine(r, STR_CONTENT_DOWNLOAD_COMPLETE, TC_FROMSTRING, SA_CENTER);
} else if (!this->name.empty()) {
SetDParamStr(0, this->name);
SetDParam(1, this->downloaded_files);
SetDParam(2, this->total_files);
str = STR_CONTENT_DOWNLOAD_FILE;
DrawStringMultiLine(r,
GetString(STR_CONTENT_DOWNLOAD_FILE, this->name, this->downloaded_files, this->total_files),
TC_FROMSTRING, SA_CENTER);
} else {
str = STR_CONTENT_DOWNLOAD_INITIALISE;
DrawStringMultiLine(r, STR_CONTENT_DOWNLOAD_INITIALISE, TC_FROMSTRING, SA_CENTER);
}
DrawStringMultiLine(r, str, TC_FROMSTRING, SA_CENTER);
break;
}
}
}
@ -697,8 +691,7 @@ public:
DrawString(hr.left, hr.right, hr.top, STR_CONTENT_DETAIL_TITLE, TC_FROMSTRING, SA_HOR_CENTER);
/* Draw the total download size */
SetDParam(0, this->filesize_sum);
DrawString(tr.left, tr.right, tr.bottom - GetCharacterHeight(FS_NORMAL) + 1, STR_CONTENT_TOTAL_DOWNLOAD_SIZE);
DrawString(tr.left, tr.right, tr.bottom - GetCharacterHeight(FS_NORMAL) + 1, GetString(STR_CONTENT_TOTAL_DOWNLOAD_SIZE, this->filesize_sum));
if (this->selected == nullptr) return;
@ -709,35 +702,28 @@ public:
tr.bottom -= GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide;
if (this->selected->upgrade) {
SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_UPDATE);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_UPDATE, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS));
tr.top += WidgetDimensions::scaled.vsep_wide;
}
SetDParamStr(0, this->selected->name);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_NAME);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_NAME, this->selected->name));
if (!this->selected->version.empty()) {
SetDParamStr(0, this->selected->version);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_VERSION);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_VERSION, this->selected->version));
}
if (!this->selected->description.empty()) {
SetDParamStr(0, this->selected->description);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_DESCRIPTION);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_DESCRIPTION, this->selected->description));
}
if (!this->selected->url.empty()) {
SetDParamStr(0, this->selected->url);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_URL);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_URL, this->selected->url));
}
SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_TYPE);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_TYPE, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS));
tr.top += WidgetDimensions::scaled.vsep_wide;
SetDParam(0, this->selected->filesize);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_FILESIZE);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_FILESIZE, this->selected->filesize));
std::string_view list_separator = GetListSeparator();
if (!this->selected->dependencies.empty()) {
@ -755,8 +741,7 @@ public:
break;
}
}
SetDParamStr(0, buf);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_DEPENDENCIES);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_DEPENDENCIES, std::move(buf)));
}
if (!this->selected->tags.empty()) {
@ -766,8 +751,7 @@ public:
if (!buf.empty()) buf += list_separator;
buf += tag;
}
SetDParamStr(0, buf);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_TAGS);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_TAGS, std::move(buf)));
}
if (this->selected->IsSelected()) {
@ -783,8 +767,7 @@ public:
buf += ci->name;
}
if (!buf.empty()) {
SetDParamStr(0, buf);
tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
tr.top = DrawStringMultiLine(tr, GetString(STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF, std::move(buf)));
}
}
}

View File

@ -371,36 +371,35 @@ protected:
if (cur_item->status == NGLS_ONLINE) {
if (const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_NG_CLIENTS); nwid->current_x != 0) {
Rect clients = nwid->GetCurrentRect();
SetDParam(0, cur_item->info.clients_on);
SetDParam(1, cur_item->info.clients_max);
SetDParam(2, cur_item->info.companies_on);
SetDParam(3, cur_item->info.companies_max);
DrawString(clients.left, clients.right, y + text_y_offset, STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(clients.left, clients.right, y + text_y_offset,
GetString(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, cur_item->info.clients_on, cur_item->info.clients_max, cur_item->info.companies_on, cur_item->info.companies_max),
TC_FROMSTRING, SA_HOR_CENTER);
}
if (const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_NG_MAPSIZE); nwid->current_x != 0) {
/* map size */
Rect mapsize = nwid->GetCurrentRect();
SetDParam(0, cur_item->info.map_width);
SetDParam(1, cur_item->info.map_height);
DrawString(mapsize.left, mapsize.right, y + text_y_offset, STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(mapsize.left, mapsize.right, y + text_y_offset,
GetString(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, cur_item->info.map_width, cur_item->info.map_height),
TC_FROMSTRING, SA_HOR_CENTER);
}
if (const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_NG_DATE); nwid->current_x != 0) {
/* current date */
Rect date = nwid->GetCurrentRect();
TimerGameCalendar::YearMonthDay ymd = TimerGameCalendar::ConvertDateToYMD(cur_item->info.calendar_date);
SetDParam(0, ymd.year);
DrawString(date.left, date.right, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
DrawString(date.left, date.right, y + text_y_offset,
GetString(STR_JUST_INT, ymd.year),
TC_BLACK, SA_HOR_CENTER);
}
if (const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_NG_YEARS); nwid->current_x != 0) {
/* play time */
Rect years = nwid->GetCurrentRect();
const auto play_time = cur_item->info.ticks_playing / Ticks::TICKS_PER_SECOND;
SetDParam(0, play_time / 60 / 60);
SetDParam(1, (play_time / 60) % 60);
DrawString(years.left, years.right, y + text_y_offset, STR_NETWORK_SERVER_LIST_PLAY_TIME_SHORT, TC_BLACK, SA_HOR_CENTER);
DrawString(years.left, years.right, y + text_y_offset,
GetString(STR_NETWORK_SERVER_LIST_PLAY_TIME_SHORT, play_time / 60 / 60, (play_time / 60) % 60),
TC_BLACK, SA_HOR_CENTER);
}
/* Set top and bottom of info rect to current row. */
@ -497,27 +496,25 @@ public:
size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
break;
case WID_NG_CLIENTS:
case WID_NG_CLIENTS: {
size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
SetDParamMaxValue(0, MAX_CLIENTS);
SetDParamMaxValue(1, MAX_CLIENTS);
SetDParamMaxValue(2, MAX_COMPANIES);
SetDParamMaxValue(3, MAX_COMPANIES);
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE));
auto max_clients = GetParamMaxValue(MAX_CLIENTS);
auto max_companies = GetParamMaxValue(MAX_COMPANIES);
size = maxdim(size, GetStringBoundingBox(GetString(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, max_clients, max_clients, max_companies, max_companies)));
break;
}
case WID_NG_MAPSIZE:
case WID_NG_MAPSIZE: {
size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
SetDParamMaxValue(0, MAX_MAP_SIZE);
SetDParamMaxValue(1, MAX_MAP_SIZE);
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT));
auto max_map_size = GetParamMaxValue(0, MAX_MAP_SIZE);
size = maxdim(size, GetStringBoundingBox(GetString(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, max_map_size, max_map_size)));
break;
}
case WID_NG_DATE:
case WID_NG_YEARS:
size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
SetDParamMaxValue(0, 5);
size = maxdim(size, GetStringBoundingBox(STR_JUST_INT));
size = maxdim(size, GetStringBoundingBox(GetString(STR_JUST_INT, GetParamMaxValue(5))));
break;
case WID_NG_INFO:
@ -639,41 +636,26 @@ public:
if (sel->status != NGLS_ONLINE) {
tr.top = DrawStringMultiLine(tr, header_msg, TC_FROMSTRING, SA_HOR_CENTER);
} else { // show game info
SetDParam(0, sel->info.clients_on);
SetDParam(1, sel->info.clients_max);
SetDParam(2, sel->info.companies_on);
SetDParam(3, sel->info.companies_max);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_CLIENTS);
tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_CLIENTS, sel->info.clients_on, sel->info.clients_max, sel->info.companies_on, sel->info.companies_max));
SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + to_underlying(sel->info.landscape));
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_LANDSCAPE); // landscape
tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_LANDSCAPE, STR_CLIMATE_TEMPERATE_LANDSCAPE + to_underlying(sel->info.landscape))); // landscape
SetDParam(0, sel->info.map_width);
SetDParam(1, sel->info.map_height);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_MAP_SIZE); // map size
tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_MAP_SIZE, sel->info.map_width, sel->info.map_height)); // map size
SetDParamStr(0, sel->info.server_revision);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_SERVER_VERSION); // server version
tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_SERVER_VERSION, sel->info.server_revision)); // server version
SetDParamStr(0, sel->connection_string);
StringID invite_or_address = sel->connection_string.starts_with("+") ? STR_NETWORK_SERVER_LIST_INVITE_CODE : STR_NETWORK_SERVER_LIST_SERVER_ADDRESS;
tr.top = DrawStringMultiLine(tr, invite_or_address); // server address / invite code
tr.top = DrawStringMultiLine(tr, GetString(invite_or_address, sel->connection_string)); // server address / invite code
SetDParam(0, sel->info.calendar_start);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_START_DATE); // start date
tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_START_DATE, sel->info.calendar_start)); // start date
SetDParam(0, sel->info.calendar_date);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_CURRENT_DATE); // current date
tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_CURRENT_DATE, sel->info.calendar_date)); // current date
const auto play_time = sel->info.ticks_playing / Ticks::TICKS_PER_SECOND;
SetDParam(0, play_time / 60 / 60);
SetDParam(1, (play_time / 60) % 60);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_PLAY_TIME); // play time
tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_PLAY_TIME, play_time / 60 / 60, (play_time / 60) % 60)); // play time
if (sel->info.gamescript_version != -1) {
SetDParamStr(0, sel->info.gamescript_name);
SetDParam(1, sel->info.gamescript_version);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_GAMESCRIPT); // gamescript name and version
tr.top = DrawStringMultiLine(tr, GetString(STR_NETWORK_SERVER_LIST_GAMESCRIPT, sel->info.gamescript_name, sel->info.gamescript_version)); // gamescript name and version
}
tr.top += WidgetDimensions::scaled.vsep_wide;
@ -1662,16 +1644,18 @@ public:
{
switch (widget) {
case WID_CL_SERVER_NAME:
case WID_CL_CLIENT_NAME:
case WID_CL_CLIENT_NAME: {
std::string str;
if (widget == WID_CL_SERVER_NAME) {
SetDParamStr(0, _network_server ? _settings_client.network.server_name : _network_server_name);
str = GetString(STR_JUST_RAW_STRING, _network_server ? _settings_client.network.server_name : _network_server_name);
} else {
const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
SetDParamStr(0, own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name);
str = GetString(STR_JUST_RAW_STRING, own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name);
}
size = GetStringBoundingBox(STR_JUST_RAW_STRING);
size = GetStringBoundingBox(str);
size.width = std::min(size.width, static_cast<uint>(ScaleGUITrad(200))); // By default, don't open the window too wide.
break;
}
case WID_CL_SERVER_VISIBILITY:
size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY));
@ -1964,9 +1948,7 @@ public:
} else {
DrawCompanyIcon(company_id, icon_left, y + offset);
SetDParam(0, company_id);
SetDParam(1, company_id);
DrawString(tr.left, tr.right, y + text_y_offset, STR_COMPANY_NAME, TC_SILVER);
DrawString(tr.left, tr.right, y + text_y_offset, GetString(STR_COMPANY_NAME, company_id, company_id), TC_SILVER);
}
}
@ -2001,8 +1983,7 @@ public:
tr = tr.Indent(d2.width + WidgetDimensions::scaled.hsep_normal, rtl);
}
SetDParamStr(0, ci->client_name);
DrawString(tr.left, tr.right, y + text_y_offset, STR_JUST_RAW_STRING, TC_BLACK);
DrawString(tr.left, tr.right, y + text_y_offset, GetString(STR_JUST_RAW_STRING, ci->client_name), TC_BLACK);
}
y += this->line_height;
@ -2118,14 +2099,17 @@ struct NetworkJoinStatusWindow : Window {
case WID_NJS_PROGRESS_TEXT:
switch (_network_join_status) {
case NETWORK_JOIN_STATUS_WAITING:
SetDParam(0, _network_join_waiting);
DrawStringMultiLine(r, STR_NETWORK_CONNECTING_WAITING, TC_FROMSTRING, SA_CENTER);
DrawStringMultiLine(r, GetString(STR_NETWORK_CONNECTING_WAITING, _network_join_waiting), TC_FROMSTRING, SA_CENTER);
break;
case NETWORK_JOIN_STATUS_DOWNLOADING:
SetDParam(0, _network_join_bytes);
SetDParam(1, _network_join_bytes_total);
DrawStringMultiLine(r, _network_join_bytes_total == 0 ? STR_NETWORK_CONNECTING_DOWNLOADING_1 : STR_NETWORK_CONNECTING_DOWNLOADING_2, TC_FROMSTRING, SA_CENTER);
if (_network_join_bytes_total == 0) {
DrawStringMultiLine(r, GetString(STR_NETWORK_CONNECTING_DOWNLOADING_1, _network_join_bytes), TC_FROMSTRING, SA_CENTER);
} else {
DrawStringMultiLine(r, GetString(STR_NETWORK_CONNECTING_DOWNLOADING_2, _network_join_bytes, _network_join_bytes_total), TC_FROMSTRING, SA_CENTER);
}
break;
default:
break;
}
@ -2142,20 +2126,19 @@ struct NetworkJoinStatusWindow : Window {
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i));
}
/* For the number of waiting (other) players */
SetDParamMaxValue(0, MAX_CLIENTS);
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_WAITING));
size = maxdim(size, GetStringBoundingBox(GetString(STR_NETWORK_CONNECTING_WAITING, GetParamMaxValue(MAX_CLIENTS))));
/* We need some spacing for the 'border' */
size.height += WidgetDimensions::scaled.frametext.Horizontal();
size.width += WidgetDimensions::scaled.frametext.Vertical();
break;
case WID_NJS_PROGRESS_TEXT:
case WID_NJS_PROGRESS_TEXT: {
/* Account for downloading ~ 10 MiB */
SetDParamMaxDigits(0, 8);
SetDParamMaxDigits(1, 8);
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1));
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1));
uint64_t max_digits = GetParamMaxDigits(8);
size = maxdim(size, GetStringBoundingBox(GetString(STR_NETWORK_CONNECTING_DOWNLOADING_1, max_digits, max_digits)));
size = maxdim(size, GetStringBoundingBox(GetString(STR_NETWORK_CONNECTING_DOWNLOADING_1, max_digits, max_digits)));
break;
}
}
}

View File

@ -2419,8 +2419,7 @@ struct GameSettingsWindow : Window {
if (this->warn_missing == WHR_NONE) {
new_warn_lines = 0;
} else {
SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
new_warn_lines = GetStringLineCount(warn_str, panel.Width());
new_warn_lines = GetStringLineCount(GetString(warn_str, _game_settings_restrict_dropdown[this->filter.min_cat]), panel.Width());
}
if (this->warn_lines != new_warn_lines) {
this->vscroll->SetCount(this->vscroll->GetCount() - this->warn_lines + new_warn_lines);