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

Method OnClick

src/road_gui.cpp:510–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508 }
509
510 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
511 {
512 _remove_button_clicked = false;
513 _one_way_button_clicked = false;
514 switch (widget) {
515 case WID_ROT_ROAD_X:
516 HandlePlacePushButton(this, WID_ROT_ROAD_X, GetRoadTypeInfo(this->roadtype)->cursor.road_nwse, HT_RECT);
517 this->last_started_action = widget;
518 break;
519
520 case WID_ROT_ROAD_Y:
521 HandlePlacePushButton(this, WID_ROT_ROAD_Y, GetRoadTypeInfo(this->roadtype)->cursor.road_swne, HT_RECT);
522 this->last_started_action = widget;
523 break;
524
525 case WID_ROT_AUTOROAD:
526 HandlePlacePushButton(this, WID_ROT_AUTOROAD, GetRoadTypeInfo(this->roadtype)->cursor.autoroad, HT_RECT);
527 this->last_started_action = widget;
528 break;
529
530 case WID_ROT_DEMOLISH:
531 HandlePlacePushButton(this, WID_ROT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
532 this->last_started_action = widget;
533 break;
534
535 case WID_ROT_DEPOT:
536 if (HandlePlacePushButton(this, WID_ROT_DEPOT, GetRoadTypeInfo(this->roadtype)->cursor.depot, HT_RECT)) {
537 ShowRoadDepotPicker(this);
538 this->last_started_action = widget;
539 }
540 break;
541
542 case WID_ROT_BUILD_WAYPOINT:
543 this->last_started_action = widget;
544 if (HandlePlacePushButton(this, WID_ROT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT)) {
545 ShowBuildRoadWaypointPicker(this);
546 }
547 break;
548
549 case WID_ROT_BUS_STATION:
550 if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
551 ShowRVStationPicker(this, RoadStopType::Bus);
552 this->last_started_action = widget;
553 }
554 break;
555
556 case WID_ROT_TRUCK_STATION:
557 if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
558 ShowRVStationPicker(this, RoadStopType::Truck);
559 this->last_started_action = widget;
560 }
561 break;
562
563 case WID_ROT_ONE_WAY:
564 if (this->IsWidgetDisabled(WID_ROT_ONE_WAY)) return;
565 this->SetDirty();
566 this->ToggleWidgetLoweredState(WID_ROT_ONE_WAY);
567 SetSelectionRed(false);

Callers

nothing calls this directly

Calls 15

HandlePlacePushButtonFunction · 0.85
GetRoadTypeInfoFunction · 0.85
ShowRoadDepotPickerFunction · 0.85
ShowRVStationPickerFunction · 0.85
SetSelectionRedFunction · 0.85
CloseWindowByIdFunction · 0.85
ToggleRoadButton_RemoveFunction · 0.85
SndClickBeepFunction · 0.85
NOT_REACHEDFunction · 0.85
RoadToolbar_CtrlChangedFunction · 0.85

Tested by

no test coverage detected