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

Method viewClick

src/Basescape/PlaceFacilityState.cpp:138–165  ·  view source on GitHub ↗

* Processes clicking on facilities. * @param action Pointer to an action. */

Source from the content-addressed store, hash-verified

136 * @param action Pointer to an action.
137 */
138void 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}

Callers

nothing calls this directly

Calls 15

isPlaceableMethod · 0.80
pushStateMethod · 0.80
getFundsMethod · 0.80
getSavedGameMethod · 0.80
getBuildCostMethod · 0.80
getGridXMethod · 0.80
getGridYMethod · 0.80
setBuildTimeMethod · 0.80
getFacilitiesMethod · 0.80
isQueuedBuildingMethod · 0.80
reCalcQueuedBuildingsMethod · 0.80
setFundsMethod · 0.80

Tested by

no test coverage detected