MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / OnDropdownSelect

Method OnDropdownSelect

src/build_vehicle_gui.cpp:1899–1949  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1897 }
1898
1899 void OnDropdownSelect(WidgetID widget, int index, int click_result) override
1900 {
1901 switch (widget) {
1902 case WID_BV_SORT_DROPDOWN:
1903 if (this->sort_criteria != index) {
1904 this->sort_criteria = index;
1905 _engine_sort_last_criteria[this->vehicle_type] = this->sort_criteria;
1906 this->eng_list.ForceRebuild();
1907 }
1908 break;
1909
1910 case WID_BV_CARGO_FILTER_DROPDOWN: // Select a cargo filter criteria
1911 if (this->cargo_filter_criteria != index) {
1912 this->cargo_filter_criteria = index;
1913 _engine_sort_last_cargo_criteria[this->vehicle_type] = this->cargo_filter_criteria;
1914 /* deactivate filter if criteria is 'Show All', activate it otherwise */
1915 this->eng_list.SetFilterState(this->cargo_filter_criteria != CargoFilterCriteria::CF_ANY);
1916 this->eng_list.ForceRebuild();
1917 this->SelectEngine(this->sel_engine);
1918 }
1919 break;
1920
1921 case WID_BV_CONFIGURE_BADGES: {
1922 bool reopen = HandleBadgeConfigurationDropDownClick(static_cast<GrfSpecFeature>(GSF_TRAINS + this->vehicle_type), BADGE_COLUMNS, index, click_result, this->badge_filter_choices);
1923
1924 this->ReInit();
1925
1926 if (reopen) {
1927 ReplaceDropDownList(this, this->BuildBadgeConfigurationList(), -1);
1928 } else {
1929 this->CloseChildWindows(WC_DROPDOWN_MENU);
1930 }
1931
1932 /* We need to refresh if a filter is removed. */
1933 this->eng_list.ForceRebuild();
1934 break;
1935 }
1936
1937 default:
1938 if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) {
1939 if (index < 0) {
1940 ResetBadgeFilter(this->badge_filter_choices, this->GetWidget<NWidgetBadgeFilter>(widget)->GetBadgeClassID());
1941 } else {
1942 SetBadgeFilter(this->badge_filter_choices, BadgeID(index));
1943 }
1944 this->eng_list.ForceRebuild();
1945 }
1946 break;
1947 }
1948 this->SetDirty();
1949 }
1950
1951 void OnResize() override
1952 {

Callers

nothing calls this directly

Calls 13

SelectEngineMethod · 0.95
ReplaceDropDownListFunction · 0.85
IsInsideMMFunction · 0.85
ResetBadgeFilterFunction · 0.85
SetBadgeFilterFunction · 0.85
ForceRebuildMethod · 0.80
SetFilterStateMethod · 0.80
ReInitMethod · 0.80
CloseChildWindowsMethod · 0.80
GetBadgeClassIDMethod · 0.80

Tested by

no test coverage detected