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

Method OnClick

src/network/network_gui.cpp:670–754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668 }
669
670 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
671 {
672 switch (widget) {
673 case WID_NG_NAME: // Sort by name
674 case WID_NG_CLIENTS: // Sort by connected clients
675 case WID_NG_MAPSIZE: // Sort by map size
676 case WID_NG_DATE: // Sort by date
677 case WID_NG_YEARS: // Sort by years
678 case WID_NG_INFO: // Connectivity (green dot)
679 if (this->servers.SortType() == widget - WID_NG_NAME) {
680 this->servers.ToggleSortOrder();
681 if (this->list_pos != SLP_INVALID) this->list_pos = (ServerListPosition)this->servers.size() - this->list_pos - 1;
682 } else {
683 this->servers.SetSortType(widget - WID_NG_NAME);
684 this->servers.ForceResort();
685 this->SortNetworkGameList();
686 }
687 this->ScrollToSelectedServer();
688 this->SetDirty();
689 break;
690
691 case WID_NG_MATRIX: { // Show available network games
692 auto it = this->vscroll->GetScrolledItemFromWidget(this->servers, pt.y, this, WID_NG_MATRIX);
693 this->server = (it != this->servers.end()) ? *it : nullptr;
694 this->list_pos = (server == nullptr) ? SLP_INVALID : it - this->servers.begin();
695 this->SetDirty();
696
697 if (click_count > 1 && !this->IsWidgetDisabled(WID_NG_JOIN)) this->OnClick(pt, WID_NG_JOIN, 1);
698 break;
699 }
700
701 case WID_NG_LASTJOINED: {
702 if (this->last_joined != nullptr) {
703 this->server = this->last_joined;
704
705 /* search the position of the newly selected server */
706 this->UpdateListPos();
707 this->ScrollToSelectedServer();
708 this->SetDirty();
709
710 if (click_count > 1 && !this->IsWidgetDisabled(WID_NG_JOIN)) this->OnClick(pt, WID_NG_JOIN, 1);
711 }
712 break;
713 }
714
715 case WID_NG_SEARCH_INTERNET:
716 _network_coordinator_client.GetListing();
717 this->searched_internet = true;
718 break;
719
720 case WID_NG_SEARCH_LAN:
721 NetworkUDPSearchGame();
722 break;
723
724 case WID_NG_ADD: // Add a server
725 ShowQueryString(
726 _settings_client.network.connect_to_ip,
727 STR_NETWORK_SERVER_LIST_ENTER_SERVER_ADDRESS,

Callers

nothing calls this directly

Calls 15

SortNetworkGameListMethod · 0.95
UpdateListPosMethod · 0.95
NetworkUDPSearchGameFunction · 0.85
ShowQueryStringFunction · 0.85
NetworkClientConnectGameFunction · 0.85
NetworkQueryServerFunction · 0.85
ShowNewGRFSettingsFunction · 0.85
ShowMissingContentWindowFunction · 0.85
SortTypeMethod · 0.80
ToggleSortOrderMethod · 0.80

Tested by

no test coverage detected