MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / addItem

Method addItem

src/Battlescape/ActionMenuState.cpp:155–169  ·  view source on GitHub ↗

* Adds a new menu item for an action. * @param ba Action type. * @param name Action description. * @param id Pointer to the new item ID. */

Source from the content-addressed store, hash-verified

153 * @param id Pointer to the new item ID.
154 */
155void ActionMenuState::addItem(BattleActionType ba, const std::string &name, int *id)
156{
157 std::wstring s1, s2;
158 int acc = _action->actor->getFiringAccuracy(ba, _action->weapon);
159 if (ba == BA_THROW)
160 acc = (int)(_action->actor->getThrowingAccuracy());
161 int tu = _action->actor->getActionTUs(ba, _action->weapon);
162
163 if (ba == BA_THROW || ba == BA_AIMEDSHOT || ba == BA_SNAPSHOT || ba == BA_AUTOSHOT || ba == BA_LAUNCH || ba == BA_HIT)
164 s1 = tr("STR_ACCURACY_SHORT").arg(Text::formatPercentage(acc));
165 s2 = tr("STR_TIME_UNITS_SHORT").arg(tu);
166 _actionMenu[*id]->setAction(ba, tr(name), s1, s2, tu);
167 _actionMenu[*id]->setVisible(true);
168 (*id)++;
169}
170
171/**
172 * Closes the window on right-click.

Callers 14

prepareDebriefingMethod · 0.45
reequipCraftMethod · 0.45
recoverItemsMethod · 0.45
dropItemMethod · 0.45
applyGravityMethod · 0.45
moveItemMethod · 0.45
btnCancelClickMethod · 0.45
btnOkClickMethod · 0.45
btnOkClickMethod · 0.45
btnOkClickMethod · 0.45
lstArmorClickMethod · 0.45
moveLeftByValueMethod · 0.45

Calls 6

getFiringAccuracyMethod · 0.80
getThrowingAccuracyMethod · 0.80
getActionTUsMethod · 0.80
setActionMethod · 0.80
argMethod · 0.60
setVisibleMethod · 0.45

Tested by

no test coverage detected