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

Method SelectSortBy

src/station_gui.cpp:2052–2078  ·  view source on GitHub ↗

* Select a new sort criterium for the cargo view. * @param index Row being selected in the sort criteria drop down. */

Source from the content-addressed store, hash-verified

2050 * @param index Row being selected in the sort criteria drop down.
2051 */
2052 void SelectSortBy(int index)
2053 {
2054 _settings_client.gui.station_gui_sort_by = index;
2055 switch (StationViewWindow::sort_names[index]) {
2056 case STR_STATION_VIEW_WAITING_STATION:
2057 this->current_mode = MODE_WAITING;
2058 this->sortings[1] = this->sortings[2] = this->sortings[3] = CargoSortType::AsGrouping;
2059 break;
2060 case STR_STATION_VIEW_WAITING_AMOUNT:
2061 this->current_mode = MODE_WAITING;
2062 this->sortings[1] = this->sortings[2] = this->sortings[3] = CargoSortType::Count;
2063 break;
2064 case STR_STATION_VIEW_PLANNED_STATION:
2065 this->current_mode = MODE_PLANNED;
2066 this->sortings[1] = this->sortings[2] = this->sortings[3] = CargoSortType::AsGrouping;
2067 break;
2068 case STR_STATION_VIEW_PLANNED_AMOUNT:
2069 this->current_mode = MODE_PLANNED;
2070 this->sortings[1] = this->sortings[2] = this->sortings[3] = CargoSortType::Count;
2071 break;
2072 default:
2073 NOT_REACHED();
2074 }
2075 /* Display the current sort variant */
2076 this->GetWidget<NWidgetCore>(WID_SV_SORT_BY)->SetString(StationViewWindow::sort_names[index]);
2077 this->SetDirty();
2078 }
2079
2080 /**
2081 * Select a new grouping mode for the cargo view.

Callers 2

StationViewWindowMethod · 0.95
OnDropdownSelectMethod · 0.95

Calls 3

NOT_REACHEDFunction · 0.85
SetStringMethod · 0.45
SetDirtyMethod · 0.45

Tested by

no test coverage detected