Index: src/lang/english.txt =================================================================== --- src/lang/english.txt (revision 11044) +++ src/lang/english.txt (working copy) @@ -3374,3 +3374,9 @@ STR_PROSPECT_NEW_INDUSTRY :{BLACK}Prospect STR_BUILD_NEW_INDUSTRY :{BLACK}Build STR_INDUSTRY_SELECTION_HINT :{BLACK}Choose the appropriate industry from this list + +#### Vehicle speeds tab +STR_WAGON_SPEEDS :{BLACK}Speeds +STR_WAGON_SPEEDS_TOOLTIP :{BLACK}Show engine and wagons speeds +STR_WAGON_SPEEDS_VELOCITY :{LTBLUE}{VELOCITY} +STR_WAGON_SPEEDS_VELOCITY_NO_LIMIT :{LTBLUE}No limit \ No newline at end of file Index: src/train_gui.cpp =================================================================== --- src/train_gui.cpp (revision 11044) +++ src/train_gui.cpp (working copy) @@ -152,7 +152,38 @@ } } +/** + * Vehicle speeds detail. + * It displays the maximum speed of the vehicle according the GRF settings and patch options + * @param *v Vehicle to display + * @param x Coordinate (horizontal) of the string to display + * @param y Coordinate (vertical) of the string to display + * @author Magicbuzz + */ +static void TrainDetailsSpeedsTab(const Vehicle *v, int x, int y) +{ + /** Vehicle max speed is found from the general vehicle information, not the vehicle itself */ + const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); + /** + * Wagons can have max speed only when the wagon_speed_limits is set and not using wagon override to reflect the + * value the vehicle actually uses. + * @see train_cmd.cpp TrainConsistChanged(Vehicle* v) + */ + if ((rvi->railveh_type != RAILVEH_WAGON || _patches.wagon_speed_limits) && !UsesWagonOverride(v)) { + uint16 speed = GetVehicleProperty(v, 0x09, rvi->max_speed) * 10 / 16; ///< GRF speeds are in MPH while OTTD uses KMPH + if (speed > 0) { + /** Max speed is set, so we display it */ + SetDParam(0, speed); + DrawStringRightAligned(x, y, STR_WAGON_SPEEDS_VELOCITY, 0); + } else { + /** Max speed is not set, so we display "no limit" */ + DrawStringRightAligned(x, y, STR_WAGON_SPEEDS_VELOCITY_NO_LIMIT, 0); + //DrawString(x, y, STR_WAGON_SPEEDS_VELOCITY_NO_LIMIT, 0); + } + } +} + static void DrawTrainDetailsWindow(Window *w) { byte det_tab = WP(w, traindetails_d).tab; @@ -167,7 +198,7 @@ num = 0; u = v = GetVehicle(w->window_number); - if (det_tab == 3) { // Total cargo tab + if (det_tab == 4) { // Total cargo tab for (CargoID i = 0; i < lengthof(act_cargo); i++) { act_cargo[i] = 0; max_cargo[i] = 0; @@ -235,8 +266,8 @@ y = 57; sel = w->vscroll.pos; - /* draw the first 3 details tabs */ - if (det_tab != 3) { + /* draw the first 4 details tabs */ + if (det_tab != 4) { x = 1; for (;;) { if (--sel < 0 && sel >= -w->vscroll.cap) { @@ -263,7 +294,8 @@ TrainDetailsInfoTab(v, px, py); } break; - case 2: TrainDetailsCapacityTab(v, px, py); break; + case 2: TrainDetailsSpeedsTab(v, 100, py); break; + case 3: TrainDetailsCapacityTab(v, px, py); break; } y += 14; @@ -327,12 +359,14 @@ /* details buttons*/ case 9: // Cargo case 10: // Information - case 11: // Capacities - case 12: // Total cargo + case 11: // Speeds + case 12: // Capacities + case 13: // Total cargo EnableWindowWidget(w, 9); EnableWindowWidget(w, 10); EnableWindowWidget(w, 11); EnableWindowWidget(w, 12); + EnableWindowWidget(w, 13); EnableWindowWidget(w, e->we.click.widget); WP(w,traindetails_d).tab = e->we.click.widget - 9; SetWindowDirty(w); @@ -368,10 +402,11 @@ { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 10, 140, 145, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 10, 146, 151, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, { WWT_PANEL, RESIZE_RTB, 14, 11, 369, 140, 151, 0x0, STR_NULL}, -{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 89, 152, 163, STR_013C_CARGO, STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED}, -{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 90, 178, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES}, -{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 179, 268, 152, 163, STR_013E_CAPACITIES, STR_8851_SHOW_CAPACITIES_OF_EACH}, -{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 269, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO}, +{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 71, 152, 163, STR_013C_CARGO, STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED}, +{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 72, 142, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES}, +{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 143, 213, 152, 163, STR_WAGON_SPEEDS, STR_WAGON_SPEEDS_TOOLTIP}, +{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 214, 285, 152, 163, STR_013E_CAPACITIES, STR_8851_SHOW_CAPACITIES_OF_EACH}, +{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 286, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO}, { WWT_RESIZEBOX, RESIZE_LRTB, 14, 358, 369, 152, 163, 0x0, STR_RESIZE_BUTTON}, { WIDGETS_END}, };