当前位置: 首页>>代码示例>>C++>>正文


C++ SurfaceSet::getFrame方法代码示例

本文整理汇总了C++中SurfaceSet::getFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ SurfaceSet::getFrame方法的具体用法?C++ SurfaceSet::getFrame怎么用?C++ SurfaceSet::getFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SurfaceSet的用法示例。


在下文中一共展示了SurfaceSet::getFrame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw

/**
 * Draw the ScannerView view
 */
void ScannerView::draw()
{
	SurfaceSet *set = _game->getResourcePack()->getSurfaceSet("DETBLOB.DAT");
	Surface *surface = 0;

	clear();

	this->lock();
	for (int x = -9; x < 10; x++)
	{
		for (int y = -9; y < 10; y++)
		{
			Tile *t = _game->getSavedGame()->getBattleGame()->getTile(Position(x,y,0) + _unit->getPosition());
			if (t && t->getUnit() && t->getUnit()->getMotionPoints())
			{
				int frame = (t->getUnit()->getMotionPoints() / 5);
				if (frame >= 0)
				{
					if (frame > 5) frame = 5;
					surface = set->getFrame(frame + _frame);
					surface->blitNShade(this, Surface::getX()+((9+x)*8)-4, Surface::getY()+((9+y)*8)-4, 0);
				}
			}
		}
	}

	// the arrow of the direction the unit is pointed
	surface = set->getFrame(7 + _unit->getDirection());

	surface->blitNShade(this, Surface::getX()+(9*8)-4, Surface::getY()+(9*8)-4, 0);
	this->unlock();


}
开发者ID:GregoryBonik,项目名称:OpenXcom,代码行数:37,代码来源:ScannerView.cpp

示例2: drawItemSprite

/**
 * Draws the item's sprite on a surface.
 * @param item the given item
 * @surface surface the given surface
 */
void BattlescapeState::drawItemSprite(BattleItem *item, Surface *surface)
{
	SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BIGOBS.PCK");
	Surface *frame = texture->getFrame(item->getRules()->getBigSprite());
	frame->setX((2 - item->getRules()->getSizeX()) * 8);
	frame->setY((3 - item->getRules()->getSizeY()) * 8);
	texture->getFrame(item->getRules()->getBigSprite())->blit(surface);
}
开发者ID:UnkLegacy,项目名称:OpenXcom,代码行数:13,代码来源:BattlescapeState.cpp

示例3: draw

/**
 * Draws the medikit view.
 */
void MedikitView::draw()
{
	SurfaceSet *set = _game->getMod()->getSurfaceSet("MEDIBITS.DAT");
	int fatal_wound = _unit->getFatalWound(_selectedPart);
	std::wostringstream ss, ss1;
	int green = 0;
	int red = 3;
	if (_game->getMod()->getInterface("medikit") && _game->getMod()->getInterface("medikit")->getElement("body"))
	{
		green = _game->getMod()->getInterface("medikit")->getElement("body")->color;
		red = _game->getMod()->getInterface("medikit")->getElement("body")->color2;
	}
	this->lock();
	for (unsigned int i = 0; i < set->getTotalFrames(); i++)
	{
		int wound = _unit->getFatalWound(i);
		Surface * surface = set->getFrame (i);
		int baseColor = wound ? red : green;
		surface->blitNShade(this, Surface::getX(), Surface::getY(), 0, false, baseColor);
	}
	this->unlock();

	_redraw = false;
	if (_selectedPart == -1)
	{
		return;
	}
	ss << _game->getLanguage()->getString(PARTS_STRING[_selectedPart]);
	ss1 << fatal_wound;
	_partTxt->setText(ss.str());
	_woundTxt->setText(ss1.str());
}
开发者ID:CliffsDover,项目名称:OpenXcom,代码行数:35,代码来源:MedikitView.cpp

示例4: init

/**
 * Update soldier stats when the soldier changes.
 */
