/** * Processes clicking on facilities. * @param action Pointer to an action. */ void BasescapeState::viewClick(Action *action) { BaseFacility *fac = _view->getSelectedFacility(); if (fac != 0) { // Pre-calculate values to ensure base stays connected int x = -1, y = -1, squares = 0; for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); i++) { if ((*i)->getRules()->getLift()) { x = (*i)->getX(); y = (*i)->getY(); } squares += (*i)->getRules()->getSize() * (*i)->getRules()->getSize(); } squares -= fac->getRules()->getSize() * fac->getRules()->getSize(); // Is facility in use? if (fac->inUse()) { _game->pushState(new BasescapeErrorState(_game, "STR_FACILITY_IN_USE")); } // Would base become disconnected? (ocuppied squares connected to Access Lift < total squares occupied by base) else if (_view->countConnected(x, y, 0, fac) < squares) { _game->pushState(new BasescapeErrorState(_game, "STR_CANNOT_DISMANTLE_FACILITY")); } else { _game->pushState(new DismantleFacilityState(_game, _base, fac)); } } }
/** * Processes clicking on facilities. * @param action Pointer to an action. */ void BasescapeState::viewLeftClick(Action *) { BaseFacility *fac = _view->getSelectedFacility(); if (fac != 0) { // Is facility in use? if (fac->inUse()) { _game->pushState(new ErrorMessageState(_game, "STR_FACILITY_IN_USE", Palette::blockOffset(15)+1, "BACK13.SCR", 6)); } // Would base become disconnected? else if (!_base->getDisconnectedFacilities(fac).empty()) { _game->pushState(new ErrorMessageState(_game, "STR_CANNOT_DISMANTLE_FACILITY", Palette::blockOffset(15)+1, "BACK13.SCR", 6)); } else { _game->pushState(new DismantleFacilityState(_game, _base, _view, fac)); } } }
/** * Processes clicking on facilities. * @param action Pointer to an action. */ void BasescapeState::viewLeftClick(Action *) { BaseFacility *fac = _view->getSelectedFacility(); if (fac != 0) { // Is facility in use? if (fac->inUse()) { _game->pushState(new ErrorMessageState(tr("STR_FACILITY_IN_USE"), _palette, _game->getMod()->getInterface("basescape")->getElement("errorMessage")->color, "BACK13.SCR", _game->getMod()->getInterface("basescape")->getElement("errorPalette")->color)); } // Would base become disconnected? else if (!_base->getDisconnectedFacilities(fac).empty()) { _game->pushState(new ErrorMessageState(tr("STR_CANNOT_DISMANTLE_FACILITY"), _palette, _game->getMod()->getInterface("basescape")->getElement("errorMessage")->color, "BACK13.SCR", _game->getMod()->getInterface("basescape")->getElement("errorPalette")->color)); } else { _game->pushState(new DismantleFacilityState(_base, _view, fac)); } } }