forked from mirror/OpenTTD
Codechange: Remove FONT_HEIGHT_... macros. (#11481)
These make it look like we're dealing with a constant, but actually each is a call to `GetCharacterHeight(...)`.
This commit is contained in:
@@ -51,7 +51,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);
|
||||
}
|
||||
|
||||
static const NWidgetPart _nested_build_vehicle_widgets[] = {
|
||||
@@ -582,7 +582,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;
|
||||
@@ -602,14 +602,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) {
|
||||
@@ -617,7 +617,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,7 +625,7 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine
|
||||
if (rvi->running_cost_class != INVALID_PRICE) {
|
||||
SetDParam(0, e->GetRunningCost());
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
y += GetCharacterHeight(FS_NORMAL);
|
||||
}
|
||||
|
||||
return y;
|
||||
@@ -647,26 +647,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->GetRunningCost());
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
y += GetCharacterHeight(FS_NORMAL);
|
||||
}
|
||||
|
||||
/* Powered wagons power - Powered wagons extra weight */
|
||||
@@ -674,7 +674,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;
|
||||
@@ -695,25 +695,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_t 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) {
|
||||
@@ -726,13 +726,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->GetRunningCost());
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
y += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
return y;
|
||||
}
|
||||
@@ -758,7 +758,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);
|
||||
@@ -768,15 +768,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);
|
||||
}
|
||||
|
||||
/* Cargo type + capacity */
|
||||
@@ -784,12 +784,12 @@ 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->GetRunningCost());
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
y += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
return y;
|
||||
}
|
||||
@@ -818,7 +818,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) {
|
||||
@@ -835,24 +835,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->GetRunningCost());
|
||||
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_t 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;
|
||||
@@ -958,7 +958,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;
|
||||
}
|
||||
@@ -970,12 +970,12 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number,
|
||||
SetDParam(0, ymd.year);
|
||||
SetDParam(1, TimerGameCalendar::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);
|
||||
}
|
||||
|
||||
if (refittable) y = ShowRefitOptionsList(left, right, y, engine_number);
|
||||
@@ -988,7 +988,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;
|
||||
@@ -1044,8 +1044,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;
|
||||
@@ -1085,7 +1085,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);
|
||||
@@ -1751,7 +1751,7 @@ struct BuildVehicleWindow : Window {
|
||||
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: {
|
||||
@@ -1822,12 +1822,12 @@ struct BuildVehicleWindow : Window {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user