void InventoryState::init()
{
	BattleUnit *unit = _battleGame->getSelectedUnit();

	unit->setCache(0);
	_soldier->clear();
	_btnRank->clear();

	_txtName->setText(unit->getName(_game->getLanguage()));
	_inv->setSelectedUnit(unit);
	Soldier *s = _game->getSavedGame()->getSoldier(unit->getId());
	if (s)
	{
		SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
		texture->getFrame(s->getRankSprite())->setX(0);
		texture->getFrame(s->getRankSprite())->setY(0);
		texture->getFrame(s->getRankSprite())->blit(_btnRank);

		std::string look = s->getArmor()->getSpriteInventory();
		if (s->getGender() == GENDER_MALE)
			look += "M";
		else
			look += "F";
		if (s->getLook() == LOOK_BLONDE)
			look += "0";
		if (s->getLook() == LOOK_BROWNHAIR)
			look += "1";
		if (s->getLook() == LOOK_ORIENTAL)
			look += "2";
		if (s->getLook() == LOOK_AFRICAN)
			look += "3";
		look += ".SPK";
		if (!CrossPlatform::fileExists(CrossPlatform::getDataFile("UFOGRAPH/" + look)))
		{
			look = s->getArmor()->getSpriteInventory() + ".SPK";
		}
		_game->getResourcePack()->getSurface(look)->blit(_soldier);
	}
	if (_tu)
	{
		std::wstringstream ss;
		ss << _game->getLanguage()->getString("STR_TUS") << L'\x01' << unit->getTimeUnits();
		_txtTus->setText(ss.str());
	}
}
开发者ID:alienjon,项目名称:OpenXcom,代码行数:48,代码来源:InventoryState.cpp

示例5: init

/**
 * Update soldier stats when the soldier changes.
 */
void InventoryState::init()
{
	BattleUnit *unit = _battleGame->getSelectedUnit();
	unit->setCache(0);
	_soldier->clear();
	_btnRank->clear();

	_txtName->setText(unit->getUnit()->getName(_game->getLanguage()));
	_inv->setSelectedUnit(unit);
	Soldier *s = dynamic_cast<Soldier*>(unit->getUnit());
	if (s)
	{
		SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
		texture->getFrame(s->getRankSprite())->setX(0);
		texture->getFrame(s->getRankSprite())->setY(0);
		texture->getFrame(s->getRankSprite())->blit(_btnRank);

		std::string look = "MAN_0";
		if (s->getGender() == GENDER_MALE)
			look += "M";
		else
			look += "F";
		if (s->getLook() == LOOK_BLONDE)
			look += "0";
		if (s->getLook() == LOOK_BROWNHAIR)
			look += "1";
		if (s->getLook() == LOOK_ORIENTAL)
			look += "2";
		if (s->getLook() == LOOK_AFRICAN)
			look += "3";
		look += ".SPK";
		_game->getResourcePack()->getSurface(look)->blit(_soldier);
	}
	if (_tu)
	{
		std::wstringstream ss;
		ss << _game->getLanguage()->getString("STR_TUS") << L'\x01' << unit->getTimeUnits();
		_txtTus->setText(ss.str());
	}
}
开发者ID:Devanon,项目名称:OpenXcom,代码行数:43,代码来源:InventoryState.cpp

示例6: mouseClick

/**
 * Handles clicks on the medikit view.
 * @param action Pointer to an action.
 * @param state State that the action handlers belong to.
 */
void MedikitView::mouseClick (Action *action, State *)
{
	SurfaceSet *set = _game->getMod()->getSurfaceSet("MEDIBITS.DAT");
	int x = action->getRelativeXMouse() / action->getXScale();
	int y = action->getRelativeYMouse() / action->getYScale();
	for (unsigned int i = 0; i < set->getTotalFrames(); i++)
	{
		Surface * surface = set->getFrame (i);
		if (surface->getPixel(x, y))
		{
			_selectedPart = i;
			_redraw = true;
			break;
		}
	}
}
开发者ID:CliffsDover,项目名称:OpenXcom,代码行数:21,代码来源:MedikitView.cpp

示例7: init

/**
 * 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");
//.........这里部分代码省略.........
开发者ID:alienjon,项目名称:OpenXcom,代码行数:101,代码来源:SoldierInfoState.cpp

示例8: init

/**
 * Updates all soldier stats when the soldier changes.
 */
