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

Function switchTab

src/OpenLoco/src/Ui/Windows/VehicleList.cpp:691–731  ·  view source on GitHub ↗

0x004C24F7

Source from the content-addressed store, hash-verified

689
690 // 0x004C24F7
691 static void switchTab(Window& self, VehicleType type)
692 {
693 if (ToolManager::isToolActive(self.type, self.number))
694 {
695 ToolManager::toolCancel();
696 }
697
698 auto tabIndex = static_cast<uint8_t>(type);
699 self.currentTab = tabIndex;
700 self.rowHeight = row_heights[tabIndex];
701 self.frameNo = 0;
702
703 if (CompanyManager::getControllingId() == CompanyId(self.number) && getGameState().lastVehicleType != type)
704 {
705 getGameState().lastVehicleType = type;
706 WindowManager::invalidate(WindowType::topToolbar);
707 }
708
709 // The original game was setting viewports and (enabled/disabled) widgets here.
710 // As all tabs are the same, we've simplified this.
711
712 disableUnavailableVehicleTypes(self);
713 self.invalidate();
714
715 if (self.width < 220)
716 {
717 self.width = 220;
718 }
719
720 self.rowCount = 0;
721 populateVehicleList(self);
722
723 self.rowHover = -1;
724
725 self.callOnResize();
726 self.callOnPeriodicUpdate();
727 self.callPrepareDraw();
728 self.initScrollWidgets();
729 self.invalidate();
730 self.moveInsideScreenEdges();
731 }
732
733 // 0x004C2409
734 static void onMouseUp(Window& self, WidgetIndex_t widgetIndex, [[maybe_unused]] const WidgetId id)

Callers 1

onMouseUpFunction · 0.70

Calls 13

isToolActiveFunction · 0.85
getControllingIdFunction · 0.85
CompanyIdEnum · 0.85
callOnResizeMethod · 0.80
callOnPeriodicUpdateMethod · 0.80
callPrepareDrawMethod · 0.80
initScrollWidgetsMethod · 0.80
moveInsideScreenEdgesMethod · 0.80
toolCancelFunction · 0.70
populateVehicleListFunction · 0.70
invalidateFunction · 0.50

Tested by

no test coverage detected