Merge branch 'master' into jgrpp

# Conflicts:
#	src/build_vehicle_gui.cpp
#	src/company_gui.cpp
#	src/gfx_func.h
#	src/group_gui.cpp
#	src/industry_gui.cpp
#	src/misc_gui.cpp
#	src/news_gui.cpp
#	src/settings_gui.cpp
#	src/ship_gui.cpp
#	src/smallmap_gui.cpp
#	src/station_gui.cpp
#	src/subsidy_gui.cpp
#	src/timetable_gui.cpp
#	src/toolbar_gui.cpp
#	src/town_gui.cpp
#	src/vehicle_gui.cpp
#	src/viewport.cpp
#	src/widget.cpp
#	src/widgets/dropdown.cpp
#	src/window.cpp
wip-string
Jonathan G Rennison 5 months ago
commit 2e06374f6f

@ -134,7 +134,7 @@ struct AIConfigWindow : public Window {
break;
case WID_AIC_LIST:
this->line_height = FONT_HEIGHT_NORMAL + padding.height;
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
resize->height = this->line_height;
size->height = 8 * this->line_height;
break;

@ -38,7 +38,7 @@ void DrawAircraftDetails(const Aircraft *v, const Rect &r)
SetDParam(1, u->build_year);
SetDParam(2, u->value);
DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
SetDParam(0, u->cargo_type);
SetDParam(1, u->cargo_cap);
@ -46,7 +46,7 @@ void DrawAircraftDetails(const Aircraft *v, const Rect &r)
SetDParam(3, u->Next()->cargo_cap);
SetDParam(4, GetCargoSubtypeText(u));
DrawString(r.left, r.right, y, (u->Next()->cargo_cap != 0) ? STR_VEHICLE_INFO_CAPACITY_CAPACITY : STR_VEHICLE_INFO_CAPACITY);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
}
if (u->cargo_cap != 0) {
@ -58,7 +58,7 @@ void DrawAircraftDetails(const Aircraft *v, const Rect &r)
SetDParam(1, cargo_count);
SetDParam(2, u->cargo.GetFirstStation());
DrawString(r.left, r.right, y, STR_VEHICLE_DETAILS_CARGO_FROM);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
feeder_share += u->cargo.GetFeederShare();
}
}

@ -330,7 +330,7 @@ public:
size->width = std::max(size->width, GetStringBoundingBox(as->name).width + padding.width);
}
this->line_height = FONT_HEIGHT_NORMAL + padding.height;
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
size->height = 5 * this->line_height;
break;
}
@ -423,14 +423,14 @@ public:
/* show the noise of the selected airport */
SetDParam(0, as->noise_level);
DrawString(r.left, r.right, top, STR_STATION_BUILD_NOISE);
top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
}
if (_settings_game.economy.infrastructure_maintenance) {
Money monthly = _price[PR_INFRASTRUCTURE_AIRPORT] * as->maintenance_cost >> 3;
SetDParam(0, monthly * 12);
DrawString(r.left, r.right, top, STR_STATION_BUILD_INFRASTRUCTURE_COST);
top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
}
/* strings such as 'Size' and 'Coverage Area' */

@ -334,7 +334,7 @@ public:
case WID_RV_LEFT_DETAILS:
case WID_RV_RIGHT_DETAILS:
size->height = FONT_HEIGHT_NORMAL * this->details_height + padding.height;
size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height;
break;
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
@ -530,7 +530,7 @@ public:
const Rect r = this->GetWidget<NWidgetBase>(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS)->GetCurrentRect()
.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
int text_end = DrawVehiclePurchaseInfo(r.left, r.right, r.top, this->sel_engine[side], ted);
needed_height = std::max(needed_height, (text_end - r.top) / FONT_HEIGHT_NORMAL);
needed_height = std::max(needed_height, (text_end - r.top) / GetCharacterHeight(FS_NORMAL));
}
}
if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.

