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

Method OnPaint

src/network/network_gui.cpp:559–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

557
558
559 void OnPaint() override
560 {
561 if (this->servers.NeedRebuild()) {
562 this->BuildGUINetworkGameList();
563 }
564 if (this->servers.NeedResort()) {
565 this->SortNetworkGameList();
566 }
567
568 NetworkGame *sel = this->server;
569 /* 'Refresh' button invisible if no server selected */
570 this->SetWidgetDisabledState(WID_NG_REFRESH, sel == nullptr);
571 /* 'Join' button disabling conditions */
572 this->SetWidgetDisabledState(WID_NG_JOIN, sel == nullptr || // no Selected Server
573 sel->status != NGLS_ONLINE || // Server offline
574 sel->info.clients_on >= sel->info.clients_max || // Server full
575 !sel->info.compatible); // Revision mismatch
576
577 this->SetWidgetLoweredState(WID_NG_REFRESH, sel != nullptr && sel->refreshing);
578
579 /* 'NewGRF Settings' button invisible if no NewGRF is used */
580 bool changed = false;
581 changed |= this->GetWidget<NWidgetStacked>(WID_NG_NEWGRF_SEL)->SetDisplayedPlane(sel == nullptr || sel->status != NGLS_ONLINE || sel->info.grfconfig.empty() ? SZSP_NONE : 0);
582 changed |= this->GetWidget<NWidgetStacked>(WID_NG_NEWGRF_MISSING_SEL)->SetDisplayedPlane(sel == nullptr || sel->status != NGLS_ONLINE || sel->info.grfconfig.empty() || !sel->info.version_compatible || sel->info.compatible ? SZSP_NONE : 0);
583 if (changed) {
584 this->ReInit();
585 return;
586 }
587
588#ifdef __EMSCRIPTEN__
589 this->SetWidgetDisabledState(WID_NG_SEARCH_INTERNET, true);
590 this->SetWidgetDisabledState(WID_NG_SEARCH_LAN, true);
591 this->SetWidgetDisabledState(WID_NG_ADD, true);
592 this->SetWidgetDisabledState(WID_NG_START, true);
593#endif
594
595 this->DrawWidgets();
596 }
597
598 StringID GetHeaderString() const
599 {

Callers

nothing calls this directly

Calls 10

SortNetworkGameListMethod · 0.95
NeedRebuildMethod · 0.80
NeedResortMethod · 0.80
SetWidgetLoweredStateMethod · 0.80
SetDisplayedPlaneMethod · 0.80
ReInitMethod · 0.80
DrawWidgetsMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected