コード例 #1
0
/**
 * Update soldier stats when
 * the soldier changes.
 */
void SoldierInfoState::init()
{
	Soldier *s = _base->getSoldiers()->at(_soldier);
	_edtSoldier->setText(s->getName());
	UnitStats *initial = s->getInitStats();
	UnitStats *current = s->getCurrentStats();

	SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
	texture->getFrame(s->getRankSprite())->setX(0);
	texture->getFrame(s->getRankSprite())->setY(0);
	texture->getFrame(s->getRankSprite())->blit(_rank);

	std::wstringstream ss;
	ss << current->tu;
	_numTimeUnits->setText(ss.str());
	_barTimeUnits->setMax(current->tu);
	_barTimeUnits->setValue(current->tu);
	_barTimeUnits->setValue2(initial->tu);

	std::wstringstream ss2;
	ss2 << current->stamina;
	_numStamina->setText(ss2.str());
	_barStamina->setMax(current->stamina);
	_barStamina->setValue(current->stamina);
	_barStamina->setValue2(initial->stamina);

	std::wstringstream ss3;
	ss3 << current->health;
	_numHealth->setText(ss3.str());
	_barHealth->setMax(current->health);
	_barHealth->setValue(current->health);
	_barHealth->setValue2(initial->health);

	std::wstringstream ss4;
	ss4 << current->bravery;
	_numBravery->setText(ss4.str());
	_barBravery->setMax(current->bravery);
	_barBravery->setValue(current->bravery);
	_barBravery->setValue2(initial->bravery);

	std::wstringstream ss5;
	ss5 << current->reactions;
	_numReactions->setText(ss5.str());
	_barReactions->setMax(current->reactions);
	_barReactions->setValue(current->reactions);
	_barReactions->setValue2(initial->reactions);

	std::wstringstream ss6;
	ss6 << current->firing;
	_numFiring->setText(ss6.str());
	_barFiring->setMax(current->firing);
	_barFiring->setValue(current->firing);
	_barFiring->setValue2(initial->firing);

	std::wstringstream ss7;
	ss7 << current->throwing;
	_numThrowing->setText(ss7.str());
	_barThrowing->setMax(current->throwing);
	_barThrowing->setValue(current->throwing);
	_barThrowing->setValue2(initial->throwing);

	std::wstringstream ss8;
	ss8 << current->strength;
	_numStrength->setText(ss8.str());
	_barStrength->setMax(current->strength);
	_barStrength->setValue(current->strength);
	_barStrength->setValue2(initial->strength);

	_txtArmor->setText(_game->getLanguage()->getString(s->getArmor()->getType()));

	std::wstringstream ss9;
	ss9 << _game->getLanguage()->getString("STR_RANK_") << L'\x01' << _game->getLanguage()->getString(s->getRankString());
	_txtRank->setText(ss9.str());

	std::wstringstream ss10;
	ss10 << _game->getLanguage()->getString("STR_MISSIONS") << L'\x01' << s->getMissions();
	_txtMissions->setText(ss10.str());

	std::wstringstream ss11;
	ss11 << _game->getLanguage()->getString("STR_KILLS") << L'\x01' << s->getKills();
	_txtKills->setText(ss11.str());

	std::wstringstream ss12;
	ss12 << _game->getLanguage()->getString("STR_CRAFT_") << L'\x01';
	if (s->getCraft() == 0)
		ss12 << _game->getLanguage()->getString("STR_NONE_UC");
	else
		ss12 << s->getCraft()->getName(_game->getLanguage());
	_txtCraft->setText(ss12.str());

	if (s->getWoundRecovery() > 1)
	{
		std::wstringstream ss13;
		ss13 << _game->getLanguage()->getString("STR_WOUND_RECOVERY") << L'\x01' << s->getWoundRecovery();
		if (s->getWoundRecovery() > 1)
			ss13 << _game->getLanguage()->getString("STR_DAYS");
		else
			ss13 << _game->getLanguage()->getString("STR_DAY");
		_txtRecovery->setText(ss13.str());
	}
	else
	{
		_txtRecovery->setText(L"");
	}
}
コード例 #2
0
/**
 * Initializes all the elements in the Soldier Armor window.
 * @param game Pointer to the core game.
 * @param base Pointer to the base to get info from.
 * @param soldier ID of the selected soldier.
 */
