/** * Updates item info. * @param action Pointer to an action. */ void InventoryState::invClick(Action *action) { BattleItem *item = _inv->getSelectedItem(); _txtItem->setText(L""); _txtAmmo->setText(L""); _selAmmo->clear(); if (item != 0) { if (item->getUnit() && item->getUnit()->getStatus() == STATUS_UNCONSCIOUS) { _txtItem->setText(item->getUnit()->getName(_game->getLanguage())); } else { if (_game->getSavedGame()->isResearched(item->getRules()->getRequirements())) { _txtItem->setText(_game->getLanguage()->getString(item->getRules()->getName())); } else { _txtItem->setText(_game->getLanguage()->getString("STR_ALIEN_ARTIFACT")); } } std::wstringstream ss; if (item->getAmmoItem() != 0 && item->needsAmmo()) { ss << _game->getLanguage()->getString("STR_AMMO_ROUNDS_LEFT") << L'\x01' << item->getAmmoItem()->getAmmoQuantity(); SDL_Rect r; r.x = 0; r.y = 0; r.w = RuleInventory::HAND_W * RuleInventory::SLOT_W; r.h = RuleInventory::HAND_H * RuleInventory::SLOT_H; _selAmmo->drawRect(&r, Palette::blockOffset(0)+8); r.x++; r.y++; r.w -= 2; r.h -= 2; _selAmmo->drawRect(&r, 0); item->getAmmoItem()->getRules()->drawHandSprite(_game->getResourcePack()->getSurfaceSet("BIGOBS.PCK"), _selAmmo); } else if (item->getAmmoQuantity() != 0 && item->needsAmmo()) { ss << _game->getLanguage()->getString("STR_AMMO_ROUNDS_LEFT") << L'\x01' << item->getAmmoQuantity(); } _txtAmmo->setText(ss.str()); } if (_tu) { std::wstringstream ss; ss << _game->getLanguage()->getString("STR_TUS") << L'\x01' << _battleGame->getSelectedUnit()->getTimeUnits(); _txtTus->setText(ss.str()); } }
/** * Updates item info. * @param action Pointer to an action. */ void InventoryState::invClick(Action *) { BattleItem *item = _inv->getSelectedItem(); _txtItem->setText(L""); _txtAmmo->setText(L""); _selAmmo->clear(); if (item != 0) { if (item->getUnit() && item->getUnit()->getStatus() == STATUS_UNCONSCIOUS) { _txtItem->setText(item->getUnit()->getName(_game->getLanguage())); } else { if (_game->getSavedGame()->isResearched(item->getRules()->getRequirements())) { _txtItem->setText(tr(item->getRules()->getName())); } else { _txtItem->setText(tr("STR_ALIEN_ARTIFACT")); } } std::wstring s; if (item->getAmmoItem() != 0 && item->needsAmmo()) { s = tr("STR_AMMO_ROUNDS_LEFT").arg(item->getAmmoItem()->getAmmoQuantity()); SDL_Rect r; r.x = 0; r.y = 0; r.w = RuleInventory::HAND_W * RuleInventory::SLOT_W; r.h = RuleInventory::HAND_H * RuleInventory::SLOT_H; _selAmmo->drawRect(&r, Palette::blockOffset(0)+8); r.x++; r.y++; r.w -= 2; r.h -= 2; _selAmmo->drawRect(&r, 0); item->getAmmoItem()->getRules()->drawHandSprite(_game->getResourcePack()->getSurfaceSet("BIGOBS.PCK"), _selAmmo); } else if (item->getAmmoQuantity() != 0 && item->needsAmmo()) { s = tr("STR_AMMO_ROUNDS_LEFT").arg(item->getAmmoQuantity()); } else if (item->getRules()->getBattleType() == BT_MEDIKIT) { s = tr("STR_MEDI_KIT_QUANTITIES_LEFT").arg(item->getPainKillerQuantity()).arg(item->getStimulantQuantity()).arg(item->getHealQuantity()); } _txtAmmo->setText(s); } updateStats(); }
/** * Shows item info. * @param action Pointer to an action. */ void InventoryState::invMouseOver(Action *) { if (_inv->getSelectedItem() != 0) { return; } BattleItem *item = _inv->getMouseOverItem(); if (item != 0) { if (item->getUnit() && item->getUnit()->getStatus() == STATUS_UNCONSCIOUS) { _txtItem->setText(item->getUnit()->getName(_game->getLanguage())); } else { if (_game->getSavedGame()->isResearched(item->getRules()->getRequirements())) { _txtItem->setText(tr(item->getRules()->getName())); } else { _txtItem->setText(tr("STR_ALIEN_ARTIFACT")); } } std::wstring s; if (item->getAmmoItem() != 0 && item->needsAmmo()) { s = tr("STR_AMMO_ROUNDS_LEFT").arg(item->getAmmoItem()->getAmmoQuantity()); SDL_Rect r; r.x = 0; r.y = 0; r.w = RuleInventory::HAND_W * RuleInventory::SLOT_W; r.h = RuleInventory::HAND_H * RuleInventory::SLOT_H; _selAmmo->drawRect(&r, _game->getMod()->getInterface("inventory")->getElement("grid")->color); r.x++; r.y++; r.w -= 2; r.h -= 2; _selAmmo->drawRect(&r, Palette::blockOffset(0)+15); item->getAmmoItem()->getRules()->drawHandSprite(_game->getMod()->getSurfaceSet("BIGOBS.PCK"), _selAmmo); _updateTemplateButtons(false); } else { _selAmmo->clear(); _updateTemplateButtons(!_tu); } if (item->getAmmoQuantity() != 0 && item->needsAmmo()) { s = tr("STR_AMMO_ROUNDS_LEFT").arg(item->getAmmoQuantity()); } else if (item->getRules()->getBattleType() == BT_MEDIKIT) { s = tr("STR_MEDI_KIT_QUANTITIES_LEFT").arg(item->getPainKillerQuantity()).arg(item->getStimulantQuantity()).arg(item->getHealQuantity()); } _txtAmmo->setText(s); } else { if (_currentTooltip.empty()) { _txtItem->setText(L""); } _txtAmmo->setText(L""); _selAmmo->clear(); _updateTemplateButtons(!_tu); } }