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

Function onCompanyDropdown

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

0x004C243F

Source from the content-addressed store, hash-verified

824
825 // 0x004C243F
826 static void onCompanyDropdown(Ui::Window& self, int16_t itemIndex)
827 {
828 if (itemIndex == -1)
829 {
830 return;
831 }
832
833 CompanyId companyId = Dropdown::getCompanyIdFromSelection(itemIndex);
834
835 // Try to find an open vehicle list for this company.
836 auto companyWindow = WindowManager::bringToFront(WindowType::vehicleList, enumValue(companyId));
837 if (companyWindow != nullptr)
838 {
839 return;
840 }
841
842 // If not, we'll turn this window into a window for the company selected.
843 auto company = CompanyManager::get(companyId);
844 if (company->name == StringIds::empty)
845 {
846 return;
847 }
848
849 self.number = enumValue(companyId);
850 self.owner = companyId;
851
852 disableUnavailableVehicleTypes(self);
853
854 self.rowCount = 0;
855 populateVehicleList(self);
856
857 self.rowHover = -1;
858
859 self.callOnResize();
860 self.callPrepareDraw();
861 self.initScrollWidgets();
862 self.invalidate();
863 }
864
865 static void onDropdown(Ui::Window& self, WidgetIndex_t widgetIndex, [[maybe_unused]] const WidgetId id, int16_t itemIndex)
866 {

Callers 1

onDropdownFunction · 0.85

Calls 10

bringToFrontFunction · 0.85
enumValueFunction · 0.85
callOnResizeMethod · 0.80
callPrepareDrawMethod · 0.80
initScrollWidgetsMethod · 0.80
populateVehicleListFunction · 0.70
getFunction · 0.50
invalidateMethod · 0.45

Tested by

no test coverage detected