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

Method OnClick

src/waypoint_gui.cpp:128–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126 }
127
128 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
129 {
130 Window *w = FindWindowByClass(WC_QUERY_STRING);
131
132 switch (widget) {
133 case WID_W_CENTER_VIEW: // scroll to location
134 if (_ctrl_pressed) {
135 ShowExtraViewportWindow(this->GetCenterTile());
136 } else {
137 ScrollMainWindowToTile(this->GetCenterTile());
138 }
139 break;
140
141 case WID_W_RENAME: // rename
142 ShowQueryString(GetString(STR_WAYPOINT_NAME, this->wp->index), STR_WAYPOINT_VIEW_EDIT_WAYPOINT_SIGN, MAX_LENGTH_STATION_NAME_CHARS, this, CS_ALPHANUMERAL,
143 {QueryStringFlag::EnableDefault, QueryStringFlag::LengthIsInChars, QueryStringFlag::EnableMove});
144 break;
145
146 case WID_W_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders
147 ShowVehicleListWindow(this->wp->owner, this->vt, this->wp->index);
148 break;
149
150 case WID_W_CATCHMENT:
151 SetViewportCatchmentWaypoint(Waypoint::Get(this->window_number), !this->IsWidgetLowered(WID_W_CATCHMENT));
152
153 if (w != nullptr && this->IsWidgetLowered(WID_W_CATCHMENT)) {
154 if (w->parent->window_class == WC_STATION_VIEW && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportStationRect(Station::Get(w->parent->window_number), true);
155 if (w->parent->window_class == WC_WAYPOINT_VIEW && w->IsWidgetLowered(WID_QS_MOVE)) SetViewportWaypointRect(Waypoint::Get(w->parent->window_number), true);
156 }
157 break;
158 }
159 }
160
161 /**
162 * Some data on this window has become invalid.

Callers

nothing calls this directly

Calls 11

GetCenterTileMethod · 0.95
FindWindowByClassFunction · 0.85
ShowExtraViewportWindowFunction · 0.85
ScrollMainWindowToTileFunction · 0.85
ShowQueryStringFunction · 0.85
ShowVehicleListWindowFunction · 0.85
SetViewportStationRectFunction · 0.85
SetViewportWaypointRectFunction · 0.85
IsWidgetLoweredMethod · 0.80
GetStringFunction · 0.70

Tested by

no test coverage detected