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

Method OnClick

src/goal_gui.cpp:64–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 }
63
64 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
65 {
66 switch (widget) {
67 case WID_GOAL_GLOBAL_BUTTON:
68 ShowGoalsList(CompanyID::Invalid());
69 break;
70
71 case WID_GOAL_COMPANY_BUTTON:
72 ShowGoalsList(_local_company);
73 break;
74
75 case WID_GOAL_LIST: {
76 int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WidgetDimensions::scaled.framerect.top);
77 for (const Goal *s : Goal::Iterate()) {
78 if (s->company == this->window_number) {
79 if (y == 0) {
80 this->HandleClick(s);
81 return;
82 }
83 y--;
84 }
85 }
86 break;
87 }
88
89 default:
90 break;
91 }
92 }
93
94 /**
95 * Handle clicking at a goal.

Callers

nothing calls this directly

Calls 4

HandleClickMethod · 0.95
ShowGoalsListFunction · 0.85
InvalidFunction · 0.85

Tested by

no test coverage detected