@ -52,7 +52,7 @@
*/
uint GetEngineListHeight(VehicleType type)
{
return std::max<uint>(FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical(), GetVehicleImageCellSize(type, EIT_PURCHASE).height);
return std::max<uint>(GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical(), GetVehicleImageCellSize(type, EIT_PURCHASE).height);
}
/* Normal layout for roadvehicles, ships and airplanes. */
@ -788,7 +788,7 @@ static int DrawCargoCapacityInfo(int left, int right, int y, TestedEngineDetails
SetDParam(1, te.all_capacities[cid]);
SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
return y;
@ -808,14 +808,14 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine
SetDParam(0, e->GetCost());
DrawString(left, right, y, STR_PURCHASE_INFO_COST);
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Wagon weight - (including cargo) */
uint weight = e->GetDisplayWeight();
SetDParam(0, weight);
SetDParam(1, GetCargoWeight(te.all_capacities, VEH_TRAIN) + weight);
DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Wagon speed limit, displayed if above zero */
if (_settings_game.vehicle.wagon_speed_limits) {
@ -823,7 +823,7 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine
if (max_speed > 0) {
SetDParam(0, PackVelocity(max_speed, e->type));
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
}
@ -831,7 +831,7 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine
if (rvi->running_cost_class != INVALID_PRICE) {
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
return y;
@ -853,26 +853,26 @@ static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engin
SetDParam(1, e->GetDisplayWeight());
DrawString(left, right, y, STR_PURCHASE_INFO_COST_WEIGHT);
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Max speed - Engine power */
SetDParam(0, PackVelocity(e->GetDisplayMaxSpeed(), e->type));
SetDParam(1, e->GetPower());
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_POWER);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Max tractive effort - not applicable if old acceleration or maglev */
if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL && GetRailTypeInfo(rvi->railtype)->acceleration_type != 2) {
SetDParam(0, e->GetDisplayMaxTractiveEffort());
DrawString(left, right, y, STR_PURCHASE_INFO_MAX_TE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
/* Running cost */
if (rvi->running_cost_class != INVALID_PRICE) {
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
/* Powered wagons power - Powered wagons extra weight */
@ -880,7 +880,7 @@ static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engin
SetDParam(0, rvi->pow_wag_power);
SetDParam(1, rvi->pow_wag_weight);
DrawString(left, right, y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
return y;
@ -901,25 +901,25 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n
SetDParam(0, e->GetCost());
DrawString(left, right, y, STR_PURCHASE_INFO_COST);
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Road vehicle weight - (including cargo) */
int16 weight = e->GetDisplayWeight();
SetDParam(0, weight);
SetDParam(1, GetCargoWeight(te.all_capacities, VEH_ROAD) + weight);
DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Max speed - Engine power */
SetDParam(0, PackVelocity(e->GetDisplayMaxSpeed(), e->type));
SetDParam(1, e->GetPower());
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_POWER);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Max tractive effort */
SetDParam(0, e->GetDisplayMaxTractiveEffort());
DrawString(left, right, y, STR_PURCHASE_INFO_MAX_TE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
} else {
/* Purchase cost - Max speed */
if (te.cost != 0) {
@ -932,13 +932,13 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n
SetDParam(1, PackVelocity(e->GetDisplayMaxSpeed(), e->type));
DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
/* Running cost */
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
return y;
}
@ -964,7 +964,7 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb
SetDParam(1, PackVelocity(ocean_speed, e->type));
DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
} else {
if (te.cost != 0) {
SetDParam(0, e->GetCost() + te.cost);
@ -974,15 +974,15 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb
SetDParam(0, e->GetCost());
DrawString(left, right, y, STR_PURCHASE_INFO_COST);
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
SetDParam(0, PackVelocity(ocean_speed, e->type));
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_OCEAN);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
SetDParam(0, PackVelocity(canal_speed, e->type));
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_CANAL);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
if (!IsArticulatedEngine(engine_number)) {
@ -991,13 +991,13 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb
SetDParam(1, te.capacity);
SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
/* Running cost */
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
return y;
}
@ -1026,7 +1026,7 @@ static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_
SetDParam(1, PackVelocity(e->GetDisplayMaxSpeed(), e->type));
DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Cargo capacity */
if (te.mail_capacity > 0) {
@ -1043,24 +1043,24 @@ static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_
SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Running cost */
SetDParam(0, e->GetDisplayRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Aircraft type */
SetDParam(0, e->GetAircraftTypeText());
DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_TYPE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Aircraft range, if available. */
uint16 range = e->GetRange();
if (range != 0) {
SetDParam(0, range);
DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_RANGE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
return y;
@ -1167,7 +1167,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number,
SetDParam(0, CT_INVALID);
SetDParam(2, STR_EMPTY);
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
} else {
y = new_y;
}
@ -1179,16 +1179,16 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number,
SetDParam(0, ymd.year);
SetDParam(1, DateToYear(e->GetLifeLengthInDays()));
DrawString(left, right, y, STR_PURCHASE_INFO_DESIGNED_LIFE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Reliability */
SetDParam(0, ToPercent16(e->reliability));
DrawString(left, right, y, STR_PURCHASE_INFO_RELIABILITY);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
} else if (_settings_client.gui.show_wagon_intro_year) {
SetDParam(0, ymd.year);
DrawString(left, right, y, STR_PURCHASE_INFO_DESIGNED);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
if (refittable) y = ShowRefitOptionsList(left, right, y, engine_number);
@ -1201,7 +1201,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number,
if (_settings_client.gui.show_newgrf_name && config != nullptr)
{
DrawString(left, right, y, config->GetName(), TC_BLACK);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
return y;
@ -1257,8 +1257,8 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
Rect rr = tr.WithWidth(replace_icon.width, !rtl); // Replace icon position
if (show_count) tr = tr.Indent(count_width + WidgetDimensions::scaled.hsep_normal + replace_icon.width + WidgetDimensions::scaled.hsep_wide, !rtl);
int normal_text_y_offset = (ir.Height() - FONT_HEIGHT_NORMAL) / 2;
int small_text_y_offset = ir.Height() - FONT_HEIGHT_SMALL;
int normal_text_y_offset = (ir.Height() - GetCharacterHeight(FS_NORMAL)) / 2;
int small_text_y_offset = ir.Height() - GetCharacterHeight(FS_SMALL);
int replace_icon_y_offset = (ir.Height() - replace_icon.height) / 2;
int y = ir.top;
@ -1298,7 +1298,7 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
if (indent > 0) {
/* Draw tree lines */
Rect fr = ir.Indent(indent - WidgetDimensions::scaled.hsep_indent, rtl).WithWidth(circle_width, rtl);
int ycenter = y + normal_text_y_offset + FONT_HEIGHT_NORMAL / 2;
int ycenter = y + normal_text_y_offset + GetCharacterHeight(FS_NORMAL) / 2;
bool continues = (min + 1U) < eng_list.size() && eng_list[min + 1].indent == item.indent;
GfxDrawLine(fr.left + circle_width / 2, y - WidgetDimensions::scaled.matrix.top, fr.left + circle_width / 2, continues ? y - WidgetDimensions::scaled.matrix.top + step_size - 1 : ycenter, linecolour, WidgetDimensions::scaled.fullbevel.top);
GfxDrawLine(fr.left + circle_width / 2, ycenter, fr.right, ycenter, linecolour, WidgetDimensions::scaled.fullbevel.top);
@ -1531,6 +1531,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
{
/* Set the last cargo filter criteria. */
this->cargo_filter_criteria = _engine_sort_last_cargo_criteria[this->vehicle_type];
if (this->cargo_filter_criteria < NUM_CARGO && !HasBit(_standard_cargo_mask, this->cargo_filter_criteria)) this->cargo_filter_criteria = CF_ANY;
this->eng_list.SetFilterFuncs(_filter_funcs);
this->eng_list.SetFilterState(this->cargo_filter_criteria != CF_ANY);
@ -2031,7 +2032,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
break;
case WID_BV_PANEL:
size->height = FONT_HEIGHT_NORMAL * this->details_height + padding.height;
size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height;
break;
case WID_BV_SORT_ASCENDING_DESCENDING: {
@ -2105,12 +2106,12 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
if (this->sel_engine != INVALID_ENGINE) {
const Rect r = this->GetWidget<NWidgetBase>(WID_BV_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
int text_end = DrawVehiclePurchaseInfo(r.left, r.right, r.top, this->sel_engine, this->te);
needed_height = std::max(needed_height, (text_end - r.top) / FONT_HEIGHT_NORMAL);
needed_height = std::max(needed_height, (text_end - r.top) / GetCharacterHeight(FS_NORMAL));
}
if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.
int resize = needed_height - this->details_height;
this->details_height = needed_height;
this->ReInit(0, resize * FONT_HEIGHT_NORMAL);
this->ReInit(0, resize * GetCharacterHeight(FS_NORMAL));
return;
}
}
@ -2414,7 +2415,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
this->UpdateButtonMode();
this->loco.details_height = this->wagon.details_height = 10 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.Vertical();
this->loco.details_height = this->wagon.details_height = 10 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.framerect.Vertical();
this->FinishInitNested(this->window_number);

@ -265,7 +265,7 @@ struct CheatWindow : Window {
uint text_left = ir.left + (rtl ? 0 : WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH);
uint text_right = ir.right - (rtl ? WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH : 0);
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
int box_y_offset = (this->line_height - this->box.height) / 2;
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
int icon_y_offset = (this->line_height - this->icon.height) / 2;
@ -374,7 +374,7 @@ struct CheatWindow : Window {
this->line_height = std::max(this->box.height, this->icon.height);
this->line_height = std::max<uint>(this->line_height, SETTING_BUTTON_HEIGHT);
this->line_height = std::max<uint>(this->line_height, FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.framerect.Vertical();
this->line_height = std::max<uint>(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical();
size->width = width + WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH /* stuff on the left */ + WidgetDimensions::scaled.hsep_wide * 2 /* extra spacing on right */;
size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lines;

@ -90,7 +90,7 @@ struct ExpensesList {
uint GetHeight() const
{
/* Add up the height of all the lines. */
return static_cast<uint>(this->items.size()) * FONT_HEIGHT_NORMAL;
return static_cast<uint>(this->items.size()) * GetCharacterHeight(FS_NORMAL);
}
/** Compute width of the expenses categories in pixels. */
@ -118,15 +118,15 @@ static const std::initializer_list<ExpensesList> _expenses_list_types = {
static uint GetTotalCategoriesHeight()
{
/* There's an empty line and blockspace on the year row */
uint total_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
uint total_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide;
for (const ExpensesList &list : _expenses_list_types) {
/* Title + expense list + total line + total + blockspace after category */
total_height += FONT_HEIGHT_NORMAL + list.GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
total_height += GetCharacterHeight(FS_NORMAL) + list.GetHeight() + WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide;
}
/* Total income */
total_height += WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
total_height += WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide;
return total_height;
}
@ -161,7 +161,7 @@ static void DrawCategory(const Rect &r, int start_y, const ExpensesList &list)
for (const ExpensesType &et : list.items) {
DrawString(tr, STR_FINANCES_SECTION_CONSTRUCTION + et);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
}
@ -173,12 +173,12 @@ static void DrawCategory(const Rect &r, int start_y, const ExpensesList &list)
static void DrawCategories(const Rect &r)
{
/* Start with an empty space in the year row, plus the blockspace under the year. */
int y = r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
int y = r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide;
for (const ExpensesList &list : _expenses_list_types) {
/* Draw category title and advance y */
DrawString(r.left, r.right, y, list.title, TC_FROMSTRING, SA_LEFT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Draw category items and advance y */
DrawCategory(r, y, list);
@ -189,7 +189,7 @@ static void DrawCategories(const Rect &r)
/* Draw category total and advance y */
DrawString(r.left, r.right, y, STR_FINANCES_TOTAL_CAPTION, TC_FROMSTRING, SA_RIGHT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Advance y by a blockspace after this category block */
y += WidgetDimensions::scaled.vsep_wide;
@ -234,7 +234,7 @@ static Money DrawYearCategory(const Rect &r, int start_y, const ExpensesList &li
Money cost = tbl[et];
sum += cost;
if (cost != 0) DrawPrice(cost, r.left, r.right, y, TC_BLACK);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
/* Draw the total at the bottom of the category. */
@ -262,14 +262,14 @@ static void DrawYearColumn(const Rect &r, int year, const Expenses &tbl)
/* Year header */
SetDParam(0, year);
DrawString(r.left, r.right, y, STR_FINANCES_YEAR, TC_FROMSTRING, SA_RIGHT, true);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide;
/* Categories */
for (const ExpensesList &list : _expenses_list_types) {
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
sum += DrawYearCategory(r, y, list, tbl);
/* Expense list + expense category title + expense category total + blockspace after category */
y += list.GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
y += list.GetHeight() + WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide;
}
/* Total income. */
@ -407,7 +407,7 @@ struct CompanyFinancesWindow : Window {
break;
case WID_CF_INTEREST_RATE:
size->height = FONT_HEIGHT_NORMAL;
size->height = GetCharacterHeight(FS_NORMAL);
break;
}
}
@ -632,7 +632,7 @@ public:
uint Height() const override
{
return std::max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + WidgetDimensions::scaled.vsep_normal);
return std::max(GetCharacterHeight(FS_NORMAL), ScaleGUITrad(12) + WidgetDimensions::scaled.vsep_normal);
}
bool Selectable() const override
@ -644,7 +644,7 @@ public:
{
bool rtl = _current_text_dir == TD_RTL;
int icon_y = CenterBounds(r.top, r.bottom, 0);
int text_y = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL);
int text_y = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL));
Rect tr = r.Shrink(WidgetDimensions::scaled.dropdowntext);
DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOUR_START + (this->result % COLOUR_END),
rtl ? tr.right - ScaleGUITrad(14) : tr.left + ScaleGUITrad(14),
@ -842,7 +842,7 @@ public:
case WID_SCL_MATRIX: {
/* 11 items in the default rail class */
this->square = GetSpriteSize(SPR_SQUARE);
this->line_height = std::max(this->square.height, (uint)FONT_HEIGHT_NORMAL) + padding.height;
this->line_height = std::max(this->square.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
size->height = 11 * this->line_height;
resize->width = 1;
@ -947,7 +947,7 @@ public:
Rect ir = r.WithHeight(this->resize.step_height).Shrink(WidgetDimensions::scaled.matrix);
int square_offs = (ir.Height() - this->square.height) / 2;
int text_offs = (ir.Height() - FONT_HEIGHT_NORMAL) / 2;
int text_offs = (ir.Height() - GetCharacterHeight(FS_NORMAL)) / 2;
int y = ir.top;
@ -1859,7 +1859,7 @@ struct CompanyInfrastructureWindow : Window
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_CI_SCROLLBAR);
this->vscroll->SetStepSize(FONT_HEIGHT_NORMAL);
this->vscroll->SetStepSize(GetCharacterHeight(FS_NORMAL));
this->FinishInitNested(window_number);
}
@ -1971,15 +1971,15 @@ struct CompanyInfrastructureWindow : Window
size->width += padding.width;
uint total_height = ((rail_lines + road_lines + tram_lines + 2 + 3) * FONT_HEIGHT_NORMAL) + (4 * EXP_SPACING);
uint total_height = ((rail_lines + road_lines + tram_lines + 2 + 3) * GetCharacterHeight(FS_NORMAL)) + (4 * EXP_SPACING);
/* Set height of the total line. */
if (_settings_game.economy.infrastructure_maintenance) total_height += EXP_SPACING + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL;
if (_settings_game.economy.infrastructure_maintenance) total_height += EXP_SPACING + WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL);
this->vscroll->SetCount(total_height);
size->height = std::max(size->height, std::min<uint>(8 * FONT_HEIGHT_NORMAL, total_height));
uint target_height = std::min<uint>(40 * FONT_HEIGHT_NORMAL, total_height);
size->height = std::max(size->height, std::min<uint>(8 * GetCharacterHeight(FS_NORMAL), total_height));
uint target_height = std::min<uint>(40 * GetCharacterHeight(FS_NORMAL), total_height);
this->height_extra = (target_height > size->height) ? (target_height - size->height) : 0;
break;
}
@ -2037,7 +2037,7 @@ struct CompanyInfrastructureWindow : Window
void DrawCountLine(int width, int &y, int count, Money monthly_cost) const
{
SetDParam(0, count);
DrawString(0, width, y += FONT_HEIGHT_NORMAL, STR_JUST_COMMA, TC_WHITE, SA_RIGHT);
DrawString(0, width, y += GetCharacterHeight(FS_NORMAL), STR_JUST_COMMA, TC_WHITE, SA_RIGHT);
if (_settings_game.economy.infrastructure_maintenance) {
SetDParam(0, monthly_cost * 12); // Convert to per year
@ -2073,16 +2073,16 @@ struct CompanyInfrastructureWindow : Window
/* Draw name of each valid railtype. */
for (const auto &rt : _sorted_railtypes) {
if (HasBit(this->railtypes, rt)) {
DrawString(offs_left, width - offs_right, y += FONT_HEIGHT_NORMAL, GetRailTypeInfo(rt)->strings.name, TC_WHITE);
DrawString(offs_left, width - offs_right, y += GetCharacterHeight(FS_NORMAL), GetRailTypeInfo(rt)->strings.name, TC_WHITE);
}
}
DrawString(offs_left, width - offs_right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS);
DrawString(offs_left, width - offs_right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS);
} else {
/* No valid railtype. */
DrawString(offs_left, width - offs_right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_VIEW_INFRASTRUCTURE_NONE);
DrawString(offs_left, width - offs_right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_VIEW_INFRASTRUCTURE_NONE);
}
y += FONT_HEIGHT_NORMAL + EXP_SPACING;
y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING;
DrawString(0, width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT);
@ -2090,11 +2090,11 @@ struct CompanyInfrastructureWindow : Window
for (const auto &rt : _sorted_roadtypes) {
if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt)) {
SetDParam(0, GetRoadTypeInfo(rt)->strings.name);
DrawString(offs_left, width - offs_right, y += FONT_HEIGHT_NORMAL, STR_JUST_STRING, TC_WHITE);
DrawString(offs_left, width - offs_right, y += GetCharacterHeight(FS_NORMAL), STR_JUST_STRING, TC_WHITE);
}
}
y += FONT_HEIGHT_NORMAL + EXP_SPACING;
y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING;
DrawString(0, width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT);
@ -2102,20 +2102,20 @@ struct CompanyInfrastructureWindow : Window
for (const auto &rt : _sorted_roadtypes) {
if (HasBit(this->roadtypes, rt) && RoadTypeIsTram(rt)) {
SetDParam(0, GetRoadTypeInfo(rt)->strings.name);
DrawString(offs_left, width - offs_right, y += FONT_HEIGHT_NORMAL, STR_JUST_STRING, TC_WHITE);
DrawString(offs_left, width - offs_right, y += GetCharacterHeight(FS_NORMAL), STR_JUST_STRING, TC_WHITE);
}
}
y += FONT_HEIGHT_NORMAL + EXP_SPACING;
y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING;
DrawString(0, width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT);
DrawString(offs_left, width - offs_right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS);
DrawString(offs_left, width - offs_right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS);
y += FONT_HEIGHT_NORMAL + EXP_SPACING;
y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING;
DrawString(0, width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT);
DrawString(offs_left, width - offs_right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS);
DrawString(offs_left, width - offs_right, y += FONT_HEIGHT_NORMAL, STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS);
DrawString(offs_left, width - offs_right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS);
DrawString(offs_left, width - offs_right, y += GetCharacterHeight(FS_NORMAL), STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS);
break;
}
@ -2132,7 +2132,7 @@ struct CompanyInfrastructureWindow : Window
this->DrawCountLine(width, y, c->infrastructure.signal, SignalMaintenanceCost(c->infrastructure.signal));
}
y += FONT_HEIGHT_NORMAL + EXP_SPACING;
y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING;
uint32 road_total = c->infrastructure.GetRoadTotal();
for (const auto &rt : _sorted_roadtypes) {
@ -2141,7 +2141,7 @@ struct CompanyInfrastructureWindow : Window
}
}
y += FONT_HEIGHT_NORMAL + EXP_SPACING;
y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING;
uint32 tram_total = c->infrastructure.GetTramTotal();
for (const auto &rt : _sorted_roadtypes) {
@ -2150,17 +2150,17 @@ struct CompanyInfrastructureWindow : Window
}
}
y += FONT_HEIGHT_NORMAL + EXP_SPACING;
y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING;
this->DrawCountLine(width, y, c->infrastructure.water, CanalMaintenanceCost(c->infrastructure.water));
y += FONT_HEIGHT_NORMAL + EXP_SPACING;
y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING;
this->DrawCountLine(width, y, c->infrastructure.station, StationMaintenanceCost(c->infrastructure.station));
this->DrawCountLine(width, y, c->infrastructure.airport, AirportMaintenanceCost(c->index));
if (_settings_game.economy.infrastructure_maintenance) {
y += FONT_HEIGHT_NORMAL + EXP_SPACING;
y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING;
int left = _current_text_dir == TD_RTL ? width - this->total_width : 0;
GfxFillRect(left, y, left + this->total_width, y + WidgetDimensions::scaled.bevel.top - 1, PC_WHITE);
y += WidgetDimensions::scaled.vsep_normal;
@ -2523,7 +2523,7 @@ struct CompanyWindow : Window
if (amount != 0) {
SetDParam(0, amount);
DrawString(r.left, r.right, y, _company_view_vehicle_count_strings[type]);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
}
@ -2542,7 +2542,7 @@ struct CompanyWindow : Window
if (rail_pieces != 0) {
SetDParam(0, rail_pieces);
DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
uint road_pieces = 0;
@ -2550,25 +2550,25 @@ struct CompanyWindow : Window
if (road_pieces != 0) {
SetDParam(0, road_pieces);
DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
if (c->infrastructure.water != 0) {
SetDParam(0, c->infrastructure.water);
DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_WATER);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
if (c->infrastructure.station != 0) {
SetDParam(0, c->infrastructure.station);
DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_STATION);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
if (c->infrastructure.airport != 0) {
SetDParam(0, c->infrastructure.airport);
DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
if (y == r.top) {
@ -2616,7 +2616,7 @@ struct CompanyWindow : Window
SetDParam(1, c2->index);
DrawString(r.left, r.right, y, STR_COMPANY_VIEW_SHARES_OWNED_BY);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
}
break;

@ -129,7 +129,7 @@ struct IConsoleWindow : Window
void OnInit() override
{
this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.hsep_normal;
this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.hsep_normal;
this->line_offset = GetStringBoundingBox("] ").width + WidgetDimensions::scaled.frametext.left;
}

@ -295,7 +295,7 @@ public:
void SetupValues()
{
this->entry_height = 1 + FONT_HEIGHT_NORMAL + 1 + (_settings_client.gui.departure_larger_font ? FONT_HEIGHT_NORMAL : FONT_HEIGHT_SMALL) + 1 + 1;
this->entry_height = 1 + GetCharacterHeight(FS_NORMAL) + 1 + (_settings_client.gui.departure_larger_font ? GetCharacterHeight(FS_NORMAL) : GetCharacterHeight(FS_SMALL)) + 1 + 1;
if (cached_veh_type_width == 0) {
cached_veh_type_width = GetStringBoundingBox(STR_DEPARTURES_TYPE_PLANE).width;
@ -507,7 +507,7 @@ public:
this->ReInit();
}
uint new_height = 1 + FONT_HEIGHT_NORMAL + 1 + (_settings_client.gui.departure_larger_font ? FONT_HEIGHT_NORMAL : FONT_HEIGHT_SMALL) + 1 + 1;
uint new_height = 1 + GetCharacterHeight(FS_NORMAL) + 1 + (_settings_client.gui.departure_larger_font ? GetCharacterHeight(FS_NORMAL) : GetCharacterHeight(FS_SMALL)) + 1 + 1;
if (new_height != this->entry_height) {
this->entry_height = new_height;
@ -678,7 +678,7 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
max_departures = _settings_client.gui.max_departures;
}
const int small_font_size = _settings_client.gui.departure_larger_font ? FONT_HEIGHT_NORMAL : FONT_HEIGHT_SMALL;
const int small_font_size = _settings_client.gui.departure_larger_font ? GetCharacterHeight(FS_NORMAL) : GetCharacterHeight(FS_SMALL);
/* Draw the black background. */
GfxFillRect(r.left + 1, r.top, r.right - 1, r.bottom, PC_BLACK);

@ -332,7 +332,7 @@ struct DepotWindow : Window {
SetDParam(0, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE));
SetDParam(1, 1);
Rect count = text.WithWidth(this->count_width - WidgetDimensions::scaled.hsep_normal, !rtl);
DrawString(count.left, count.right, count.bottom - FONT_HEIGHT_SMALL + 1, STR_JUST_DECIMAL, TC_BLACK, SA_RIGHT, false, FS_SMALL); // Draw the counter
DrawString(count.left, count.right, count.bottom - GetCharacterHeight(FS_SMALL) + 1, STR_JUST_DECIMAL, TC_BLACK, SA_RIGHT, false, FS_SMALL); // Draw the counter
break;
}
@ -350,10 +350,10 @@ struct DepotWindow : Window {
} else {
/* Arrange unitnumber and flag vertically */
diff_x = 0;
diff_y = WidgetDimensions::scaled.matrix.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
diff_y = WidgetDimensions::scaled.matrix.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
}
text = text.WithWidth(this->header_width - WidgetDimensions::scaled.hsep_normal, rtl).WithHeight(FONT_HEIGHT_NORMAL).Indent(diff_x, rtl);
text = text.WithWidth(this->header_width - WidgetDimensions::scaled.hsep_normal, rtl).WithHeight(GetCharacterHeight(FS_NORMAL)).Indent(diff_x, rtl);
if (free_wagon) {
DrawString(text, STR_DEPOT_NO_ENGINE);
} else {
@ -509,7 +509,7 @@ struct DepotWindow : Window {
case VEH_SHIP:
case VEH_AIRCRAFT:
if (xm <= this->flag_size.width && ym >= (uint)(FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal)) return MODE_START_STOP;
if (xm <= this->flag_size.width && ym >= (uint)(GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal)) return MODE_START_STOP;
break;
default: NOT_REACHED();

@ -99,7 +99,7 @@ struct EnginePreviewWindow : Window {
size->width = std::max(size->width, x - x_offs);
SetDParam(0, GetEngineCategoryName(engine));
size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + FONT_HEIGHT_NORMAL + this->vehicle_space;
size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space;
SetDParam(0, engine);
size->height += GetStringHeight(GetEngineInfoString(engine), size->width);
}
@ -114,7 +114,7 @@ struct EnginePreviewWindow : Window {
SetDParam(0, PackEngineNameDParam(engine, EngineNameContext::PreviewNews));
DrawString(r.left, r.right, y, STR_ENGINE_NAME, TC_BLACK, SA_HOR_CENTER);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
DrawVehicleEngine(r.left, r.right, this->width >> 1, y + this->vehicle_space / 2, engine, GetEnginePalette(engine, _local_company), EIT_PREVIEW);

@ -441,7 +441,7 @@ public:
Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
if (free_space.has_value()) SetDParam(0, free_space.value());
DrawString(ir.left, ir.right, ir.top + FONT_HEIGHT_NORMAL, free_space.has_value() ? STR_SAVELOAD_BYTES_FREE : STR_ERROR_UNABLE_TO_READ_DRIVE);
DrawString(ir.left, ir.right, ir.top + GetCharacterHeight(FS_NORMAL), free_space.has_value() ? STR_SAVELOAD_BYTES_FREE : STR_ERROR_UNABLE_TO_READ_DRIVE);
DrawString(ir.left, ir.right, ir.top, path, TC_BLACK);
break;
}
@ -475,7 +475,7 @@ public:
void DrawDetails(const Rect &r) const
{
/* Header panel */
int HEADER_HEIGHT = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.Vertical();
int HEADER_HEIGHT = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.Vertical();
Rect hr = r.WithHeight(HEADER_HEIGHT).Shrink(WidgetDimensions::scaled.frametext);
Rect tr = r.Shrink(WidgetDimensions::scaled.frametext);
@ -488,7 +488,7 @@ public:
if (this->selected == nullptr) return;
/* Details panel */
tr.bottom -= FONT_HEIGHT_NORMAL - 1;
tr.bottom -= GetCharacterHeight(FS_NORMAL) - 1;
if (tr.top > tr.bottom) return;
if (!_load_check_data.version_name.empty()) {
@ -499,7 +499,7 @@ public:
if (!_load_check_data.checkable) {
/* Old savegame, no information available */
DrawString(tr, STR_SAVELOAD_DETAIL_NOT_AVAILABLE);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
} else if (_load_check_data.error != INVALID_STRING_ID) {
/* Incompatible / broken savegame */
SetDParamStr(0, _load_check_data.error_msg);
@ -508,11 +508,11 @@ public:
/* Warning if save unique id differ when saving */
if (this->fop == SLO_SAVE) {
if (_load_check_data.settings.game_creation.generation_unique_id == 0) {
DrawString(tr.left, tr.right, tr.bottom - FONT_HEIGHT_NORMAL, STR_SAVELOAD_UNKNOWN_ID);
tr.bottom -= FONT_HEIGHT_NORMAL;
DrawString(tr.left, tr.right, tr.bottom - GetCharacterHeight(FS_NORMAL), STR_SAVELOAD_UNKNOWN_ID);
tr.bottom -= GetCharacterHeight(FS_NORMAL);
} else if (_load_check_data.settings.game_creation.generation_unique_id != _settings_game.game_creation.generation_unique_id) {
DrawString(tr.left, tr.right, tr.bottom - FONT_HEIGHT_NORMAL, STR_SAVELOAD_DIFFERENT_ID);
tr.bottom -= FONT_HEIGHT_NORMAL;
DrawString(tr.left, tr.right, tr.bottom - GetCharacterHeight(FS_NORMAL), STR_SAVELOAD_DIFFERENT_ID);
tr.bottom -= GetCharacterHeight(FS_NORMAL);
}
}
@ -520,7 +520,7 @@ public:
SetDParam(0, _load_check_data.map_size_x);
SetDParam(1, _load_check_data.map_size_y);
DrawString(tr, STR_NETWORK_SERVER_LIST_MAP_SIZE);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
if (tr.top > tr.bottom) return;
/* Climate */
@ -528,7 +528,7 @@ public:
if (landscape < NUM_LANDSCAPE) {
SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + landscape);
DrawString(tr, STR_NETWORK_SERVER_LIST_LANDSCAPE);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
tr.top += WidgetDimensions::scaled.vsep_normal;
@ -538,7 +538,7 @@ public:
if (_load_check_data.settings.game_creation.starting_year != 0) {
SetDParam(0, ConvertYMDToDate(_load_check_data.settings.game_creation.starting_year, 0, 1));
DrawString(tr, STR_NETWORK_SERVER_LIST_START_DATE);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
if (tr.top > tr.bottom) return;
@ -547,7 +547,7 @@ public:
/* Current date */
SetDParam(0, _load_check_data.current_date);
DrawString(tr, STR_NETWORK_SERVER_LIST_CURRENT_DATE);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
/* Hide the NewGRF stuff when saving. We also hide the button. */
@ -559,7 +559,7 @@ public:
SetDParam(0, _load_check_data.grfconfig == nullptr ? STR_NEWGRF_LIST_NONE :
STR_NEWGRF_LIST_ALL_FOUND + _load_check_data.grf_compatibility);
DrawString(tr, STR_SAVELOAD_DETAIL_GRFSTATUS);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
if (tr.top > tr.bottom) return;
@ -580,7 +580,7 @@ public:
SetDParam(2, c.name_2);
}
DrawString(tr, STR_SAVELOAD_DETAIL_COMPANY_INDEX);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
if (tr.top > tr.bottom) break;
}
}
@ -591,11 +591,11 @@ public:
{
switch (widget) {
case WID_SL_BACKGROUND:
size->height = 2 * FONT_HEIGHT_NORMAL + padding.height;
size->height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height;
break;
case WID_SL_DRIVES_DIRECTORIES_LIST:
resize->height = FONT_HEIGHT_NORMAL;
resize->height = GetCharacterHeight(FS_NORMAL);
size->height = resize->height * 10 + padding.height;
break;
case WID_SL_SORT_BYNAME:

@ -450,7 +450,7 @@ struct FramerateWindow : Window {
this->next_update.SetInterval(100);
/* Window is always initialised to MIN_ELEMENTS height, resize to contain num_displayed */
ResizeWindow(this, 0, (std::max(MIN_ELEMENTS, this->num_displayed) - MIN_ELEMENTS) * FONT_HEIGHT_NORMAL);
ResizeWindow(this, 0, (std::max(MIN_ELEMENTS, this->num_displayed) - MIN_ELEMENTS) * GetCharacterHeight(FS_NORMAL));
}
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
@ -558,9 +558,9 @@ struct FramerateWindow : Window {
case WID_FRW_TIMES_NAMES: {
size->width = 0;
size->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal + MIN_ELEMENTS * FONT_HEIGHT_NORMAL;
size->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + MIN_ELEMENTS * GetCharacterHeight(FS_NORMAL);
resize->width = 0;
resize->height = FONT_HEIGHT_NORMAL;
resize->height = GetCharacterHeight(FS_NORMAL);
for (PerformanceElement e : DISPLAY_ORDER_PFE) {
if (_pf_data[e].num_valid == 0) continue;
Dimension line_size;
@ -584,9 +584,9 @@ struct FramerateWindow : Window {
SetDParam(1, 2);
Dimension item_size = GetStringBoundingBox(STR_FRAMERATE_MS_GOOD);
size->width = std::max(size->width, item_size.width);
size->height += FONT_HEIGHT_NORMAL * MIN_ELEMENTS + WidgetDimensions::scaled.vsep_normal;
size->height += GetCharacterHeight(FS_NORMAL) * MIN_ELEMENTS + WidgetDimensions::scaled.vsep_normal;
resize->width = 0;
resize->height = FONT_HEIGHT_NORMAL;
resize->height = GetCharacterHeight(FS_NORMAL);
break;
}
}
@ -600,7 +600,7 @@ struct FramerateWindow : Window {
int drawable = this->num_displayed;
int y = r.top;
DrawString(r.left, r.right, y, heading_str, TC_FROMSTRING, SA_CENTER, true);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
for (PerformanceElement e : DISPLAY_ORDER_PFE) {
if (_pf_data[e].num_valid == 0) continue;
if (skip > 0) {
@ -608,7 +608,7 @@ struct FramerateWindow : Window {
} else {
values[e].InsertDParams(0);
DrawString(r.left, r.right, y, values[e].strid, TC_FROMSTRING, SA_RIGHT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
drawable--;
if (drawable == 0) break;
}
@ -622,7 +622,7 @@ struct FramerateWindow : Window {
int drawable = this->num_displayed;
int y = r.top;
DrawString(r.left, r.right, y, STR_FRAMERATE_MEMORYUSE, TC_FROMSTRING, SA_CENTER, true);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
for (PerformanceElement e : DISPLAY_ORDER_PFE) {
if (_pf_data[e].num_valid == 0) continue;
if (skip > 0) {
@ -634,12 +634,12 @@ struct FramerateWindow : Window {
SetDParam(0, Company::Get(e - PFE_AI0)->ai_instance->GetAllocatedMemory());
}
DrawString(r.left, r.right, y, STR_FRAMERATE_BYTES_GOOD, TC_FROMSTRING, SA_RIGHT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
drawable--;
if (drawable == 0) break;
} else {
/* skip non-script */
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
drawable--;
if (drawable == 0) break;
}
@ -654,7 +654,7 @@ struct FramerateWindow : Window {
const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
uint16 skip = sb->GetPosition();
int drawable = this->num_displayed;
int y = r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; // first line contains headings in the value columns
int y = r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; // first line contains headings in the value columns
for (PerformanceElement e : DISPLAY_ORDER_PFE) {
if (_pf_data[e].num_valid == 0) continue;
if (skip > 0) {
@ -667,7 +667,7 @@ struct FramerateWindow : Window {
SetDParamStr(1, GetAIName(e - PFE_AI0));
DrawString(r.left, r.right, y, STR_FRAMERATE_AI, TC_FROMSTRING, SA_LEFT);
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
drawable--;
if (drawable == 0) break;
}
@ -696,7 +696,7 @@ struct FramerateWindow : Window {
case WID_FRW_TIMES_AVERAGE: {
/* Open time graph windows when clicking detail measurement lines */
const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
int line = sb->GetScrolledRowFromWidget(pt.y, this, widget, WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL);
int line = sb->GetScrolledRowFromWidget(pt.y, this, widget, WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL));
if (line != INT_MAX) {
line++;
/* Find the visible line that was clicked */
@ -716,7 +716,7 @@ struct FramerateWindow : Window {
void OnResize() override
{
auto *wid = this->GetWidget<NWidgetResizeBase>(WID_FRW_TIMES_NAMES);
this->num_displayed = (wid->current_y - wid->min_y - WidgetDimensions::scaled.vsep_normal) / FONT_HEIGHT_NORMAL - 1; // subtract 1 for headings
this->num_displayed = (wid->current_y - wid->min_y - WidgetDimensions::scaled.vsep_normal) / GetCharacterHeight(FS_NORMAL) - 1; // subtract 1 for headings
this->GetScrollbar(WID_FRW_SCROLLBAR)->SetCapacity(this->num_displayed);
}
};
@ -925,10 +925,10 @@ struct FrametimeGraphWindow : Window {
if (division % 2 == 0) {
if ((TimingMeasurement)this->vertical_scale > TIMESTAMP_PRECISION) {
SetDParam(0, this->vertical_scale * division / 10 / TIMESTAMP_PRECISION);
DrawString(r.left, x_zero - 2, y - FONT_HEIGHT_SMALL, STR_FRAMERATE_GRAPH_SECONDS, TC_GREY, SA_RIGHT | SA_FORCE, false, FS_SMALL);
DrawString(r.left, x_zero - 2, y - GetCharacterHeight(FS_SMALL), STR_FRAMERATE_GRAPH_SECONDS, TC_GREY, SA_RIGHT | SA_FORCE, false, FS_SMALL);
} else {
SetDParam(0, this->vertical_scale * division / 10 * 1000 / TIMESTAMP_PRECISION);
DrawString(r.left, x_zero - 2, y - FONT_HEIGHT_SMALL, STR_FRAMERATE_GRAPH_MILLISECONDS, TC_GREY, SA_RIGHT | SA_FORCE, false, FS_SMALL);
DrawString(r.left, x_zero - 2, y - GetCharacterHeight(FS_SMALL), STR_FRAMERATE_GRAPH_MILLISECONDS, TC_GREY, SA_RIGHT | SA_FORCE, false, FS_SMALL);
}
}
}
@ -996,7 +996,7 @@ struct FrametimeGraphWindow : Window {
TextColour tc_peak = (TextColour)(TC_IS_PALETTE_COLOUR | c_peak);
GfxFillRect(peak_point.x - 1, peak_point.y - 1, peak_point.x + 1, peak_point.y + 1, c_peak);
SetDParam(0, peak_value * 1000 / TIMESTAMP_PRECISION);
int label_y = std::max(y_max, peak_point.y - FONT_HEIGHT_SMALL);
int label_y = std::max(y_max, peak_point.y - GetCharacterHeight(FS_SMALL));
if (peak_point.x - x_zero > (int)this->graph_size.width / 2) {
DrawString(x_zero, peak_point.x - 2, label_y, STR_FRAMERATE_GRAPH_MILLISECONDS, tc_peak, SA_RIGHT | SA_FORCE, false, FS_SMALL);
} else {

@ -143,14 +143,14 @@ struct GSConfigWindow : public Window {
{
switch (widget) {
case WID_GSC_SETTINGS:
this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + padding.height;
this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height;
resize->width = 1;
resize->height = this->line_height;
size->height = 5 * this->line_height;
break;
case WID_GSC_GSLIST:
this->line_height = FONT_HEIGHT_NORMAL + padding.height;
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
size->height = 1 * this->line_height;
break;
}
@ -193,7 +193,7 @@ struct GSConfigWindow : public Window {
int y = r.top;
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) {
const ScriptConfigItem &config_item = **it;
int current_value = config->GetSetting((config_item).name);

@ -227,7 +227,7 @@ static const NWidgetPart _nested_heightmap_load_widgets[] = {
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
/* Heightmap name label. */
NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_NULL),
NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_NAME_TEXT), SetTextStyle(TC_ORANGE), SetDataTip(STR_JUST_RAW_STRING, STR_EMPTY), SetFill(1, 0),
NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_NAME_TEXT), SetTextStyle(TC_ORANGE), SetDataTip(STR_JUST_RAW_STRING, STR_NULL), SetFill(1, 0),
EndContainer(),
/* Generation options. */
@ -645,7 +645,7 @@ struct GenerateLandscapeWindow : public Window {
void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
{
Dimension d{0, (uint)FONT_HEIGHT_NORMAL};
Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)};
const StringID *strs = nullptr;
switch (widget) {
case WID_GL_HEIGHTMAP_HEIGHT_TEXT:
@ -1563,7 +1563,7 @@ struct GenerateProgressWindow : public Window {
for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width);
}
size->height = FONT_HEIGHT_NORMAL * 2 + WidgetDimensions::scaled.vsep_normal;
size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
break;
}
}
@ -1577,7 +1577,7 @@ struct GenerateProgressWindow : public Window {
Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, false), COLOUR_MAUVE, FR_NONE);
SetDParam(0, _gws.percent);
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_NORMAL), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
break;
}
@ -1588,7 +1588,7 @@ struct GenerateProgressWindow : public Window {
/* And say where we are in that class */
SetDParam(0, _gws.current);
SetDParam(1, _gws.total);
DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(r.left, r.right, r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
}
}
};

@ -685,7 +685,7 @@ static int DrawLayoutLine(const ParagraphLayouter::Line &line, int y, int left,
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
{
/* The string may contain control chars to change the font, just use the biggest font for clipping. */
int max_height = std::max({FONT_HEIGHT_SMALL, FONT_HEIGHT_NORMAL, FONT_HEIGHT_LARGE, FONT_HEIGHT_MONO});
int max_height = std::max({GetCharacterHeight(FS_SMALL), GetCharacterHeight(FS_NORMAL), GetCharacterHeight(FS_LARGE), GetCharacterHeight(FS_MONO)});
/* Funny glyphs may extent outside the usual bounds, so relax the clipping somewhat. */
int extra = max_height / 2;
@ -966,7 +966,7 @@ void DrawCharCentered(WChar c, const Rect &r, TextColour colour)
ctx.SetColourRemap(colour);
GfxMainBlitter(ctx, GetGlyph(FS_NORMAL, c),
CenterBounds(r.left, r.right, GetCharacterWidth(FS_NORMAL, c)),
CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL),
CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)),
BM_COLOUR_REMAP);
}

@ -222,18 +222,6 @@ inline int GetCharacterHeight(FontSize size)
return font_height_cache[size];
}
/** Height of characters in the small (#FS_SMALL) font. @note Some characters may be oversized. */
#define FONT_HEIGHT_SMALL (GetCharacterHeight(FS_SMALL))
/** Height of characters in the normal (#FS_NORMAL) font. @note Some characters may be oversized. */
#define FONT_HEIGHT_NORMAL (GetCharacterHeight(FS_NORMAL))
/** Height of characters in the large (#FS_LARGE) font. @note Some characters may be oversized. */
#define FONT_HEIGHT_LARGE (GetCharacterHeight(FS_LARGE))
/** Height of characters in the large (#FS_MONO) font. @note Some characters may be oversized. */
#define FONT_HEIGHT_MONO (GetCharacterHeight(FS_MONO))
TextColour GetContrastColour(uint8 background, uint8 threshold = 128);
/**

@ -219,7 +219,7 @@ struct GoalListWindow : public Window {
}
break;
}
r.top += FONT_HEIGHT_NORMAL;
r.top += GetCharacterHeight(FS_NORMAL);
}
pos++;
num++;

@ -76,7 +76,7 @@ struct GraphLegendWindow : Window {
const Rect tr = ir.Indent(d.width + WidgetDimensions::scaled.hsep_normal, rtl);
SetDParam(0, cid);
SetDParam(1, cid);
DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, FONT_HEIGHT_NORMAL), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE);
DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE);
}
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
@ -545,7 +545,7 @@ public:
uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width;
size->width = std::max<uint>(size->width, ScaleGUITrad(5) + y_label_width + this->num_on_x_axis * (x_label_width + ScaleGUITrad(5)) + ScaleGUITrad(9));
size->height = std::max<uint>(size->height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->draw_dates ? 3 : 1)) * FONT_HEIGHT_SMALL + ScaleGUITrad(4));
size->height = std::max<uint>(size->height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->draw_dates ? 3 : 1)) * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(4));
size->height = std::max<uint>(size->height, size->width / 3);
}
@ -754,7 +754,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow {
void OnInit() override
{
/* Width of the legend blob. */
this->legend_width = (FONT_HEIGHT_SMALL - ScaleGUITrad(1)) * 8 / 5;
this->legend_width = (GetCharacterHeight(FS_SMALL) - ScaleGUITrad(1)) * 9 / 6;
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
@ -1252,7 +1252,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
void OnInit() override
{
/* Width of the legend blob. */
this->legend_width = (FONT_HEIGHT_SMALL - ScaleGUITrad(1)) * 8 / 5;
this->legend_width = GetCharacterHeight(FS_SMALL) * 9 / 6;
}
void UpdateExcludedData()
@ -1273,7 +1273,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
return;
}
size->height = FONT_HEIGHT_SMALL + WidgetDimensions::scaled.framerect.Vertical();
size->height = GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.framerect.Vertical();
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
SetDParam(0, cs->name);
@ -1538,7 +1538,7 @@ struct PerformanceRatingDetailWindow : Window {
{
switch (widget) {
case WID_PRD_SCORE_FIRST:
this->bar_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.Vertical();
this->bar_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.Vertical();
size->height = this->bar_height + WidgetDimensions::scaled.matrix.Vertical();
uint score_info_width = 0;
@ -1626,7 +1626,7 @@ struct PerformanceRatingDetailWindow : Window {
}
uint bar_top = CenterBounds(r.top, r.bottom, this->bar_height);
uint text_top = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL);
uint text_top = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL));
DrawString(this->score_info_left, this->score_info_right, text_top, STR_PERFORMANCE_DETAIL_VEHICLES + score_type);
@ -1833,7 +1833,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow {
void OnInit() override
{
/* Width of the legend blob. */
this->legend_width = (FONT_HEIGHT_SMALL - ScaleGUITrad(1)) * 8 / 5;
this->legend_width = (GetCharacterHeight(FS_SMALL) - ScaleGUITrad(1)) * 9 / 6;
this->legend_excluded_cargo = 0;
}
@ -1894,7 +1894,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow {
int x = ir.left;
int y = ir.top;
const uint row_height = FONT_HEIGHT_SMALL;
const uint row_height = GetCharacterHeight(FS_SMALL);
const int padding = ScaleGUITrad(1);
int pos = this->vscroll->GetPosition();

@ -238,7 +238,7 @@ private:
this->tiny_step_height = this->column_size[VGC_FOLD].height;
this->column_size[VGC_NAME] = maxdim(GetStringBoundingBox(STR_GROUP_DEFAULT_TRAINS + this->vli.vtype), GetStringBoundingBox(STR_GROUP_ALL_TRAINS + this->vli.vtype));
this->column_size[VGC_NAME].width = std::max((170u * FONT_HEIGHT_NORMAL) / 10u, this->column_size[VGC_NAME].width) + WidgetDimensions::scaled.hsep_indent;
this->column_size[VGC_NAME].width = std::max((170u * GetCharacterHeight(FS_NORMAL)) / 10u, this->column_size[VGC_NAME].width) + WidgetDimensions::scaled.hsep_indent;
this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[VGC_NAME].height);
this->column_size[VGC_PROTECT] = GetSpriteSize(SPR_GROUP_REPLACE_PROTECT);
@ -637,17 +637,17 @@ public:
const int left = r.left + WidgetDimensions::scaled.framerect.left + WidgetDimensions::scaled.vsep_wide;
const int right = r.right - WidgetDimensions::scaled.framerect.right - WidgetDimensions::scaled.vsep_wide;
int y = r.top + (1 + r.bottom - r.top - (3 * FONT_HEIGHT_NORMAL)) / 2;
int y = r.top + (1 + r.bottom - r.top - (3 * GetCharacterHeight(FS_NORMAL))) / 2;
DrawString(left, right, y, STR_GROUP_PROFIT_THIS_YEAR, TC_BLACK);
SetDParam(0, this->money_this_year);
DrawString(left, right, y, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
DrawString(left, right, y, STR_GROUP_PROFIT_LAST_YEAR, TC_BLACK);
SetDParam(0, this->money_last_year);
DrawString(left, right, y, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
DrawString(left, right, y, STR_GROUP_OCCUPANCY, TC_BLACK);
if (this->vehicles.size() > 0) {
SetDParam(0, this->occupancy_ratio);

@ -201,7 +201,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow {
DrawString(pt.x + ScaleSpriteTrad(71), pt.x + ScaleSpriteTrad(569), pt.y + ScaleSpriteTrad(140 + i * 55), STR_JUST_BIG_RAW_STRING, colour);
SetDParam(0, hs[i].title);
SetDParam(1, hs[i].score);
DrawString(pt.x + ScaleSpriteTrad(71), pt.x + ScaleSpriteTrad(569), pt.y + ScaleSpriteTrad(140) + FONT_HEIGHT_LARGE + ScaleSpriteTrad(i * 55), STR_HIGHSCORE_STATS, colour);
DrawString(pt.x + ScaleSpriteTrad(71), pt.x + ScaleSpriteTrad(569), pt.y + ScaleSpriteTrad(140) + GetCharacterHeight(FS_LARGE) + ScaleSpriteTrad(i * 55), STR_HIGHSCORE_STATS, colour);
}
}
}

@ -424,8 +424,8 @@ public:
void OnInit() override
{
/* Width of the legend blob -- slightly larger than the smallmap legend blob. */
this->legend.height = FONT_HEIGHT_SMALL;
this->legend.width = this->legend.height * 8 / 5;
this->legend.height = GetCharacterHeight(FS_SMALL);
this->legend.width = this->legend.height * 9 / 6;
this->SetupArrays();
}
@ -438,7 +438,7 @@ public:
for (const auto &indtype : this->list) {
d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(indtype)->name));
}
resize->height = std::max<uint>(this->legend.height, FONT_HEIGHT_NORMAL) + padding.height;
resize->height = std::max<uint>(this->legend.height, GetCharacterHeight(FS_NORMAL)) + padding.height;
d.width += this->legend.width + WidgetDimensions::scaled.hsep_wide + padding.width;
d.height = 5 * resize->height;
*size = maxdim(*size, d);
@ -451,7 +451,7 @@ public:
uint extra_lines_req = 0;
uint extra_lines_prd = 0;
uint extra_lines_newgrf = 0;
uint max_minwidth = FONT_HEIGHT_NORMAL * MAX_MINWIDTH_LINEHEIGHTS;
uint max_minwidth = GetCharacterHeight(FS_NORMAL) * MAX_MINWIDTH_LINEHEIGHTS;
Dimension d = {0, 0};
for (const auto &indtype : this->list) {
const IndustrySpec *indsp = GetIndustrySpec(indtype);
@ -485,7 +485,7 @@ public:
/* Set it to something more sane :) */
height += extra_lines_prd + extra_lines_req + extra_lines_newgrf;
size->height = height * FONT_HEIGHT_NORMAL + padding.height;
size->height = height * GetCharacterHeight(FS_NORMAL) + padding.height;
size->width = d.width + padding.width;
break;
}
@ -567,7 +567,7 @@ public:
if (_game_mode != GM_EDITOR) {
SetDParam(0, indsp->GetConstructionCost());
DrawString(ir, STR_FUND_INDUSTRY_INDUSTRY_BUILD_COST);
ir.top += FONT_HEIGHT_NORMAL;
ir.top += GetCharacterHeight(FS_NORMAL);
}
CargoSuffix cargo_suffix[lengthof(indsp->accepts_cargo)];
@ -825,7 +825,7 @@ public:
this->editbox_line = IL_NONE;
this->clicked_line = IL_NONE;
this->clicked_button = 0;
this->info_height = WidgetDimensions::scaled.framerect.Vertical() + 2 * FONT_HEIGHT_NORMAL; // Info panel has at least two lines text.
this->info_height = WidgetDimensions::scaled.framerect.Vertical() + 2 * GetCharacterHeight(FS_NORMAL); // Info panel has at least two lines text.
this->InitNested(window_number);
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_IV_VIEWPORT);
@ -837,7 +837,7 @@ public:
void OnInit() override
{
/* This only used when the cheat to alter industry production is enabled */
this->cheat_line_height = std::max(SETTING_BUTTON_HEIGHT + WidgetDimensions::scaled.vsep_normal, FONT_HEIGHT_NORMAL);
this->cheat_line_height = std::max(SETTING_BUTTON_HEIGHT + WidgetDimensions::scaled.vsep_normal, GetCharacterHeight(FS_NORMAL));
}
void OnPaint() override
@ -871,7 +871,7 @@ public:
if (i->prod_level == PRODLEVEL_CLOSURE) {
DrawString(ir, STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE);
ir.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
ir.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide;
}
CargoSuffix cargo_suffix[lengthof(i->accepts_cargo)];
@ -883,7 +883,7 @@ public:
has_accept = true;
if (first) {
DrawString(ir, STR_INDUSTRY_VIEW_REQUIRES);
ir.top += FONT_HEIGHT_NORMAL;
ir.top += GetCharacterHeight(FS_NORMAL);
first = false;
}
SetDParam(0, CargoSpec::Get(i->accepts_cargo[j])->name);
@ -910,12 +910,12 @@ public:
NOT_REACHED();
}
DrawString(ir.Indent(WidgetDimensions::scaled.hsep_indent, rtl), str);
ir.top += FONT_HEIGHT_NORMAL;
ir.top += GetCharacterHeight(FS_NORMAL);
}
GetAllCargoSuffixes(CARGOSUFFIX_OUT, CST_VIEW, i, i->type, ind, i->produced_cargo, cargo_suffix);
int line_height = this->editable == EA_RATE ? this->cheat_line_height : FONT_HEIGHT_NORMAL;
int text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2;
int line_height = this->editable == EA_RATE ? this->cheat_line_height : GetCharacterHeight(FS_NORMAL);
int text_y_offset = (line_height - GetCharacterHeight(FS_NORMAL)) / 2;
int button_y_offset = (line_height - SETTING_BUTTON_HEIGHT) / 2;
first = true;
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
@ -923,7 +923,7 @@ public:
if (first) {
if (has_accept) ir.top += WidgetDimensions::scaled.vsep_wide;
DrawString(ir, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE);
ir.top += FONT_HEIGHT_NORMAL;
ir.top += GetCharacterHeight(FS_NORMAL);
if (this->editable == EA_RATE) this->production_offset_y = ir.top;
first = false;
}
@ -944,7 +944,7 @@ public:
/* Display production multiplier if editable */
if (this->editable == EA_MULTIPLIER) {
line_height = this->cheat_line_height;
text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2;
text_y_offset = (line_height - GetCharacterHeight(FS_NORMAL)) / 2;
button_y_offset = (line_height - SETTING_BUTTON_HEIGHT) / 2;
ir.top += WidgetDimensions::scaled.vsep_wide;
this->production_offset_y = ir.top;
@ -2148,7 +2148,7 @@ struct CargoesField {
break;
case CFT_HEADER:
ypos += (small_height - FONT_HEIGHT_NORMAL) / 2;
ypos += (small_height - GetCharacterHeight(FS_NORMAL)) / 2;
DrawString(xpos, xpos + industry_width, ypos, this->u.header, TC_WHITE, SA_HOR_CENTER);
break;
@ -2160,7 +2160,7 @@ struct CargoesField {
GfxDrawLine(xpos, ypos1, xpos, ypos2, INDUSTRY_LINE_COLOUR);
GfxDrawLine(xpos, ypos2, xpos2, ypos2, INDUSTRY_LINE_COLOUR);
GfxDrawLine(xpos2, ypos1, xpos2, ypos2, INDUSTRY_LINE_COLOUR);
ypos += (normal_height - FONT_HEIGHT_NORMAL) / 2;
ypos += (normal_height - GetCharacterHeight(FS_NORMAL)) / 2;
if (this->u.industry.ind_type < NUM_INDUSTRYTYPES) {
const IndustrySpec *indsp = GetIndustrySpec(this->u.industry.ind_type);
DrawString(xpos, xpos2, ypos, indsp->name, TC_WHITE, SA_HOR_CENTER);
@ -2189,7 +2189,7 @@ struct CargoesField {
other_right = this->u.industry.other_produced;
other_left = this->u.industry.other_accepted;
}
ypos1 += CargoesField::cargo_border.height + (FONT_HEIGHT_NORMAL - CargoesField::cargo_line.height) / 2;
ypos1 += CargoesField::cargo_border.height + (GetCharacterHeight(FS_NORMAL) - CargoesField::cargo_line.height) / 2;
for (uint i = 0; i < CargoesField::max_cargoes; i++) {
if (other_right[i] != CT_INVALID) {
const CargoSpec *csp = CargoSpec::Get(other_right[i]);
@ -2203,7 +2203,7 @@ struct CargoesField {
DrawHorConnection(xp + 1, xpos - 1, ypos1, csp);
GfxDrawLine(xp, ypos1, xp, ypos1 + CargoesField::cargo_line.height - 1, CARGO_LINE_COLOUR);
}
ypos1 += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.height;
ypos1 += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height;
}
break;
}
@ -2233,7 +2233,7 @@ struct CargoesField {
hor_left = this->u.cargo.supp_cargoes;
hor_right = this->u.cargo.cust_cargoes;
}
ypos += CargoesField::cargo_border.height + vert_inter_industry_space / 2 + (FONT_HEIGHT_NORMAL - CargoesField::cargo_line.height) / 2;
ypos += CargoesField::cargo_border.height + vert_inter_industry_space / 2 + (GetCharacterHeight(FS_NORMAL) - CargoesField::cargo_line.height) / 2;
for (uint i = 0; i < MAX_CARGOES; i++) {
if (hor_left[i] != CT_INVALID) {
int col = hor_left[i];
@ -2257,7 +2257,7 @@ struct CargoesField {
}
DrawHorConnection(cargo_base + col * CargoesField::cargo_space.width + (col + 1) * CargoesField::cargo_line.width - 1 + dx, xpos + CargoesField::cargo_field_width - 1, ypos, csp);
}
ypos += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.height;
ypos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height;
}
break;
}
@ -2270,7 +2270,7 @@ struct CargoesField {
DrawString(xpos + WidgetDimensions::scaled.framerect.left, xpos + industry_width - 1 - WidgetDimensions::scaled.framerect.right, ypos, csp->name, TC_WHITE,
(this->u.cargo_label.left_align) ? SA_LEFT : SA_RIGHT);
}
ypos += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.height;
ypos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height;
}
break;
@ -2304,8 +2304,8 @@ struct CargoesField {
uint row;
for (row = 0; row < MAX_CARGOES; row++) {
if (pt.y < vpos) return CT_INVALID;
if (pt.y < vpos + FONT_HEIGHT_NORMAL) break;
vpos += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.width;
if (pt.y < vpos + GetCharacterHeight(FS_NORMAL)) break;
vpos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.width;
}
if (row == MAX_CARGOES) return CT_INVALID;
@ -2356,8 +2356,8 @@ struct CargoesField {
uint row;
for (row = 0; row < MAX_CARGOES; row++) {
if (pt.y < vpos) return CT_INVALID;
if (pt.y < vpos + FONT_HEIGHT_NORMAL) break;
vpos += FONT_HEIGHT_NORMAL + CargoesField::cargo_space.height;
if (pt.y < vpos + GetCharacterHeight(FS_NORMAL)) break;
vpos += GetCharacterHeight(FS_NORMAL) + CargoesField::cargo_space.height;
}
if (row == MAX_CARGOES) return CT_INVALID;
return this->u.cargo_label.cargoes[row];
@ -2565,8 +2565,8 @@ struct IndustryCargoesWindow : public Window {
CargoesField::small_height = d.height;
/* Size of the legend blob -- slightly larger than the smallmap legend blob. */
CargoesField::legend.height = FONT_HEIGHT_SMALL;
CargoesField::legend.width = CargoesField::legend.height * 8 / 5;
CargoesField::legend.height = GetCharacterHeight(FS_SMALL);
CargoesField::legend.width = CargoesField::legend.height * 9 / 6;
/* Size of cargo lines. */
CargoesField::cargo_line.width = ScaleGUITrad(6);
@ -2614,7 +2614,7 @@ struct IndustryCargoesWindow : public Window {
d.width += WidgetDimensions::scaled.frametext.Horizontal();
/* Ensure the height is enough for the industry type text, for the horizontal connections, and for the cargo labels. */
uint min_ind_height = CargoesField::cargo_border.height * 2 + CargoesField::max_cargoes * FONT_HEIGHT_NORMAL + (CargoesField::max_cargoes - 1) * CargoesField::cargo_space.height;
uint min_ind_height = CargoesField::cargo_border.height * 2 + CargoesField::max_cargoes * GetCharacterHeight(FS_NORMAL) + (CargoesField::max_cargoes - 1) * CargoesField::cargo_space.height;
d.height = std::max(d.height + WidgetDimensions::scaled.frametext.Vertical(), min_ind_height);
CargoesField::industry_width = d.width;

@ -440,31 +440,25 @@ STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS :Transparent bui
STR_SETTINGS_MENU_TRANSPARENT_SIGNS :Transparent signs
# File menu
###length 5
STR_FILE_MENU_SAVE_GAME :Save game
STR_FILE_MENU_LOAD_GAME :Load game
STR_FILE_MENU_QUIT_GAME :Abandon game
STR_FILE_MENU_SEPARATOR :
STR_FILE_MENU_EXIT :Exit
# Map menu
###length 4
STR_MAP_MENU_MAP_OF_WORLD :Map of world
STR_MAP_MENU_EXTRA_VIEWPORT :Extra viewport
STR_MAP_MENU_LINGRAPH_LEGEND :Cargo flow legend
STR_MAP_MENU_SIGN_LIST :Sign list
# Town menu
###length 2
STR_TOWN_MENU_TOWN_DIRECTORY :Town directory
STR_TOWN_MENU_FOUND_TOWN :Found town
# Subsidies menu
###length 1
STR_SUBSIDIES_MENU_SUBSIDIES :Subsidies
# Graph menu
###length 6
STR_GRAPH_MENU_OPERATING_PROFIT_GRAPH :Operating profit graph
STR_GRAPH_MENU_INCOME_GRAPH :Income graph
STR_GRAPH_MENU_DELIVERED_CARGO_GRAPH :Delivered cargo graph
@ -473,58 +467,47 @@ STR_GRAPH_MENU_COMPANY_VALUE_GRAPH :Company value g
STR_GRAPH_MENU_CARGO_PAYMENT_RATES :Cargo payment rates
# Company league menu
###length 3
STR_GRAPH_MENU_COMPANY_LEAGUE_TABLE :Company league table
STR_GRAPH_MENU_DETAILED_PERFORMANCE_RATING :Detailed performance rating
STR_GRAPH_MENU_HIGHSCORE :Highscore table
# Industry menu
###length 3
STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY :Industry directory
STR_INDUSTRY_MENU_INDUSTRY_CHAIN :Industry chains
STR_INDUSTRY_MENU_FUND_NEW_INDUSTRY :Fund new industry
# URailway construction menu
###length 4
STR_RAIL_MENU_RAILROAD_CONSTRUCTION :Railway construction
STR_RAIL_MENU_ELRAIL_CONSTRUCTION :Electrified railway construction
STR_RAIL_MENU_MONORAIL_CONSTRUCTION :Monorail construction
STR_RAIL_MENU_MAGLEV_CONSTRUCTION :Maglev construction
# Road construction menu
###length 2
STR_ROAD_MENU_ROAD_CONSTRUCTION :Road construction
STR_ROAD_MENU_TRAM_CONSTRUCTION :Tramway construction
# Waterways construction menu
###length 1
STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION :Waterways construction
# Aairport construction menu
###length 1
STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION :Airport construction
# Landscaping menu
###length 3
STR_LANDSCAPING_MENU_LANDSCAPING :Landscaping
STR_LANDSCAPING_MENU_PLANT_TREES :Plant trees
STR_LANDSCAPING_MENU_PLACE_SIGN :Place sign
# Music menu
###length 1
STR_TOOLBAR_SOUND_MUSIC :Sound/music
# Message menu
###length 3
STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT :Last message/news report
STR_NEWS_MENU_MESSAGE_HISTORY_MENU :Message history
STR_NEWS_MENU_DELETE_ALL_MESSAGES :Delete all messages
# About menu
###length 12
STR_ABOUT_MENU_LAND_BLOCK_INFO :Land area information
STR_ABOUT_MENU_HELP :Help & manuals
STR_ABOUT_MENU_SEPARATOR :
STR_ABOUT_MENU_TOGGLE_CONSOLE :Toggle console
STR_ABOUT_MENU_AI_DEBUG :AI/Game script debug
STR_ABOUT_MENU_SCREENSHOT :Screenshot

@ -106,7 +106,7 @@ public:
Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
int icon_y_offset = (this->line_height - this->icon.height) / 2;
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
bool rtl = _current_text_dir == TD_RTL;
Rect ordinal = ir.WithWidth(this->ordinal_width, rtl);
@ -148,7 +148,7 @@ public:
}
this->icon = GetSpriteSize(SPR_COMPANY_ICON);
this->line_height = std::max<int>(this->icon.height + WidgetDimensions::scaled.vsep_normal, FONT_HEIGHT_NORMAL);
this->line_height = std::max<int>(this->icon.height + WidgetDimensions::scaled.vsep_normal, GetCharacterHeight(FS_NORMAL));
for (const Company *c : Company::Iterate()) {
SetDParam(0, c->index);
@ -328,7 +328,7 @@ public:
}
int icon_y_offset = (this->line_height - this->icon_size.height) / 2;
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
/* Calculate positions.of the columns */
bool rtl = _current_text_dir == TD_RTL;
@ -363,7 +363,7 @@ public:
if (lt == nullptr) return;
this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
this->line_height = std::max<int>(this->icon_size.height + WidgetDimensions::scaled.fullbevel.Vertical(), FONT_HEIGHT_NORMAL);
this->line_height = std::max<int>(this->icon_size.height + WidgetDimensions::scaled.fullbevel.Vertical(), GetCharacterHeight(FS_NORMAL));
/* Calculate maximum width of every column */
this->rank_width = this->text_width = this->score_width = 0;

@ -821,13 +821,13 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const
str = STR_LINKGRAPH_LEGEND_SATURATED;
}
if (str != STR_NULL) {
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), str, GetContrastColour(colour) | TC_FORCED, SA_HOR_CENTER, false, FS_SMALL);
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_SMALL)), str, GetContrastColour(colour) | TC_FORCED, SA_HOR_CENTER, false, FS_SMALL);
}
}
if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) {
const CargoSpec *cargo = _sorted_cargo_specs[widget - WID_LGL_CARGO_FIRST];
GfxFillRect(br, cargo->legend_colour);
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), cargo->abbrev, GetContrastColour(cargo->legend_colour, 73), SA_HOR_CENTER, false, FS_SMALL);
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_SMALL)), cargo->abbrev, GetContrastColour(cargo->legend_colour, 73), SA_HOR_CENTER, false, FS_SMALL);
}
}

@ -80,7 +80,7 @@ public:
Rect ir = r.Shrink(WidgetDimensions::scaled.frametext);
for (size_t i = 0; i < this->landinfo_data.size(); i++) {
DrawString(ir, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING, SA_HOR_CENTER);
ir.top += FONT_HEIGHT_NORMAL + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
ir.top += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
}
if (!this->cargo_acceptance.empty()) {
@ -98,7 +98,7 @@ public:
uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WidgetDimensions::scaled.frametext.Horizontal();
size->width = std::max(size->width, width);
size->height += FONT_HEIGHT_NORMAL + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
size->height += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
}
if (!this->cargo_acceptance.empty()) {
@ -512,7 +512,7 @@ struct AboutWindow : public Window {
int line_height; ///< The height of a single line
static const int num_visible_lines = 19; ///< The number of lines visible simultaneously
static const uint TIMER_INTERVAL = 2100; ///< Scrolling interval, scaled by line text line height. This value chosen to maintain parity: 2100 / FONT_HEIGHT_NORMAL = 150ms
static const uint TIMER_INTERVAL = 2100; ///< Scrolling interval, scaled by line text line height. This value chosen to maintain parity: 2100 / GetCharacterHeight(FS_NORMAL) = 150ms
GUITimer timer;
AboutWindow() : Window(&_about_desc)
@ -534,7 +534,7 @@ struct AboutWindow : public Window {
{
if (widget != WID_A_SCROLLING_TEXT) return;
this->line_height = FONT_HEIGHT_NORMAL;
this->line_height = GetCharacterHeight(FS_NORMAL);
Dimension d;
d.height = this->line_height * num_visible_lines;
@ -547,7 +547,7 @@ struct AboutWindow : public Window {
/* Set scroll interval based on required speed. To keep scrolling smooth,
* the interval is adjusted rather than the distance moved. */
this->timer.SetInterval(TIMER_INTERVAL / FONT_HEIGHT_NORMAL);
this->timer.SetInterval(TIMER_INTERVAL / GetCharacterHeight(FS_NORMAL));
}
void DrawWidget(const Rect &r, int widget) const override

@ -547,7 +547,7 @@ struct MusicTrackSelectionWindow : public Window {
SetDParam(1, 2);
SetDParamStr(2, song.songname);
DrawString(tr, STR_PLAYLIST_TRACK_NAME);
tr.top += FONT_HEIGHT_SMALL;
tr.top += GetCharacterHeight(FS_SMALL);
}
break;
}
@ -561,7 +561,7 @@ struct MusicTrackSelectionWindow : public Window {
SetDParam(1, 2);
SetDParamStr(2, song.songname);
DrawString(tr, STR_PLAYLIST_TRACK_NAME);
tr.top += FONT_HEIGHT_SMALL;
tr.top += GetCharacterHeight(FS_SMALL);
}
break;
}
@ -572,13 +572,13 @@ struct MusicTrackSelectionWindow : public Window {
{
switch (widget) {
case WID_MTS_LIST_LEFT: { // add to playlist
int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL);
int y = this->GetRowFromWidget(pt.y, widget, 0, GetCharacterHeight(FS_SMALL));
_music.PlaylistAdd(y);
break;
}
case WID_MTS_LIST_RIGHT: { // remove from playlist
int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL);
int y = this->GetRowFromWidget(pt.y, widget, 0, GetCharacterHeight(FS_SMALL));
_music.PlaylistRemove(y);
break;
}

@ -110,8 +110,8 @@ void NetworkAddChatMessage(TextColour colour, uint duration, const std::string_v
/** 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. */
@ -228,10 +228,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;

@ -129,7 +129,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;
}
}
@ -145,7 +145,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;
}
@ -602,7 +602,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;
}
@ -651,7 +651,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();
@ -690,7 +690,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);
@ -702,15 +702,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);

@ -357,7 +357,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;
@ -476,13 +476,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:
@ -594,7 +594,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);
@ -618,45 +618,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);
@ -1692,7 +1692,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;
@ -1957,7 +1957,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);
@ -2135,7 +2135,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;
}

@ -425,7 +425,7 @@ struct NewGRFInspectWindow : Window {
assert(this->HasChainIndex());
GrfSpecFeature f = GetFeatureNum(this->window_number);
if (f == GSF_SHIPS) {
size->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.Vertical();
size->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.framerect.Vertical();
break;
}
size->height = std::max(size->height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical());
@ -433,7 +433,7 @@ struct NewGRFInspectWindow : Window {
}
case WID_NGRFI_MAINPANEL:
resize->height = std::max(11, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal);
resize->height = std::max(11, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal);
resize->width = 1;
size->height = 5 * resize->height + WidgetDimensions::scaled.frametext.Vertical();
@ -1329,7 +1329,7 @@ struct SpriteAlignerWindow : Window {
case WID_SA_LIST:
SetDParamMaxDigits(0, 6);
size->width = GetStringBoundingBox(STR_JUST_COMMA).width + padding.width;
resize->height = FONT_HEIGHT_NORMAL + padding.height;
resize->height = GetCharacterHeight(FS_NORMAL) + padding.height;
resize->width = 1;
fill->height = resize->height;
break;

@ -226,8 +226,8 @@ struct NewGRFParametersWindow : public Window {
switch (widget) {
case WID_NP_NUMPAR_DEC:
case WID_NP_NUMPAR_INC: {
size->width = std::max(SETTING_BUTTON_WIDTH / 2, FONT_HEIGHT_NORMAL);
size->height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL);
size->width = std::max(SETTING_BUTTON_WIDTH / 2, GetCharacterHeight(FS_NORMAL));
size->height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL));
break;
}
@ -241,7 +241,7 @@ struct NewGRFParametersWindow : public Window {
}
case WID_NP_BACKGROUND:
this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + padding.height;
this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height;
resize->width = 1;
resize->height = this->line_height;
@ -250,7 +250,7 @@ struct NewGRFParametersWindow : public Window {
case WID_NP_DESCRIPTION:
/* Minimum size of 4 lines. The 500 is the default size of the window. */
Dimension suggestion = {500U - WidgetDimensions::scaled.frametext.Horizontal(), (uint)FONT_HEIGHT_NORMAL * 4 + WidgetDimensions::scaled.frametext.Vertical()};
Dimension suggestion = {500U - WidgetDimensions::scaled.frametext.Horizontal(), (uint)GetCharacterHeight(FS_NORMAL) * 4 + WidgetDimensions::scaled.frametext.Vertical()};
for (const auto &par_info : this->grf_config->param_info) {
if (!par_info.has_value()) continue;
const char *desc = GetGRFStringFromGRFText(par_info->desc);
@ -292,7 +292,7 @@ struct NewGRFParametersWindow : public Window {
Rect tr = ir.Indent(SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide, rtl);
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
GRFParameterInfo &par_info = this->GetParameterInfo(i);
uint32 current_value = par_info.GetValue(this->grf_config);
@ -762,7 +762,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
case WID_NS_FILE_LIST:
{
Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN));
resize->height = std::max<uint>(d.height + 2U, FONT_HEIGHT_NORMAL);
resize->height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
size->height = std::max(size->height, padding.height + 6 * resize->height);
break;
}
@ -770,7 +770,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
case WID_NS_AVAIL_LIST:
{
Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN));
resize->height = std::max<uint>(d.height + 2U, FONT_HEIGHT_NORMAL);
resize->height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
size->height = std::max(size->height, padding.height + 8 * resize->height);
break;
}
@ -783,7 +783,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
}
case WID_NS_NEWGRF_INFO:
size->height = std::max<uint>(size->height, WidgetDimensions::scaled.framerect.Vertical() + 10 * FONT_HEIGHT_NORMAL);
size->height = std::max<uint>(size->height, WidgetDimensions::scaled.framerect.Vertical() + 10 * GetCharacterHeight(FS_NORMAL));
break;
case WID_NS_PRESET_LIST: {
@ -876,7 +876,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
Dimension warning = GetSpriteSize(SPR_WARNING_SIGN);
int square_offset_y = (step_height - square.height) / 2;
int warning_offset_y = (step_height - warning.height) / 2;
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
int offset_y = (step_height - GetCharacterHeight(FS_NORMAL)) / 2;
bool rtl = _current_text_dir == TD_RTL;
uint text_left = rtl ? tr.left : tr.left + square.width + 13;
@ -921,7 +921,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
uint step_height = this->GetWidget<NWidgetBase>(WID_NS_AVAIL_LIST)->resize_y;
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
int offset_y = (step_height - GetCharacterHeight(FS_NORMAL)) / 2;
uint min_index = this->vscroll2->GetPosition();
uint max_index = std::min(min_index + this->vscroll2->GetCapacity(), (uint)this->avails.size());
@ -940,7 +940,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
case WID_NS_NEWGRF_INFO_TITLE: {
/* Create the nice grayish rectangle at the details top. */
GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_DARK_BLUE);
DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), STR_NEWGRF_SETTINGS_INFO_TITLE, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), STR_NEWGRF_SETTINGS_INFO_TITLE, TC_FROMSTRING, SA_HOR_CENTER);
break;
}
@ -2139,7 +2139,7 @@ struct SavePresetWindow : public Window {
{
switch (widget) {
case WID_SVP_PRESET_LIST: {
resize->height = FONT_HEIGHT_NORMAL;
resize->height = GetCharacterHeight(FS_NORMAL);
size->height = 0;
for (uint i = 0; i < this->presets.size(); i++) {
Dimension d = GetStringBoundingBox(this->presets[i]);
@ -2160,7 +2160,7 @@ struct SavePresetWindow : public Window {
GfxFillRect(br, PC_BLACK);
uint step_height = this->GetWidget<NWidgetBase>(WID_SVP_PRESET_LIST)->resize_y;
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
int offset_y = (step_height - GetCharacterHeight(FS_NORMAL)) / 2;
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
uint min_index = this->vscroll->GetPosition();
uint max_index = std::min(min_index + this->vscroll->GetCapacity(), (uint)this->presets.size());
@ -2268,7 +2268,7 @@ struct ScanProgressWindow : public Window {
/* We really don't know the width. We could determine it by scanning the NewGRFs,
* but this is the status window for scanning them... */
size->width = std::max<uint>(size->width, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width + padding.width);
size->height = FONT_HEIGHT_NORMAL * 2 + WidgetDimensions::scaled.vsep_normal;
size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
break;
}
}
@ -2283,7 +2283,7 @@ struct ScanProgressWindow : public Window {
uint percent = scanned * 100 / std::max(1U, _settings_client.gui.last_newgrf_count);
DrawFrameRect(ir.WithWidth(ir.Width() * percent / 100, false), COLOUR_MAUVE, FR_NONE);
SetDParam(0, percent);
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, FONT_HEIGHT_NORMAL), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
break;
}
@ -2292,7 +2292,7 @@ struct ScanProgressWindow : public Window {
SetDParam(1, _settings_client.gui.last_newgrf_count);
DrawString(r.left, r.right, r.top, STR_NEWGRF_SCAN_STATUS, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal, this->last_name, TC_BLACK, SA_HOR_CENTER);
DrawString(r.left, r.right, r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal, this->last_name, TC_BLACK, SA_HOR_CENTER);
break;
}
}

@ -323,7 +323,7 @@ struct NewsWindow : Window {
void OnInit() override
{
this->timer.SetInterval(TIMER_INTERVAL / FONT_HEIGHT_NORMAL);
this->timer.SetInterval(TIMER_INTERVAL / GetCharacterHeight(FS_NORMAL));
}
void DrawNewsBorder(const Rect &r) const
@ -1138,7 +1138,7 @@ struct MessageHistoryWindow : Window {
void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
{
if (widget == WID_MH_BACKGROUND) {
this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
resize->height = this->line_height;
/* Months are off-by-one, so it's actually 8. Not using

@ -219,7 +219,7 @@ public:
if (objclass->GetUISpecCount() == 0) continue;
size->width = std::max(size->width, GetStringBoundingBox(objclass->name).width + padding.width);
}
this->line_height = FONT_HEIGHT_NORMAL + padding.height;
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
resize->height = this->line_height;
size->height = 5 * this->line_height;
break;

@ -190,16 +190,16 @@ public:
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget == WID_CTO_HEADER) {
(*size).height = std::max((*size).height, (uint) FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.Vertical());
(*size).height = std::max((*size).height, (uint) GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.framerect.Vertical());
} else if (WID_CTO_CARGO_LABEL_FIRST <= widget && widget <= WID_CTO_CARGO_LABEL_LAST) {
(*size).width = std::max((*size).width, WidgetDimensions::scaled.framerect.left + this->CARGO_ICON_WIDTH + WidgetDimensions::scaled.framerect.Horizontal() + this->max_cargo_name_width + padding.width);
(*size).height = std::max((*size).height, (uint) FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.Vertical());
(*size).height = std::max((*size).height, (uint) GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.framerect.Vertical());
} else if ((WID_CTO_CARGO_DROPDOWN_FIRST <= widget && widget <= WID_CTO_CARGO_DROPDOWN_LAST) || widget == WID_CTO_SET_TO_ALL_DROPDOWN) {
(*size).width = std::max((*size).width, WidgetDimensions::scaled.dropdowntext.Horizontal() + this->max_cargo_dropdown_width + NWidgetLeaf::GetDropdownBoxDimension().width);
(*size).height = std::max((*size).height, (uint) WidgetDimensions::scaled.dropdowntext.Vertical() + FONT_HEIGHT_NORMAL);
(*size).height = std::max((*size).height, (uint) WidgetDimensions::scaled.dropdowntext.Vertical() + GetCharacterHeight(FS_NORMAL));
} else if (widget == WID_CTO_SET_TO_ALL_LABEL) {
(*size).width = std::max((*size).width, this->max_cargo_name_width + WidgetDimensions::scaled.framerect.right + padding.width);
(*size).height = std::max((*size).height, (uint) FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.Vertical());
(*size).height = std::max((*size).height, (uint) GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.framerect.Vertical());
}
}
@ -845,11 +845,11 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
Dimension sprite_size = GetSpriteSize(sprite);
if (v->cur_real_order_index == order_index) {
/* Draw two arrows before the next real order. */
DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
DrawSprite(sprite, PAL_NONE, rtl ? right - 2 * sprite_size.width : left + sprite_size.width, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)GetCharacterHeight(FS_NORMAL) - (int)sprite_size.height) / 2);
DrawSprite(sprite, PAL_NONE, rtl ? right - 2 * sprite_size.width : left + sprite_size.width, y + ((int)GetCharacterHeight(FS_NORMAL) - (int)sprite_size.height) / 2);
} else if (v->cur_implicit_order_index == order_index) {
/* Draw one arrow before the next implicit order; the next real order will still get two arrows. */
DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)GetCharacterHeight(FS_NORMAL) - (int)sprite_size.height) / 2);
}
TextColour colour = TC_BLACK;
@ -1917,7 +1917,7 @@ public:
case WID_O_SEL_OCCUPANCY:
case WID_O_ORDER_LIST:
resize->height = FONT_HEIGHT_NORMAL;
resize->height = GetCharacterHeight(FS_NORMAL);
size->height = 6 * resize->height + padding.height;
break;

@ -301,13 +301,13 @@ struct PlansWindow : Window {
}
SetDParam(dparam_offset++, p->lines.size());
SetDParam(dparam_offset++, p->creation_date);
DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, str, TC_IS_PALETTE_COLOUR | (TextColour)_colour_value[p->colour]);
DrawString(text_left, text_right, y + (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2, str, TC_IS_PALETTE_COLOUR | (TextColour)_colour_value[p->colour]);
} else {
PlanLine *pl = p->lines[list[i].line_id];
DrawBoolButton(btn_left, y + (this->resize.step_height - SETTING_BUTTON_HEIGHT) / 2, pl->visible, true);
SetDParam(0, list[i].line_id + 1);
SetDParam(1, pl->tiles.size() - 1);
DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, STR_PLANS_LIST_ITEM_LINE, TC_WHITE);
DrawString(text_left, text_right, y + (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2, STR_PLANS_LIST_ITEM_LINE, TC_WHITE);
}
y += this->resize.step_height;
}
@ -335,7 +335,7 @@ struct PlansWindow : Window {
switch (widget) {
case WID_PLN_LIST:
this->company_icon_spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
resize->height = std::max<int>(FONT_HEIGHT_NORMAL, SETTING_BUTTON_HEIGHT);
resize->height = std::max<int>(GetCharacterHeight(FS_NORMAL), SETTING_BUTTON_HEIGHT);
size->height = resize->height * 5 + WidgetDimensions::scaled.framerect.Vertical();
break;

@ -607,7 +607,7 @@ public:
{
switch (widget) {
case PROGRAM_WIDGET_INSTRUCTION_LIST:
resize->height = FONT_HEIGHT_NORMAL;
resize->height = GetCharacterHeight(FS_NORMAL);
size->height = 6 * resize->height + WidgetDimensions::scaled.framerect.Vertical();
break;
}

@ -1188,7 +1188,7 @@ private:
public:
BuildRailStationWindow(WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent), filter_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE)
{
this->coverage_height = 2 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
this->vscroll = nullptr;
_railstation.newstations = newstation;
@ -1414,7 +1414,7 @@ public:
d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name));
}
size->width = std::max(size->width, d.width + padding.width);
this->line_height = FONT_HEIGHT_NORMAL + padding.height;
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
size->height = 5 * this->line_height;
resize->height = this->line_height;
break;

@ -1287,7 +1287,7 @@ private:
public:
BuildRoadStationWindow(WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent), filter_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE)
{
this->coverage_height = 2 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
this->vscrollList = nullptr;
this->vscrollMatrix = nullptr;
this->road_stop_type = rs;
@ -1511,7 +1511,7 @@ public:
d = maxdim(d, GetStringBoundingBox(RoadStopClass::Get(rs_class)->name));
}
size->width = std::max(size->width, d.width + padding.width);
this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical();
this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical();
size->height = 5 * this->line_height;
resize->height = this->line_height;
break;

@ -36,7 +36,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
SetDParam(1, v->build_year);
SetDParam(2, v->value);
DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
if (v->HasArticulatedPart()) {
CargoArray max_cargo{};
@ -71,7 +71,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
}
DrawString(r.left, r.right, y, capacity, TC_BLUE);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
if (u->cargo_cap == 0) continue;
@ -85,7 +85,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
feeder_share += u->cargo.GetFeederShare();
}
DrawString(r.left, r.right, y, str);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
y += WidgetDimensions::scaled.vsep_normal;
} else {
@ -93,7 +93,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
SetDParam(1, v->cargo_cap);
SetDParam(4, GetCargoSubtypeText(v));
DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
if (v->cargo.StoredCount() > 0) {
@ -104,13 +104,13 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
feeder_share += v->cargo.GetFeederShare();
}
DrawString(r.left, r.right, y, str);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
}
/* Draw Transfer credits text */
SetDParam(0, feeder_share);
DrawString(r.left, r.right, y, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
if (RoadVehicle::From(v)->critical_breakdown_count > 0) {
SetDParam(0, RoadVehicle::From(v)->GetDisplayEffectiveMaxSpeed());

@ -281,15 +281,15 @@ struct SchdispatchWindow : GeneralVehicleWindow {
}
case WID_SCHDISPATCH_SUMMARY_PANEL:
size->height = 6 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.Vertical();
size->height = 6 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.framerect.Vertical();
uint warning_count = this->warning_count;
if (this->no_order_warning_pad) {
warning_count++;
size->height -= FONT_HEIGHT_NORMAL;
size->height -= GetCharacterHeight(FS_NORMAL);
}
if (warning_count > 0) {
const Dimension warning_dimensions = GetSpriteSize(SPR_WARNING_SIGN);
size->height += warning_count * std::max<int>(warning_dimensions.height, FONT_HEIGHT_NORMAL);
size->height += warning_count * std::max<int>(warning_dimensions.height, GetCharacterHeight(FS_NORMAL));
}
break;
}
@ -492,14 +492,14 @@ struct SchdispatchWindow : GeneralVehicleWindow {
int y = ir.top;
if (!HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH) || !this->IsScheduleSelected()) {
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_NOT_ENABLED);
} else {
const DispatchSchedule &ds = this->GetSelectedSchedule();
auto draw_warning = [&](StringID text) {
const Dimension warning_dimensions = GetSpriteSize(SPR_WARNING_SIGN);
int step_height = std::max<int>(warning_dimensions.height, FONT_HEIGHT_NORMAL);
int step_height = std::max<int>(warning_dimensions.height, GetCharacterHeight(FS_NORMAL));
int left = ir.left;
int right = ir.right;
const bool rtl = (_current_text_dir == TD_RTL);
@ -509,7 +509,7 @@ struct SchdispatchWindow : GeneralVehicleWindow {
} else {
left += (warning_dimensions.width + 10);
}
DrawString(left, right, y + (step_height - FONT_HEIGHT_NORMAL) / 2, text);
DrawString(left, right, y + (step_height - GetCharacterHeight(FS_NORMAL)) / 2, text);
y += step_height;
};
@ -563,7 +563,7 @@ struct SchdispatchWindow : GeneralVehicleWindow {
}
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_ASSIGNED_TO_ORDER);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
const DateTicksScaled last_departure = ds.GetScheduledDispatchStartTick() + ds.GetScheduledDispatchLastDispatch();
@ -571,7 +571,7 @@ struct SchdispatchWindow : GeneralVehicleWindow {
const_cast<SchdispatchWindow*>(this)->last_departure_future = (last_departure > _scaled_date_ticks);
DrawString(ir.left, ir.right, y,
this->last_departure_future ? STR_SCHDISPATCH_SUMMARY_LAST_DEPARTURE_FUTURE : STR_SCHDISPATCH_SUMMARY_LAST_DEPARTURE_PAST);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
if (!have_conditional) {
const int required_vehicle = CalculateMaxRequiredVehicle(v->orders->GetTimetableTotalDuration(), ds.GetScheduledDispatchDuration(), ds.GetScheduledDispatch());
@ -580,20 +580,20 @@ struct SchdispatchWindow : GeneralVehicleWindow {
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_L1);
}
}
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
SetTimetableParams(0, ds.GetScheduledDispatchDuration(), true);
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_L2);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
SetDParam(0, ds.GetScheduledDispatchStartTick());
SetDParam(1, ds.GetScheduledDispatchStartTick() + ds.GetScheduledDispatchDuration());
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_L3);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
SetTimetableParams(0, ds.GetScheduledDispatchDelay());
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_L4);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
uint32 duration = ds.GetScheduledDispatchDuration();
uint warnings = 0;

