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

Function prepareDraw

src/OpenLoco/src/Ui/Windows/ObjectSelectionWindow.cpp:634–696  ·  view source on GitHub ↗

0x004733AC

Source from the content-addressed store, hash-verified

632
633 // 0x004733AC
634 static void prepareDraw(Ui::Window& self)
635 {
636 self.activatedWidgets = (1 << widx::objectImage);
637
638 self.widgets[widx::closeButton].hidden = false;
639 if (SceneManager::isEditorMode())
640 {
641 self.widgets[widx::closeButton].hidden = true;
642 }
643
644 self.activatedWidgets |= 1ULL << (widx::primaryTab1 + self.currentTab);
645 const auto& currentTab = kMainTabInfo[self.currentTab];
646 const auto& subTabs = currentTab.subTabs;
647 const bool showSecondaryTabs = !subTabs.empty() && FilterLevel(self.filterLevel) != FilterLevel::beginner;
648
649 static constexpr std::array<StringId, 3> kFilterLevelStringIds = {
650 StringIds::objSelectionFilterBeginner,
651 StringIds::objSelectionFilterAdvanced,
652 StringIds::objSelectionFilterExpert,
653 };
654
655 {
656 auto& widget = self.widgets[widx::filterLabel];
657 FormatArguments args{ widget.textArgs };
658 args.push(kFilterLevelStringIds[self.filterLevel]);
659 }
660
661 // Update page title
662 auto args = FormatArguments(self.widgets[widx::caption].textArgs);
663 if (showSecondaryTabs)
664 {
665 args.push(subTabs[self.currentSecondaryTab].name);
666 }
667 else
668 {
669 args.push(kMainTabInfo[self.currentTab].name);
670 }
671
672 // Toggle secondary tabs
673 for (auto i = 0U; i < kMaxNumSecondaryTabs; i++)
674 {
675 const auto widgetIndex = i + widx::secondaryTab1;
676
677 const bool subTabIsVisible = showSecondaryTabs && i < subTabs.size() && shouldShowSubTab(subTabs, i, FilterLevel(self.filterLevel));
678 if (subTabIsVisible)
679 {
680 self.disabledWidgets &= ~(1ULL << widgetIndex);
681 }
682 else
683 {
684 self.disabledWidgets |= (1ULL << widgetIndex);
685 }
686
687 if (self.currentSecondaryTab == i)
688 {
689 self.activatedWidgets |= 1ULL << widgetIndex;
690 }
691 else

Callers

nothing calls this directly

Calls 7

isEditorModeFunction · 0.85
FilterLevelEnum · 0.85
shouldShowSubTabFunction · 0.85
FormatArgumentsClass · 0.50
emptyMethod · 0.45
pushMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected