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

Method OnClick

src/town_gui.cpp:935–970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

933 }
934
935 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
936 {
937 switch (widget) {
938 case WID_TD_SORT_ORDER: // Click on sort order button
939 if (this->towns.SortType() != 2) { // A different sort than by rating.
940 this->towns.ToggleSortOrder();
941 this->last_sorting = this->towns.GetListing(); // Store new sorting order.
942 } else {
943 /* Some parts are always sorted ascending on name. */
944 this->last_sorting.order = !this->last_sorting.order;
945 this->towns.SetListing(this->last_sorting);
946 this->towns.ForceResort();
947 this->towns.Sort();
948 }
949 this->SetDirty();
950 break;
951
952 case WID_TD_SORT_CRITERIA: // Click on sort criteria dropdown
953 ShowDropDownMenu(this, TownDirectoryWindow::sorter_names, this->towns.SortType(), WID_TD_SORT_CRITERIA, 0, 0);
954 break;
955
956 case WID_TD_LIST: { // Click on Town Matrix
957 auto it = this->vscroll->GetScrolledItemFromWidget(this->towns, pt.y, this, WID_TD_LIST, WidgetDimensions::scaled.framerect.top);
958 if (it == this->towns.end()) return; // click out of town bounds
959
960 const Town *t = *it;
961 assert(t != nullptr);
962 if (_ctrl_pressed) {
963 ShowExtraViewportWindow(t->xy);
964 } else {
965 ScrollMainWindowToTile(t->xy);
966 }
967 break;
968 }
969 }
970 }
971
972 void OnDropdownSelect(WidgetID widget, int index, int) override
973 {

Callers

nothing calls this directly

Calls 12

ShowDropDownMenuFunction · 0.85
ShowExtraViewportWindowFunction · 0.85
ScrollMainWindowToTileFunction · 0.85
SortTypeMethod · 0.80
ToggleSortOrderMethod · 0.80
SetListingMethod · 0.80
ForceResortMethod · 0.80
GetListingMethod · 0.45
SortMethod · 0.45
SetDirtyMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected