diff options
Diffstat (limited to 'src/gui/windows/inventorywindow.cpp')
-rw-r--r-- | src/gui/windows/inventorywindow.cpp | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index ef6cee215..5681e8e04 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -1137,38 +1137,53 @@ void InventoryWindow::attributeChanged(const AttributesT id, } } -void InventoryWindow::combineItems(const int index1, - const int index2) +void InventoryWindow::combineItems(const int srcIndex, + const int dstIndex) { if (mInventory == nullptr) return; - const Item *item1 = mInventory->getItem(index1); - if (item1 == nullptr) + const Item *srcItem = mInventory->getItem(srcIndex); + if (srcItem == nullptr) return; - const Item *item2 = mInventory->getItem(index2); - if (item2 == nullptr) + const Item *dstItem = mInventory->getItem(dstIndex); + if (dstItem == nullptr) return; - if (item1->getType() != ItemType::Card) - { - const Item *tmpItem = item1; - item1 = item2; - item2 = tmpItem; - } + // Build up a total all-that-could-go-wrong list of messages. (note: + // this is a small subset of all the checks that hercules does). + // This way insertion will continue to work even if server removes + // some checks (I would prefer if the server sent failure messages + // itself, but it fails silently). + std::string question + = strprintf( + // TRANSLATORS: question dialog message + _("Insert %s into %s?"), + srcItem->getName().c_str(), + dstItem->getName().c_str()); + + if (srcItem->getType() != ItemType::Card) + // TRANSLATORS: failure reason appended to card insert question + (question += ' ') += _(" Item to be inserted may not be insertable."); + + if (dstItem->isEquipped() == Equipped_true) + // TRANSLATORS: failure reason appended to card insert question + (question += ' ') += _(" Destination item is equipped."); + + if (dstItem->isEquipment() == Equipm_false) + // TRANSLATORS: failure reason appended to card insert question + (question += " ") += _("Inserting into non-equipment items may fail."); ConfirmDialog *const confirmDlg = CREATEWIDGETR(ConfirmDialog, // TRANSLATORS: question dialog title _("Insert card request"), - // TRANSLATORS: question dialog message - strprintf(_("Insert %s into %s?"), - item1->getName().c_str(), - item2->getName().c_str()), + question, SOUND_REQUEST, false, Modal_true, nullptr); - insertCardListener.itemIndex = item2->getInvIndex(); - insertCardListener.cardIndex = item1->getInvIndex(); + + insertCardListener.itemIndex = dstItem->getInvIndex(); + insertCardListener.cardIndex = srcItem->getInvIndex(); confirmDlg->addActionListener(&insertCardListener); } |