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

Method OnInvalidateData

src/dock_gui.cpp:122–148  ·  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

120 * @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.
121 */
122 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
123 {
124 if (!gui_scope) return;
125
126 bool can_build = CanBuildVehicleInfrastructure(VEH_SHIP);
127 this->SetWidgetsDisabledState(!can_build,
128 WID_DT_DEPOT,
129 WID_DT_STATION,
130 WID_DT_BUOY);
131 if (!can_build) {
132 CloseWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
133 CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
134 }
135
136 if (_game_mode != GM_EDITOR) {
137 if (!can_build) {
138 /* Show in the tooltip why this button is disabled. */
139 this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
140 this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
141 this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
142 } else {
143 this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP);
144 this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP);
145 this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP);
146 }
147 }
148 }
149
150 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
151 {

Callers 1

Calls 4

CloseWindowByIdFunction · 0.85
SetToolTipMethod · 0.80

Tested by

no test coverage detected