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

Method globeClick

src/Geoscape/BuildNewBaseState.cpp:223–257  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

221 * @param action Pointer to an action.
222 */
223void BuildNewBaseState::globeClick(Action *action)
224{
225 double lon, lat;
226 int mouseX = (int)floor(action->getAbsoluteXMouse()), mouseY = (int)floor(action->getAbsoluteYMouse());
227 _globe->cartToPolar(mouseX, mouseY, &lon, &lat);
228
229 // Ignore window clicks
230 if (mouseY < 28)
231 {
232 return;
233 }
234
235 // Clicking on land for a base location
236 if (action->getDetails()->button.button == SDL_BUTTON_LEFT)
237 {
238 if (_globe->insideLand(lon, lat))
239 {
240 _base->setLongitude(lon);
241 _base->setLatitude(lat);
242 for (std::vector<Craft*>::iterator i = _base->getCrafts()->begin(); i != _base->getCrafts()->end(); ++i)
243 {
244 (*i)->setLongitude(lon);
245 (*i)->setLatitude(lat);
246 }
247 if (_first)
248 {
249 _game->pushState(new BaseNameState(_game, _base, _globe, _first));
250 }
251 else
252 {
253 _game->pushState(new ConfirmNewBaseState(_game, _base, _globe));
254 }
255 }
256 }
257}
258
259/**
260 * 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
insideLandMethod · 0.80
pushStateMethod · 0.80
setLongitudeMethod · 0.45
setLatitudeMethod · 0.45
getCraftsMethod · 0.45

Tested by

no test coverage detected