forked from mirror/OpenTTD
Codechange: Pass by reference to UpdateWidgetSize. (#12457)
These parameters are always provided and not optional.
This commit is contained in:
@@ -256,34 +256,34 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
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_TA_ACTION_INFO: {
|
||||
assert(size->width > padding.width && size->height > padding.height);
|
||||
assert(size.width > padding.width && size.height > padding.height);
|
||||
Dimension d = {0, 0};
|
||||
for (int i = 0; i < TACT_COUNT; i++) {
|
||||
SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[i] >> 8);
|
||||
d = maxdim(d, GetStringMultiLineBoundingBox(this->action_tooltips[i], *size));
|
||||
d = maxdim(d, GetStringMultiLineBoundingBox(this->action_tooltips[i], size));
|
||||
}
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_TA_COMMAND_LIST:
|
||||
size->height = (TACT_COUNT + 1) * GetCharacterHeight(FS_NORMAL) + padding.height;
|
||||
size->width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width;
|
||||
size.height = (TACT_COUNT + 1) * GetCharacterHeight(FS_NORMAL) + padding.height;
|
||||
size.width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width;
|
||||
for (uint i = 0; i < TACT_COUNT; i++ ) {
|
||||
size->width = std::max(size->width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width + padding.width);
|
||||
size.width = std::max(size.width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width + padding.width);
|
||||
}
|
||||
size->width += padding.width;
|
||||
size.width += padding.width;
|
||||
break;
|
||||
|
||||
case WID_TA_RATING_INFO:
|
||||
resize->height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)GetCharacterHeight(FS_NORMAL)});
|
||||
size->height = 9 * resize->height + padding.height;
|
||||
resize.height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)GetCharacterHeight(FS_NORMAL)});
|
||||
size.height = 9 * resize.height + padding.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -524,11 +524,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
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_TV_INFO:
|
||||
size->height = GetDesiredInfoHeight(size->width) + padding.height;
|
||||
size.height = GetDesiredInfoHeight(size.width) + padding.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -878,14 +878,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
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_TD_SORT_ORDER: {
|
||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
case WID_TD_SORT_CRITERIA: {
|
||||
@@ -895,7 +895,7 @@ public:
|
||||
}
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
case WID_TD_LIST: {
|
||||
@@ -912,11 +912,11 @@ public:
|
||||
Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
|
||||
d.width += icon_size.width + 2;
|
||||
d.height = std::max(d.height, icon_size.height);
|
||||
resize->height = d.height;
|
||||
resize.height = d.height;
|
||||
d.height *= 5;
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
case WID_TD_WORLD_POPULATION: {
|
||||
@@ -924,7 +924,7 @@ public:
|
||||
Dimension d = GetStringBoundingBox(STR_TOWN_POPULATION);
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user