diff -r ef3eff47c044 -r 9a09ba6c56cf src/build_vehicle_gui.cpp --- a/src/build_vehicle_gui.cpp Tue Jul 22 15:02:18 2008 +0000 +++ b/src/build_vehicle_gui.cpp Tue Jul 22 16:13:42 2008 +0000 @@ -736,7 +736,7 @@ * @param selected_id what engine to highlight as selected, if any * @param count_location Offset to print the engine count (used by autoreplace). 0 means it's off */ -void DrawEngineList(VehicleType type, int x, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, int count_location, GroupID selected_group) +void DrawEngineList(VehicleType type, int x, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, int count_location, GroupID selected_group) { byte step_size = GetVehicleListHeight(type); byte x_offset = 0; @@ -769,13 +769,15 @@ default: NOT_REACHED(); } + uint maxw = r - x - x_offset; + for (; min < max; min++, y += step_size) { const EngineID engine = (*eng_list)[min]; /* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_player here. */ const uint num_engines = GetGroupNumEngines(_local_player, selected_group, engine); SetDParam(0, engine); - DrawString(x + x_offset, y, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK); + DrawStringTruncated(x + x_offset, y, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK, maxw); DrawVehicleEngine(type, x, y + y_offset, engine, (count_location != 0 && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_player)); if (count_location != 0) { SetDParam(0, num_engines); @@ -1118,7 +1120,7 @@ this->DrawWidgets(); - DrawEngineList(this->vehicle_type, this->widget[BUILD_VEHICLE_WIDGET_LIST].left + 2, this->widget[BUILD_VEHICLE_WIDGET_LIST].top + 1, &this->eng_list, this->vscroll.pos, max, this->sel_engine, 0, DEFAULT_GROUP); + DrawEngineList(this->vehicle_type, this->widget[BUILD_VEHICLE_WIDGET_LIST].left + 2, this->widget[BUILD_VEHICLE_WIDGET_LIST].right, this->widget[BUILD_VEHICLE_WIDGET_LIST].top + 1, &this->eng_list, this->vscroll.pos, max, this->sel_engine, 0, DEFAULT_GROUP); if (this->sel_engine != INVALID_ENGINE) { const Widget *wi = &this->widget[BUILD_VEHICLE_WIDGET_PANEL];