void InventoryState::init()
{
	State::init();
	BattleUnit *unit = _battleGame->getSelectedUnit();

	// no selected unit, close inventory
	if (unit == 0)
	{
		btnOkClick(0);
		return;
	}
	// skip to the first unit with inventory
	if (!unit->hasInventory())
	{
		if (_parent)
		{
			_parent->selectNextPlayerUnit(false, false, true);
		}
		else
		{
			_battleGame->selectNextPlayerUnit(false, false, true);
		}
		// no available unit, close inventory
		if (_battleGame->getSelectedUnit() == 0 || !_battleGame->getSelectedUnit()->hasInventory())
		{
			// starting a mission with just vehicles
			btnOkClick(0);
			return;
		}
		else
		{
			unit = _battleGame->getSelectedUnit();
		}
	}

	unit->setCache(0);
	_soldier->clear();
	_rank->clear();

	_txtName->setBig();
	_txtName->setText(unit->getName(_game->getLanguage()));
	_inv->setSelectedUnit(unit);
	Soldier *s = unit->getGeoscapeSoldier();
	if (s)
	{
		SurfaceSet *texture = _game->getMod()->getSurfaceSet("SMOKE.PCK");
		texture->getFrame(20 + s->getRank())->setX(0);
		texture->getFrame(20 + s->getRank())->setY(0);
		texture->getFrame(20 + s->getRank())->blit(_rank);

		std::string look = s->getArmor()->getSpriteInventory();
		if (s->getGender() == GENDER_MALE)
			look += "M";
		else
			look += "F";
		if (s->getLook() == LOOK_BLONDE)
			look += "0";
		if (s->getLook() == LOOK_BROWNHAIR)
			look += "1";
		if (s->getLook() == LOOK_ORIENTAL)
			look += "2";
		if (s->getLook() == LOOK_AFRICAN)
			look += "3";
		look += ".SPK";
		const std::set<std::string> &ufographContents = FileMap::getVFolderContents("UFOGRAPH");
		std::string lcaseLook = look;
		std::transform(lcaseLook.begin(), lcaseLook.end(), lcaseLook.begin(), tolower);
		if (ufographContents.find("lcaseLook") == ufographContents.end() && !_game->getMod()->getSurface(look))
		{
			look = s->getArmor()->getSpriteInventory() + ".SPK";
		}
		_game->getMod()->getSurface(look)->blit(_soldier);
	}
	else
	{
		Surface *armorSurface = _game->getMod()->getSurface(unit->getArmor()->getSpriteInventory());
		if (armorSurface)
		{
			armorSurface->blit(_soldier);
		}
	}

	updateStats();
	_refreshMouse();
}
开发者ID:Xracer,项目名称:OXCHD,代码行数:88,代码来源:InventoryState.cpp

示例9: init

/**
 * 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());
//.........这里部分代码省略.........
开发者ID:2xG,项目名称:OpenXcom,代码行数:101,代码来源:SoldierInfoState.cpp

示例10: updateSoldierInfo

/**
 * Updates soldier name/rank/tu/energy/health/morale.
 * @param battleUnit Pointer to current unit.
 */
