* Processes any left-clicks for base placement, * or right-clicks to scroll the globe. * @param action Pointer to an action. */
| 221 | * @param action Pointer to an action. |
| 222 | */ |
| 223 | void 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. |
nothing calls this directly
no test coverage detected