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

Method HandleClick

src/subsidy_gui.cpp:81–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 }
80
81 void HandleClick(const Subsidy *s)
82 {
83 /* determine src coordinate for subsidy and try to scroll to it */
84 TileIndex xy;
85 switch (s->src.type) {
86 case SourceType::Industry: xy = Industry::Get(s->src.ToIndustryID())->location.tile; break;
87 case SourceType::Town: xy = Town::Get(s->src.ToTownID())->xy; break;
88 default: NOT_REACHED();
89 }
90
91 if (_ctrl_pressed || !ScrollMainWindowToTile(xy)) {
92 if (_ctrl_pressed) ShowExtraViewportWindow(xy);
93
94 /* otherwise determine dst coordinate for subsidy and scroll to it */
95 switch (s->dst.type) {
96 case SourceType::Industry: xy = Industry::Get(s->dst.ToIndustryID())->location.tile; break;
97 case SourceType::Town: xy = Town::Get(s->dst.ToTownID())->xy; break;
98 default: NOT_REACHED();
99 }
100
101 if (_ctrl_pressed) {
102 ShowExtraViewportWindow(xy);
103 } else {
104 ScrollMainWindowToTile(xy);
105 }
106 }
107 }
108
109 /**
110 * Count the number of lines in this window.

Callers 1

OnClickMethod · 0.95

Calls 5

NOT_REACHEDFunction · 0.85
ScrollMainWindowToTileFunction · 0.85
ShowExtraViewportWindowFunction · 0.85
ToIndustryIDMethod · 0.80
ToTownIDMethod · 0.80

Tested by

no test coverage detected