void BattlescapeState::updateSoldierInfo(BattleUnit *battleUnit)
{
	if (battleUnit == 0)
	{
		_txtName->setText(L"");
		_rank->clear();
		_numTimeUnits->clear();
		_barTimeUnits->clear();
		_barTimeUnits->clear();
		_numEnergy->clear();
		_barEnergy->clear();
		_barEnergy->clear();
		_numHealth->clear();
		_barHealth->clear();
		_barHealth->clear();
		_numMorale->clear();
		_barMorale->clear();
		_barMorale->clear();
		_btnLeftHandItem->clear();
		_btnRightHandItem->clear();
		return;
	}

	_txtName->setText(battleUnit->getUnit()->getName());
	Soldier *soldier = dynamic_cast<Soldier*>(battleUnit->getUnit());
	if (soldier != 0)
	{
		SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
		texture->getFrame(soldier->getRankSprite())->blit(_rank);
	}
	_numTimeUnits->setValue(battleUnit->getTimeUnits());
	_barTimeUnits->setMax(battleUnit->getUnit()->getTimeUnits());
	_barTimeUnits->setValue(battleUnit->getTimeUnits());
	_numEnergy->setValue(battleUnit->getEnergy());
	_barEnergy->setMax(battleUnit->getUnit()->getStamina());
	_barEnergy->setValue(battleUnit->getEnergy());
	_numHealth->setValue(battleUnit->getHealth());
	_barHealth->setMax(battleUnit->getUnit()->getHealth());
	_barHealth->setValue(battleUnit->getHealth());
	_numMorale->setValue(battleUnit->getMorale());
	_barMorale->setMax(100);
	_barMorale->setValue(battleUnit->getMorale());

	BattleItem *leftHandItem = _battleGame->getItemFromUnit(battleUnit, LEFT_HAND);
	_btnLeftHandItem->clear();
	_numAmmoLeft->clear();
	if (leftHandItem)
	{
		drawItemSprite(leftHandItem, _btnLeftHandItem);
		_numAmmoLeft->setValue(leftHandItem->getAmmoQuantity());
	}
	BattleItem *rightHandItem = _battleGame->getItemFromUnit(battleUnit, RIGHT_HAND);
	_btnRightHandItem->clear();
	_numAmmoRight->clear();
	if (rightHandItem)
	{
		drawItemSprite(rightHandItem, _btnRightHandItem);
		_numAmmoRight->setValue(rightHandItem->getAmmoQuantity());
	}

	_battleGame->getTerrainModifier()->calculateFOV(_battleGame->getSelectedUnit());
	for (int i = 0; i < 10; i++)
	{
		_btnVisibleUnit[i]->hide();
		_numVisibleUnit[i]->hide();
		_visibleUnit[i] = 0;
	}
	int j = 0;
	for (std::vector<BattleUnit*>::iterator i = battleUnit->getVisibleUnits()->begin(); i != battleUnit->getVisibleUnits()->end(); i++)
	{
		_btnVisibleUnit[j]->show();
		_numVisibleUnit[j]->show();
		_visibleUnit[j] = (*i);
		j++;
	}
}
开发者ID:UnkLegacy,项目名称:OpenXcom,代码行数:80,代码来源:BattlescapeState.cpp

示例11: init

/**
 * Updates all soldier stats when the soldier changes.
 */
void InventoryState::init()
{
	BattleUnit *unit = _battleGame->getSelectedUnit();

	unit->setCache(0);
	_soldier->clear();
	_btnRank->clear();

	_txtName->setText(unit->getName(_game->getLanguage()));
	_inv->setSelectedUnit(unit);
	Soldier *s = _game->getSavedGame()->getSoldier(unit->getId());
	if (s)
	{
		SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
		texture->getFrame(s->getRankSprite())->setX(0);
		texture->getFrame(s->getRankSprite())->setY(0);
		texture->getFrame(s->getRankSprite())->blit(_btnRank);

		std::string look = s->getArmor()->getSpriteInventory();
		if (s->getGender() == GENDER_MALE)
			look += "M";
		else
			look += "F";
		if (s->getLook() == LOOK_BLONDE)
			look += "0";
		if (s->getLook() == LOOK_BROWNHAIR)
			look += "1";
		if (s->getLook() == LOOK_ORIENTAL)
			look += "2";
		if (s->getLook() == LOOK_AFRICAN)
			look += "3";
		look += ".SPK";
		if (!CrossPlatform::fileExists(CrossPlatform::getDataFile("UFOGRAPH/" + look)))
		{
			look = s->getArmor()->getSpriteInventory() + ".SPK";
		}
		_game->getResourcePack()->getSurface(look)->blit(_soldier);
	}
	if (_showMoreStatsInInventoryView && !_tu)
	{
		std::wstringstream ss2;
		ss2 << _game->getLanguage()->getString("STR_FACCURACY") << L'\x01' << (int)(unit->getStats()->firing * unit->getAccuracyModifier());
		_txtFAcc->setText(ss2.str());

		std::wstringstream ss3;
		ss3 << _game->getLanguage()->getString("STR_REACT") << L'\x01' << unit->getStats()->reactions;
		_txtReact->setText(ss3.str());

		if (unit->getStats()->psiSkill > 0)
		{
			std::wstringstream ss4;
			ss4 << _game->getLanguage()->getString("STR_PSKILL") << L'\x01' << unit->getStats()->psiSkill;
			_txtPSkill->setText(ss4.str());

			std::wstringstream ss5;
			ss5 << _game->getLanguage()->getString("STR_PSTRENGTH") << L'\x01' << unit->getStats()->psiStrength;
			_txtPStr->setText(ss5.str());
		}
		else
		{
			_txtPSkill->setText(L"");
			_txtPStr->setText(L"");
		}
	}
	updateStats();
}
开发者ID:GregoryBonik,项目名称:OpenXcom,代码行数:69,代码来源:InventoryState.cpp

