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


C++ Armor::getStoreItem方法代码示例

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


在下文中一共展示了Armor::getStoreItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()));
                }
            }
        }
    }
}
开发者ID:FalkoOXC,项目名称:OpenXcom,代码行数:38,代码来源:CraftArmorState.cpp

示例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()));
                }
            }
        }
    }
}
开发者ID:R1dO,项目名称:OpenXcom,代码行数:46,代码来源:CraftArmorState.cpp

示例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);
}
开发者ID:Arthur1994,项目名称:OpenXcom,代码行数:82,代码来源:SoldierArmorState.cpp

示例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);
}
开发者ID:stavrossk,项目名称:OpenXcom,代码行数:76,代码来源:SoldierArmorState.cpp

示例5: Window


//.........这里部分代码省略.........

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

    _txtSell->setText(tr("STR_SELL_SACK"));

    _txtValue->setText(tr("STR_VALUE"));

    _lstItems->setArrowColumn(182, ARROW_VERTICAL);
    _lstItems->setColumns(4, 156, 54, 24, 53);
    _lstItems->setSelectable(true);
    _lstItems->setBackground(_window);
    _lstItems->setMargin(2);
    _lstItems->onLeftArrowPress((ActionHandler)&SellState::lstItemsLeftArrowPress);
    _lstItems->onLeftArrowRelease((ActionHandler)&SellState::lstItemsLeftArrowRelease);
    _lstItems->onLeftArrowClick((ActionHandler)&SellState::lstItemsLeftArrowClick);
    _lstItems->onRightArrowPress((ActionHandler)&SellState::lstItemsRightArrowPress);
    _lstItems->onRightArrowRelease((ActionHandler)&SellState::lstItemsRightArrowRelease);
    _lstItems->onRightArrowClick((ActionHandler)&SellState::lstItemsRightArrowClick);
    _lstItems->onMousePress((ActionHandler)&SellState::lstItemsMousePress);

    _cats.push_back("STR_ALL_ITEMS");

    const std::vector<std::string> &cw = _game->getMod()->getCraftWeaponsList();
    for (std::vector<std::string>::const_iterator i = cw.begin(); i != cw.end(); ++i)
    {
        RuleCraftWeapon *rule = _game->getMod()->getCraftWeapon(*i);
        _craftWeapons.insert(rule->getLauncherItem());
        _craftWeapons.insert(rule->getClipItem());
    }
    const std::vector<std::string> &ar = _game->getMod()->getArmorsList();
    for (std::vector<std::string>::const_iterator i = ar.begin(); i != ar.end(); ++i)
    {
        Armor *rule = _game->getMod()->getArmor(*i);
        _armors.insert(rule->getStoreItem());
    }

    for (std::vector<Soldier*>::iterator i = _base->getSoldiers()->begin(); i != _base->getSoldiers()->end(); ++i)
    {
        if ((*i)->getCraft() == 0)
        {
            TransferRow row = { TRANSFER_SOLDIER, (*i), (*i)->getName(true), 0, 1, 0, 0 };
            _items.push_back(row);
            std::string cat = getCategory(_items.size() - 1);
            if (std::find(_cats.begin(), _cats.end(), cat) == _cats.end())
            {
                _cats.push_back(cat);
            }
        }
    }
    for (std::vector<Craft*>::iterator i = _base->getCrafts()->begin(); i != _base->getCrafts()->end(); ++i)
    {
        if ((*i)->getStatus() != "STR_OUT")
        {
            TransferRow row = { TRANSFER_CRAFT, (*i), (*i)->getName(_game->getLanguage()), (*i)->getRules()->getSellCost(), 1, 0, 0 };
            _items.push_back(row);
            std::string cat = getCategory(_items.size() - 1);
            if (std::find(_cats.begin(), _cats.end(), cat) == _cats.end())
            {
                _cats.push_back(cat);
            }
        }
    }
    if (_base->getAvailableScientists() > 0)
    {
        TransferRow row = { TRANSFER_SCIENTIST, 0, tr("STR_SCIENTIST"), 0, _base->getAvailableScientists(), 0, 0 };
        _items.push_back(row);
开发者ID:MeridianOXC,项目名称:OpenXcom,代码行数:67,代码来源:SellState.cpp


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