* 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. */
| 44 | * @param soldier ID of the selected soldier. |
| 45 | */ |
| 46 | SoldierArmorState::SoldierArmorState(Game *game, Base *base, size_t soldier) : State(game), _base(base), _soldier(soldier) |
| 47 | { |
| 48 | _screen = false; |
| 49 | |
| 50 | // Create objects |
| 51 | _window = new Window(this, 192, 120, 64, 40, POPUP_BOTH); |
| 52 | _btnCancel = new TextButton(140, 16, 90, 136); |
| 53 | _txtTitle = new Text(182, 16, 69, 48); |
| 54 | _txtType = new Text(90, 9, 80, 72); |
| 55 | _txtQuantity = new Text(70, 9, 177, 72); |
| 56 | _lstArmor = new TextList(160, 40, 73, 88); |
| 57 | |
| 58 | // Set palette |
| 59 | setPalette("PAL_BASESCAPE", 4); |
| 60 | |
| 61 | add(_window); |
| 62 | add(_btnCancel); |
| 63 | add(_txtTitle); |
| 64 | add(_txtType); |
| 65 | add(_txtQuantity); |
| 66 | add(_lstArmor); |
| 67 | |
| 68 | centerAllSurfaces(); |
| 69 | |
| 70 | // Set up objects |
| 71 | _window->setColor(Palette::blockOffset(13)+10); |
| 72 | _window->setBackground(_game->getResourcePack()->getSurface("BACK14.SCR")); |
| 73 | |
| 74 | _btnCancel->setColor(Palette::blockOffset(13)+5); |
| 75 | _btnCancel->setText(tr("STR_CANCEL_UC")); |
| 76 | _btnCancel->onMouseClick((ActionHandler)&SoldierArmorState::btnCancelClick); |
| 77 | _btnCancel->onKeyboardPress((ActionHandler)&SoldierArmorState::btnCancelClick, Options::keyCancel); |
| 78 | |
| 79 | Soldier *s = _base->getSoldiers()->at(_soldier); |
| 80 | _txtTitle->setColor(Palette::blockOffset(13)+5); |
| 81 | _txtTitle->setAlign(ALIGN_CENTER); |
| 82 | _txtTitle->setText(tr("STR_SELECT_ARMOR_FOR_SOLDIER").arg(s->getName())); |
| 83 | |
| 84 | _txtType->setColor(Palette::blockOffset(13)+5); |
| 85 | _txtType->setText(tr("STR_TYPE")); |
| 86 | |
| 87 | _txtQuantity->setColor(Palette::blockOffset(13)+5); |
| 88 | _txtQuantity->setText(tr("STR_QUANTITY_UC")); |
| 89 | |
| 90 | _lstArmor->setColor(Palette::blockOffset(13)); |
| 91 | _lstArmor->setArrowColor(Palette::blockOffset(13)+5); |
| 92 | _lstArmor->setColumns(2, 112, 41); |
| 93 | _lstArmor->setSelectable(true); |
| 94 | _lstArmor->setBackground(_window); |
| 95 | _lstArmor->setMargin(8); |
| 96 | |
| 97 | const std::vector<std::string> &armors = _game->getRuleset()->getArmorsList(); |
| 98 | for (std::vector<std::string>::const_iterator i = armors.begin(); i != armors.end(); ++i) |
| 99 | { |
| 100 | Armor *a = _game->getRuleset()->getArmor(*i); |
| 101 | if (_base->getItems()->getItem(a->getStoreItem()) > 0) |
| 102 | { |
| 103 | _armors.push_back(a); |
nothing calls this directly
no test coverage detected