MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / Build

Method Build

extensions/olcPGEX_PopUpMenu.h:315–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

313 }
314
315 void Menu::Build()
316 {
317 // Recursively build all children, so they can determine their size, use
318 // that size to indicate cell sizes if this object contains more than
319 // one item
320 for (auto& m : items)
321 {
322 if (m.HasChildren())
323 {
324 m.Build();
325 }
326
327 // Longest child name determines cell width
328 vCellSize.x = std::max(m.GetSize().x, vCellSize.x);
329 vCellSize.y = std::max(m.GetSize().y, vCellSize.y);
330 }
331
332 // Adjust size of this object (in patches) if it were rendered as a panel
333 vSizeInPatches.x = vCellTable.x * vCellSize.x + (vCellTable.x - 1) * vCellPadding.x + 2;
334 vSizeInPatches.y = vCellTable.y * vCellSize.y + (vCellTable.y - 1) * vCellPadding.y + 2;
335
336 // Calculate how many rows this item has to hold
337 nTotalRows = (items.size() / vCellTable.x) + (((items.size() % vCellTable.x) > 0) ? 1 : 0);
338 }
339
340 void Menu::DrawSelf(olc::PixelGameEngine& pge, olc::Sprite* sprGFX, olc::vi2d vScreenOffset)
341 {

Callers

nothing calls this directly

Calls 3

HasChildrenMethod · 0.80
GetSizeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected