MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateWidgetSize

Method UpdateWidgetSize

src/engine_gui.cpp:82–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 12

NOT_REACHEDFunction · 0.85
GetTrainSpriteSizeFunction · 0.85
GetRoadVehSpriteSizeFunction · 0.85
GetShipSpriteSizeFunction · 0.85
GetAircraftSpriteSizeFunction · 0.85
ScaleSpriteTradFunction · 0.85
absFunction · 0.85
GetStringHeightFunction · 0.85
GetEngineCategoryNameFunction · 0.85
GetCharacterHeightFunction · 0.85
GetEngineInfoStringFunction · 0.85
GetStringFunction · 0.70

Tested by

no test coverage detected