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

Method GetPageElementHeight

src/story_gui.cpp:319–342  ·  view source on GitHub ↗

* Get the height in pixels used by a page element. * @param pe The story page element. * @param max_width Available width to display content. * @return the height in pixels. */

Source from the content-addressed store, hash-verified

317 * @return the height in pixels.
318 */
319 uint GetPageElementHeight(const StoryPageElement &pe, int max_width) const
320 {
321 switch (pe.type) {
322 case SPET_TEXT:
323 return GetStringHeight(pe.text.GetDecodedString(), max_width);
324
325 case SPET_GOAL:
326 case SPET_LOCATION: {
327 Dimension sprite_dim = GetSpriteSize(GetPageElementSprite(pe));
328 return sprite_dim.height;
329 }
330
331 case SPET_BUTTON_PUSH:
332 case SPET_BUTTON_TILE:
333 case SPET_BUTTON_VEHICLE: {
334 Dimension dim = GetStringBoundingBox(pe.text.GetDecodedString(), FS_NORMAL);
335 return dim.height + WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.frametext.Vertical();
336 }
337
338 default:
339 NOT_REACHED();
340 }
341 return 0;
342 }
343
344 /**
345 * Get the float style of a page element.

Callers

nothing calls this directly

Calls 6

GetStringHeightFunction · 0.85
GetSpriteSizeFunction · 0.85
GetStringBoundingBoxFunction · 0.85
NOT_REACHEDFunction · 0.85
GetDecodedStringMethod · 0.80
VerticalMethod · 0.80

Tested by

no test coverage detected