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

Method OnClick

src/subsidy_gui.cpp:45–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 }
44
45 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
46 {
47 if (widget != WID_SUL_PANEL) return;
48
49 int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SUL_PANEL, WidgetDimensions::scaled.framerect.top);
50 int num = 0;
51 for (const Subsidy *s : Subsidy::Iterate()) {
52 if (!s->IsAwarded()) {
53 y--;
54 if (y == 0) {
55 this->HandleClick(s);
56 return;
57 }
58 num++;
59 }
60 }
61
62 if (num == 0) {
63 y--; // "None"
64 if (y < 0) return;
65 }
66
67 y -= 2; // "Services already subsidised:"
68 if (y < 0) return;
69
70 for (const Subsidy *s : Subsidy::Iterate()) {
71 if (s->IsAwarded()) {
72 y--;
73 if (y == 0) {
74 this->HandleClick(s);
75 return;
76 }
77 }
78 }
79 }
80
81 void HandleClick(const Subsidy *s)
82 {

Callers

nothing calls this directly

Calls 3

HandleClickMethod · 0.95
IsAwardedMethod · 0.45

Tested by

no test coverage detected