@ -107,7 +107,7 @@ struct ScriptListWindow : public Window {
{
if (widget != WID_SCRL_LIST) return;
this->line_height = FONT_HEIGHT_NORMAL + padding.height;
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
resize->width = 1;
resize->height = this->line_height;
@ -150,14 +150,14 @@ struct ScriptListWindow : public Window {
Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
SetDParamStr(0, selected_info->GetAuthor());
DrawString(tr, STR_AI_LIST_AUTHOR);
tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
SetDParam(0, selected_info->GetVersion());
DrawString(tr, STR_AI_LIST_VERSION);
tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
if (!selected_info->GetURL().empty()) {
SetDParamStr(0, selected_info->GetURL());
DrawString(tr, STR_AI_LIST_URL);
tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
}
SetDParamStr(0, selected_info->GetDescription());
DrawStringMultiLine(tr, STR_JUST_RAW_STRING, TC_WHITE);
@ -361,7 +361,7 @@ struct ScriptSettingsWindow : public Window {
{
if (widget != WID_SCRS_BACKGROUND) return;
this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + padding.height;
this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height;
resize->width = 1;
resize->height = this->line_height;
@ -384,7 +384,7 @@ struct ScriptSettingsWindow : public Window {
int y = r.top;
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) {
const ScriptConfigItem &config_item = **it;
int current_value = config->GetSetting((config_item).name);
@ -810,7 +810,7 @@ struct ScriptDebugWindow : public Window {
void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
{
if (widget == WID_SCRD_LOG_PANEL) {
resize->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
resize->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
size->height = 14 * resize->height + WidgetDimensions::scaled.framerect.Vertical();
}
}

@ -1490,7 +1490,7 @@ void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right,
DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state,
editable && value != (sd->flags & SF_GUI_0_IS_SPECIAL ? 0 : sd->min), editable && (uint32)value != sd->max);
}
this->DrawSettingString(text_left, text_right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, highlight, value);
this->DrawSettingString(text_left, text_right, y + (SETTING_HEIGHT - GetCharacterHeight(FS_NORMAL)) / 2, highlight, value);
}
void SettingEntry::DrawSettingString(uint left, uint right, int y, bool highlight, int32 value) const
@ -1502,7 +1502,7 @@ void SettingEntry::DrawSettingString(uint left, uint right, int y, bool highligh
const Dimension warning_dimensions = GetSpriteSize(SPR_WARNING_SIGN);
if ((int)warning_dimensions.height <= SETTING_HEIGHT) {
DrawSprite(SPR_WARNING_SIGN, 0, (_current_text_dir == TD_RTL) ? edge - warning_dimensions.width - 5 : edge + 5,
y + (((int)FONT_HEIGHT_NORMAL - (int)warning_dimensions.height) / 2));
y + (((int)GetCharacterHeight(FS_NORMAL) - (int)warning_dimensions.height) / 2));
}
}
}
@ -1867,7 +1867,7 @@ void SettingsPage::DrawSetting(GameSettings *, int left, int right, int y, bool)
{
bool rtl = _current_text_dir == TD_RTL;
DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - _circle_size.width : left, y + (SETTING_HEIGHT - _circle_size.height) / 2);
DrawString(rtl ? left : left + _circle_size.width + WidgetDimensions::scaled.hsep_normal, rtl ? right - _circle_size.width - WidgetDimensions::scaled.hsep_normal : right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, this->title, TC_ORANGE);
DrawString(rtl ? left : left + _circle_size.width + WidgetDimensions::scaled.hsep_normal, rtl ? right - _circle_size.width - WidgetDimensions::scaled.hsep_normal : right, y + (SETTING_HEIGHT - GetCharacterHeight(FS_NORMAL)) / 2, this->title, TC_ORANGE);
}
/** Construct settings tree */
@ -2567,7 +2567,7 @@ struct GameSettingsWindow : Window {
{
switch (widget) {
case WID_GS_OPTIONSPANEL:
resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + WidgetDimensions::scaled.vsep_normal;
resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal;
resize->width = 1;
size->height = 5 * resize->height + WidgetDimensions::scaled.framerect.Vertical();
@ -2583,7 +2583,7 @@ struct GameSettingsWindow : Window {
SetDParam(0, setting_types[i]);
size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width + padding.width);
}
size->height = 2 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal +
size->height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal +
std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width));
break;
}
@ -2627,7 +2627,7 @@ struct GameSettingsWindow : Window {
/* Draw the 'some search results are hidden' notice. */
if (this->warn_missing != WHR_NONE) {
SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
DrawStringMultiLine(panel.WithHeight(this->warn_lines * FONT_HEIGHT_NORMAL), warn_str, TC_FROMSTRING, SA_CENTER);
DrawStringMultiLine(panel.WithHeight(this->warn_lines * GetCharacterHeight(FS_NORMAL)), warn_str, TC_FROMSTRING, SA_CENTER);
}
}
@ -2698,17 +2698,17 @@ struct GameSettingsWindow : Window {
default: NOT_REACHED();
}
DrawString(tr, STR_CONFIG_SETTING_TYPE);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
std::unique_ptr<SettingEntry::SetValueDParamsTempData> tempdata;
this->last_clicked->SetValueDParams(0, sd->def, tempdata);
DrawString(tr, STR_CONFIG_SETTING_DEFAULT_VALUE);
tr.top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
if (sd->flags & SF_GUI_ADVISE_DEFAULT) {
const Dimension warning_dimensions = GetSpriteSize(SPR_WARNING_SIGN);
const int step_height = std::max<int>(warning_dimensions.height, FONT_HEIGHT_NORMAL);
const int text_offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
const int step_height = std::max<int>(warning_dimensions.height, GetCharacterHeight(FS_NORMAL));
const int text_offset_y = (step_height - GetCharacterHeight(FS_NORMAL)) / 2;
const int warning_offset_y = (step_height - warning_dimensions.height) / 2;
const bool rtl = _current_text_dir == TD_RTL;

@ -67,7 +67,7 @@ void DrawShipDetails(const Vehicle *v, const Rect &r)
SetDParam(1, v->build_year);
SetDParam(2, v->value);
DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
Money feeder_share = 0;
@ -110,7 +110,7 @@ void DrawShipDetails(const Vehicle *v, const Rect &r)
}
DrawString(r.left, r.right, y, capacity, TC_BLUE);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
if (u->cargo_cap == 0) continue;
@ -124,7 +124,7 @@ void DrawShipDetails(const Vehicle *v, const Rect &r)
feeder_share += u->cargo.GetFeederShare();
}
DrawString(r.left, r.right, y, str);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
y += WidgetDimensions::scaled.vsep_normal;
} else {
@ -132,7 +132,7 @@ void DrawShipDetails(const Vehicle *v, const Rect &r)
SetDParam(1, v->cargo_cap);
SetDParam(4, GetCargoSubtypeText(v));
DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
StringID str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
if (v->cargo.StoredCount() > 0) {
@ -143,13 +143,13 @@ void DrawShipDetails(const Vehicle *v, const Rect &r)
feeder_share += v->cargo.GetFeederShare();
}
DrawString(r.left, r.right, y, str);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
}
/* Draw Transfer credits text */
SetDParam(0, feeder_share);
DrawString(r.left, r.right, y, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
if (Ship::From(v)->critical_breakdown_count > 0) {
SetDParam(0, Ship::From(v)->GetDisplayEffectiveMaxSpeed());

@ -194,7 +194,7 @@ struct SignListWindow : Window, SignList {
switch (widget) {
case WID_SIL_LIST: {
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
uint text_offset_y = (this->resize.step_height - FONT_HEIGHT_NORMAL + 1) / 2;
uint text_offset_y = (this->resize.step_height - GetCharacterHeight(FS_NORMAL) + 1) / 2;
/* No signs? */
if (this->vscroll->GetCount() == 0) {
DrawString(tr.left, tr.right, tr.top + text_offset_y, STR_STATION_LIST_NONE);
@ -266,7 +266,7 @@ struct SignListWindow : Window, SignList {
case WID_SIL_LIST: {
Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
this->text_offset = WidgetDimensions::scaled.frametext.left + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
resize->height = std::max<uint>(FONT_HEIGHT_NORMAL, spr_dim.height + 2);
resize->height = std::max<uint>(GetCharacterHeight(FS_NORMAL), spr_dim.height + 2);
Dimension d = {(uint)(this->text_offset + WidgetDimensions::scaled.frametext.right), padding.height + 5 * resize->height};
*size = maxdim(*size, d);
break;

@ -912,7 +912,7 @@ void SmallMapWindow::DrawTowns(const DrawPixelInfo *dpi) const
/* Check if the town sign is within bounds */
if (x + t->cache.sign.width_small > dpi->left &&
x < dpi->left + dpi->width &&
y + FONT_HEIGHT_SMALL > dpi->top &&
y + GetCharacterHeight(FS_SMALL) > dpi->top &&
y < dpi->top + dpi->height) {
/* And draw it. */
SetDParam(0, t->index);
@ -1170,7 +1170,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
}
/* Width of the legend blob. */
this->legend_width = (FONT_HEIGHT_SMALL - ScaleGUITrad(1)) * 8 / 5;
this->legend_width = (GetCharacterHeight(FS_SMALL) - ScaleGUITrad(1)) * 9 / 6;
/* The width of a column is the minimum width of all texts + the size of the blob + some spacing */
this->column_width = min_width + WidgetDimensions::scaled.hsep_normal + this->legend_width + WidgetDimensions::scaled.framerect.Horizontal();
@ -1208,7 +1208,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
uint number_of_rows = this->GetNumberRowsLegend(columns);
bool rtl = _current_text_dir == TD_RTL;
uint i = 0; // Row counter for industry legend.
uint row_height = FONT_HEIGHT_SMALL;
uint row_height = GetCharacterHeight(FS_SMALL);
int padding = ScaleGUITrad(1);
Rect origin = r.WithWidth(this->column_width, rtl).Shrink(WidgetDimensions::scaled.framerect).WithHeight(row_height);
@ -1379,7 +1379,7 @@ void SmallMapWindow::SetOverlayCargoMask()
int SmallMapWindow::GetPositionOnLegend(Point pt)
{
const NWidgetBase *wi = this->GetWidget<NWidgetBase>(WID_SM_LEGEND);
uint line = (pt.y - wi->pos_y - WidgetDimensions::scaled.framerect.top) / FONT_HEIGHT_SMALL;
uint line = (pt.y - wi->pos_y - WidgetDimensions::scaled.framerect.top) / GetCharacterHeight(FS_SMALL);
uint columns = this->GetNumberColumnsLegend(wi->current_x);
uint number_of_rows = this->GetNumberRowsLegend(columns);
if (line >= number_of_rows) return -1;

@ -162,7 +162,7 @@ protected:
inline uint GetLegendHeight(uint num_columns) const
{
return WidgetDimensions::scaled.framerect.Vertical() +
this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL;
this->GetNumberRowsLegend(num_columns) * GetCharacterHeight(FS_SMALL);
}
/**

@ -508,7 +508,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 */
@ -567,7 +567,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 */
@ -593,7 +593,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;
@ -607,7 +607,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;
}
@ -1505,13 +1505,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:
@ -1559,7 +1559,7 @@ struct StationViewWindow : public Window {
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
const GoodsEntry *ge = &st->goods[cs->Index()];
if (!ge->HasRating()) continue;
ofs_y -= FONT_HEIGHT_NORMAL;
ofs_y -= GetCharacterHeight(FS_NORMAL);
if (ofs_y < 0) {
GuiShowStationRatingTooltip(this, st, cs);
break;
@ -1939,7 +1939,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());
@ -2012,7 +2012,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));
}
/**
@ -2033,7 +2033,7 @@ struct StationViewWindow : public Window {
}
DrawString(tr, STR_STATION_VIEW_SUPPLY_RATINGS_TITLE);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
this->ratings_list_y = tr.top;
@ -2050,12 +2050,12 @@ struct StationViewWindow : public Window {
Rect rating_rect = tr.Indent(WidgetDimensions::scaled.hsep_indent, rtl);
int x = DrawString(rating_rect, STR_STATION_VIEW_CARGO_SUPPLY_RATING);
if (!ge->IsSupplyAllowed() && x != 0) {
int line_y = rating_rect.top + (FONT_HEIGHT_NORMAL / 2) - 1;
int line_y = rating_rect.top + (GetCharacterHeight(FS_NORMAL) / 2) - 1;
GfxDrawLine(rating_rect.left, line_y, x, line_y, PC_WHITE, 1);
}
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));
}
/**
@ -2123,7 +2123,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;
}
@ -2194,7 +2194,7 @@ struct StationViewWindow : public Window {
case WID_SV_ACCEPT_RATING_LIST: {
if (this->owner != _local_company || !_ctrl_pressed || this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) break;
int row = this->GetRowFromWidget(pt.y, WID_SV_ACCEPT_RATING_LIST, WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL);
int row = this->GetRowFromWidget(pt.y, WID_SV_ACCEPT_RATING_LIST, WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FS_NORMAL));
if (row < 1) break;
const Station *st = Station::Get(this->window_number);
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
@ -3056,7 +3056,7 @@ public:
width += RATING_TOOLTIP_NEWGRF_INDENT;
}
size->width = std::max(size->width, width);
size->height += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
size->height += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
}
size->height -= WidgetDimensions::scaled.vsep_normal;
@ -3075,7 +3075,7 @@ public:
DrawString(left0, right0, y, this->data[0], TC_LIGHT_BLUE, SA_CENTER);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
for (uint i = 1; i <= RATING_TOOLTIP_MAX_LINES; i++) {
if (StrEmpty(this->data[i])) break;
@ -3093,7 +3093,7 @@ public:
DrawString(left, right, y, this->data[i], TC_BLACK);
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
}
}

@ -117,7 +117,7 @@ struct StatusBarWindow : Window {
void DrawWidget(const Rect &r, int widget) const override
{
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect, RectPadding::zero);
tr.top = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL);
tr.top = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL));
switch (widget) {
case WID_S_LEFT:
/* Draw the date */

@ -290,7 +290,7 @@ protected:
int height = 0;
/* Title lines */
height += FONT_HEIGHT_NORMAL; // Date always use exactly one line.
height += GetCharacterHeight(FS_NORMAL); // Date always use exactly one line.
SetDParamStr(0, !page->title.empty() ? page->title : this->selected_generic_title);
height += GetStringHeight(STR_STORY_BOOK_TITLE, max_width);
@ -407,7 +407,7 @@ protected:
StoryPage *page = this->GetSelPage();
if (page == nullptr) return;
int max_width = GetAvailablePageContentWidth();
int element_dist = FONT_HEIGHT_NORMAL;
int element_dist = GetCharacterHeight(FS_NORMAL);
/* Make space for the header */
int main_y = GetHeadHeight(max_width) + element_dist;
@ -428,7 +428,7 @@ protected:
if (fl == ElementFloat::None) {
/* Verify available width */
const int min_required_width = 10 * FONT_HEIGHT_NORMAL;
const int min_required_width = 10 * GetCharacterHeight(FS_NORMAL);
int left_offset = (left_width == 0) ? 0 : (left_width + element_dist);
int right_offset = (right_width == 0) ? 0 : (right_width + element_dist);
if (left_offset + right_offset + min_required_width >= max_width) {
@ -599,7 +599,7 @@ public:
{
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_SB_SCROLLBAR);
this->vscroll->SetStepSize(FONT_HEIGHT_NORMAL);
this->vscroll->SetStepSize(GetCharacterHeight(FS_NORMAL));
/* Initialize page sort. */
this->story_pages.SetSortFuncs(StoryBookWindow::page_sorter_funcs);
@ -697,7 +697,7 @@ public:
/* Draw content (now coordinates given to Draw** are local to the new clipping region). */
fr = fr.Translate(-fr.left, -fr.top);
int line_height = FONT_HEIGHT_NORMAL;
int line_height = GetCharacterHeight(FS_NORMAL);
const int scrollpos = this->vscroll->GetPosition();
int y_offset = -scrollpos;
@ -759,7 +759,7 @@ public:
if (widget != WID_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return;
Dimension d;
d.height = FONT_HEIGHT_NORMAL;
d.height = GetCharacterHeight(FS_NORMAL);
d.width = 0;
switch (widget) {

@ -130,7 +130,7 @@ struct SubsidyListWindow : Window {
if (widget != WID_SUL_PANEL) return;
Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE));
resize->height = FONT_HEIGHT_NORMAL;
resize->height = GetCharacterHeight(FS_NORMAL);
d.height *= 5;
d.width += WidgetDimensions::scaled.framerect.Horizontal();
@ -148,7 +148,7 @@ struct SubsidyListWindow : Window {
const int cap = this->vscroll->GetCapacity();
/* Section for drawing the offered subsidies */
if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_TITLE);
if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_OFFERED_TITLE);
pos++;
uint num = 0;
@ -158,7 +158,7 @@ struct SubsidyListWindow : Window {
/* Displays the two offered towns */
SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::Gui);
SetDParam(7, _date - _cur_date_ymd.day + s->remaining * 32);
DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_FROM_TO);
DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_OFFERED_FROM_TO);
}
pos++;
num++;
@ -166,13 +166,13 @@ struct SubsidyListWindow : Window {
}
if (num == 0) {
if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_NONE);
pos++;
}
/* Section for drawing the already granted subsidies */
pos++;
if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_TITLE);
if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_TITLE);
pos++;
num = 0;
@ -184,7 +184,7 @@ struct SubsidyListWindow : Window {
SetDParam(8, _date - _cur_date_ymd.day + s->remaining * 32);
/* Displays the two connected stations */
DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_FROM_TO);
DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_FROM_TO);
}
pos++;
num++;
@ -192,7 +192,7 @@ struct SubsidyListWindow : Window {
}
if (num == 0) {
if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_NONE);
pos++;
}
}

