| 80 | } |
| 81 | |
| 82 | void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override |
| 83 | { |
| 84 | if (widget != WID_EP_QUESTION) return; |
| 85 | |
| 86 | /* Get size of engine sprite, on loan from depot_gui.cpp */ |
| 87 | EngineID engine = static_cast<EngineID>(this->window_number); |
| 88 | EngineImageType image_type = EIT_PREVIEW; |
| 89 | uint x, y; |
| 90 | int x_offs, y_offs; |
| 91 | |
| 92 | const Engine *e = Engine::Get(engine); |
| 93 | switch (e->type) { |
| 94 | default: NOT_REACHED(); |
| 95 | case VEH_TRAIN: GetTrainSpriteSize( engine, x, y, x_offs, y_offs, image_type); break; |
| 96 | case VEH_ROAD: GetRoadVehSpriteSize( engine, x, y, x_offs, y_offs, image_type); break; |
| 97 | case VEH_SHIP: GetShipSpriteSize( engine, x, y, x_offs, y_offs, image_type); break; |
| 98 | case VEH_AIRCRAFT: GetAircraftSpriteSize(engine, x, y, x_offs, y_offs, image_type); break; |
| 99 | } |
| 100 | this->vehicle_space = std::max<int>(ScaleSpriteTrad(40), y - y_offs); |
| 101 | |
| 102 | size.width = std::max(size.width, x + std::abs(x_offs)); |
| 103 | size.height = GetStringHeight(GetString(STR_ENGINE_PREVIEW_MESSAGE, GetEngineCategoryName(engine)), size.width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space; |
| 104 | size.height += GetStringHeight(GetEngineInfoString(engine), size.width); |
| 105 | } |
| 106 | |
| 107 | void DrawWidget(const Rect &r, WidgetID widget) const override |
| 108 | { |
nothing calls this directly
no test coverage detected