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

Method OnClick

src/linkgraph/linkgraph_gui.cpp:680–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

678}
679
680void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count)
681{
682 /* Check which button is clicked */
683 if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
684 if (!this->IsWidgetDisabled(widget)) {
685 this->ToggleWidgetLoweredState(widget);
686 this->UpdateOverlayCompanies();
687 }
688 } else if (widget == WID_LGL_COMPANIES_ALL || widget == WID_LGL_COMPANIES_NONE) {
689 for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
690 if (this->IsWidgetDisabled(WID_LGL_COMPANY_FIRST + c)) continue;
691 this->SetWidgetLoweredState(WID_LGL_COMPANY_FIRST + c, widget == WID_LGL_COMPANIES_ALL);
692 }
693 this->UpdateOverlayCompanies();
694 this->SetDirty();
695 } else if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) {
696 this->ToggleWidgetLoweredState(widget);
697 this->UpdateOverlayCargoes();
698 } else if (widget == WID_LGL_CARGOES_ALL || widget == WID_LGL_CARGOES_NONE) {
699 for (uint c = 0; c < this->num_cargo; c++) {
700 this->SetWidgetLoweredState(WID_LGL_CARGO_FIRST + c, widget == WID_LGL_CARGOES_ALL);
701 }
702 this->UpdateOverlayCargoes();
703 }
704 this->SetDirty();
705}
706
707/**
708 * Invalidate the data of this window if the cargoes or companies have changed.

Callers

nothing calls this directly

Calls 8

UpdateOverlayCargoesMethod · 0.95
IsInsideMMFunction · 0.85
BeginFunction · 0.85
IsWidgetDisabledMethod · 0.80
SetWidgetLoweredStateMethod · 0.80
SetDirtyMethod · 0.45

Tested by

no test coverage detected