コード例 #1
0
ファイル: BasescapeState.cpp プロジェクト: gpin/OpenXcom
/**
 * 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));
		}
	}
}
コード例 #2
0
ファイル: BasescapeState.cpp プロジェクト: cfailde/OpenXcom
/**
 * Processes right clicking on facilities.
 * @param action Pointer to an action.
 */
void BasescapeState::viewRightClick(Action *)
{
	BaseFacility *f = _view->getSelectedFacility();
	if (f == 0)
	{
		_game->pushState(new BaseInfoState(_game, _base, this));
	}
	else if (f->getRules()->getCrafts() > 0)
	{
		if (f->getCraft() == 0)
		{
			_game->pushState(new CraftsState(_game, _base));
		}
		else
			for (size_t craft = 0; craft < _base->getCrafts()->size(); ++craft)
			{
				if (f->getCraft() == _base->getCrafts()->at(craft))
				{
					_game->pushState(new CraftInfoState(_game, _base, craft));
					break;
				}
			}
	}
	else if (f->getRules()->getStorage() > 0)
	{
		_game->pushState(new SellState(_game, _base));
	}
	else if (f->getRules()->getPersonnel() > 0)
	{
		_game->pushState(new SoldiersState(_game, _base));
	}
	else if (f->getRules()->getPsiLaboratories() > 0 && Options::anytimePsiTraining && _base->getAvailablePsiLabs() > 0)
	{
		_game->pushState(new AllocatePsiTrainingState(_game, _base));
	}
	else if (f->getRules()->getLaboratories() > 0)
	{
		_game->pushState(new ResearchState(_game, _base));
	}
	else if (f->getRules()->getWorkshops() > 0)
	{
		_game->pushState(new ManufactureState(_game, _base));
	}
	else if (f->getRules()->getAliens() > 0)
	{
		_game->pushState(new ManageAlienContainmentState(_game, _base, OPT_GEOSCAPE));
	}
	else if (f->getRules()->isLift() || f->getRules()->getRadarRange() > 0)
	{
		_game->popState();
	}
}
コード例 #3
0
ファイル: BasescapeState.cpp プロジェクト: gpin/OpenXcom
/**
 * Displays the name of the facility the mouse is over.
 * @param action Pointer to an action.
 */
void BasescapeState::viewMouseOver(Action *action)
{
	BaseFacility *f = _view->getSelectedFacility();
	if (f == 0)
		_txtFacility->setText(L"");
	else
		_txtFacility->setText(_game->getLanguage()->getString(f->getRules()->getType()));
}
コード例 #4
0
ファイル: BasescapeState.cpp プロジェクト: cfailde/OpenXcom
/**
 * Displays the name of the facility the mouse is over.
 * @param action Pointer to an action.
 */
void BasescapeState::viewMouseOver(Action *)
{
	BaseFacility *f = _view->getSelectedFacility();
	std::wostringstream ss;
	if (f != 0)
	{
		if (f->getRules()->getCrafts() == 0 || f->getBuildTime() > 0)
		{
			ss << tr(f->getRules()->getType());
		}
		else
		{
			ss << tr(f->getRules()->getType());
			if (f->getCraft() != 0)
			{
				ss << L" " << tr("STR_CRAFT_").arg(f->getCraft()->getName(_game->getLanguage()));
			}
		}
	}
	_txtFacility->setText(ss.str());
}