SoldierArmorState::SoldierArmorState(Game *game, Base *base, size_t soldier) : State(game), _base(base), _soldier(soldier)
{
	_screen = false;

	// Create objects
	_window = new Window(this, 192, 120, 64, 40, POPUP_BOTH);
	_btnCancel = new TextButton(140, 16, 90, 136);
	_txtTitle = new Text(182, 9, 69, 48);
	_txtSoldier = new Text(182, 9, 69, 56);
	_txtType = new Text(90, 9, 80, 72);
	_txtQuantity = new Text(70, 9, 177, 72);
	_lstArmor = new TextList(160, 48, 73, 88);

	// Set palette
	_game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(4)), Palette::backPos, 16);

	add(_window);
	add(_btnCancel);
	add(_txtTitle);
	add(_txtSoldier);
	add(_txtType);
	add(_txtQuantity);
	add(_lstArmor);

	centerAllSurfaces();

	// Set up objects
	_window->setColor(Palette::blockOffset(13)+10);
	_window->setBackground(_game->getResourcePack()->getSurface("BACK14.SCR"));

	_btnCancel->setColor(Palette::blockOffset(13)+5);
	_btnCancel->setText(_game->getLanguage()->getString("STR_CANCEL_UC"));
	_btnCancel->onMouseClick((ActionHandler)&SoldierArmorState::btnCancelClick);
	_btnCancel->onKeyboardPress((ActionHandler)&SoldierArmorState::btnCancelClick, (SDLKey)Options::getInt("keyCancel"));

	_txtTitle->setColor(Palette::blockOffset(13)+5);
	_txtTitle->setAlign(ALIGN_CENTER);
	_txtTitle->setText(_game->getLanguage()->getString("STR_SELECT_ARMOR_FOR"));

	_txtSoldier->setColor(Palette::blockOffset(13)+5);
	_txtSoldier->setAlign(ALIGN_CENTER);
	Soldier *s = _base->getSoldiers()->at(_soldier);
	_txtSoldier->setText(s->getName());

	_txtType->setColor(Palette::blockOffset(13)+5);
	_txtType->setText(_game->getLanguage()->getString("STR_TYPE"));

	_txtQuantity->setColor(Palette::blockOffset(13)+5);
	_txtQuantity->setText(_game->getLanguage()->getString("STR_QUANTITY_UC"));

	_lstArmor->setColor(Palette::blockOffset(13));
	_lstArmor->setArrowColor(Palette::blockOffset(13)+5);
	_lstArmor->setColumns(2, 112, 41);
	_lstArmor->setSelectable(true);
	_lstArmor->setBackground(_window);
	_lstArmor->setMargin(8);

	const std::vector<std::string> &armors = _game->getRuleset()->getArmorsList();
	for (std::vector<std::string>::const_iterator i = armors.begin(); i != armors.end(); ++i)
	{
		Armor *a = _game->getRuleset()->getArmor(*i);
		if (_base->getItems()->getItem(a->getStoreItem()) > 0)
		{
			_armors.push_back(a);
			std::wstringstream ss;
			ss << _base->getItems()->getItem(a->getStoreItem());
			_lstArmor->addRow(2, _game->getLanguage()->getString(a->getType()).c_str(), ss.str().c_str());
		}
		else if (a->getStoreItem() == "STR_NONE")
		{
			_armors.push_back(a);
			_lstArmor->addRow(1, _game->getLanguage()->getString(a->getType()).c_str());
		}
	}
	_lstArmor->onMouseClick((ActionHandler)&SoldierArmorState::lstArmorClick);
}
コード例 #3
0
ファイル: Soldier.cpp プロジェクト: Rage2Play/Cpp
void Soldier::copy(const Soldier& otherSoldier) {
	setName(otherSoldier.getName());
	setAge(otherSoldier.getAge());
	setSkillpoints(otherSoldier.getSkillpoints());
	setSalary(otherSoldier.getSalary());
}
コード例 #4
0
ファイル: SoldierInfoState.cpp プロジェクト: 2xG/OpenXcom
/**
 * Updates soldier stats when
 * the soldier changes.
 */