@ -323,10 +323,10 @@ public:
}
if (!buildable) {
DrawString(left, right, y, STR_TMPL_WARNING_VEH_UNAVAILABLE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
} else if (types == RAILTYPES_NONE) {
DrawString(left, right, y, STR_TMPL_WARNING_VEH_NO_COMPATIBLE_RAIL_TYPE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
SetDParam(0, STR_TMPL_TEMPLATE_OVR_VALUE_LTBLUE);
@ -334,7 +334,7 @@ public:
SetDParam(2, STR_TMPL_TEMPLATE_OVR_RUNNING_COST);
SetDParam(3, this->virtual_train->GetDisplayRunningCost());
DrawString(left, right, y, STR_TMPL_TEMPLATE_OVR_MULTIPLE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
/* Draw vehicle performance info */
const bool original_acceleration = (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL ||
@ -350,7 +350,7 @@ public:
full_cargo_weight += train->GetCargoWeight(train->cargo_cap);
}
if (full_cargo_weight > 0 || _settings_client.gui.show_train_weight_ratios_in_details) {
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
uint full_weight = gcache->cached_weight + full_cargo_weight;
SetDParam(0, full_weight);
if (_settings_client.gui.show_train_weight_ratios_in_details) {
@ -365,7 +365,7 @@ public:
DrawString(left, right, y, STR_VEHICLE_INFO_FULL_WEIGHT_WITH_RATIOS);
}
if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) {
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
SetDParam(0, GetTrainEstimatedMaxAchievableSpeed(this->virtual_train, gcache->cached_weight + full_cargo_weight, this->virtual_train->GetDisplayMaxSpeed()));
DrawString(left, right, y, STR_VEHICLE_INFO_MAX_SPEED_LOADED);
}
@ -374,13 +374,13 @@ public:
for (const Train *tmp = this->virtual_train; tmp != nullptr; tmp = tmp->Next()) {
cargo_caps[tmp->cargo_type] += tmp->cargo_cap;
}
y += FONT_HEIGHT_NORMAL * 2;
y += GetCharacterHeight(FS_NORMAL) * 2;
for (CargoID i = 0; i < NUM_CARGO; ++i) {
if (cargo_caps[i] > 0) {
SetDParam(0, i);
SetDParam(1, cargo_caps[i]);
DrawString(left, right, y, STR_TMPL_CARGO_SUMMARY, TC_LIGHT_BLUE, SA_LEFT);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
}
}
@ -553,7 +553,7 @@ public:
{
uint min_width = 32;
uint width = 0;
uint height = ScaleGUITrad(8) + (3 * FONT_HEIGHT_NORMAL);
uint height = ScaleGUITrad(8) + (3 * GetCharacterHeight(FS_NORMAL));
CargoArray cargo_caps{};
if (virtual_train != nullptr) {
@ -565,13 +565,13 @@ public:
if (!IsEngineBuildable(train->engine_type, VEH_TRAIN, train->owner)) buildable = false;
full_cargo_weight += train->GetCargoWeight(train->cargo_cap);
}
if (!buildable) height += FONT_HEIGHT_NORMAL;
if (full_cargo_weight > 0 || _settings_client.gui.show_train_weight_ratios_in_details) height += FONT_HEIGHT_NORMAL;
if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) height += FONT_HEIGHT_NORMAL;
if (!buildable) height += GetCharacterHeight(FS_NORMAL);
if (full_cargo_weight > 0 || _settings_client.gui.show_train_weight_ratios_in_details) height += GetCharacterHeight(FS_NORMAL);
if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) height += GetCharacterHeight(FS_NORMAL);
for (CargoID i = 0; i < NUM_CARGO; ++i) {
if (cargo_caps[i] > 0) {
height += FONT_HEIGHT_NORMAL;
height += GetCharacterHeight(FS_NORMAL);
}
}
}

@ -228,7 +228,7 @@ public:
this->sel_railtype = INVALID_RAILTYPE;
this->details_height = 10 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.Vertical();
this->details_height = 10 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.framerect.Vertical();
this->CreateNestedTree(wdesc != nullptr);
this->vscroll[0] = this->GetScrollbar(TRW_WIDGET_TOP_SCROLLBAR);
@ -264,12 +264,12 @@ public:
{
switch (widget) {
case TRW_WIDGET_TOP_MATRIX:
resize->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical();
resize->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical();
size->height = 8 * resize->height;
break;
case TRW_WIDGET_BOTTOM_MATRIX: {
int base_resize = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical();
int target_resize = WidgetDimensions::scaled.matrix.top + FONT_HEIGHT_NORMAL + ScaleGUITrad(GetVehicleHeight(VEH_TRAIN));
int base_resize = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical();
int target_resize = WidgetDimensions::scaled.matrix.top + GetCharacterHeight(FS_NORMAL) + ScaleGUITrad(GetVehicleHeight(VEH_TRAIN));
this->bottom_matrix_item_size = resize->height = CeilT<int>(target_resize, base_resize);
size->height = 4 * resize->height;
@ -303,7 +303,7 @@ public:
break;
}
case TRW_WIDGET_TMPL_CONFIG_HEADER:
size->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.Vertical();
size->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.framerect.Vertical();
break;
case TRW_WIDGET_TMPL_BUTTONS_CONFIG_RIGHTPANEL:
case TRW_WIDGET_TMPL_BUTTONS_EDIT_RIGHTPANEL:
@ -370,13 +370,13 @@ public:
TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_OLD_ONLY);
} else {
const TemplateVehicle *tmp = this->templates[this->selected_template_index];
uint height = ScaleGUITrad(8) + (3 * FONT_HEIGHT_NORMAL);
uint height = ScaleGUITrad(8) + (3 * GetCharacterHeight(FS_NORMAL));
CargoArray cargo_caps{};
uint count_columns = 0;
uint max_columns = 2;
if (tmp->full_weight > tmp->empty_weight || _settings_client.gui.show_train_weight_ratios_in_details) height += FONT_HEIGHT_NORMAL;
if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) height += FONT_HEIGHT_NORMAL;
if (tmp->full_weight > tmp->empty_weight || _settings_client.gui.show_train_weight_ratios_in_details) height += GetCharacterHeight(FS_NORMAL);
if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) height += GetCharacterHeight(FS_NORMAL);
for (const TemplateVehicle *u = tmp; u != nullptr; u = u->Next()) {
cargo_caps[u->cargo_type] += u->cargo_cap;
@ -385,7 +385,7 @@ public:
for (CargoID i = 0; i < NUM_CARGO; ++i) {
if (cargo_caps[i] > 0) {
if (count_columns % max_columns == 0) {
height += FONT_HEIGHT_NORMAL;
height += GetCharacterHeight(FS_NORMAL);
}
++count_columns;
@ -495,7 +495,7 @@ public:
ShowDropDownList(this, GetRailTypeDropDownList(true, true), this->sel_railtype, TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN);
break;
case TRW_WIDGET_TOP_MATRIX: {
uint16 newindex = (uint16)((pt.y - this->nested_array[TRW_WIDGET_TOP_MATRIX]->pos_y) / (FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical()) ) + this->vscroll[0]->GetPosition();
uint16 newindex = (uint16)((pt.y - this->nested_array[TRW_WIDGET_TOP_MATRIX]->pos_y) / (GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical()) ) + this->vscroll[0]->GetPosition();
if (newindex == this->selected_group_index || newindex >= this->groups.size()) {
this->selected_group_index = -1;
} else if (newindex < this->groups.size()) {
@ -676,7 +676,7 @@ public:
/* Fill the background of the current cell in a darker tone for the currently selected template */
if (this->selected_group_index == i) {
GfxFillRect(r.left + 1, y, r.right, y + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical(), _colour_gradient[COLOUR_GREY][3]);
GfxFillRect(r.left + 1, y, r.right, y + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical(), _colour_gradient[COLOUR_GREY][3]);
}
int text_y = y + WidgetDimensions::scaled.matrix.top;
@ -726,7 +726,7 @@ public:
draw_text(col2 + ScaleGUITrad(4), right - ScaleGUITrad(4), STR_TMPL_NUM_TRAINS_NEED_RPL, num_trains > 0 ? TC_BLACK : TC_GREY, SA_RIGHT);
}
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical();
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical();
}
}
@ -796,7 +796,7 @@ public:
SetDParam(1, 1);
draw_text_across(0, ScaleGUITrad(4), ScaleGUITrad(2), STR_JUST_DECIMAL, TC_BLACK, SA_RIGHT, FS_SMALL);
int bottom_edge = this->bottom_matrix_item_size - FONT_HEIGHT_NORMAL - WidgetDimensions::scaled.framerect.bottom;
int bottom_edge = this->bottom_matrix_item_size - GetCharacterHeight(FS_NORMAL) - WidgetDimensions::scaled.framerect.bottom;
/* Buying cost */
SetDParam(0, CalculateOverallTemplateCost(v));
@ -862,7 +862,7 @@ public:
SetDParam(0, CalculateOverallTemplateDisplayRunningCost(tmp));
DrawString(left, right, top, STR_TMPL_TEMPLATE_OVR_RUNNING_COST);
top += FONT_HEIGHT_NORMAL;
top += GetCharacterHeight(FS_NORMAL);
/* Draw vehicle performance info */
const bool original_acceleration = (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL ||
@ -874,7 +874,7 @@ public:
DrawString(left, right, top, original_acceleration ? STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED : STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE);
if (tmp->full_weight > tmp->empty_weight || _settings_client.gui.show_train_weight_ratios_in_details) {
top += FONT_HEIGHT_NORMAL;
top += GetCharacterHeight(FS_NORMAL);
SetDParam(0, tmp->full_weight);
if (_settings_client.gui.show_train_weight_ratios_in_details) {
SetDParam(1, STR_VEHICLE_INFO_WEIGHT_RATIOS);
@ -888,13 +888,13 @@ public:
DrawString(8, right, top, STR_VEHICLE_INFO_FULL_WEIGHT_WITH_RATIOS);
}
if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) {
top += FONT_HEIGHT_NORMAL;
top += GetCharacterHeight(FS_NORMAL);
SetDParam(0, GetTemplateVehicleEstimatedMaxAchievableSpeed(tmp, tmp->full_weight, tmp->max_speed));
DrawString(8, right, top, STR_VEHICLE_INFO_MAX_SPEED_LOADED);
}
/* Draw cargo summary */
top += FONT_HEIGHT_NORMAL * 2;
top += GetCharacterHeight(FS_NORMAL) * 2;
int count_columns = 0;
int max_columns = 2;
@ -916,7 +916,7 @@ public:
x += step;
if (count_columns % max_columns == 0) {
x = 0;
top += FONT_HEIGHT_NORMAL;
top += GetCharacterHeight(FS_NORMAL);
}
}
}

@ -136,7 +136,7 @@ void DrawTextEffects(ViewportDrawerDynamic *vdd, DrawPixelInfo *dpi, bool load_t
if (dpi->zoom > ZOOM_LVL_OUT_8X) return;
const int bottom_threshold = dpi->top + dpi->height;
const int top_threshold = dpi->top - ScaleByZoom(WidgetDimensions::scaled.framerect.Horizontal() + FONT_HEIGHT_NORMAL, dpi->zoom);
const int top_threshold = dpi->top - ScaleByZoom(WidgetDimensions::scaled.framerect.Horizontal() + GetCharacterHeight(FS_NORMAL), dpi->zoom);
const bool show_loading = (_settings_client.gui.loading_indicators && !load_transparent);
for (TextEffect &te : _text_effects) {

@ -114,7 +114,7 @@ uint TextfileWindow::ReflowContent()
int max_width = this->GetWidget<NWidgetCore>(WID_TF_BACKGROUND)->current_x - WidgetDimensions::scaled.frametext.Horizontal();
for (auto &line : this->lines) {
line.top = height;
height += GetStringHeight(line.text, max_width, FS_MONO) / FONT_HEIGHT_MONO;
height += GetStringHeight(line.text, max_width, FS_MONO) / GetCharacterHeight(FS_MONO);
line.bottom = height;
}
}
@ -132,7 +132,7 @@ uint TextfileWindow::GetContentHeight()
{
switch (widget) {
case WID_TF_BACKGROUND:
resize->height = FONT_HEIGHT_MONO;
resize->height = GetCharacterHeight(FS_MONO);
size->height = 4 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); // At least 4 lines are visible.
size->width = std::max(200u, size->width); // At least 200 pixels wide.
@ -303,7 +303,7 @@ void TextfileWindow::CheckHyperlinkClick(Point pt)
if (this->links.empty()) return;
/* Which line was clicked. */
const int clicked_row = this->GetRowFromWidget(pt.y, WID_TF_BACKGROUND, WidgetDimensions::scaled.frametext.top, FONT_HEIGHT_MONO) + this->GetScrollbar(WID_TF_VSCROLLBAR)->GetPosition();
const int clicked_row = this->GetRowFromWidget(pt.y, WID_TF_BACKGROUND, WidgetDimensions::scaled.frametext.top, GetCharacterHeight(FS_MONO)) + this->GetScrollbar(WID_TF_VSCROLLBAR)->GetPosition();
size_t line_index;
size_t subline;
if (IsWidgetLowered(WID_TF_WRAPTEXT)) {
@ -313,7 +313,7 @@ void TextfileWindow::CheckHyperlinkClick(Point pt)
subline = clicked_row - it->top;
Debug(misc, 4, "TextfileWindow check hyperlink: clicked_row={}, line_index={}, line.top={}, subline={}", clicked_row, line_index, it->top, subline);
} else {
line_index = clicked_row / FONT_HEIGHT_MONO;
line_index = clicked_row / GetCharacterHeight(FS_MONO);
subline = 0;
}
@ -562,7 +562,7 @@ void TextfileWindow::AfterLoadMarkdown()
/* Draw content (now coordinates given to DrawString* are local to the new clipping region). */
fr = fr.Translate(-fr.left, -fr.top);
int line_height = FONT_HEIGHT_MONO;
int line_height = GetCharacterHeight(FS_MONO);
int pos = this->vscroll->GetPosition();
int cap = this->vscroll->GetCapacity();

@ -415,13 +415,13 @@ struct TimetableWindow : GeneralVehicleWindow {
case WID_VT_ARRIVAL_DEPARTURE_SELECTION:
case WID_VT_TIMETABLE_PANEL:
resize->height = std::max<int>(FONT_HEIGHT_NORMAL, GetSpriteSize(SPR_LOCK).height);
resize->height = std::max<int>(GetCharacterHeight(FS_NORMAL), GetSpriteSize(SPR_LOCK).height);
size->height = 8 * resize->height + padding.height;
break;
case WID_VT_SUMMARY_PANEL: {
Dimension d = GetSpriteSize(SPR_WARNING_SIGN);
size->height = 2 * FONT_HEIGHT_NORMAL + std::min<int>(MAX_SUMMARY_WARNINGS, this->summary_warnings) * std::max<int>(d.height, FONT_HEIGHT_NORMAL) + padding.height;
size->height = 2 * GetCharacterHeight(FS_NORMAL) + std::min<int>(MAX_SUMMARY_WARNINGS, this->summary_warnings) * std::max<int>(d.height, GetCharacterHeight(FS_NORMAL)) + padding.height;
break;
}
}
@ -662,7 +662,7 @@ struct TimetableWindow : GeneralVehicleWindow {
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
int i = this->vscroll->GetPosition();
Dimension lock_d = GetSpriteSize(SPR_LOCK);
int line_height = std::max<int>(FONT_HEIGHT_NORMAL, lock_d.height);
int line_height = std::max<int>(GetCharacterHeight(FS_NORMAL), lock_d.height);
VehicleOrderID order_id = (i + 1) / 2;
bool final_order = false;
@ -749,7 +749,7 @@ struct TimetableWindow : GeneralVehicleWindow {
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
Dimension lock_d = GetSpriteSize(SPR_LOCK);
int line_height = std::max<int>(FONT_HEIGHT_NORMAL, lock_d.height);
int line_height = std::max<int>(GetCharacterHeight(FS_NORMAL), lock_d.height);
bool show_late = this->show_expected && v->lateness_counter > DATE_UNIT_SIZE;
Ticks offset = show_late ? 0 : -v->lateness_counter;
@ -795,7 +795,7 @@ struct TimetableWindow : GeneralVehicleWindow {
SetTimetableParams(0, total_time);
DrawString(tr, v->orders->IsCompleteTimetable() ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE);
}
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
if (v->timetable_start != 0) {
/* We are running towards the first station so we can start the
@ -813,12 +813,12 @@ struct TimetableWindow : GeneralVehicleWindow {
SetTimetableParams(0, abs(v->lateness_counter));
DrawString(tr, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE);
}
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
{
const Dimension warning_dimensions = GetSpriteSize(SPR_WARNING_SIGN);
const int step_height = std::max<int>(warning_dimensions.height, FONT_HEIGHT_NORMAL);
const int text_offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
const int step_height = std::max<int>(warning_dimensions.height, GetCharacterHeight(FS_NORMAL));
const int text_offset_y = (step_height - GetCharacterHeight(FS_NORMAL)) / 2;
const int warning_offset_y = (step_height - warning_dimensions.height) / 2;
const bool rtl = _current_text_dir == TD_RTL;

@ -155,7 +155,7 @@ public:
uint Height() const override
{
return std::max(std::max(this->icon_size.height, this->lock_size.height) + WidgetDimensions::scaled.imgbtn.Vertical(), (uint)FONT_HEIGHT_NORMAL);
return std::max(std::max(this->icon_size.height, this->lock_size.height) + WidgetDimensions::scaled.imgbtn.Vertical(), (uint)GetCharacterHeight(FS_NORMAL));
}
void Draw(const Rect &r, bool sel, Colours) const override
@ -168,7 +168,7 @@ public:
Rect tr = r.Shrink(WidgetDimensions::scaled.dropdowntext, RectPadding::zero);
int icon_y = CenterBounds(r.top, r.bottom, icon_size.height);
int text_y = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL);
int text_y = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL));
int lock_y = CenterBounds(r.top, r.bottom, lock_size.height);
DrawCompanyIcon(company, tr.WithWidth(this->icon_size.width, rtl).left, icon_y);
@ -201,7 +201,7 @@ DropDownListItem *MakeCompanyDropDownListItem(CompanyID cid)
* @param list List of items
* @param def Default item
*/
static void PopupMainToolbMenu(Window *w, int widget, DropDownList &&list, int def)
static void PopupMainToolbarMenu(Window *w, int widget, DropDownList &&list, int def)
{
ShowDropDownList(w, std::move(list), def, widget, 0, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
@ -211,16 +211,21 @@ static void PopupMainToolbMenu(Window *w, int widget, DropDownList &&list, int d
* Pop up a generic text only menu.
* @param w Toolbar
* @param widget Toolbar button
* @param string String for the first item in the menu
* @param count Number of items in the menu
* @param strings List of strings for each item in the menu
*/
static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count, uint32 disabled = 0)
static void PopupMainToolbarMenu(Window *w, int widget, const std::initializer_list<StringID> &strings)
{
DropDownList list;
for (int i = 0; i < count; i++) {
list.push_back(std::make_unique<DropDownListStringItem>(string + i, i, i < 32 && HasBit(disabled, i)));
int i = 0;
for (StringID string : strings) {
if (string == STR_NULL) {
list.push_back(std::make_unique<DropDownListItem>(-1, false));
} else {
list.push_back(std::make_unique<DropDownListStringItem>(string, i, false));
i++;
}
}
PopupMainToolbMenu(w, widget, std::move(list), 0);
PopupMainToolbarMenu(w, widget, std::move(list), 0);
}
/** Enum for the Company Toolbar's network related buttons */
@ -263,7 +268,7 @@ static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
list.push_back(std::make_unique<DropDownListCompanyItem>(c, false, HasBit(grey, c)));
}
PopupMainToolbMenu(w, widget, std::move(list), _local_company == COMPANY_SPECTATOR ? (widget == WID_TN_COMPANIES ? CTMN_CLIENT_LIST : CTMN_SPECTATOR) : (int)_local_company);
PopupMainToolbarMenu(w, widget, std::move(list), _local_company == COMPANY_SPECTATOR ? (widget == WID_TN_COMPANIES ? CTMN_CLIENT_LIST : CTMN_SPECTATOR) : (int)_local_company);
}
static ToolbarMode _toolbar_mode;
@ -411,24 +416,22 @@ static CallBackFunction MenuClickSettings(int index)
* SaveLoad entries in scenario editor mode.
*/
enum SaveLoadEditorMenuEntries {
SLEME_SAVE_SCENARIO = 0,
SLEME_SAVE_SCENARIO = 0,
SLEME_LOAD_SCENARIO,
SLEME_SAVE_HEIGHTMAP,
SLEME_LOAD_HEIGHTMAP,
SLEME_EXIT_TOINTRO,
SLEME_EXIT_GAME = 6,
SLEME_MENUCOUNT,
SLEME_EXIT_GAME,
};
/**
* SaveLoad entries in normal game mode.
*/
enum SaveLoadNormalMenuEntries {
SLNME_SAVE_GAME = 0,
SLNME_SAVE_GAME = 0,
SLNME_LOAD_GAME,
SLNME_EXIT_TOINTRO,
SLNME_EXIT_GAME = 4,
SLNME_MENUCOUNT,
SLNME_EXIT_GAME,
};
/**
@ -439,7 +442,8 @@ enum SaveLoadNormalMenuEntries {
*/
static CallBackFunction ToolbarSaveClick(Window *w)
{
PopupMainToolbMenu(w, WID_TN_SAVE, STR_FILE_MENU_SAVE_GAME, SLNME_MENUCOUNT);
PopupMainToolbarMenu(w, WID_TN_SAVE, {STR_FILE_MENU_SAVE_GAME, STR_FILE_MENU_LOAD_GAME, STR_FILE_MENU_QUIT_GAME,
STR_NULL, STR_FILE_MENU_EXIT});
return CBF_NONE;
}
@ -451,7 +455,9 @@ static CallBackFunction ToolbarSaveClick(Window *w)
*/
static CallBackFunction ToolbarScenSaveOrLoad(Window *w)
{
PopupMainToolbMenu(w, WID_TE_SAVE, STR_SCENEDIT_FILE_MENU_SAVE_SCENARIO, SLEME_MENUCOUNT);
PopupMainToolbarMenu(w, WID_TE_SAVE, {STR_SCENEDIT_FILE_MENU_SAVE_SCENARIO, STR_SCENEDIT_FILE_MENU_LOAD_SCENARIO,
STR_SCENEDIT_FILE_MENU_SAVE_HEIGHTMAP, STR_SCENEDIT_FILE_MENU_LOAD_HEIGHTMAP,
STR_SCENEDIT_FILE_MENU_QUIT_EDITOR, STR_NULL, STR_SCENEDIT_FILE_MENU_QUIT});
return CBF_NONE;
}
@ -503,7 +509,7 @@ static CallBackFunction ToolbarMapClick(Window *w)
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH, false));
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_PLAN_LIST, MME_SHOW_PLANS, false));
PopupMainToolbMenu(w, WID_TN_SMALL_MAP, std::move(list), 0);
PopupMainToolbarMenu(w, WID_TN_SMALL_MAP, std::move(list), 0);
return CBF_NONE;
}
@ -515,7 +521,7 @@ static CallBackFunction ToolbarScenMapTownDir(Window *w)
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
list.push_back(std::make_unique<DropDownListStringItem>(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false));
list.push_back(std::make_unique<DropDownListStringItem>(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false));
PopupMainToolbMenu(w, WID_TE_SMALL_MAP, std::move(list), 0);
PopupMainToolbarMenu(w, WID_TE_SMALL_MAP, std::move(list), 0);
return CBF_NONE;
}
@ -543,7 +549,11 @@ static CallBackFunction MenuClickMap(int index)
static CallBackFunction ToolbarTownClick(Window *w)
{
PopupMainToolbMenu(w, WID_TN_TOWNS, STR_TOWN_MENU_TOWN_DIRECTORY, (_settings_game.economy.found_town == TF_FORBIDDEN) ? 1 : 2);
if (_settings_game.economy.found_town == TF_FORBIDDEN) {
PopupMainToolbarMenu(w, WID_TN_TOWNS, {STR_TOWN_MENU_TOWN_DIRECTORY});
} else {
PopupMainToolbarMenu(w, WID_TN_TOWNS, {STR_TOWN_MENU_TOWN_DIRECTORY, STR_TOWN_MENU_FOUND_TOWN});
}
return CBF_NONE;
}
@ -568,7 +578,7 @@ static CallBackFunction MenuClickTown(int index)
static CallBackFunction ToolbarSubsidiesClick(Window *w)
{
PopupMainToolbMenu(w, WID_TN_SUBSIDIES, STR_SUBSIDIES_MENU_SUBSIDIES, 1);
PopupMainToolbarMenu(w, WID_TN_SUBSIDIES, {STR_SUBSIDIES_MENU_SUBSIDIES});
return CBF_NONE;
}
@ -796,7 +806,11 @@ static CallBackFunction MenuClickGraphsOrLeague(int index)
static CallBackFunction ToolbarIndustryClick(Window *w)
{
/* Disable build-industry menu if we are a spectator */
PopupMainToolbMenu(w, WID_TN_INDUSTRIES, STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, (_local_company == COMPANY_SPECTATOR) ? 2 : 3);
if (_local_company == COMPANY_SPECTATOR) {
PopupMainToolbarMenu(w, WID_TN_INDUSTRIES, {STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, STR_INDUSTRY_MENU_INDUSTRY_CHAIN});
} else {
PopupMainToolbarMenu(w, WID_TN_INDUSTRIES, {STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, STR_INDUSTRY_MENU_INDUSTRY_CHAIN, STR_INDUSTRY_MENU_FUND_NEW_INDUSTRY});
}
return CBF_NONE;
}
@ -1072,7 +1086,7 @@ static CallBackFunction MenuClickForest(int index)
static CallBackFunction ToolbarMusicClick(Window *w)
{
PopupMainToolbMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_MUSIC_SOUND : (int)WID_TN_MUSIC_SOUND, STR_TOOLBAR_SOUND_MUSIC, 1);
PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_MUSIC_SOUND : (int)WID_TN_MUSIC_SOUND, {STR_TOOLBAR_SOUND_MUSIC});
return CBF_NONE;
}
@ -1091,7 +1105,7 @@ static CallBackFunction MenuClickMusicWindow(int)
static CallBackFunction ToolbarNewspaperClick(Window *w)
{
PopupMainToolbMenu(w, WID_TN_MESSAGES, STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT, 3);
PopupMainToolbarMenu(w, WID_TN_MESSAGES, {STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT, STR_NEWS_MENU_MESSAGE_HISTORY_MENU, STR_NEWS_MENU_DELETE_ALL_MESSAGES});
return CBF_NONE;
}
@ -1119,7 +1133,7 @@ static CallBackFunction MenuClickNewspaper(int index)
enum HelpMenuEntries {
HME_LANDINFO = 0,
HME_PICKER,
HME_SEPARATOR,
HME_HELP,
HME_CONSOLE,
HME_SCRIPT_DEBUG,
@ -1239,7 +1253,7 @@ static CallBackFunction ToolbarHelpClick(Window *w)
DropDownList list;
list.emplace_back(new DropDownListStringItem(STR_ABOUT_MENU_LAND_BLOCK_INFO, HME_LANDINFO, false));
list.emplace_back(new DropDownListStringItem(STR_ABOUT_MENU_SHOW_PICKER_TOOL, HME_PICKER, _local_company == COMPANY_SPECTATOR));
list.emplace_back(new DropDownListStringItem(STR_ABOUT_MENU_SEPARATOR, HME_SEPARATOR, false));
list.emplace_back(new DropDownListItem(-1, false));
list.emplace_back(new DropDownListStringItem(STR_ABOUT_MENU_HELP, HME_HELP, false));
list.emplace_back(new DropDownListStringItem(STR_ABOUT_MENU_TOGGLE_CONSOLE, HME_CONSOLE, false));
list.emplace_back(new DropDownListStringItem(STR_ABOUT_MENU_AI_DEBUG, HME_SCRIPT_DEBUG, false));
@ -1253,7 +1267,7 @@ static CallBackFunction ToolbarHelpClick(Window *w)
list.emplace_back(new DropDownListStringItem(STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS, HME_DIRTY_BLOCKS, false));
list.emplace_back(new DropDownListStringItem(STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES, HME_WIDGET_OUTLINES, false));
}
PopupMainToolbMenu(w, widget, std::move(list), 0);
PopupMainToolbarMenu(w, widget, std::move(list), 0);
return CBF_NONE;
}
@ -2585,11 +2599,11 @@ struct ScenarioEditorToolbarWindow : Window {
switch (widget) {
case WID_TE_SPACER: {
int height = r.Height();
if (height > 2 * FONT_HEIGHT_NORMAL) {
DrawString(r.left, r.right, height / 2 - FONT_HEIGHT_NORMAL, STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER);
if (height > 2 * GetCharacterHeight(FS_NORMAL)) {
DrawString(r.left, r.right, height / 2 - GetCharacterHeight(FS_NORMAL), STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(r.left, r.right, height / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
} else {
DrawString(r.left, r.right, (height - FONT_HEIGHT_NORMAL) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(r.left, r.right, (height - GetCharacterHeight(FS_NORMAL)) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
}
break;
}

@ -121,7 +121,7 @@ public:
this->town = Town::Get(window_number);
this->InitNested(window_number);
this->vscroll = this->GetScrollbar(WID_TA_SCROLLBAR);
this->vscroll->SetCapacity((this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST)->current_y - WidgetDimensions::scaled.framerect.Vertical()) / FONT_HEIGHT_NORMAL);
this->vscroll->SetCapacity((this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST)->current_y - WidgetDimensions::scaled.framerect.Vertical()) / GetCharacterHeight(FS_NORMAL));
}
void OnInit() override
@ -158,7 +158,7 @@ public:
{
Rect r = this->GetWidget<NWidgetBase>(WID_TA_RATING_INFO)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2;
int text_y_offset = (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2;
int icon_y_offset = (this->resize.step_height - this->icon_size.height) / 2;
int exclusive_y_offset = (this->resize.step_height - this->exclusive_size.height) / 2;
@ -287,14 +287,14 @@ public:
if (--pos < 0) {
DrawString(ir.left, ir.right, y, STR_LOCAL_AUTHORITY_ACTIONS_TITLE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
for (int i = 0; buttons; i++, buttons >>= 1) {
if ((buttons & 1) && --pos < 0) {
DrawString(ir.left, ir.right, y,
STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, this->sel_index == i ? TC_WHITE : TC_ORANGE);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
}
for (int i = 0; i < (int)SETTING_OVERRIDE_COUNT; i++) {
@ -337,7 +337,7 @@ public:
}
DrawString(ir.left, ir.right, y,
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_STR, tc);
y += FONT_HEIGHT_NORMAL;
y += GetCharacterHeight(FS_NORMAL);
}
}
break;
@ -362,7 +362,7 @@ public:
}
case WID_TA_COMMAND_LIST:
size->height = (5 + SETTING_OVERRIDE_COUNT) * FONT_HEIGHT_NORMAL + padding.height;
size->height = (5 + SETTING_OVERRIDE_COUNT) * 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);
@ -371,7 +371,7 @@ public:
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)FONT_HEIGHT_NORMAL});
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;
}
@ -394,7 +394,7 @@ public:
}
case WID_TA_COMMAND_LIST: {
int y = this->GetRowFromWidget(pt.y, WID_TA_COMMAND_LIST, 1, FONT_HEIGHT_NORMAL);
int y = this->GetRowFromWidget(pt.y, WID_TA_COMMAND_LIST, 1, GetCharacterHeight(FS_NORMAL));
if (!IsInsideMM(y, 0, 5 + SETTING_OVERRIDE_COUNT)) return;
const uint setting_override_offset = 32 - SETTING_OVERRIDE_COUNT;
@ -564,19 +564,19 @@ public:
SetDParam(0, this->town->cache.population);
SetDParam(1, this->town->cache.num_houses);
DrawString(tr, STR_TOWN_VIEW_POPULATION_HOUSES);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
SetDParam(0, 1 << CT_PASSENGERS);
SetDParam(1, this->town->supplied[CT_PASSENGERS].old_act);
SetDParam(2, this->town->supplied[CT_PASSENGERS].old_max);
DrawString(tr, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
SetDParam(0, 1 << CT_MAIL);
SetDParam(1, this->town->supplied[CT_MAIL].old_act);
SetDParam(2, this->town->supplied[CT_MAIL].old_max);
DrawString(tr, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
bool first = true;
for (int i = TE_BEGIN; i < TE_END; i++) {
@ -586,7 +586,7 @@ public:
if (first) {
DrawString(tr, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
first = false;
}
@ -621,16 +621,16 @@ public:
SetDParam(3, this->town->goal[i]);
}
DrawString(tr.Indent(20, rtl), string);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
if (HasBit(this->town->flags, TOWN_IS_GROWING)) {
SetDParam(0, RoundDivSU(this->town->growth_rate + 1, DAY_TICKS));
DrawString(tr, this->town->fund_buildings_months == 0 ? STR_TOWN_VIEW_TOWN_GROWS_EVERY : STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
} else {
DrawString(tr, STR_TOWN_VIEW_TOWN_GROW_STOPPED);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
/* only show the town noise, if the noise option is activated. */
@ -639,7 +639,7 @@ public:
SetDParam(0, this->town->noise_reached);
SetDParam(1, max_noise);
DrawString(tr, max_noise == UINT16_MAX ? STR_TOWN_VIEW_NOISE_IN_TOWN_NO_LIMIT : STR_TOWN_VIEW_NOISE_IN_TOWN);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
if (!this->town->text.empty()) {
@ -698,7 +698,7 @@ public:
*/
uint GetDesiredInfoHeight(int width) const
{
uint aimed_height = 3 * FONT_HEIGHT_NORMAL;
uint aimed_height = 3 * GetCharacterHeight(FS_NORMAL);
bool first = true;
for (int i = TE_BEGIN; i < TE_END; i++) {
@ -707,14 +707,14 @@ public:
if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;
if (first) {
aimed_height += FONT_HEIGHT_NORMAL;
aimed_height += GetCharacterHeight(FS_NORMAL);
first = false;
}
aimed_height += FONT_HEIGHT_NORMAL;
aimed_height += GetCharacterHeight(FS_NORMAL);
}
aimed_height += FONT_HEIGHT_NORMAL;
aimed_height += GetCharacterHeight(FS_NORMAL);
if (_settings_game.economy.station_noise_level) aimed_height += FONT_HEIGHT_NORMAL;
if (_settings_game.economy.station_noise_level) aimed_height += GetCharacterHeight(FS_NORMAL);
if (!this->town->text.empty()) {
SetDParamStr(0, this->town->text);
@ -1032,7 +1032,7 @@ public:
SetDParam(0, t->index);
SetDParam(1, t->cache.population);
DrawString(tr.left, tr.right, tr.top + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, GetTownString(t));
DrawString(tr.left, tr.right, tr.top + (this->resize.step_height - GetCharacterHeight(FS_NORMAL)) / 2, GetTownString(t));
tr.top += this->resize.step_height;
if (++n == this->vscroll->GetCapacity()) break; // max number of towns in 1 window
@ -1825,7 +1825,7 @@ public:
max_w = std::max(max_w, GetStringBoundingBox(this->house_list.GetNameOfHouseSet(i)).width);
}
size->width = std::max(size->width, max_w + padding.width);
this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.matrix.Vertical();
this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical();
size->height = this->house_list.NumHouseSets() * this->line_height;
break;
}

@ -2594,7 +2594,7 @@ public:
{
switch (widget) {
case TR_WIDGET_INSTRUCTION_LIST:
resize->height = FONT_HEIGHT_NORMAL;
resize->height = GetCharacterHeight(FS_NORMAL);
size->height = 6 * resize->height + WidgetDimensions::scaled.framerect.Vertical();
break;
@ -3756,7 +3756,7 @@ private:
uint ComputeSlotInfoSize()
{
this->column_size[VGC_NAME] = GetStringBoundingBox(STR_GROUP_ALL_TRAINS);
this->column_size[VGC_NAME].width = std::max((170u * FONT_HEIGHT_NORMAL) / 10u, this->column_size[VGC_NAME].width);
this->column_size[VGC_NAME].width = std::max((170u * GetCharacterHeight(FS_NORMAL)) / 10u, this->column_size[VGC_NAME].width);
this->tiny_step_height = this->column_size[VGC_NAME].height;
SetDParamMaxValue(0, 9999, 3, FS_SMALL);

@ -419,7 +419,7 @@ void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vsc
bool rtl = _current_text_dir == TD_RTL;
int line_height = r.Height();
int sprite_y_offset = line_height / 2;
int text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2;
int text_y_offset = (line_height - GetCharacterHeight(FS_NORMAL)) / 2;
/* draw the first 3 details tabs */
if (det_tab != TDW_TAB_TOTALS) {

@ -646,12 +646,12 @@ static void DrawVehicleRefitWindow(const RefitOptions &refits, const RefitOption
if (has_subtypes) {
if (refit.subtype != UINT8_MAX) {
/* Draw tree lines */
int ycenter = tr.top + FONT_HEIGHT_NORMAL / 2;
int ycenter = tr.top + GetCharacterHeight(FS_NORMAL) / 2;
GfxDrawLine(iconcenter, tr.top - WidgetDimensions::scaled.matrix.top, iconcenter, (&refit == &pair.second.back()) ? ycenter : tr.top - WidgetDimensions::scaled.matrix.top + delta - 1, linecolour);
GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
} else {
/* Draw expand/collapse icon */
DrawSprite((sel != nullptr && sel->cargo == refit.cargo) ? SPR_CIRCLE_UNFOLDED : SPR_CIRCLE_FOLDED, PAL_NONE, iconleft, tr.top + (FONT_HEIGHT_NORMAL - iconheight) / 2);
DrawSprite((sel != nullptr && sel->cargo == refit.cargo) ? SPR_CIRCLE_UNFOLDED : SPR_CIRCLE_FOLDED, PAL_NONE, iconleft, tr.top + (GetCharacterHeight(FS_NORMAL) - iconheight) / 2);
}
}
@ -951,7 +951,7 @@ struct RefitWindow : public Window {
{
switch (widget) {
case WID_VR_MATRIX:
resize->height = FONT_HEIGHT_NORMAL + padding.height;
resize->height = GetCharacterHeight(FS_NORMAL) + padding.height;
size->height = resize->height * 8;
break;
@ -1775,7 +1775,7 @@ static void DrawSmallOrderList(const Vehicle *v, int left, int right, int y, uin
SetDParam(0, order->GetDestination());
DrawString(left + l_offset, right - r_offset, y, STR_STATION_NAME, TC_BLACK, SA_LEFT, false, FS_SMALL);
y += FONT_HEIGHT_SMALL;
y += GetCharacterHeight(FS_SMALL);
if (++i == 4) break;
}
@ -1800,7 +1800,7 @@ static void DrawSmallOrderList(const Order *order, int left, int right, int y, u
SetDParam(0, order->GetDestination());
DrawString(left + l_offset, right - r_offset, y, STR_STATION_NAME, TC_BLACK, SA_LEFT, false, FS_SMALL);
y += FONT_HEIGHT_SMALL;
y += GetCharacterHeight(FS_SMALL);
if (++i == 4) break;
}
order = order->next;
@ -1834,9 +1834,9 @@ void DrawVehicleImage(const Vehicle *v, const Rect &r, VehicleID selection, Engi
uint GetVehicleListHeight(VehicleType type, uint divisor)
{
/* Name + vehicle + profit */
uint base = ScaleGUITrad(GetVehicleHeight(type)) + 2 * FONT_HEIGHT_SMALL + ScaleGUITrad(1);
uint base = ScaleGUITrad(GetVehicleHeight(type)) + 2 * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(1);
/* Drawing of the 4 small orders + profit*/
if (type >= VEH_SHIP) base = std::max(base, 5U * FONT_HEIGHT_SMALL + ScaleGUITrad(1));
if (type >= VEH_SHIP) base = std::max(base, 5U * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(1));
if (divisor == 1) return base;
@ -1976,7 +1976,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
}
DrawVehicleImage(v, {image_left, ir.top, image_right, ir.bottom}, selected_vehicle, EIT_IN_LIST, 0);
DrawString(tr.left, tr.right, ir.top + line_height - FONT_HEIGHT_SMALL - WidgetDimensions::scaled.framerect.bottom - 1, str);
DrawString(tr.left, tr.right, ir.top + line_height - GetCharacterHeight(FS_SMALL) - WidgetDimensions::scaled.framerect.bottom - 1, str);
/* company colour stripe along vehicle description row */
if (_settings_client.gui.show_vehicle_list_company_colour && v->owner != this->vli.company) {
@ -1985,22 +1985,22 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
if (c != nullptr) {
ccolour = _colour_gradient[c->colour][6];
}
GfxFillRect((tr.right - 1) - (FONT_HEIGHT_SMALL - 2), ir.top + 1, tr.right - 1, (ir.top + 1) + (FONT_HEIGHT_SMALL - 2), ccolour, FILLRECT_OPAQUE);
GfxFillRect((tr.right - 1) - (GetCharacterHeight(FS_SMALL) - 2), ir.top + 1, tr.right - 1, (ir.top + 1) + (GetCharacterHeight(FS_SMALL) - 2), ccolour, FILLRECT_OPAQUE);
}
} else {
SetDParam(0, vehgroup.GetDisplayProfitThisYear());
SetDParam(1, vehgroup.GetDisplayProfitLastYear());
DrawString(tr.left, tr.right, ir.bottom - FONT_HEIGHT_SMALL - WidgetDimensions::scaled.framerect.bottom, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
DrawString(tr.left, tr.right, ir.bottom - GetCharacterHeight(FS_SMALL) - WidgetDimensions::scaled.framerect.bottom, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
}
DrawVehicleProfitButton(vehgroup.GetOldestVehicleAge(), vehgroup.GetDisplayProfitLastYear(), vehgroup.NumVehicles(), vehicle_button_x, ir.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal);
DrawVehicleProfitButton(vehgroup.GetOldestVehicleAge(), vehgroup.GetDisplayProfitLastYear(), vehgroup.NumVehicles(), vehicle_button_x, ir.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal);
switch (this->grouping) {
case GB_NONE: {
const Vehicle *v = vehgroup.GetSingleVehicle();
if (HasBit(v->vehicle_flags, VF_PATHFINDER_LOST)) {
DrawSprite(SPR_WARNING_SIGN, PAL_NONE, vehicle_button_x, ir.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal + profit.height);
DrawSprite(SPR_WARNING_SIGN, PAL_NONE, vehicle_button_x, ir.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + profit.height);
}
DrawVehicleImage(v, {image_left, ir.top, image_right, ir.bottom}, selected_vehicle, EIT_IN_LIST, 0);
@ -2888,14 +2888,14 @@ struct VehicleDetailsWindow : Window {
uint desired_height;
if (v->Next() != nullptr) {
/* An articulated RV has its text drawn under the sprite instead of after it, hence 15 pixels extra. */
desired_height = 4 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal * 2;
desired_height = 4 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2;
if (v->type == VEH_ROAD) desired_height += ScaleGUITrad(15);
/* Add space for the cargo amount for each part. */
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
if (u->cargo_cap != 0) desired_height += FONT_HEIGHT_NORMAL;
if (u->cargo_cap != 0) desired_height += GetCharacterHeight(FS_NORMAL);
}
} else {
desired_height = 5 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal * 2;
desired_height = 5 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2;
}
return desired_height;
}
@ -2944,7 +2944,7 @@ struct VehicleDetailsWindow : Window {
if (this->vehicle_slots_line_shown) lines++;
if (this->vehicle_speed_restriction_line_shown) lines++;
if (this->vehicle_speed_adaptation_exempt_line_shown) lines++;
size->height = lines * FONT_HEIGHT_NORMAL + padding.height;
size->height = lines * GetCharacterHeight(FS_NORMAL) + padding.height;
for (uint i = 0; i < 5; i++) SetDParamMaxValue(i, INT16_MAX);
static const StringID info_strings[] = {
@ -2994,7 +2994,7 @@ struct VehicleDetailsWindow : Window {
break;
case VEH_AIRCRAFT:
size->height = 5 * FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal * 2 + padding.height;
size->height = 5 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height;
break;
default:
@ -3004,7 +3004,7 @@ struct VehicleDetailsWindow : Window {
}
case WID_VD_MATRIX:
resize->height = std::max<uint>(ScaleGUITrad(14), FONT_HEIGHT_NORMAL + padding.height);
resize->height = std::max<uint>(ScaleGUITrad(14), GetCharacterHeight(FS_NORMAL) + padding.height);
size->height = 4 * resize->height;
break;
@ -3027,7 +3027,7 @@ struct VehicleDetailsWindow : Window {
GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT).width,
GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS).width
) + padding.width;
size->height = FONT_HEIGHT_NORMAL + padding.height;
size->height = GetCharacterHeight(FS_NORMAL) + padding.height;
break;
}
}
@ -3084,7 +3084,7 @@ struct VehicleDetailsWindow : Window {
SetDParam(2, DateToYear(v->max_age));
SetDParam(3, v->GetDisplayRunningCost());
DrawString(tr, STR_VEHICLE_INFO_AGE_RUNNING_COST_YR);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
/* Draw max speed */
StringID string;
@ -3116,7 +3116,7 @@ struct VehicleDetailsWindow : Window {
}
}
DrawString(tr, string);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
bool should_show_weight_ratio = this->ShouldShowWeightRatioLine(v);
if (should_show_weight_ratio) {
@ -3125,7 +3125,7 @@ struct VehicleDetailsWindow : Window {
SetDParam(2, Train::From(v)->GetAccelerationType() == 2 ? STR_EMPTY : STR_VEHICLE_INFO_TE_WEIGHT_RATIO);
SetDParam(3, (100 * Train::From(v)->gcache.cached_max_te) / std::max<uint>(1, Train::From(v)->gcache.cached_weight));
DrawString(tr, STR_VEHICLE_INFO_WEIGHT_RATIOS);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
/* Draw profit */
@ -3146,7 +3146,7 @@ struct VehicleDetailsWindow : Window {
SetDParam(3, v->GetDisplayProfitLifetime());
DrawString(tr, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR_LIFETIME);
}
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
/* Draw breakdown & reliability */
byte total_engines = 0;
@ -3169,13 +3169,13 @@ struct VehicleDetailsWindow : Window {
SetDParam(1, v->breakdowns_since_last_service);
}
DrawString(tr, STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
bool should_show_group = this->ShouldShowGroupLine(v);
if (should_show_group) {
SetDParam(0, v->group_id | GROUP_NAME_HIERARCHY);
DrawString(tr, STR_VEHICLE_INFO_GROUP);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
bool should_show_slots = this->ShouldShowSlotsLine(v);
@ -3195,20 +3195,20 @@ struct VehicleDetailsWindow : Window {
}
SetDParamStr(0, text_buffer);
DrawString(tr, STR_JUST_RAW_STRING);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
bool should_show_speed_restriction = this->ShouldShowSpeedRestrictionLine(v);
if (should_show_speed_restriction) {
SetDParam(0, Train::From(v)->speed_restriction);
DrawString(tr, STR_VEHICLE_INFO_SPEED_RESTRICTION);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
bool should_show_speed_adaptation_exempt = this->ShouldShowSpeedAdaptationExemptLine(v);
if (should_show_speed_adaptation_exempt) {
DrawString(tr, STR_VEHICLE_INFO_SPEED_ADAPTATION_EXEMPT);
tr.top += FONT_HEIGHT_NORMAL;
tr.top += GetCharacterHeight(FS_NORMAL);
}
if (this->vehicle_weight_ratio_line_shown != should_show_weight_ratio ||
@ -3250,7 +3250,7 @@ struct VehicleDetailsWindow : Window {
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
SetDParam(0, v->GetServiceInterval());
SetDParam(1, v->date_of_last_service);
DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL),
DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)),
v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS);
break;
}
@ -3668,7 +3668,7 @@ public:
const Vehicle *v = Vehicle::Get(this->window_number);
switch (widget) {
case WID_VV_START_STOP:
size->height = std::max<uint>({size->height, (uint)FONT_HEIGHT_NORMAL, GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height;
size->height = std::max<uint>({size->height, (uint)GetCharacterHeight(FS_NORMAL), GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height;
break;
case WID_VV_FORCE_PROCEED:
@ -3895,7 +3895,7 @@ public:
SpriteID image = ((v->vehstatus & VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : (HasBit(v->vehicle_flags, VF_PATHFINDER_LOST)) ? SPR_WARNING_SIGN : SPR_FLAG_VEH_RUNNING;
DrawSpriteIgnorePadding(image, PAL_NONE, tr.WithWidth(icon_width, rtl), false, SA_CENTER);
tr = tr.Indent(icon_width + WidgetDimensions::scaled.imgbtn.Horizontal(), rtl);
DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, FONT_HEIGHT_NORMAL), str, text_colour, SA_HOR_CENTER);
DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), str, text_colour, SA_HOR_CENTER);
}
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override

@ -434,7 +434,7 @@ static void SetTextInputRect()
winrect.x = win.x + caret.x;
winrect.y = win.y + caret.y;
winrect.w = 1;
winrect.h = FONT_HEIGHT_NORMAL;
winrect.h = GetCharacterHeight(FS_NORMAL);
#if defined(WITH_FCITX)
if (_fcitx_mode) {

@ -1793,7 +1793,7 @@ void ViewportAddString(ViewportDrawerDynamic *vdd, const DrawPixelInfo *dpi, Zoo
int right = left + dpi->width;
int bottom = top + dpi->height;
int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.bottom, dpi->zoom);
int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom, dpi->zoom);
int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, dpi->zoom);
if (bottom < sign->top ||
@ -1819,7 +1819,7 @@ void ViewportAddString(ViewportDrawerDynamic *vdd, const DrawPixelInfo *dpi, Zoo
static Rect ExpandRectWithViewportSignMargins(Rect r, ZoomLevel zoom)
{
/* Pessimistically always use normal font, but also assume small font is never larger in either dimension */
const int fh = FONT_HEIGHT_NORMAL;
const int fh = GetCharacterHeight(FS_NORMAL);
const int max_tw = _viewport_sign_maxwidth / 2 + 1;
const int expand_y = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + fh + WidgetDimensions::scaled.fullbevel.bottom, zoom);
const int expand_x = ScaleByZoom(WidgetDimensions::scaled.fullbevel.left + max_tw + WidgetDimensions::scaled.fullbevel.right, zoom);
@ -1977,7 +1977,7 @@ void ViewportSign::MarkDirty(ZoomLevel maxzoom) const
zoomlevels[zoom].left = this->center - ScaleByZoom(width / 2 + 1, zoom);
zoomlevels[zoom].top = this->top - ScaleByZoom(1, zoom);
zoomlevels[zoom].right = this->center + ScaleByZoom(width / 2 + 1, zoom);
zoomlevels[zoom].bottom = this->top + ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.bottom + 1, zoom);
zoomlevels[zoom].bottom = this->top + ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom + 1, zoom);
}
for (Viewport *vp : _viewport_window_cache) {
@ -2266,7 +2266,7 @@ static void ViewportDrawStrings(ViewportDrawerDynamic *vdd, ZoomLevel zoom, cons
int w = GB(ss.width, 0, 15);
int x = UnScaleByZoom(ss.x, zoom);
int y = UnScaleByZoom(ss.y, zoom);
int h = WidgetDimensions::scaled.fullbevel.Vertical() + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL);
int h = WidgetDimensions::scaled.fullbevel.Vertical() + (small ? GetCharacterHeight(FS_SMALL) : GetCharacterHeight(FS_NORMAL));
SetDParam(0, ss.params[0]);
SetDParam(1, ss.params[1]);
@ -4654,7 +4654,7 @@ static bool CheckClickOnViewportSign(const Viewport *vp, int x, int y, const Vie
{
bool small = (vp->zoom >= ZOOM_LVL_OUT_16X);
int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, vp->zoom);
int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom, vp->zoom);
int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + (small ? GetCharacterHeight(FS_SMALL) : GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.fullbevel.bottom, vp->zoom);
return y >= sign->top && y < sign->top + sign_height &&
x >= sign->center - sign_half_width && x < sign->center + sign_half_width;

@ -693,7 +693,7 @@ static inline void DrawFrame(const Rect &r, Colours colour, TextColour text_colo
/* If the frame has text, adjust the top bar to fit half-way through */
Rect inner = r.Shrink(ScaleGUITrad(1));
if (str != STR_NULL) inner.top = r.top + FONT_HEIGHT_NORMAL / 2;
if (str != STR_NULL) inner.top = r.top + GetCharacterHeight(FS_NORMAL) / 2;
Rect outer = inner.Expand(WidgetDimensions::scaled.bevel);
Rect inside = inner.Shrink(WidgetDimensions::scaled.bevel);
@ -851,14 +851,14 @@ static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicke
DrawImageButtons(r.WithWidth(dd_width, true), WWT_DROPDOWN, colour, clicked_dropdown, SPR_ARROW_DOWN, SA_CENTER);
if (str != STR_NULL) {
int o = clicked_button ? WidgetDimensions::scaled.pressed : 0;
DrawString(r.left + WidgetDimensions::scaled.dropdowntext.left + o, r.right - dd_width - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL) + o, str, TC_BLACK, align);
DrawString(r.left + WidgetDimensions::scaled.dropdowntext.left + o, r.right - dd_width - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)) + o, str, TC_BLACK, align);
}
} else {
DrawFrameRect(r.left + dd_width, r.top, r.right, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
DrawImageButtons(r.WithWidth(dd_width, false), WWT_DROPDOWN, colour, clicked_dropdown, SPR_ARROW_DOWN, SA_CENTER);
if (str != STR_NULL) {
int o = clicked_button ? WidgetDimensions::scaled.pressed : 0;
DrawString(r.left + dd_width + WidgetDimensions::scaled.dropdowntext.left + o, r.right - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL) + o, str, TC_BLACK, align);
DrawString(r.left + dd_width + WidgetDimensions::scaled.dropdowntext.left + o, r.right - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)) + o, str, TC_BLACK, align);
}
}
}
@ -1165,7 +1165,7 @@ void NWidgetResizeBase::SetResize(uint resize_x, uint resize_y)
bool NWidgetResizeBase::UpdateMultilineWidgetSize(const std::string &str, int max_lines)
{
int y = GetStringHeight(str, this->current_x);
if (y > max_lines * FONT_HEIGHT_NORMAL) {
if (y > max_lines * GetCharacterHeight(FS_NORMAL)) {
/* Text at the current width is too tall, so try to guess a better width. */
Dimension d = GetStringBoundingBox(str);
d.height *= max_lines;
@ -2346,7 +2346,7 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array)
if (this->type == WWT_FRAME) {
/* Account for the size of the frame's text if that exists */
this->child->padding = WidgetDimensions::scaled.frametext;
this->child->padding.top = std::max<uint8>(WidgetDimensions::scaled.frametext.top, this->widget_data != STR_NULL ? FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.top / 2 : 0);
this->child->padding.top = std::max<uint8>(WidgetDimensions::scaled.frametext.top, this->widget_data != STR_NULL ? GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.top / 2 : 0);
this->smallest_x += this->child->padding.Horizontal();
this->smallest_y += this->child->padding.Vertical();

@ -47,14 +47,10 @@ uint DropDownListStringItem::Width() const
return GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal();
}
void DropDownListStringItem::Draw(const Rect &r, bool sel, Colours bg_colour) const
void DropDownListStringItem::Draw(const Rect &r, bool sel, Colours) const
{
if (this->String().empty()) {
this->DropDownListItem::Draw(r, sel, bg_colour);
} else {
Rect ir = r.Shrink(WidgetDimensions::scaled.dropdowntext);
DrawString(ir.left, ir.right, r.top, this->String(), (sel ? TC_WHITE : TC_BLACK) | this->colour_flags);
}
Rect ir = r.Shrink(WidgetDimensions::scaled.dropdowntext);
DrawString(ir.left, ir.right, r.top, this->String(), (sel ? TC_WHITE : TC_BLACK) | this->colour_flags);
}
/**
@ -79,7 +75,7 @@ DropDownListIconItem::DropDownListIconItem(SpriteID sprite, PaletteID pal, Strin
uint DropDownListIconItem::Height() const
{
return std::max(this->dim.height, (uint)FONT_HEIGHT_NORMAL);
return std::max(this->dim.height, (uint)GetCharacterHeight(FS_NORMAL));
}
uint DropDownListIconItem::Width() const
@ -93,7 +89,7 @@ void DropDownListIconItem::Draw(const Rect &r, bool sel, Colours) const
Rect ir = r.Shrink(WidgetDimensions::scaled.dropdowntext);
Rect tr = ir.Indent(this->dim.width + WidgetDimensions::scaled.hsep_normal, rtl);
DrawSprite(this->sprite, this->pal, ir.WithWidth(this->dim.width, rtl).left, CenterBounds(r.top, r.bottom, this->sprite_y));
DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), this->String(), (sel ? TC_WHITE : TC_BLACK) | this->colour_flags);
DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), this->String(), (sel ? TC_WHITE : TC_BLACK) | this->colour_flags);
}
void DropDownListIconItem::SetDimension(Dimension d)

@ -35,7 +35,7 @@ public:
virtual ~DropDownListItem() = default;
virtual bool Selectable() const { return false; }
virtual uint Height() const { return FONT_HEIGHT_NORMAL; }
virtual uint Height() const { return GetCharacterHeight(FS_NORMAL); }
virtual uint Width() const { return 0; }
virtual void Draw(const Rect &r, bool sel, Colours bg_colour) const;
};
@ -51,7 +51,7 @@ public:
DropDownListStringItem(StringID string, int result, bool masked);
DropDownListStringItem(const std::string &string, int result, bool masked);
bool Selectable() const override { return !this->String().empty(); }
bool Selectable() const override { return true; }
uint Width() const override;
void Draw(const Rect &r, bool sel, Colours bg_colour) const override;
const std::string &String() const { return this->string; }

@ -29,7 +29,7 @@ static const int SLIDER_WIDTH = 3;
void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map<int, StringID> &labels)
{
/* Allow space for labels. We assume they are in the small font. */
if (!labels.empty()) r.bottom -= FONT_HEIGHT_SMALL + WidgetDimensions::scaled.hsep_normal;
if (!labels.empty()) r.bottom -= GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.hsep_normal;
max_value -= min_value;

@ -1730,7 +1730,7 @@ static Point GetAutoPlacePosition(int width, int height)
int left = rtl ? _screen.width - width : 0, top = toolbar_y;
const Dimension &closebox_dimension = NWidgetLeaf::GetCloseBoxDimension();
int offset_x = rtl ? -(int)closebox_dimension.width : (int)closebox_dimension.width;
int offset_y = std::max<int>(closebox_dimension.height, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.captiontext.Vertical());
int offset_y = std::max<int>(closebox_dimension.height, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.captiontext.Vertical());
restart:
for (const Window *w : Window::IterateFromBack()) {
@ -1797,7 +1797,7 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int
* - X position: closebox on left/right, resizebox on right/left (depending on ltr/rtl)
*/
const Dimension &closebox_dimension = NWidgetLeaf::GetCloseBoxDimension();
int indent_y = std::max<int>(closebox_dimension.height, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.captiontext.Vertical());
int indent_y = std::max<int>(closebox_dimension.height, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.captiontext.Vertical());
if (w->top + 3 * indent_y < _screen.height) {
pt.y = w->top + indent_y;
int indent_close = closebox_dimension.width;

@ -146,7 +146,7 @@ struct ZoningWindow : public Window {
}
}
size->width += padding.width;
size->height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.dropdowntext.Vertical();
size->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.dropdowntext.Vertical();
}
};

Loading…
Cancel
Save