本文整理汇总了C++中RuleItem类的典型用法代码示例。如果您正苦于以下问题:C++ RuleItem类的具体用法?C++ RuleItem怎么用?C++ RuleItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RuleItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onHealClick
/**
* Handler for clicking on the heal button.
* @param action Pointer to an action.
*/
void MedikitState::onHealClick(Action *)
{
int heal = _item->getHealQuantity();
RuleItem *rule = _item->getRules();
if (heal == 0)
{
return;
}
if (_unit->spendTimeUnits (rule->getTUUse()))
{
_targetUnit->heal(_medikitView->getSelectedPart(), rule->getWoundRecovery(), rule->getHealthRecovery());
_item->setHealQuantity(--heal);
_medikitView->updateSelectedPart();
_medikitView->invalidate();
update();
if (_targetUnit->getStatus() == STATUS_UNCONSCIOUS && _targetUnit->getStunlevel() < _targetUnit->getHealth() && _targetUnit->getHealth() > 0)
{
_targetUnit->setTimeUnits(0);
_action->actor->getStatistics()->revivedSoldier++;
}
_unit->getStatistics()->woundsHealed++;
}
else
{
_action->result = "STR_NOT_ENOUGH_TIME_UNITS";
onEndClick(0);
}
}
示例2: setting
bool RuleListModel::realDeserializeData()
{
QSettings setting("Ray Fung", "Excel JSON");
QByteArray json = setting.value("rule_list", QByteArray("[]")).toByteArray();
QJsonDocument doc = QJsonDocument::fromJson(json);
ruleList.clear();
if(doc.isArray() == false)
return false;
QJsonArray array = doc.array();
int count = array.size();
for(int i = 0; i < count; ++i)
{
QJsonValue val = array.at(i);
if(val.isObject() == false)
return false;
QJsonObject data = val.toObject();
RuleData rule;
RuleItem item;
rule.isEnabled = data.value("enable").toBool(true);
rule.excelPath = data.value("excel_path").toString();
rule.jsonPath = data.value("json_path").toString();
item.setRule(rule);
ruleList.append(item);
}
return true;
}
示例3: onStimulantClick
/**
* Handler for clicking on the stimulant button
* @param action Pointer to an action.
*/
void MedikitState::onStimulantClick(Action *)
{
int stimulant = _item->getStimulantQuantity();
RuleItem *rule = _item->getRules();
if (stimulant == 0)
{
return;
}
if (_unit->spendTimeUnits (rule->getTUUse()))
{
_targetUnit->stimulant(rule->getEnergy(), rule->getStun());
_item->setStimulantQuantity(--stimulant);
update();
// if the unit has revived we quit this screen automatically
if (_targetUnit->getStatus() == STATUS_UNCONSCIOUS && _targetUnit->getStunlevel() < _targetUnit->getHealth() && _targetUnit->getHealth() > 0)
{
_targetUnit->setTimeUnits(0);
_game->popState();
}
}
else
{
_action->result = "STR_NOT_ENOUGH_TIME_UNITS";
_game->popState();
}
}
示例4: updateQuantity
/**
* Updates the displayed quantities of the
* selected item on the list.
*/
void CraftEquipmentState::updateQuantity()
{
Craft *c = _base->getCrafts()->at(_craft);
std::wstringstream ss, ss2;
ss << _base->getItems()->getItem(_items[_sel]);
ss2 << c->getItems()->getItem(_items[_sel]);
Uint8 color;
if (c->getItems()->getItem(_items[_sel]) == 0)
{
RuleItem *rule = _game->getRuleset()->getItem(_items[_sel]);
if (rule->getBattleType() == BT_AMMO)
{
color = Palette::blockOffset(15)+6;
}
else
{
color = Palette::blockOffset(13)+10;
}
}
else
{
color = Palette::blockOffset(13);
}
_lstEquipment->setRowColor(_sel, color);
_lstEquipment->setCellText(_sel, 1, ss.str());
_lstEquipment->setCellText(_sel, 2, ss2.str());
}
示例5: State
/**
* Initializes all the elements in the Stores window.
* @param game Pointer to the core game.
* @param base Pointer to the base to get info from.
*/
StoresState::StoresState(Game *game, Base *base) : State(game), _base(base)
{
// Create objects
_window = new Window(this, 320, 200, 0, 0);
_btnOk = new TextButton(300, 16, 10, 176);
_txtTitle = new Text(310, 16, 5, 8);
_txtItem = new Text(142, 8, 10, 32);
_txtQuantity = new Text(88, 8, 152, 32);
_txtSpaceUsed = new Text(74, 8, 240, 32);
_lstStores = new TextList(288, 128, 8, 40);
// Set palette
_game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(0)), Palette::backPos, 16);
add(_window);
add(_btnOk);
add(_txtTitle);
add(_txtItem);
add(_txtQuantity);
add(_txtSpaceUsed);
add(_lstStores);
// Set up objects
_window->setColor(Palette::blockOffset(13)+10);
_window->setBackground(_game->getResourcePack()->getSurface("BACK13.SCR"));
_btnOk->setColor(Palette::blockOffset(13)+10);
_btnOk->setText(_game->getLanguage()->getString("STR_OK"));
_btnOk->onMouseClick((ActionHandler)&StoresState::btnOkClick);
_txtTitle->setColor(Palette::blockOffset(13)+10);
_txtTitle->setBig();
_txtTitle->setAlign(ALIGN_CENTER);
_txtTitle->setText(_game->getLanguage()->getString("STR_STORES"));
_txtItem->setColor(Palette::blockOffset(13)+10);
_txtItem->setText(_game->getLanguage()->getString("STR_ITEM"));
_txtQuantity->setColor(Palette::blockOffset(13)+10);
_txtQuantity->setText(_game->getLanguage()->getString("STR_QUANTITY_UC"));
_txtSpaceUsed->setColor(Palette::blockOffset(13)+10);
_txtSpaceUsed->setText(_game->getLanguage()->getString("STR_SPACE_USED"));
_lstStores->setColor(Palette::blockOffset(13)+10);
_lstStores->setColumns(3, 162, 92, 32);
_lstStores->setSelectable(true);
_lstStores->setBackground(_window);
_lstStores->setMargin(2);
for (std::map<std::string, int>::iterator i = _base->getItems()->getContents()->begin(); i != _base->getItems()->getContents()->end(); ++i)
{
RuleItem *rule = _game->getRuleset()->getItem(i->first);
std::wstringstream ss, ss2;
ss << i->second;
ss2 << i->second * rule->getSize();
_lstStores->addRow(3, _game->getLanguage()->getString(i->first).c_str(), ss.str().c_str(), ss2.str().c_str());
}
}
示例6: setRealData
void RuleListModel::setRealData(const QModelIndex &index, RuleData data)
{
int row = index.row();
RuleItem item;
item.setRule(data);
ruleList[row] = item;
emit QAbstractListModel::dataChanged(index, index);
}
示例7: getClipsLoaded
/*
* get how many clips are loaded into this weapon.
* @param mod a pointer to the core mod.
* @return number of clips loaded.
*/
int CraftWeapon::getClipsLoaded(const Mod *mod)
{
int retVal = (int)floor((double)_ammo / _rules->getRearmRate());
RuleItem *clip = mod->getItem(_rules->getClipItem());
if (clip && clip->getClipSize() > 0)
{
retVal = (int)floor((double)_ammo / clip->getClipSize());
}
return retVal;
}
示例8: updateQuantity
/**
* Updates the displayed quantities of the
* selected item on the list.
*/
void CraftEquipmentState::updateQuantity()
{
Craft *c = _base->getCrafts()->at(_craft);
RuleItem *item = _game->getRuleset()->getItem(_items[_sel]);
int cQty = 0;
if (item->isFixed())
{
cQty = c->getVehicleCount(_items[_sel]);
}
else
{
cQty = c->getItems()->getItem(_items[_sel]);
}
std::wstringstream ss, ss2;
if (_game->getSavedGame()->getMonthsPassed() > -1)
{
ss << _base->getItems()->getItem(_items[_sel]);
}
else
{
ss << "-";
}
ss2 << cQty;
Uint8 color;
if (cQty == 0)
{
RuleItem *rule = _game->getRuleset()->getItem(_items[_sel]);
if (rule->getBattleType() == BT_AMMO)
{
color = Palette::blockOffset(15)+6;
}
else
{
color = Palette::blockOffset(13)+10;
}
}
else
{
color = Palette::blockOffset(13);
}
_lstEquipment->setRowColor(_sel, color);
_lstEquipment->setCellText(_sel, 1, ss.str());
_lstEquipment->setCellText(_sel, 2, ss2.str());
std::wstringstream ss3;
ss3 << tr("STR_SPACE_AVAILABLE") << L'\x01' << c->getSpaceAvailable();
_txtAvailable->setText(ss3.str());
std::wstringstream ss4;
ss4 << tr("STR_SPACE_USED") << L'\x01' << c->getSpaceUsed();
_txtUsed->setText(ss4.str());
}
示例9: onHealClick
/**
* Handler for clicking on the heal button.
* @param action Pointer to an action.
*/
void MedikitState::onHealClick(Action *)
{
int heal = _item->getHealQuantity();
RuleItem *rule = _item->getRules();
if (heal == 0)
{
return;
}
if (_unit->spendTimeUnits(_tu))
{
_targetUnit->heal(_medikitView->getSelectedPart(), rule->getWoundRecovery(), rule->getHealthRecovery());
_item->setHealQuantity(--heal);
_medikitView->updateSelectedPart();
_medikitView->invalidate();
update();
if (_targetUnit->getStatus() == STATUS_UNCONSCIOUS && _targetUnit->getStunlevel() < _targetUnit->getHealth() && _targetUnit->getHealth() > 0)
{
if (!_revivedTarget)
{
_targetUnit->setTimeUnits(0);
if(_targetUnit->getOriginalFaction() == FACTION_PLAYER)
{
_action->actor->getStatistics()->revivedSoldier++;
}
else if(_targetUnit->getOriginalFaction() == FACTION_HOSTILE)
{
_action->actor->getStatistics()->revivedHostile++;
}
else
{
_action->actor->getStatistics()->revivedNeutral++;
}
_revivedTarget = true;
}
// if the unit has revived and has no more wounds, we quit this screen automatically
if (_targetUnit->getFatalWounds() == 0)
{
onEndClick(0);
}
}
_unit->getStatistics()->woundsHealed++;
}
else
{
_action->result = "STR_NOT_ENOUGH_TIME_UNITS";
onEndClick(0);
}
}
示例10: QVariant
QVariant RuleListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
RuleItem item = ruleList.at(index.row());
if(role == Qt::ForegroundRole)
return item.getForegroundColor();
if(role == Qt::DisplayRole)
return item.toString();
return QVariant();
}
示例11: updateQuantity
/**
* Updates the displayed quantities of the
* selected item on the list.
*/
void CraftEquipmentState::updateQuantity()
{
Craft *c = _base->getCrafts()->at(_craft);
RuleItem *item = _game->getMod()->getItem(_items[_sel]);
int cQty = 0;
if (item->isFixed())
{
cQty = c->getVehicleCount(_items[_sel]);
}
else
{
cQty = c->getItems()->getItem(_items[_sel]);
}
std::wostringstream ss, ss2;
if (_game->getSavedGame()->getMonthsPassed() > -1)
{
ss << _base->getStorageItems()->getItem(_items[_sel]);
}
else
{
ss << "-";
}
ss2 << cQty;
Uint8 color;
if (cQty == 0)
{
RuleItem *rule = _game->getMod()->getItem(_items[_sel]);
if (rule->getBattleType() == BT_AMMO)
{
color = _ammoColor;
}
else
{
color = _lstEquipment->getColor();
}
}
else
{
color = _lstEquipment->getSecondaryColor();
}
_lstEquipment->setRowColor(_sel, color);
_lstEquipment->setCellText(_sel, 1, ss.str());
_lstEquipment->setCellText(_sel, 2, ss2.str());
_txtAvailable->setText(tr("STR_SPACE_AVAILABLE").arg(c->getSpaceAvailable()));
_txtUsed->setText(tr("STR_SPACE_USED").arg(c->getSpaceUsed()));
}
示例12: while
/**
* Moves all the items to the base on right-click.
* @param action Pointer to an action.
*/
void CraftEquipmentState::lstEquipmentLeftArrowClick(Action *action)
{
if (action->getDetails()->button.button == SDL_BUTTON_RIGHT)
{
Craft *c = _base->getCrafts()->at(_craft);
RuleItem *item = _game->getRuleset()->getItem(_items[_sel]);
int cQty = 0;
if (item->isFixed())
{
cQty = c->getVehicleCount(_items[_sel]);
if (cQty > 0)
{
while (cQty > 0)
{
RuleItem *ammo = _game->getRuleset()->getItem(item->getCompatibleAmmo()->front());
for (std::vector<Vehicle*>::iterator i = c->getVehicles()->begin(); i != c->getVehicles()->end(); ++i)
{
if ((*i)->getRules() == item)
{
_base->getItems()->addItem(ammo->getType(), (*i)->getAmmo());
delete (*i);
c->getVehicles()->erase(i);
break;
}
}
_base->getItems()->addItem(_items[_sel]);
cQty = c->getVehicleCount(_items[_sel]);
}
updateQuantity();
}
}
else
{
cQty = c->getItems()->getItem(_items[_sel]);
if (cQty > 0)
{
_base->getItems()->addItem(_items[_sel], cQty);
c->getItems()->removeItem(_items[_sel], cQty);
updateQuantity();
}
}
}
}
示例13: onPainKillerClick
/**
* Handler for clicking on the pain killer button.
* @param action Pointer to an action.
*/
void MedikitState::onPainKillerClick(Action *)
{
int pk = _item->getPainKillerQuantity();
RuleItem *rule = _item->getRules();
if (pk == 0)
{
return;
}
if (_unit->spendTimeUnits (rule->getTUUse()))
{
_targetUnit->painKillers();
_item->setPainKillerQuantity(--pk);
update();
}
else
{
_action->result = "STR_NOT_ENOUGH_TIME_UNITS";
onEndClick(0);
}
}
示例14: getQuantity
/**
* Updates the quantity-strings of the selected item.
*/
void SellState::updateItemStrings()
{
std::wostringstream ss, ss2, ss5;
ss << _qtys[_sel];
_lstItems->setCellText(_sel, 2, ss.str());
ss2 << getQuantity() - _qtys[_sel];
_lstItems->setCellText(_sel, 1, ss2.str());
_txtSales->setText(tr("STR_VALUE_OF_SALES").arg(Text::formatFunding(_total)));
if (_qtys[_sel] > 0)
{
_lstItems->setRowColor(_sel, _lstItems->getSecondaryColor());
}
else
{
_lstItems->setRowColor(_sel, _lstItems->getColor());
if (_sel > _itemOffset)
{
RuleItem *rule = _game->getRuleset()->getItem(_items[_sel - _itemOffset]);
if (rule->getBattleType() == BT_AMMO || (rule->getBattleType() == BT_NONE && rule->getClipSize() > 0))
{
_lstItems->setRowColor(_sel, _ammoColor);
}
}
}
ss5 << _base->getUsedStores();
if (std::abs(_spaceChange) > 0.05)
{
ss5 << "(";
if (_spaceChange > 0.05)
ss5 << "+";
ss5 << std::fixed << std::setprecision(1) << _spaceChange << ")";
}
ss5 << ":" << _base->getAvailableStores();
_txtSpaceUsed->setText(tr("STR_SPACE_USED").arg(ss5.str()));
if (Options::storageLimitsEnforced)
{
_btnOk->setVisible(!_base->storesOverfull(_spaceChange));
}
}
示例15: getRow
/**
* Updates the quantity-strings of the selected item.
*/
void SellState::updateItemStrings()
{
std::ostringstream ss, ss2, ss3;
ss << getRow().amount;
_lstItems->setCellText(_sel, 2, ss.str());
ss2 << getRow().qtySrc - getRow().amount;
_lstItems->setCellText(_sel, 1, ss2.str());
_txtSales->setText(tr("STR_VALUE_OF_SALES").arg(Unicode::formatFunding(_total)));
if (getRow().amount > 0)
{
_lstItems->setRowColor(_sel, _lstItems->getSecondaryColor());
}
else
{
_lstItems->setRowColor(_sel, _lstItems->getColor());
if (getRow().type == TRANSFER_ITEM)
{
RuleItem *rule = (RuleItem*)getRow().rule;
if (rule->getBattleType() == BT_AMMO || (rule->getBattleType() == BT_NONE && rule->getClipSize() > 0))
{
_lstItems->setRowColor(_sel, _ammoColor);
}
}
}
ss3 << _base->getUsedStores();
if (std::abs(_spaceChange) > 0.05)
{
ss3 << "(";
if (_spaceChange > 0.05)
ss3 << "+";
ss3 << std::fixed << std::setprecision(1) << _spaceChange << ")";
}
ss3 << ":" << _base->getAvailableStores();
_txtSpaceUsed->setText(tr("STR_SPACE_USED").arg(ss3.str()));
if (Options::storageLimitsEnforced)
{
_btnOk->setVisible(!_base->storesOverfull(_spaceChange));
}
}