void SoldierInfoState::init()
{
	if(_base->getSoldiers()->empty())
	{
		_game->popState();
		return;
	}
	if(_soldier == _base->getSoldiers()->size())
	{
		_soldier = 0;
	}
	Soldier *s = _base->getSoldiers()->at(_soldier);
	_edtSoldier->setText(s->getName());
	UnitStats *initial = s->getInitStats();
	UnitStats *current = s->getCurrentStats();

	SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
	texture->getFrame(s->getRankSprite())->setX(0);
	texture->getFrame(s->getRankSprite())->setY(0);
	texture->getFrame(s->getRankSprite())->blit(_rank);

	std::wstringstream ss;
	ss << current->tu;
	_numTimeUnits->setText(ss.str());
	_barTimeUnits->setMax(current->tu);
	_barTimeUnits->setValue(current->tu);
	_barTimeUnits->setValue2(initial->tu);

	std::wstringstream ss2;
	ss2 << current->stamina;
	_numStamina->setText(ss2.str());
	_barStamina->setMax(current->stamina);
	_barStamina->setValue(current->stamina);
	_barStamina->setValue2(initial->stamina);

	std::wstringstream ss3;
	ss3 << current->health;
	_numHealth->setText(ss3.str());
	_barHealth->setMax(current->health);
	_barHealth->setValue(current->health);
	_barHealth->setValue2(initial->health);

	std::wstringstream ss4;
	ss4 << current->bravery;
	_numBravery->setText(ss4.str());
	_barBravery->setMax(current->bravery);
	_barBravery->setValue(current->bravery);
	_barBravery->setValue2(initial->bravery);

	std::wstringstream ss5;
	ss5 << current->reactions;
	_numReactions->setText(ss5.str());
	_barReactions->setMax(current->reactions);
	_barReactions->setValue(current->reactions);
	_barReactions->setValue2(initial->reactions);

	std::wstringstream ss6;
	ss6 << current->firing;
	_numFiring->setText(ss6.str());
	_barFiring->setMax(current->firing);
	_barFiring->setValue(current->firing);
	_barFiring->setValue2(initial->firing);

	std::wstringstream ss7;
	ss7 << current->throwing;
	_numThrowing->setText(ss7.str());
	_barThrowing->setMax(current->throwing);
	_barThrowing->setValue(current->throwing);
	_barThrowing->setValue2(initial->throwing);

	std::wstringstream ss8;
	ss8 << current->strength;
	_numStrength->setText(ss8.str());
	_barStrength->setMax(current->strength);
	_barStrength->setValue(current->strength);
	_barStrength->setValue2(initial->strength);

	std::wstring wsArmor;
	std::string armorType = s->getArmor()->getType();
	if (armorType == "STR_NONE_UC")
	{
		wsArmor.reserve(15);
		wsArmor = tr("STR_ARMOR");
		wsArmor += L"> ";
		wsArmor += tr(armorType);
	}
	else
		wsArmor = tr(armorType);

	_btnArmor->setText(wsArmor);
//	_txtArmor->setText(tr(s->getArmor()->getType()));

	_btnSack->setVisible(!(s->getCraft() && s->getCraft()->getStatus() == "STR_OUT"));

	std::wstringstream ss9;
	ss9 << tr("STR_RANK_") << L'\x01' << tr(s->getRankString());
	_txtRank->setText(ss9.str());

	std::wstringstream ss10;
	ss10 << tr("STR_MISSIONS") << L'\x01' << s->getMissions();
	_txtMissions->setText(ss10.str());

	std::wstringstream ss11;
	ss11 << tr("STR_KILLS") << L'\x01' << s->getKills();
	_txtKills->setText(ss11.str());

	std::wstringstream ss12;
	ss12 << tr("STR_CRAFT_") << L'\x01';
	if (s->getCraft() == 0)
		ss12 << tr("STR_NONE_UC");
	else
		ss12 << s->getCraft()->getName(_game->getLanguage());
	_txtCraft->setText(ss12.str());

	if (s->getWoundRecovery() > 0)
	{
		std::wstringstream ss13;
		ss13 << tr("STR_WOUND_RECOVERY") << L'\x01' << tr("STR_DAY", s->getWoundRecovery());
		_txtRecovery->setText(ss13.str());
	}
	else
	{
		_txtRecovery->setText(L"");
	}

	_txtPsionic->setVisible(s->isInPsiTraining());

	if(current->psiSkill > 0)
	{
		std::wstringstream ss14;
		ss14 << current->psiStrength;
		_numPsiStrength->setText(ss14.str());
		_barPsiStrength->setMax(current->psiStrength);
		_barPsiStrength->setValue(current->psiStrength);
		_barPsiStrength->setValue2(initial->psiStrength);

		std::wstringstream ss15;
		ss15 << current->psiSkill;
		_numPsiSkill->setText(ss15.str());
		_barPsiSkill->setMax(current->psiSkill);
		_barPsiSkill->setValue(current->psiSkill);
		_barPsiSkill->setValue2(initial->psiSkill);

		_txtPsiStrength->setVisible(true);
		_numPsiStrength->setVisible(true);
		_barPsiStrength->setVisible(true);

		_txtPsiSkill->setVisible(true);
		_numPsiSkill->setVisible(true);
		_barPsiSkill->setVisible(true);
	}
	else
	{
		_txtPsiStrength->setVisible(false);
		_numPsiStrength->setVisible(false);
		_barPsiStrength->setVisible(false);

		_txtPsiSkill->setVisible(false);
		_numPsiSkill->setVisible(false);
		_barPsiSkill->setVisible(false);
	}
}
コード例 #5
0
/**
 * Initializes all the elements in the Soldier Armor window.
 * @param game Pointer to the core game.
 * @param base Pointer to the base to get info from.
 * @param soldier ID of the selected soldier.
 */
