diff --git a/src/train_gui.cpp b/src/train_gui.cpp --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -221,17 +221,65 @@ static void TrainDetailsCargoTab(const C * @param right The right most coordinate to draw * @param y The y coordinate */ -static void TrainDetailsInfoTab(const Vehicle *v, int left, int right, int y) +static void TrainDetailsInfoTab(const Train *v, int left, int right, int y, byte line_number) { - if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) { + const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); + bool show_speed = !UsesWagonOverride(v) && (_settings_game.vehicle.wagon_speed_limits || rvi->railveh_type != RAILVEH_WAGON); + uint16 speed; + + if (rvi->railveh_type == RAILVEH_WAGON) { SetDParam(0, v->engine_type); SetDParam(1, v->value); + + if ( show_speed && (speed = GetVehicleProperty(v, PROP_TRAIN_SPEED, rvi->max_speed))) { + SetDParam(2, speed); // StringID++ + DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_WAGON_VALUE_AND_SPEED); + } else DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_WAGON_VALUE); } else { + switch ( line_number ) { + case 0: SetDParam(0, v->engine_type); SetDParam(1, v->build_year); SetDParam(2, v->value); + + if ( show_speed && (speed = GetVehicleProperty(v, PROP_TRAIN_SPEED, rvi->max_speed))) { + SetDParam(3, speed); // StringID++ + DrawString( left, right, y, STR_VEHICLE_DETAILS_TRAIN_ENGINE_BUILT_AND_VALUE_AND_SPEED, TC_FROMSTRING, SA_LEFT); + } else DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_ENGINE_BUILT_AND_VALUE); + + break; + + case 1: + SetDParam(0, v->reliability * 100 >> 16); + SetDParam(1, v->breakdowns_since_last_service); + DrawString(left, right, y, STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS, TC_FROMSTRING, SA_LEFT); + break; + + case 2: + if ( v->breakdown_ctr == 1 ) { + if ( _settings_game.vehicle.improved_breakdowns ) { + SetDParam( 0, STR_VEHICLE_STATUS_BROKEN_DOWN_VEL ); + SetDParam( 1, STR_BREAKDOWN_TYPE_CRITICAL + v->breakdown_type ); + if ( v->breakdown_type == BREAKDOWN_LOW_SPEED ) { + SetDParam( 2, std::min( v->First( )->GetCurrentMaxSpeed( ), v->breakdown_severity ) ); + } else if ( v->breakdown_type == BREAKDOWN_LOW_POWER ) { + SetDParam( 2, v->breakdown_severity * 100 / 256 ); + } + } else + SetDParam( 0, STR_VEHICLE_STATUS_BROKEN_DOWN ); + } else { + if ( HasBit( v->flags, VRF_NEED_REPAIR ) ) { + SetDParam( 0, STR_NEED_REPAIR ); + SetDParam( 1, v->vcache.cached_max_speed ); + } else + SetDParam( 0, STR_RUNNING ); + } + DrawString( left, right, y, STR_CURRENT_STATUS); + break; + default: NOT_REACHED(); + } } } @@ -342,6 +390,7 @@ int GetTrainDetailsWndVScroll(VehicleID uint length = GetLengthOfArticulatedVehicle(v); if (length > TRAIN_DETAILS_MAX_INDENT) num++; } + if (det_tab == 1) num += 2 * Train::Get(veh_id)->tcache.cached_num_engines; } return num; @@ -373,6 +422,7 @@ void DrawTrainDetails(const Train *v, in bool rtl = _current_text_dir == TD_RTL; Direction dir = rtl ? DIR_E : DIR_W; int x = rtl ? right : left; + byte line_number = 0; for (; v != nullptr && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) { GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary); @@ -383,7 +433,7 @@ void DrawTrainDetails(const Train *v, in do { Point offset; int width = u->GetDisplayImageWidth(&offset); - if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) { + if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap && line_number == 0) { int pitch = 0; const Engine *e = Engine::Get(v->engine_type); if (e->GetGRF() != nullptr) { @@ -406,7 +456,7 @@ void DrawTrainDetails(const Train *v, in } uint num_lines = std::max(1u, (unsigned)_cargo_summary.size()); - for (uint i = 0; i < num_lines; i++) { + for (uint i = 0; i < num_lines;) { int sprite_width = std::max(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3; int data_left = left + (rtl ? 0 : sprite_width); int data_right = right - (rtl ? sprite_width : 0); @@ -425,7 +475,7 @@ void DrawTrainDetails(const Train *v, in break; case TDW_TAB_INFO: - if (i == 0) TrainDetailsInfoTab(v, data_left, data_right, py); + if (i == 0) TrainDetailsInfoTab(v, data_left, data_right, py, line_number); break; case TDW_TAB_CAPACITY: @@ -440,6 +490,11 @@ void DrawTrainDetails(const Train *v, in default: NOT_REACHED(); } } + if (det_tab != 1 || line_number >= (Train::From(v)->IsWagon() ? 0 : 2)) { + line_number = 0; + i++; + } else + line_number++; vscroll_pos--; } }