Codechange: Pass by reference to UpdateWidgetSize. (#12457)

These parameters are always provided and not optional.
This commit is contained in:
Peter Nelson
2024-04-09 08:34:45 +01:00
committed by GitHub
parent b5ad28022d
commit de4e00c93f
55 changed files with 602 additions and 602 deletions

View File

@@ -116,21 +116,21 @@ void BaseNetworkContentDownloadStatusWindow::Close([[maybe_unused]] int data)
this->Window::Close();
}
void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize)
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);
size = GetStringBoundingBox(STR_CONTENT_DOWNLOAD_PROGRESS_SIZE);
/* We need some spacing for the 'border' */
size->height += WidgetDimensions::scaled.frametext.Horizontal();
size->width += WidgetDimensions::scaled.frametext.Vertical();
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;
size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
break;
}
}
@@ -585,25 +585,25 @@ public:
this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT));
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
switch (widget) {
case WID_NCL_CHECKBOX:
size->width = this->checkbox_size.width + padding.width;
size.width = this->checkbox_size.width + padding.width;
break;
case WID_NCL_TYPE: {
Dimension d = *size;
Dimension d = size;
for (int i = CONTENT_TYPE_BEGIN; i < CONTENT_TYPE_END; i++) {
d = maxdim(d, GetStringBoundingBox(STR_CONTENT_TYPE_BASE_GRAPHICS + i - CONTENT_TYPE_BASE_GRAPHICS));
}
size->width = d.width + padding.width;
size.width = d.width + padding.width;
break;
}
case WID_NCL_MATRIX:
resize->height = std::max(this->checkbox_size.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
size->height = 10 * resize->height;
resize.height = std::max(this->checkbox_size.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
size.height = 10 * resize.height;
break;
}
}

View File

@@ -33,7 +33,7 @@ public:
BaseNetworkContentDownloadStatusWindow(WindowDesc *desc);
void Close([[maybe_unused]] int data = 0) override;
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override;
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override;
void DrawWidget(const Rect &r, WidgetID widget) const override;
void OnDownloadProgress(const ContentInfo *ci, int bytes) override;
};

View File

@@ -475,48 +475,48 @@ public:
this->flag_offset = this->blot_offset + ScaleGUITrad(2) + GetSpriteSize(SPR_BLOT).width;
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
switch (widget) {
case WID_NG_MATRIX:
resize->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
fill->height = resize->height;
size->height = 12 * resize->height;
resize.height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
fill.height = resize.height;
size.height = 12 * resize.height;
break;
case WID_NG_LASTJOINED:
size->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.matrix.Vertical();
size.height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.matrix.Vertical();
break;
case WID_NG_LASTJOINED_SPACER:
size->width = NWidgetScrollbar::GetVerticalDimension().width;
size.width = NWidgetScrollbar::GetVerticalDimension().width;
break;
case WID_NG_NAME:
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
break;
case WID_NG_CLIENTS:
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
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));
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE));
break;
case WID_NG_MAPSIZE:
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
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));
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT));
break;
case WID_NG_DATE:
case WID_NG_YEARS:
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
SetDParamMaxValue(0, 5);
*size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
size = maxdim(size, GetStringBoundingBox(STR_JUST_INT));
break;
}
}
@@ -1010,13 +1010,13 @@ struct NetworkStartServerWindow : public Window {
}
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
switch (widget) {
case WID_NSS_CONNTYPE_BTN:
*size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY));
size->width += padding.width;
size->height += padding.height;
size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY));
size.width += padding.width;
size.height += padding.height;
break;
}
}
@@ -1673,7 +1673,7 @@ public:
this->SetWidgetDisabledState(WID_CL_SERVER_NAME_EDIT, !_network_server);
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
switch (widget) {
case WID_CL_SERVER_NAME:
@@ -1684,14 +1684,14 @@ public:
const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
SetDParamStr(0, own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name);
}
*size = GetStringBoundingBox(STR_JUST_RAW_STRING);
size->width = std::min(size->width, static_cast<uint>(ScaleGUITrad(200))); // By default, don't open the window too wide.
size = GetStringBoundingBox(STR_JUST_RAW_STRING);
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));
size->width += padding.width;
size->height += padding.height;
size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY));
size.width += padding.width;
size.height += padding.height;
break;
case WID_CL_MATRIX: {
@@ -1699,10 +1699,10 @@ public:
height += WidgetDimensions::scaled.framerect.Vertical();
this->line_height = std::max(height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
resize->width = 1;
resize->height = this->line_height;
fill->height = this->line_height;
size->height = std::max(size->height, 5 * this->line_height);
resize.width = 1;
resize.height = this->line_height;
fill.height = this->line_height;
size.height = std::max(size.height, 5 * this->line_height);
break;
}
}
@@ -2162,28 +2162,28 @@ struct NetworkJoinStatusWindow : Window {
}
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
switch (widget) {
case WID_NJS_PROGRESS_BAR:
/* Account for the statuses */
for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) {
*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i));
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(STR_NETWORK_CONNECTING_WAITING));
/* We need some spacing for the 'border' */
size->height += WidgetDimensions::scaled.frametext.Horizontal();
size->width += WidgetDimensions::scaled.frametext.Vertical();
size.height += WidgetDimensions::scaled.frametext.Horizontal();
size.width += WidgetDimensions::scaled.frametext.Vertical();
break;
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));
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1));
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1));
break;
}
}
@@ -2273,10 +2273,10 @@ struct NetworkCompanyPasswordWindow : public Window {
this->ReInit();
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
if (widget == WID_NCP_WARNING) {
*size = this->warning_size;
size = this->warning_size;
}
}
@@ -2379,10 +2379,10 @@ struct NetworkAskRelayWindow : public Window {
this->Window::Close();
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
if (widget == WID_NAR_TEXT) {
*size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT);
size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT);
}
}
@@ -2482,10 +2482,10 @@ struct NetworkAskSurveyWindow : public Window {
this->InitNested(0);
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
if (widget == WID_NAS_TEXT) {
*size = GetStringBoundingBox(STR_NETWORK_ASK_SURVEY_TEXT);
size = GetStringBoundingBox(STR_NETWORK_ASK_SURVEY_TEXT);
}
}