示例12: init

/**
 * Updates all soldier stats when the soldier changes.
 */
void InventoryState::init()
{
	State::init();
	BattleUnit *unit = _battleGame->getSelectedUnit();

	// no selected unit, close inventory
	if (unit == 0)
	{
		btnOkClick(0);
		return;
	}
	// skip to the first unit with inventory
	if (!unit->hasInventory())
	{
		if (_parent)
		{
			_parent->selectNextPlayerUnit(false, false, true);
		}
		else
		{
			_battleGame->selectNextPlayerUnit(false, false, true);
		}
		// no available unit, close inventory
		if (_battleGame->getSelectedUnit() == 0 || !_battleGame->getSelectedUnit()->hasInventory())
		{
			// starting a mission with just vehicles
			btnOkClick(0);
			return;
		}
		else
		{
			unit = _battleGame->getSelectedUnit();
		}
	}

	if (_parent)
		_parent->getMap()->getCamera()->centerOnPosition(unit->getPosition(), false);

	unit->setCache(0);
	_soldier->clear();
	_btnRank->clear();

	_txtName->setBig();
	_txtName->setText(unit->getName(_game->getLanguage()));
	_inv->setSelectedUnit(unit);
	Soldier *s = _game->getSavedGame()->getSoldier(unit->getId());
	if (s)
	{
		SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
		texture->getFrame(s->getRankSprite())->setX(0);
		texture->getFrame(s->getRankSprite())->setY(0);
		texture->getFrame(s->getRankSprite())->blit(_btnRank);

		std::string look = s->getArmor()->getSpriteInventory();
		if (s->getGender() == GENDER_MALE)
			look += "M";
		else
			look += "F";
		if (s->getLook() == LOOK_BLONDE)
			look += "0";
		if (s->getLook() == LOOK_BROWNHAIR)
			look += "1";
		if (s->getLook() == LOOK_ORIENTAL)
			look += "2";
		if (s->getLook() == LOOK_AFRICAN)
			look += "3";
		look += ".SPK";
		if (!CrossPlatform::fileExists(CrossPlatform::getDataFile("UFOGRAPH/" + look)) && !_game->getResourcePack()->getSurface(look))
		{
			look = s->getArmor()->getSpriteInventory() + ".SPK";
		}
		_game->getResourcePack()->getSurface(look)->blit(_soldier);
	}
	else
	{
		Surface *armorSurface = _game->getResourcePack()->getSurface(unit->getArmor()->getSpriteInventory());
		if (armorSurface)
		{
			armorSurface->blit(_soldier);
		}
	}

	updateStats();
}
开发者ID:fibercube,项目名称:OpenXcom,代码行数:87,代码来源:InventoryState.cpp

示例13: init

/**
 * Updates all soldier stats when the soldier changes.
 */
