* Adds a new menu item for an action. * @param ba Action type. * @param name Action description. * @param id Pointer to the new item ID. */
| 153 | * @param id Pointer to the new item ID. |
| 154 | */ |
| 155 | void 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. |
no test coverage detected