* Processes any left-clicks for picking a target, * or right-clicks to scroll the globe. * @param action Pointer to an action. */
| 186 | * @param action Pointer to an action. |
| 187 | */ |
| 188 | void 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. |
nothing calls this directly
no test coverage detected