void InventoryState::init()
{
	BattleUnit *unit = _battleGame->getSelectedUnit();

	// no selected unit, close inventory
	if (unit == 0)
	{
		btnOkClick(0);
		return;
	}
	// skip to the first unit with inventory
	if (!unit->hasInventory())
	{
		if (_parent)
		{
			_parent->selectNextPlayerUnit(false, false, true);
		}
		else
		{
			_battleGame->selectNextPlayerUnit(false, false, true);
		}
		// no available unit, close inventory
		if (_battleGame->getSelectedUnit() == 0)
		{
			// starting a mission with just vehicles
			btnOkClick(0);
			return;
		}
		else
		{
			unit = _battleGame->getSelectedUnit();
		}
	}

	if (_parent)
		_parent->getMap()->getCamera()->centerOnPosition(unit->getPosition());

	unit->setCache(0);
	_soldier->clear();
	_btnRank->clear();

	_txtName->setBig();
	_txtName->setText(unit->getName(_game->getLanguage()));
	_inv->setSelectedUnit(unit);
	Soldier *s = _game->getSavedGame()->getSoldier(unit->getId());
	if (s)
	{
		SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK");
		texture->getFrame(s->getRankSprite())->setX(0);
		texture->getFrame(s->getRankSprite())->setY(0);
		texture->getFrame(s->getRankSprite())->blit(_btnRank);

		std::string look = s->getArmor()->getSpriteInventory();
		if (s->getGender() == GENDER_MALE)
			look += "M";
		else
			look += "F";
		if (s->getLook() == LOOK_BLONDE)
			look += "0";
		if (s->getLook() == LOOK_BROWNHAIR)
			look += "1";
		if (s->getLook() == LOOK_ORIENTAL)
			look += "2";
		if (s->getLook() == LOOK_AFRICAN)
			look += "3";
		look += ".SPK";
		if (!CrossPlatform::fileExists(CrossPlatform::getDataFile("UFOGRAPH/" + look)) && !_game->getResourcePack()->getSurface(look))
		{
			look = s->getArmor()->getSpriteInventory() + ".SPK";
		}
		_game->getResourcePack()->getSurface(look)->blit(_soldier);
	}
	else
	{
		Surface *armorSurface = _game->getResourcePack()->getSurface(unit->getArmor()->getSpriteInventory());
		if (armorSurface)
		{
			armorSurface->blit(_soldier);
		}
	}

	if (_showMoreStatsInInventoryView && !_tu)
	{
		std::wstringstream ss2;
		ss2 << tr("STR_FACCURACY") << L'\x01' << (int)(unit->getStats()->firing * unit->getAccuracyModifier());
		_txtFAcc->setText(ss2.str());

		std::wstringstream ss3;
		ss3 << tr("STR_REACT") << L'\x01' << unit->getStats()->reactions;
		_txtReact->setText(ss3.str());

		if (unit->getStats()->psiSkill > 0)
		{
			std::wstringstream ss4;
			ss4 << tr("STR_PSKILL") << L'\x01' << unit->getStats()->psiSkill;
			_txtPSkill->setText(ss4.str());

//.........这里部分代码省略.........
开发者ID:Bleistift33,项目名称:OpenXcom,代码行数:101,代码来源:InventoryState.cpp

示例14: init

/**
 * 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());
}
开发者ID:Gilligan-MN,项目名称:OpenXcom,代码行数:84,代码来源:SoldierInfoState.cpp

示例15: init

/**
 * Updates soldier stats when
 * the soldier changes.
 */
void SoldierInfoState::init()
{
	State::init();
	if (_list->empty())
	{
		_game->popState();
		return;
	}
	if (_soldierId >= _list->size())
	{
		_soldierId = 0;
	}
	_soldier = _list->at(_soldierId);
	_edtSoldier->setBig();
	_edtSoldier->setText(_soldier->getName());
	UnitStats *initial = _soldier->getInitStats();
	UnitStats *current = _soldier->getCurrentStats();

	UnitStats withArmor(*current);
	withArmor += *(_soldier->getArmor()->getStats());

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

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

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

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

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

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

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

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

	std::wostringstream ss8;
	ss8 << withArmor.melee;
	_numMelee->setText(ss8.str());
	_barMelee->setMax(current->melee);
	_barMelee->setValue(withArmor.melee);
	_barMelee->setValue2(std::min(withArmor.melee, initial->melee));

	std::wostringstream ss9;
	ss9 << withArmor.strength;
	_numStrength->setText(ss9.str());
	_barStrength->setMax(current->strength);
	_barStrength->setValue(withArmor.strength);
	_barStrength->setValue2(std::min(withArmor.strength, initial->strength));

	std::wstring wsArmor;
	std::string armorType = _soldier->getArmor()->getType();
	if (armorType == "STR_NONE_UC")
	{
		wsArmor= tr("STR_ARMOR_").arg(tr(armorType));
	}
	else
//.........这里部分代码省略.........
开发者ID:AMDmi3,项目名称:OpenXcom,代码行数:101,代码来源:SoldierInfoState.cpp


注:本文中的SurfaceSet::getFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。