Codechange: Remove FONT_HEIGHT_... macros. (#11481)

These make it look like we're dealing with a constant, but actually each is a call to `GetCharacterHeight(...)`.
This commit is contained in:
Peter Nelson
2023-11-21 19:04:24 +00:00
committed by GitHub
parent 96ec9c1b47
commit c18a1494b7
57 changed files with 369 additions and 381 deletions

View File

@@ -407,7 +407,7 @@ public:
}
case WID_STL_LIST:
resize->height = std::max(FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL + ScaleGUITrad(3));
resize->height = std::max(GetCharacterHeight(FS_NORMAL), GetCharacterHeight(FS_SMALL) + ScaleGUITrad(3));
size->height = padding.height + 5 * resize->height;
/* Determine appropriate width for mini station rating graph */
@@ -466,7 +466,7 @@ public:
SetDParam(0, st->index);
SetDParam(1, st->facilities);
int x = DrawString(tr.left, tr.right, tr.top + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_STATION);
int x = DrawString(tr.left, tr.right, tr.top + (line_height - GetCharacterHeight(FS_NORMAL)) / 2, STR_STATION_LIST_STATION);
x += rtl ? -text_spacing : text_spacing;
/* show cargo waiting and station ratings */
@@ -492,7 +492,7 @@ public:
}
if (this->vscroll->GetCount() == 0) { // company has no stations
DrawString(tr.left, tr.right, tr.top + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_NONE);
DrawString(tr.left, tr.right, tr.top + (line_height - GetCharacterHeight(FS_NORMAL)) / 2, STR_STATION_LIST_NONE);
return;
}
break;
@@ -506,7 +506,7 @@ public:
br = br.Translate(cg_ofst, cg_ofst);
GfxFillRect(br, cs->rating_colour);
TextColour tc = GetContrastColour(cs->rating_colour);
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), cs->abbrev, tc, SA_HOR_CENTER, false, FS_SMALL);
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_SMALL)), cs->abbrev, tc, SA_HOR_CENTER, false, FS_SMALL);
}
break;
}
@@ -1385,13 +1385,13 @@ struct StationViewWindow : public Window {
{
switch (widget) {
case WID_SV_WAITING:
resize->height = FONT_HEIGHT_NORMAL;
resize->height = GetCharacterHeight(FS_NORMAL);
size->height = 4 * resize->height + padding.height;
this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width);
break;
case WID_SV_ACCEPT_RATING_LIST:
size->height = ((this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * FONT_HEIGHT_NORMAL + padding.height;
size->height = ((this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * GetCharacterHeight(FS_NORMAL) + padding.height;
break;
case WID_SV_CLOSE_AIRPORT:
@@ -1763,7 +1763,7 @@ struct StationViewWindow : public Window {
if (pos > -maxrows && pos <= 0) {
StringID str = STR_EMPTY;
int y = r.top - pos * FONT_HEIGHT_NORMAL;
int y = r.top - pos * GetCharacterHeight(FS_NORMAL);
SetDParam(0, cargo);
SetDParam(1, cd->GetCount());
@@ -1836,7 +1836,7 @@ struct StationViewWindow : public Window {
SetDParam(0, GetAcceptanceMask(st));
int bottom = DrawStringMultiLine(tr.left, tr.right, tr.top, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO);
return CeilDiv(bottom - r.top - WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL);
return CeilDiv(bottom - r.top - WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FS_NORMAL));
}
/**
@@ -1857,7 +1857,7 @@ struct StationViewWindow : public Window {
}
DrawString(tr, STR_STATION_VIEW_SUPPLY_RATINGS_TITLE);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
const GoodsEntry *ge = &st->goods[cs->Index()];
@@ -1869,9 +1869,9 @@ struct StationViewWindow : public Window {
SetDParam(2, STR_CARGO_RATING_APPALLING + (ge->rating >> 5));
SetDParam(3, ToPercent8(ge->rating));
DrawString(tr.Indent(WidgetDimensions::scaled.hsep_indent, rtl), STR_STATION_VIEW_CARGO_SUPPLY_RATING);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
return CeilDiv(tr.top - r.top - WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL);
return CeilDiv(tr.top - r.top - WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FS_NORMAL));
}
/**
@@ -1939,7 +1939,7 @@ struct StationViewWindow : public Window {
nwi->SetDataTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP); // Switch to ratings view.
height_change = this->accepts_lines - this->rating_lines;
}
this->ReInit(0, height_change * FONT_HEIGHT_NORMAL);
this->ReInit(0, height_change * GetCharacterHeight(FS_NORMAL));
break;
}