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

Function onMouseUp

src/OpenLoco/src/Ui/Windows/BuildVehicle.cpp:775–871  ·  view source on GitHub ↗

0x4C3576

Source from the content-addressed store, hash-verified

773
774 // 0x4C3576
775 static void onMouseUp(Ui::Window& window, WidgetIndex_t widgetIndex, [[maybe_unused]] const WidgetId id)
776 {
777 switch (widgetIndex)
778 {
779 case widx::close_button:
780 WindowManager::close(&window);
781 break;
782
783 case widx::tab_build_new_trains:
784 case widx::tab_build_new_buses:
785 case widx::tab_build_new_trucks:
786 case widx::tab_build_new_trams:
787 case widx::tab_build_new_aircraft:
788 case widx::tab_build_new_ships:
789 {
790
791 if (Input::hasFlag(Input::Flags::toolActive))
792 {
793 ToolManager::toolCancel(window.type, window.number);
794 }
795
796 auto newTab = widgetIndex - widx::tab_build_new_trains;
797 window.currentTab = newTab;
798 window.rowHeight = kScrollRowHeight[newTab];
799 window.frameNo = 0;
800 window.currentSecondaryTab = 0;
801 if (newTab != enumValue(getGameState().lastBuildVehiclesOption))
802 {
803 getGameState().lastBuildVehiclesOption = static_cast<VehicleType>(newTab);
804 WindowManager::invalidate(WindowType::topToolbar, 0);
805 }
806
807 auto curViewport = window.viewports[0];
808 window.viewports[0] = nullptr;
809 if (curViewport != nullptr)
810 {
811 curViewport->width = 0;
812 }
813
814 window.holdableWidgets = 0;
815 window.eventHandlers = &getEvents();
816 window.setWidgets(_widgets);
817 setDisabledTransportTabs(window);
818 window.invalidate();
819 _buildTargetVehicle = -1;
820 setTrackTypeTabs(&window);
821 resetTrackTypeTabSelection(&window);
822 window.rowCount = 0;
823 window.rowHover = -1;
824 sub_4B92A5(&window);
825 window.callOnResize();
826 window.callOnPeriodicUpdate();
827 window.callPrepareDraw();
828 window.initScrollWidgets();
829 window.invalidate();
830 window.moveInsideScreenEdges();
831 break;
832 }

Callers

nothing calls this directly

Calls 15

enumValueFunction · 0.85
setDisabledTransportTabsFunction · 0.85
setTrackTypeTabsFunction · 0.85
sub_4B92A5Function · 0.85
widxToTrackTypeTabFunction · 0.85
setTopToolbarLastTrackFunction · 0.85
setWidgetsMethod · 0.80
callOnResizeMethod · 0.80
callOnPeriodicUpdateMethod · 0.80
callPrepareDrawMethod · 0.80
initScrollWidgetsMethod · 0.80

Tested by

no test coverage detected