SoldierArmorState::SoldierArmorState(Base *base, size_t soldier) : _base(base), _soldier(soldier)
{
	_screen = false;

	// Create objects
	_window = new Window(this, 192, 120, 64, 40, POPUP_BOTH);
	_btnCancel = new TextButton(140, 16, 90, 136);
	_txtTitle = new Text(182, 16, 69, 48);
	_txtType = new Text(90, 9, 80, 72);
	_txtQuantity = new Text(70, 9, 177, 72);
	_lstArmor = new TextList(160, 40, 73, 88);

	// Set palette
	setPalette("PAL_BASESCAPE", _game->getRuleset()->getInterface("soldierArmor")->getElement("palette")->color);

	add(_window, "window", "soldierArmor");
	add(_btnCancel, "button", "soldierArmor");
	add(_txtTitle, "text", "soldierArmor");
	add(_txtType, "text", "soldierArmor");
	add(_txtQuantity, "text", "soldierArmor");
	add(_lstArmor, "list", "soldierArmor");

	centerAllSurfaces();

	// Set up objects
	_window->setBackground(_game->getResourcePack()->getSurface("BACK14.SCR"));

	_btnCancel->setText(tr("STR_CANCEL_UC"));
	_btnCancel->onMouseClick((ActionHandler)&SoldierArmorState::btnCancelClick);
	_btnCancel->onKeyboardPress((ActionHandler)&SoldierArmorState::btnCancelClick, Options::keyCancel);

	Soldier *s = _base->getSoldiers()->at(_soldier);
	_txtTitle->setAlign(ALIGN_CENTER);
	_txtTitle->setText(tr("STR_SELECT_ARMOR_FOR_SOLDIER").arg(s->getName()));

	_txtType->setText(tr("STR_TYPE"));

	_txtQuantity->setText(tr("STR_QUANTITY_UC"));

	_lstArmor->setColumns(2, 112, 41);
	_lstArmor->setSelectable(true);
	_lstArmor->setBackground(_window);
	_lstArmor->setMargin(8);

	const std::vector<std::string> &armors = _game->getRuleset()->getArmorsList();
	for (std::vector<std::string>::const_iterator i = armors.begin(); i != armors.end(); ++i)
	{
		Armor *a = _game->getRuleset()->getArmor(*i);
		if (_base->getItems()->getItem(a->getStoreItem()) > 0)
		{
			_armors.push_back(a);
			std::wostringstream ss;
			if (_game->getSavedGame()->getMonthsPassed() > -1)
			{
				ss << _base->getItems()->getItem(a->getStoreItem());
			}
			else
			{
				ss << "-";
			}
			_lstArmor->addRow(2, tr(a->getType()).c_str(), ss.str().c_str());
		}
		else if (a->getStoreItem() == "STR_NONE")
		{
			_armors.push_back(a);
			_lstArmor->addRow(1, tr(a->getType()).c_str());
		}
	}
	_lstArmor->onMouseClick((ActionHandler)&SoldierArmorState::lstArmorClick);
}
コード例 #6
0
/**
 * Update soldier stats when
 * the soldier changes.
 */
