MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / onRender

Method onRender

game/ui/components/equipscreen.cpp:100–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void EquipmentPaperDoll::onRender()
101{
102 Control::onRender();
103
104 if (!object)
105 {
106 return;
107 }
108 // Draw all equipment after slot lines to ensure they're on top
109 const auto &slotList = this->object->getSlots();
110 if (object->drawLines())
111 {
112 for (auto &slot : slotList)
113 {
114 Vec2<int> p00 = (slot.bounds.p0 * slotSizePixels);
115 Vec2<int> p11 = (slot.bounds.p1 * slotSizePixels);
116 Vec2<int> p01 = {p00.x, p11.y};
117 Vec2<int> p10 = {p11.x, p00.y};
118
119 if (this->slotHighlightTypes.find(slot.type) != this->slotHighlightTypes.end())
120 {
121 if (this->highlightColour.a == 0)
122 {
123 continue;
124 }
125 fw().renderer->drawLine(p00, p01, highlightColour, 2);
126 fw().renderer->drawLine(p01, p11, highlightColour, 2);
127 fw().renderer->drawLine(p11, p10, highlightColour, 2);
128 fw().renderer->drawLine(p10, p00, highlightColour, 2);
129 }
130 else
131 {
132 if (this->nonHighlightColour.a == 0)
133 {
134 continue;
135 }
136 fw().renderer->drawLine(p00, p01, nonHighlightColour, 2);
137 fw().renderer->drawLine(p01, p11, nonHighlightColour, 2);
138 fw().renderer->drawLine(p11, p10, nonHighlightColour, 2);
139 fw().renderer->drawLine(p10, p00, nonHighlightColour, 2);
140 }
141 }
142 }
143 // Draw equipment
144 auto equipment = this->object->getEquipment();
145 for (auto &equipPair : equipment)
146 {
147 auto pos = equipPair.first;
148 auto equipment = equipPair.second;
149 auto *slot = getSlotAtPosition(pos, slotList);
150 if (!slot)
151 {
152 LogWarning("Equipment at %s not in slot", pos);
153 }
154 auto equipmentSize = equipment->getEquipmentSlotSize();
155 auto alignX = slot->align_x;
156 auto alignY = slot->align_y;
157 auto slotBounds = slot->bounds;

Callers

nothing calls this directly

Calls 10

getSlotAtPositionFunction · 0.85
endMethod · 0.80
getWidthMethod · 0.80
getHeightMethod · 0.80
drawLinesMethod · 0.45
drawLineMethod · 0.45
getEquipmentSlotSizeMethod · 0.45
getEquipmentImageMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected