本文整理汇总了C++中Armor::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ Armor::getType方法的具体用法?C++ Armor::getType怎么用?C++ Armor::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Armor
的用法示例。
在下文中一共展示了Armor::getType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lstSoldiersClick
/**
* Shows the Select Armor window.
* @param action Pointer to an action.
*/
void CraftArmorState::lstSoldiersClick(Action *action)
{
Soldier *s = _base->getSoldiers()->at(_lstSoldiers->getSelectedRow());
if (!(s->getCraft() && s->getCraft()->getStatus() == "STR_OUT"))
{
if (action->getDetails()->button.button == SDL_BUTTON_LEFT)
{
_game->pushState(new SoldierArmorState(_base, _lstSoldiers->getSelectedRow()));
}
else
{
if (_game->getSavedGame()->getMonthsPassed() != -1)
{
SavedGame *_save;
_save = _game->getSavedGame();
Armor *a = _game->getRuleset()->getArmor(_save->getLastSelectedArmor());
if (_base->getItems()->getItem(a->getStoreItem()) > 0 || a->getStoreItem() == "STR_NONE")
{
if (s->getArmor()->getStoreItem() != "STR_NONE")
{
_base->getItems()->addItem(s->getArmor()->getStoreItem());
}
if (a->getStoreItem() != "STR_NONE")
{
_base->getItems()->removeItem(a->getStoreItem());
}
s->setArmor(a);
_lstSoldiers->setCellText(_lstSoldiers->getSelectedRow(), 2, tr(a->getType()));
}
}
}
}
}
示例2: lstSoldiersClick
/**
* Shows the Select Armor window.
* @param action Pointer to an action.
*/
void CraftArmorState::lstSoldiersClick(Action *action)
{
Soldier *s = _base->getSoldiers()->at(_lstSoldiers->getSelectedRow());
if (!(s->getCraft() && s->getCraft()->getStatus() == "STR_OUT"))
{
if (action->getDetails()->button.button == SDL_BUTTON_LEFT)
{
_game->pushState(new SoldierArmorState(_base, _lstSoldiers->getSelectedRow()));
}
else if (action->getDetails()->button.button == SDL_BUTTON_RIGHT)
{
SavedGame *save;
save = _game->getSavedGame();
Armor *a = _game->getMod()->getArmor(save->getLastSelectedArmor());
if (a && (a->getUnits().empty() || std::find(a->getUnits().begin(), a->getUnits().end(), s->getRules()->getType()) != a->getUnits().end()))
{
if (save->getMonthsPassed() != -1)
{
if (_base->getStorageItems()->getItem(a->getStoreItem()) > 0 || a->getStoreItem() == Armor::NONE)
{
if (s->getArmor()->getStoreItem() != Armor::NONE)
{
_base->getStorageItems()->addItem(s->getArmor()->getStoreItem());
}
if (a->getStoreItem() != Armor::NONE)
{
_base->getStorageItems()->removeItem(a->getStoreItem());
}
s->setArmor(a);
_lstSoldiers->setCellText(_lstSoldiers->getSelectedRow(), 2, tr(a->getType()));
}
}
else
{
s->setArmor(a);
_lstSoldiers->setCellText(_lstSoldiers->getSelectedRow(), 2, tr(a->getType()));
}
}
}
}
}
示例3: if
/**
* 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);
}
示例4: if
/**
* 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);
}