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

Function draw

src/OpenLoco/src/Ui/Dropdown.cpp:261–358  ·  view source on GitHub ↗

0x004CD00E

Source from the content-addressed store, hash-verified

259
260 // 0x004CD00E
261 static void draw([[maybe_unused]] Window& self, Gfx::DrawingContext& drawingCtx)
262 {
263 self.draw(drawingCtx);
264 _windowDropdownOnpaintCellX = 0;
265 _windowDropdownOnpaintCellY = 0;
266
267 for (auto itemCount = 0; itemCount < _dropdownItemCount; itemCount++)
268 {
269 if (_dropdownItemFormats[itemCount] != StringIds::empty)
270 {
271 if (itemCount == _dropdownHighlightedIndex)
272 {
273 auto x = _windowDropdownOnpaintCellX * _dropdownItemWidth + self.x + 2;
274 auto y = _windowDropdownOnpaintCellY * _dropdownItemHeight + self.y + 2;
275 drawingCtx.drawRect(x, y, _dropdownItemWidth, _dropdownItemHeight, enumValue(ExtColour::unk2E), Gfx::RectFlags::transparent);
276 }
277
278 auto args = FormatArguments();
279
280 dropdownFormatArgsToFormatArgs(itemCount, args);
281
282 auto dropdownItemFormat = _dropdownItemFormats[itemCount];
283
284 if (dropdownItemFormat != (StringId)-2)
285 {
286 if (dropdownItemFormat != StringIds::null)
287 {
288 if (itemCount < 32)
289 {
290 if (_dropdownSelection & (1 << itemCount))
291 {
292 dropdownItemFormat++;
293 }
294 }
295
296 auto colour = self.getColour(WindowColour::primary).opaque();
297
298 if (itemCount == _dropdownHighlightedIndex)
299 {
300 colour = Colour::white;
301 }
302
303 if ((_dropdownDisabledItems & (1 << itemCount)))
304 {
305 if (itemCount < 32)
306 {
307 colour = self.getColour(WindowColour::primary).opaque().inset();
308 }
309 }
310
311 auto x = _windowDropdownOnpaintCellX * _dropdownItemWidth + self.x + 2;
312 auto y = _windowDropdownOnpaintCellY * _dropdownItemHeight + self.y + 1;
313 auto width = self.width - 5;
314 sub_494BF6(&self, drawingCtx, dropdownItemFormat, x, y, width, colour, args);
315 }
316 }
317
318 if (dropdownItemFormat == (StringId)-2 || dropdownItemFormat == StringIds::null)

Callers

nothing calls this directly

Calls 14

enumValueFunction · 0.85
sub_494BF6Function · 0.85
getShadeFunction · 0.85
getTranslucentFunction · 0.85
opaqueMethod · 0.80
getColourMethod · 0.80
insetMethod · 0.80
cMethod · 0.80
FormatArgumentsClass · 0.50
drawMethod · 0.45
drawRectMethod · 0.45

Tested by

no test coverage detected