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

Method DrawCargoIcon

src/subsidy_gui.cpp:147–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145 }
146
147 void DrawCargoIcon(const Rect &r, int y_offset, CargoType cargo_type) const
148 {
149 bool rtl = _current_text_dir == TD_RTL;
150 SpriteID icon = CargoSpec::Get(cargo_type)->GetCargoIcon();
151 Dimension d = GetSpriteSize(icon);
152 Rect ir = r.WithWidth(this->cargo_icon_size.width, rtl).WithHeight(GetCharacterHeight(FS_NORMAL));
153 DrawSprite(icon, PAL_NONE, CentreBounds(ir.left, ir.right, d.width), CentreBounds(ir.top, ir.bottom, this->cargo_icon_size.height) + y_offset);
154 }
155
156 void DrawWidget(const Rect &r, WidgetID widget) const override
157 {

Callers

nothing calls this directly

Calls 7

GetSpriteSizeFunction · 0.85
GetCharacterHeightFunction · 0.85
DrawSpriteFunction · 0.85
CentreBoundsFunction · 0.85
GetCargoIconMethod · 0.80
WithHeightMethod · 0.80
WithWidthMethod · 0.80

Tested by

no test coverage detected