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

Method OnClick

src/airport_gui.cpp:497–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495 }
496
497 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
498 {
499 switch (widget) {
500 case WID_AP_CLASS_DROPDOWN:
501 ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, WID_AP_CLASS_DROPDOWN);
502 break;
503
504 case WID_AP_AIRPORT_LIST: {
505 int32_t num_clicked = this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height);
506 if (num_clicked == INT32_MAX) break;
507 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked);
508 if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
509 break;
510 }
511
512 case WID_AP_BTN_DONTHILIGHT: case WID_AP_BTN_DOHILIGHT:
513 _settings_client.gui.station_show_coverage = (widget != WID_AP_BTN_DONTHILIGHT);
514 this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
515 this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
516 this->SetDirty();
517 SndClickBeep();
518 this->UpdateSelectSize();
519 SetViewportCatchmentStation(nullptr, true);
520 break;
521
522 case WID_AP_LAYOUT_DECREASE:
523 _selected_airport_layout--;
524 this->UpdateSelectSize();
525 this->SetDirty();
526 break;
527
528 case WID_AP_LAYOUT_INCREASE:
529 _selected_airport_layout++;
530 this->UpdateSelectSize();
531 this->SetDirty();
532 break;
533 }
534 }
535
536 /**
537 * Select the first available airport.

Callers

nothing calls this directly

Calls 10

SelectOtherAirportMethod · 0.95
UpdateSelectSizeMethod · 0.95
ShowDropDownListFunction · 0.85
SndClickBeepFunction · 0.85
SetWidgetLoweredStateMethod · 0.80
GetSpecMethod · 0.45
IsAvailableMethod · 0.45
SetDirtyMethod · 0.45

Tested by

no test coverage detected