From 15c3bc456f8bbdda3eabb158f5ec5edefd126dc7 Mon Sep 17 00:00:00 2001 From: Andy <1780327+andythenorth@users.noreply.github.com> Date: Sun, 16 Apr 2023 23:02:32 +0100 Subject: [PATCH] Change: extend callback 161 (engine name) with bit 0x22 for context 'Autoreplace - Vehicles in use' (#10666) --- src/build_vehicle_gui.cpp | 7 ++++++- src/engine_type.h | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index cc918c792a..99b0b655e7 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1038,7 +1038,12 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li StringID str = hidden ? STR_HIDDEN_ENGINE_NAME : STR_ENGINE_NAME; TextColour tc = (item.engine_id == selected_id) ? TC_WHITE : (TC_NO_SHADE | ((hidden | shaded) ? TC_GREY : TC_BLACK)); - SetDParam(0, PackEngineNameDParam(item.engine_id, EngineNameContext::PurchaseList, item.indent)); + if (show_count) { + /* relies on show_count to find 'Vehicle in use' panel of autoreplace window */ + SetDParam(0, PackEngineNameDParam(item.engine_id, EngineNameContext::AutoreplaceVehicleInUse, item.indent)); + } else { + SetDParam(0, PackEngineNameDParam(item.engine_id, EngineNameContext::PurchaseList, item.indent)); + } Rect itr = tr.Indent(indent, rtl); DrawString(itr.left, itr.right, y + normal_text_y_offset, str, tc); int sprite_x = ir.Indent(indent + circle_width + WidgetDimensions::scaled.hsep_normal, rtl).WithWidth(sprite_width, rtl).left + sprite_left; diff --git a/src/engine_type.h b/src/engine_type.h index 789ddbbca0..bbebe786b0 100644 --- a/src/engine_type.h +++ b/src/engine_type.h @@ -186,10 +186,11 @@ enum EngineFlags { * Contexts an engine name can be shown in. */ enum EngineNameContext : uint8 { - Generic = 0x00, ///< No specific context available. - VehicleDetails = 0x11, ///< Name is shown in the vehicle details GUI. - PurchaseList = 0x20, ///< Name is shown in the purchase list (including autoreplace window). - PreviewNews = 0x21, ///< Name is shown in exclusive preview or newspaper. + Generic = 0x00, ///< No specific context available. + VehicleDetails = 0x11, ///< Name is shown in the vehicle details GUI. + PurchaseList = 0x20, ///< Name is shown in the purchase list (including autoreplace window 'Available vehicles' panel). + PreviewNews = 0x21, ///< Name is shown in exclusive preview or newspaper. + AutoreplaceVehicleInUse = 0x22, ///< Name is show in the autoreplace window 'Vehicles in use' panel. }; /** Combine an engine ID and a name context to an engine name dparam. */