mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-29 09:29:10 +00:00
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:
@@ -101,8 +101,8 @@ void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const std::st
|
||||
/** Initialize all font-dependent chat box sizes. */
|
||||
void NetworkReInitChatBoxSize()
|
||||
{
|
||||
_chatmsg_box.y = 3 * FONT_HEIGHT_NORMAL;
|
||||
_chatmsg_box.height = MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + ScaleGUITrad(NETWORK_CHAT_LINE_SPACING)) + ScaleGUITrad(4);
|
||||
_chatmsg_box.y = 3 * GetCharacterHeight(FS_NORMAL);
|
||||
_chatmsg_box.height = MAX_CHAT_MESSAGES * (GetCharacterHeight(FS_NORMAL) + ScaleGUITrad(NETWORK_CHAT_LINE_SPACING)) + ScaleGUITrad(4);
|
||||
}
|
||||
|
||||
/** Initialize all buffers of the chat visualisation. */
|
||||
@@ -218,10 +218,10 @@ void NetworkDrawChatMessage()
|
||||
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) * FONT_HEIGHT_NORMAL + NETWORK_CHAT_LINE_SPACING;
|
||||
string_height += GetStringLineCount(STR_JUST_RAW_STRING, width - 1) * GetCharacterHeight(FS_NORMAL) + NETWORK_CHAT_LINE_SPACING;
|
||||
}
|
||||
|
||||
string_height = std::min<uint>(string_height, MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + NETWORK_CHAT_LINE_SPACING));
|
||||
string_height = std::min<uint>(string_height, MAX_CHAT_MESSAGES * (GetCharacterHeight(FS_NORMAL) + NETWORK_CHAT_LINE_SPACING));
|
||||
|
||||
int top = _screen.height - _chatmsg_box.y - string_height - 2;
|
||||
int bottom = _screen.height - _chatmsg_box.y - 2;
|
||||
|
@@ -128,7 +128,7 @@ void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(int widget, Dimens
|
||||
break;
|
||||
|
||||
case WID_NCDS_PROGRESS_TEXT:
|
||||
size->height = FONT_HEIGHT_NORMAL * 2 + WidgetDimensions::scaled.vsep_normal;
|
||||
size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widge
|
||||
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, FONT_HEIGHT_NORMAL), STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ public:
|
||||
}
|
||||
|
||||
case WID_NCL_MATRIX:
|
||||
resize->height = std::max(this->checkbox_size.height, (uint)FONT_HEIGHT_NORMAL) + padding.height;
|
||||
resize->height = std::max(this->checkbox_size.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
|
||||
size->height = 10 * resize->height;
|
||||
break;
|
||||
}
|
||||
@@ -647,7 +647,7 @@ public:
|
||||
|
||||
/* Fill the matrix with the information */
|
||||
int sprite_y_offset = (this->resize.step_height - this->checkbox_size.height) / 2;
|
||||
int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2;
|
||||
int text_y_offset = (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2;
|
||||
|
||||
Rect mr = r.WithHeight(this->resize.step_height);
|
||||
auto iter = this->content.begin() + this->vscroll->GetPosition();
|
||||
@@ -686,7 +686,7 @@ public:
|
||||
void DrawDetails(const Rect &r) const
|
||||
{
|
||||
/* Height for the title banner */
|
||||
int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.Vertical();
|
||||
int HEADER_HEIGHT = 3 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.Vertical();
|
||||
|
||||
Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext);
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.frametext);
|
||||
@@ -698,15 +698,15 @@ public:
|
||||
|
||||
/* Draw the total download size */
|
||||
SetDParam(0, this->filesize_sum);
|
||||
DrawString(tr.left, tr.right, tr.bottom - FONT_HEIGHT_NORMAL + 1, STR_CONTENT_TOTAL_DOWNLOAD_SIZE);
|
||||
DrawString(tr.left, tr.right, tr.bottom - GetCharacterHeight(FS_NORMAL) + 1, STR_CONTENT_TOTAL_DOWNLOAD_SIZE);
|
||||
|
||||
if (this->selected == nullptr) return;
|
||||
|
||||
/* And fill the rest of the details when there's information to place there */
|
||||
DrawStringMultiLine(hr.left, hr.right, hr.top + FONT_HEIGHT_NORMAL, hr.bottom, STR_CONTENT_DETAIL_SUBTITLE_UNSELECTED + this->selected->state, TC_FROMSTRING, SA_CENTER);
|
||||
DrawStringMultiLine(hr.left, hr.right, hr.top + GetCharacterHeight(FS_NORMAL), hr.bottom, STR_CONTENT_DETAIL_SUBTITLE_UNSELECTED + this->selected->state, TC_FROMSTRING, SA_CENTER);
|
||||
|
||||
/* Also show the total download size, so keep some space from the bottom */
|
||||
tr.bottom -= FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
|
||||
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);
|
||||
|
@@ -352,7 +352,7 @@ protected:
|
||||
}
|
||||
|
||||
/* offsets to vertically centre text and icons */
|
||||
int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2 + 1;
|
||||
int text_y_offset = (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2 + 1;
|
||||
int icon_y_offset = (this->resize.step_height - GetSpriteSize(SPR_BLOT).height) / 2;
|
||||
int lock_y_offset = (this->resize.step_height - GetSpriteSize(SPR_LOCK).height) / 2;
|
||||
|
||||
@@ -468,13 +468,13 @@ public:
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_NG_MATRIX:
|
||||
resize->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + padding.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)FONT_HEIGHT_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:
|
||||
@@ -586,7 +586,7 @@ public:
|
||||
NetworkGameList *sel = this->server;
|
||||
|
||||
/* Height for the title banner */
|
||||
int HEADER_HEIGHT = 3 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.Vertical();
|
||||
int HEADER_HEIGHT = 3 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.Vertical();
|
||||
|
||||
Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext);
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.frametext);
|
||||
@@ -610,45 +610,45 @@ public:
|
||||
}
|
||||
|
||||
DrawString(hr.left, hr.right, hr.top, message, TC_FROMSTRING, SA_HOR_CENTER); // server offline
|
||||
DrawStringMultiLine(hr.left, hr.right, hr.top + FONT_HEIGHT_NORMAL, hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
|
||||
DrawStringMultiLine(hr.left, hr.right, hr.top + GetCharacterHeight(FS_NORMAL), hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
|
||||
DrawString(tr.left, tr.right, tr.top, message, TC_FROMSTRING, SA_HOR_CENTER); // server offline
|
||||
} else { // show game info
|
||||
|
||||
DrawString(hr.left, hr.right, hr.top, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
DrawStringMultiLine(hr.left, hr.right, hr.top + FONT_HEIGHT_NORMAL, hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
|
||||
DrawStringMultiLine(hr.left, hr.right, hr.top + GetCharacterHeight(FS_NORMAL), hr.bottom, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
|
||||
|
||||
SetDParam(0, sel->info.clients_on);
|
||||
SetDParam(1, sel->info.clients_max);
|
||||
SetDParam(2, sel->info.companies_on);
|
||||
SetDParam(3, sel->info.companies_max);
|
||||
DrawString(tr, STR_NETWORK_SERVER_LIST_CLIENTS);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
tr.top += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + sel->info.landscape);
|
||||
DrawString(tr, STR_NETWORK_SERVER_LIST_LANDSCAPE); // landscape
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
tr.top += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
SetDParam(0, sel->info.map_width);
|
||||
SetDParam(1, sel->info.map_height);
|
||||
DrawString(tr, STR_NETWORK_SERVER_LIST_MAP_SIZE); // map size
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
tr.top += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
SetDParamStr(0, sel->info.server_revision);
|
||||
DrawString(tr, STR_NETWORK_SERVER_LIST_SERVER_VERSION); // server version
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
tr.top += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
SetDParamStr(0, sel->connection_string);
|
||||
StringID invite_or_address = StrStartsWith(sel->connection_string, "+") ? STR_NETWORK_SERVER_LIST_INVITE_CODE : STR_NETWORK_SERVER_LIST_SERVER_ADDRESS;
|
||||
DrawString(tr, invite_or_address); // server address / invite code
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
tr.top += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
SetDParam(0, sel->info.start_date);
|
||||
DrawString(tr, STR_NETWORK_SERVER_LIST_START_DATE); // start date
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
tr.top += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
SetDParam(0, sel->info.game_date);
|
||||
DrawString(tr, STR_NETWORK_SERVER_LIST_CURRENT_DATE); // current date
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
tr.top += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
if (sel->info.gamescript_version != -1) {
|
||||
SetDParamStr(0, sel->info.gamescript_name);
|
||||
@@ -1682,7 +1682,7 @@ public:
|
||||
case WID_CL_MATRIX: {
|
||||
uint height = std::max({GetSpriteSize(SPR_COMPANY_ICON).height, GetSpriteSize(SPR_JOIN).height, GetSpriteSize(SPR_ADMIN).height, GetSpriteSize(SPR_CHAT).height});
|
||||
height += WidgetDimensions::scaled.framerect.Vertical();
|
||||
this->line_height = std::max(height, (uint)FONT_HEIGHT_NORMAL) + padding.height;
|
||||
this->line_height = std::max(height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
|
||||
|
||||
resize->width = 1;
|
||||
resize->height = this->line_height;
|
||||
@@ -1947,7 +1947,7 @@ public:
|
||||
void DrawCompany(CompanyID company_id, const Rect &r, uint &line) const
|
||||
{
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
int text_y_offset = CenterBounds(0, this->line_height, FONT_HEIGHT_NORMAL);
|
||||
int text_y_offset = CenterBounds(0, this->line_height, GetCharacterHeight(FS_NORMAL));
|
||||
|
||||
Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
int offset = CenterBounds(0, this->line_height, d.height);
|
||||
@@ -2125,7 +2125,7 @@ struct NetworkJoinStatusWindow : Window {
|
||||
break;
|
||||
}
|
||||
DrawFrameRect(ir.WithWidth(ir.Width() * progress / 100, false), COLOUR_MAUVE, FR_NONE);
|
||||
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, FONT_HEIGHT_NORMAL), STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user