本文整理汇总了C++中gcn::ActionEvent::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionEvent::getId方法的具体用法?C++ ActionEvent::getId怎么用?C++ ActionEvent::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gcn::ActionEvent
的用法示例。
在下文中一共展示了ActionEvent::getId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: action
void CharCreateDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "create")
{
if (getName().length() >= 4)
{
// Attempt to create the character
mCreateButton->setEnabled(false);
std::vector<int> atts;
// for (unsigned i = 0; i < mAttributeSlider.size(); i++)
// {
// atts.push_back((int) mAttributeSlider[i]->getValue());
// }
atts.push_back(9);
atts.push_back(9);
atts.push_back(9);
atts.push_back(1);
atts.push_back(1);
atts.push_back(1);
Net::getCharHandler()->newCharacter(getName(), mSlot,
mFemale->isSelected(), mHairStyle,
mHairColor, atts);
}
else
{
new OkDialog(_("Error"),
_("Your name needs to be at least 4 characters."),
this);
}
}
else if (event.getId() == "cancel")
scheduleDelete();
else if (event.getId() == "nextcolor")
{
mHairColor++;
updateHair();
}
else if (event.getId() == "prevcolor")
{
mHairColor--;
updateHair();
}
else if (event.getId() == "nextstyle")
{
mHairStyle++;
updateHair();
}
else if (event.getId() == "prevstyle")
{
mHairStyle--;
updateHair();
}
else if (event.getId() == "statslider") {
updateSliders();
}
else if (event.getId() == "gender") {
if (mMale->isSelected()) {
mPlayer->setGender(GENDER_MALE);
} else {
mPlayer->setGender(GENDER_FEMALE);
}
}
}
示例2: action
void TradeWindow::action(const gcn::ActionEvent &event)
{
if (!inventoryWindow)
return;
Item *const item = inventoryWindow->getSelectedItem();
const std::string &eventId = event.getId();
if (eventId == "add")
{
if (mStatus != PREPARING)
return;
if (!inventoryWindow->isWindowVisible())
{
inventoryWindow->setVisible(true);
return;
}
if (!item)
return;
if (mMyInventory->getFreeSlot() == -1)
return;
if (!checkItem(item))
return;
// Choose amount of items to trade
ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd, this, item);
setStatus(PREPARING);
}
else if (eventId == "cancel")
{
setVisible(false);
reset();
PlayerInfo::setTrading(false);
Net::getTradeHandler()->cancel();
}
else if (eventId == "ok")
{
mMoneyField->setEnabled(false);
mAddButton->setEnabled(false);
mMoneyChangeButton->setEnabled(false);
receivedOk(true);
setStatus(PROPOSING);
Net::getTradeHandler()->confirm();
}
else if (eventId == "trade")
{
receivedOk(true);
setStatus(ACCEPTED);
Net::getTradeHandler()->finish();
}
else if (eventId == "money")
{
if (mStatus != PREPARING)
return;
int v = atoi(mMoneyField->getText().c_str());
const int curMoney = PlayerInfo::getAttribute(PlayerInfo::MONEY);
if (v > curMoney)
{
if (localChatTab)
{
// TRANSLATORS: trade error
localChatTab->chatLog(_("You don't have enough money."),
BY_SERVER);
}
v = curMoney;
}
Net::getTradeHandler()->setMoney(v);
mMoneyField->setText(strprintf("%d", v));
}
}
示例3: action
void SellDialog::action(const gcn::ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "quit")
{
close();
return;
}
const int selectedItem = mShopItemList->getSelected();
// The following actions require a valid item selection
if (selectedItem == -1
|| selectedItem >= mShopItems->getNumberOfElements())
{
return;
}
if (eventId == "slider")
{
mAmountItems = static_cast<int>(mSlider->getValue());
updateButtonsAndLabels();
}
else if (eventId == "inc" && mAmountItems < mMaxItems)
{
mAmountItems++;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
else if (eventId == "dec" && mAmountItems > 1)
{
mAmountItems--;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
else if (eventId == "max")
{
mAmountItems = mMaxItems;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
else if ((eventId == "presell" || eventId == "sell" || eventId == "yes")
&& mAmountItems > 0 && mAmountItems <= mMaxItems)
{
if (mNpcId != -1)
{
ShopItem *const item = mShopItems->at(selectedItem);
if (PlayerInfo::isItemProtected(item->getId()))
return;
if (eventId == "presell")
{
const ItemInfo &info = ItemDB::get(item->getId());
if (info.isProtected())
{
ConfirmDialog *const dialog = new ConfirmDialog(
// TRANSLATORS: sell confirmation header
_("sell item"),
// TRANSLATORS: sell confirmation message
strprintf(_("Do you really want to sell %s?"),
info.getName().c_str()), SOUND_REQUEST, false, true);
dialog->postInit();
dialog->addActionListener(this);
return;
}
}
// Attempt sell
mPlayerMoney +=
mAmountItems * mShopItems->at(selectedItem)->getPrice();
mMaxItems -= mAmountItems;
while (mAmountItems > 0)
{
#ifdef MANASERV_SUPPORT
// This order is important, item->getCurrentInvIndex() would
// return the inventory index of the next Duplicate otherwise.
int itemIndex = item->getCurrentInvIndex();
const int sellCount = item->sellCurrentDuplicate(mAmountItems);
// For Manaserv, the Item id is to be given as index.
if ((Net::getNetworkType() == ServerInfo::MANASERV))
itemIndex = item->getId();
#else
// This order is important, item->getCurrentInvIndex() would
// return the inventory index of the next Duplicate otherwise.
const int itemIndex = item->getCurrentInvIndex();
const int sellCount = item->sellCurrentDuplicate(mAmountItems);
#endif
Net::getNpcHandler()->sellItem(mNpcId, itemIndex, sellCount);
mAmountItems -= sellCount;
}
mPlayerMoney +=
mAmountItems * mShopItems->at(selectedItem)->getPrice();
mAmountItems = 1;
mSlider->setValue(0);
if (mMaxItems)
{
updateButtonsAndLabels();
}
else
//.........这里部分代码省略.........