* Processes clicking on facilities. * @param action Pointer to an action. */
| 136 | * @param action Pointer to an action. |
| 137 | */ |
| 138 | void PlaceFacilityState::viewClick(Action *) |
| 139 | { |
| 140 | if (!_view->isPlaceable(_rule)) |
| 141 | { |
| 142 | _game->popState(); |
| 143 | _game->pushState(new ErrorMessageState(_game, "STR_CANNOT_BUILD_HERE", _palette, Palette::blockOffset(15)+1, "BACK01.SCR", 6)); |
| 144 | } |
| 145 | else if (_game->getSavedGame()->getFunds() < _rule->getBuildCost()) |
| 146 | { |
| 147 | _game->popState(); |
| 148 | _game->pushState(new ErrorMessageState(_game, "STR_NOT_ENOUGH_MONEY", _palette, Palette::blockOffset(15)+1, "BACK01.SCR", 6)); |
| 149 | } |
| 150 | else |
| 151 | { |
| 152 | BaseFacility *fac = new BaseFacility(_rule, _base); |
| 153 | fac->setX(_view->getGridX()); |
| 154 | fac->setY(_view->getGridY()); |
| 155 | fac->setBuildTime(_rule->getBuildTime()); |
| 156 | _base->getFacilities()->push_back(fac); |
| 157 | if (Options::allowBuildingQueue) |
| 158 | { |
| 159 | if (_view->isQueuedBuilding(_rule)) fac->setBuildTime(std::numeric_limits<int>::max()); |
| 160 | _view->reCalcQueuedBuildings(); |
| 161 | } |
| 162 | _game->getSavedGame()->setFunds(_game->getSavedGame()->getFunds() - _rule->getBuildCost()); |
| 163 | _game->popState(); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | } |
nothing calls this directly
no test coverage detected