Add routing restriction action to make exempt from speed adaptation

This commit is contained in:
Jonathan G Rennison
2022-03-06 21:28:38 +00:00
parent 60a33feac8
commit 92142e5684
11 changed files with 131 additions and 6 deletions

View File

@@ -2731,6 +2731,7 @@ struct VehicleDetailsWindow : Window {
bool vehicle_weight_ratio_line_shown;
bool vehicle_slots_line_shown;
bool vehicle_speed_restriction_line_shown;
bool vehicle_speed_adaptation_exempt_line_shown;
/** Initialize a newly created vehicle details window */
VehicleDetailsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
@@ -2830,6 +2831,12 @@ struct VehicleDetailsWindow : Window {
return Train::From(v)->speed_restriction != 0;
}
bool ShouldShowSpeedAdaptationExemptLine(const Vehicle *v) const
{
if (v->type != VEH_TRAIN) return false;
return HasBit(Train::From(v)->flags, VRF_SPEED_ADAPTATION_EXEMPT);
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
@@ -2840,11 +2847,13 @@ struct VehicleDetailsWindow : Window {
this->vehicle_weight_ratio_line_shown = ShouldShowWeightRatioLine(v);
this->vehicle_slots_line_shown = ShouldShowSlotsLine(v);
this->vehicle_speed_restriction_line_shown = ShouldShowSpeedRestrictionLine(v);
this->vehicle_speed_adaptation_exempt_line_shown = ShouldShowSpeedAdaptationExemptLine(v);
int lines = 4;
if (this->vehicle_group_line_shown) lines++;
if (this->vehicle_weight_ratio_line_shown) lines++;
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 = WD_FRAMERECT_TOP + lines * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
for (uint i = 0; i < 5; i++) SetDParamMaxValue(i, INT16_MAX);
@@ -3105,10 +3114,17 @@ struct VehicleDetailsWindow : Window {
y += FONT_HEIGHT_NORMAL;
}
bool should_show_speed_adaptation_exempt = this->ShouldShowSpeedAdaptationExemptLine(v);
if (should_show_speed_adaptation_exempt) {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_SPEED_ADAPTATION_EXEMPT);
y += FONT_HEIGHT_NORMAL;
}
if (this->vehicle_weight_ratio_line_shown != should_show_weight_ratio ||
this->vehicle_weight_ratio_line_shown != should_show_weight_ratio ||
this->vehicle_slots_line_shown != should_show_slots ||
this->vehicle_speed_restriction_line_shown != should_show_speed_restriction) {
this->vehicle_speed_restriction_line_shown != should_show_speed_restriction ||
this->vehicle_speed_adaptation_exempt_line_shown != should_show_speed_adaptation_exempt) {
const_cast<VehicleDetailsWindow *>(this)->ReInit();
}
break;