void SoldierInfoState::init()
{
	Soldier *s = _base->getSoldiers()->at(_soldier);
	_edtSoldier->setText(s->getName());

	SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
	texture->getFrame(s->getRankSprite())->setX(0);
	texture->getFrame(s->getRankSprite())->setY(0);
	texture->getFrame(s->getRankSprite())->blit(_rank);

	std::wstringstream ss;
	ss << s->getTimeUnits();
	_numTimeUnits->setText(ss.str());
	_barTimeUnits->setMax(s->getTimeUnits());
	_barTimeUnits->setValue(s->getTimeUnits());

	std::wstringstream ss2;
	ss2 << s->getStamina();
	_numStamina->setText(ss2.str());
	_barStamina->setMax(s->getStamina());
	_barStamina->setValue(s->getStamina());

	std::wstringstream ss3;
	ss3 << s->getHealth();
	_numHealth->setText(ss3.str());
	_barHealth->setMax(s->getHealth());
	_barHealth->setValue(s->getHealth());

	std::wstringstream ss4;
	ss4 << s->getBravery();
	_numBravery->setText(ss4.str());
	_barBravery->setMax(s->getBravery());
	_barBravery->setValue(s->getBravery());

	std::wstringstream ss5;
	ss5 << s->getReactions();
	_numReactions->setText(ss5.str());
	_barReactions->setMax(s->getReactions());
	_barReactions->setValue(s->getReactions());

	std::wstringstream ss6;
	ss6 << s->getFiringAccuracy();
	_numFiring->setText(ss6.str());
	_barFiring->setMax(s->getFiringAccuracy());
	_barFiring->setValue(s->getFiringAccuracy());

	std::wstringstream ss7;
	ss7 << s->getThrowingAccuracy();
	_numThrowing->setText(ss7.str());
	_barThrowing->setMax(s->getThrowingAccuracy());
	_barThrowing->setValue(s->getThrowingAccuracy());

	std::wstringstream ss8;
	ss8 << s->getStrength();
	_numStrength->setText(ss8.str());
	_barStrength->setMax(s->getStrength());
	_barStrength->setValue(s->getStrength());

	_txtArmor->setText(_game->getLanguage()->getString("STR_NONE_UC"));

	std::wstringstream ss9;
	ss9 << _game->getLanguage()->getString("STR_RANK_") << L'\x01' << _game->getLanguage()->getString(s->getRankString());
	_txtRank->setText(ss9.str());

	std::wstringstream ss10;
	ss10 << _game->getLanguage()->getString("STR_MISSIONS") << L'\x01' << s->getMissions();
	_txtMissions->setText(ss10.str());

	std::wstringstream ss11;
	ss11 << _game->getLanguage()->getString("STR_KILLS") << L'\x01' << s->getKills();
	_txtKills->setText(ss11.str());

	std::wstringstream ss12;
	ss12 << _game->getLanguage()->getString("STR_CRAFT_") << L'\x01';
	if (s->getCraft() == 0)
		ss12 << _game->getLanguage()->getString("STR_NONE");
	else
		ss12 << s->getCraft()->getName(_game->getLanguage());
	_txtCraft->setText(ss12.str());
}