diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 31bf75dee9..10b1684e11 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -765,7 +765,10 @@ CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, ui cost = RemoveEngineReplacementForCompany(c, old_engine_type, id_g, flags); } - if (flags & DC_EXEC) GroupStatistics::UpdateAutoreplace(_current_company); + if (flags & DC_EXEC) { + GroupStatistics::UpdateAutoreplace(_current_company); + SetWindowClassesDirty(GetWindowClassForVehicleType(Engine::Get(old_engine_type)->type)); + } if ((flags & DC_EXEC) && IsLocalCompany()) InvalidateAutoreplaceWindow(old_engine_type, id_g); return cost; diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 0a1b4686ca..c70a735f9e 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -493,8 +493,8 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = { NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_RV_RIGHT_SCROLLBAR), EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(228, 102), SetResize(1, 0), EndContainer(), - NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(228, 102), SetResize(1, 0), EndContainer(), + NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(), + NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON), @@ -513,7 +513,7 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = { }; static const WindowDesc _replace_rail_vehicle_desc( - WDP_AUTO, 456, 140, + WDP_AUTO, 500, 140, WC_REPLACE_VEHICLE, WC_NONE, WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION, _nested_replace_rail_vehicle_widgets, lengthof(_nested_replace_rail_vehicle_widgets) diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 93d229184d..b937af5666 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -885,8 +885,16 @@ void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList * int sprite_x = (rtl ? r - sprite_width / 2 : l + sprite_width / 2) - 1; int sprite_y_offset = sprite_y_offsets[type] + step_size / 2; - int text_left = l + (rtl ? WD_FRAMERECT_LEFT : sprite_width); - int text_right = r - (rtl ? sprite_width : WD_FRAMERECT_RIGHT); + int count_width = 0; + if (show_count) { + SetDParam(0, 999); + count_width = GetStringBoundingBox(STR_TINY_BLACK_COMA).width; + } + + int text_left = l + (rtl ? WD_FRAMERECT_LEFT + count_width : sprite_width); + int text_right = r - (rtl ? sprite_width : WD_FRAMERECT_RIGHT + count_width); + int count_left = l; + int count_right = rtl ? text_left : r - WD_FRAMERECT_RIGHT; int normal_text_y_offset = (step_size - FONT_HEIGHT_NORMAL) / 2; int small_text_y_offset = step_size - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM - 1; @@ -901,7 +909,7 @@ void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList * DrawVehicleEngine(l, r, sprite_x, y + sprite_y_offset, engine, (show_count && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_company), EIT_PURCHASE); if (show_count) { SetDParam(0, num_engines); - DrawString(text_left, text_right, y + small_text_y_offset, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT); + DrawString(count_left, count_right, y + small_text_y_offset, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE); } } } diff --git a/src/engine.cpp b/src/engine.cpp index b9479d82f2..63f391d223 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -927,6 +927,8 @@ void EnginesMonthlyLoop() } } } + + InvalidateWindowClassesData(WC_BUILD_VEHICLE); // rebuild the purchase list (esp. when sorted by reliability) } }