MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / drawPreviewImage

Method drawPreviewImage

src/OpenLoco/src/Objects/TreeObject.cpp:13–52  ·  view source on GitHub ↗

0x004BE2A2

Source from the content-addressed store, hash-verified

11{
12 // 0x004BE2A2
13 void TreeObject::drawPreviewImage(Gfx::DrawingContext& drawingCtx, const int16_t x, const int16_t y) const
14 {
15 uint32_t image = getTreeGrowthDisplayOffset() * numRotations;
16 auto rotation = (numRotations - 1) & 2;
17 image += rotation;
18 image += sprites[seasonState];
19
20 auto colourOptions = colours;
21 if (colourOptions != 0)
22 {
23
24 auto bit = Numerics::bitScanReverse(colourOptions);
25
26 auto colour = (bit == -1) ? Colour::black : static_cast<Colour>(bit);
27
28 image = Gfx::recolour(image, colour);
29 }
30
31 Ui::Point treePos = Ui::Point{ x, y } + Ui::Point{ 0, 48 };
32
33 if (hasFlags(TreeObjectFlags::hasSnowVariation))
34 {
35 auto snowImage = getTreeGrowthDisplayOffset() * numRotations;
36 snowImage += rotation;
37 snowImage += snowSprites[seasonState];
38
39 if (colourOptions != 0)
40 {
41 auto bit = Numerics::bitScanReverse(colourOptions);
42
43 auto colour = (bit == -1) ? Colour::black : static_cast<Colour>(bit);
44
45 snowImage = Gfx::recolour(snowImage, colour);
46 }
47 treePos.x = x + 28;
48 drawingCtx.drawImage(treePos.x, treePos.y, snowImage);
49 treePos.x = 28;
50 }
51 drawingCtx.drawImage(treePos.x, treePos.y, image);
52 }
53
54 // 0x00500775
55 constexpr std::array<uint8_t, 11> treeGrowth = { {

Callers

nothing calls this directly

Calls 4

bitScanReverseFunction · 0.85
recolourFunction · 0.85
hasFlagsFunction · 0.50
drawImageMethod · 0.45

Tested by

no test coverage detected