MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / globeClick

Method globeClick

src/Geoscape/SelectDestinationState.cpp:188–213  ·  view source on GitHub ↗

* Processes any left-clicks for picking a target, * or right-clicks to scroll the globe. * @param action Pointer to an action. */

Source from the content-addressed store, hash-verified

186 * @param action Pointer to an action.
187 */
188void SelectDestinationState::globeClick(Action *action)
189{
190 double lon, lat;
191 int mouseX = (int)floor(action->getAbsoluteXMouse()), mouseY = (int)floor(action->getAbsoluteYMouse());
192 _globe->cartToPolar(mouseX, mouseY, &lon, &lat);
193
194 // Ignore window clicks
195 if (mouseY < 28)
196 {
197 return;
198 }
199
200 // Clicking on a valid target
201 if (action->getDetails()->button.button == SDL_BUTTON_LEFT)
202 {
203 std::vector<Target*> v = _globe->getTargets(mouseX, mouseY, true);
204 if (v.empty())
205 {
206 Waypoint *w = new Waypoint();
207 w->setLongitude(lon);
208 w->setLatitude(lat);
209 v.push_back(w);
210 }
211 _game->pushState(new MultipleTargetsState(_game, v, _craft, 0));
212 }
213}
214
215/**
216 * Starts rotating the globe to the left.

Callers

nothing calls this directly

Calls 9

getAbsoluteXMouseMethod · 0.80
getAbsoluteYMouseMethod · 0.80
cartToPolarMethod · 0.80
getDetailsMethod · 0.80
getTargetsMethod · 0.80
pushStateMethod · 0.80
emptyMethod · 0.45
setLongitudeMethod · 0.45
setLatitudeMethod · 0.45

Tested by

no test coverage detected