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

Method OnInvalidateData

src/airport_gui.cpp:108–122  ·  view source on GitHub ↗

* Some data on this window has become invalid. * @param data Information about the changed data. * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. */

Source from the content-addressed store, hash-verified

106 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
107 */
108 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
109 {
110 if (!gui_scope) return;
111
112 bool can_build = CanBuildVehicleInfrastructure(VEH_AIRCRAFT);
113 this->SetWidgetDisabledState(WID_AT_AIRPORT, !can_build);
114 if (!can_build) {
115 CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
116
117 /* Show in the tooltip why this button is disabled. */
118 this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
119 } else {
120 this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP);
121 }
122 }
123
124 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
125 {

Callers 2

BuildAirToolbarWindowMethod · 0.95
BuildAirportWindowMethod · 0.45

Calls 4

CloseWindowByIdFunction · 0.85
SetToolTipMethod · 0.80

Tested by

no test coverage detected