summaryrefslogtreecommitdiff
path: root/src/gui/windows/inventorywindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows/inventorywindow.cpp')
-rw-r--r--src/gui/windows/inventorywindow.cpp57
1 files changed, 36 insertions, 21 deletions
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 41d34df13..5681e8e04 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -1,11 +1,11 @@
/*
- * The ManaPlus Client
+ * The ManaVerse Client
* Copyright (C) 2004-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011-2020 The ManaPlus Developers
- * Copyright (C) 2020-2023 The ManaVerse Developers
+ * Copyright (C) 2020-2025 The ManaVerse Developers
*
- * This file is part of The ManaPlus Client.
+ * This file is part of The ManaVerse Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -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);
}