mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use parameterised GetString() for depot window. (#13691)
parent
2aa99a70ff
commit
600450f8a4
|
@ -327,10 +327,10 @@ struct DepotWindow : Window {
|
||||||
DrawTrainImage(u, image.Indent(x_space, rtl), this->sel, EIT_IN_DEPOT, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over);
|
DrawTrainImage(u, image.Indent(x_space, rtl), this->sel, EIT_IN_DEPOT, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over);
|
||||||
|
|
||||||
/* Length of consist in tiles with 1 fractional digit (rounded up) */
|
/* Length of consist in tiles with 1 fractional digit (rounded up) */
|
||||||
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);
|
Rect count = text.WithWidth(this->count_width - WidgetDimensions::scaled.hsep_normal, !rtl);
|
||||||
DrawString(count.left, count.right, count.bottom - GetCharacterHeight(FS_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,
|
||||||
|
GetString(STR_JUST_DECIMAL, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE), 1),
|
||||||
|
TC_BLACK, SA_RIGHT, false, FS_SMALL); // Draw the counter
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,8 +358,7 @@ struct DepotWindow : Window {
|
||||||
Rect flag = r.WithWidth(this->flag_size.width, rtl).WithHeight(this->flag_size.height).Translate(0, diff_y);
|
Rect flag = r.WithWidth(this->flag_size.width, rtl).WithHeight(this->flag_size.height).Translate(0, diff_y);
|
||||||
DrawSpriteIgnorePadding((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, flag, SA_CENTER);
|
DrawSpriteIgnorePadding((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, flag, SA_CENTER);
|
||||||
|
|
||||||
SetDParam(0, v->unitnumber);
|
DrawString(text, GetString(STR_JUST_COMMA, v->unitnumber), (v->max_age - CalendarTime::DAYS_IN_LEAP_YEAR) >= v->age ? TC_BLACK : TC_RED);
|
||||||
DrawString(text, STR_JUST_COMMA, (v->max_age - CalendarTime::DAYS_IN_LEAP_YEAR) >= v->age ? TC_BLACK : TC_RED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,15 +656,12 @@ struct DepotWindow : Window {
|
||||||
uint min_height = 0;
|
uint min_height = 0;
|
||||||
|
|
||||||
if (this->type == VEH_TRAIN) {
|
if (this->type == VEH_TRAIN) {
|
||||||
SetDParamMaxValue(0, 1000, 0, FS_SMALL);
|
this->count_width = GetStringBoundingBox(GetString(STR_JUST_DECIMAL, GetParamMaxValue(1000, 0, FS_SMALL), 1), FS_SMALL).width + WidgetDimensions::scaled.hsep_normal;
|
||||||
SetDParam(1, 1);
|
|
||||||
this->count_width = GetStringBoundingBox(STR_JUST_DECIMAL, FS_SMALL).width + WidgetDimensions::scaled.hsep_normal;
|
|
||||||
} else {
|
} else {
|
||||||
this->count_width = 0;
|
this->count_width = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDParamMaxDigits(0, this->unitnumber_digits);
|
Dimension unumber = GetStringBoundingBox(GetString(STR_JUST_COMMA, GetParamMaxDigits(this->unitnumber_digits)));
|
||||||
Dimension unumber = GetStringBoundingBox(STR_JUST_COMMA);
|
|
||||||
|
|
||||||
if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
|
if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
|
||||||
min_height = std::max<uint>(unumber.height, this->flag_size.height);
|
min_height = std::max<uint>(unumber.height, this->flag_size.height);
|
||||||
|
@ -882,11 +878,8 @@ struct DepotWindow : Window {
|
||||||
CargoType cargo_type = cs->Index();
|
CargoType cargo_type = cs->Index();
|
||||||
if (capacity[cargo_type] == 0) continue;
|
if (capacity[cargo_type] == 0) continue;
|
||||||
|
|
||||||
SetDParam(0, cargo_type); // {CARGO} #1
|
auto params = MakeParameters(cargo_type, loaded[cargo_type], cargo_type, capacity[cargo_type]);
|
||||||
SetDParam(1, loaded[cargo_type]); // {CARGO} #2
|
AppendStringWithArgsInPlace(details, STR_DEPOT_VEHICLE_TOOLTIP_CARGO, params);
|
||||||
SetDParam(2, cargo_type); // {SHORTCARGO} #1
|
|
||||||
SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2
|
|
||||||
AppendStringInPlace(details, STR_DEPOT_VEHICLE_TOOLTIP_CARGO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show tooltip window */
|
/* Show tooltip window */
|
||||||
|
|
Loading…
Reference in New Issue