Shift-click bag items to insert item links into chat input

This commit is contained in:
Kelsi 2026-03-11 21:09:42 -07:00
parent e415451f89
commit 43c239ee2f
3 changed files with 45 additions and 0 deletions

View file

@ -511,6 +511,19 @@ void GameScreen::render(game::GameHandler& gameHandler) {
inventoryScreen.setGameHandler(&gameHandler);
inventoryScreen.render(gameHandler.getInventory(), gameHandler.getMoneyCopper());
// Insert item link into chat if player shift-clicked a bag item
{
std::string pendingLink = inventoryScreen.getAndClearPendingChatLink();
if (!pendingLink.empty()) {
size_t curLen = strlen(chatInputBuffer);
if (curLen + pendingLink.size() + 1 < sizeof(chatInputBuffer)) {
strncat(chatInputBuffer, pendingLink.c_str(), sizeof(chatInputBuffer) - curLen - 1);
chatInputMoveCursorToEnd = true;
refocusChatInput = true;
}
}
}
// Character screen (C key toggle handled inside render())
inventoryScreen.renderCharacterScreen(gameHandler);

View file

@ -1737,6 +1737,28 @@ void InventoryScreen::renderItemSlot(game::Inventory& inventory, const game::Ite
}
}
// Shift+left-click: insert item link into chat input
if (ImGui::IsItemHovered() && !holdingItem &&
ImGui::IsMouseClicked(ImGuiMouseButton_Left) &&
ImGui::GetIO().KeyShift &&
item.itemId != 0 && !item.name.empty()) {
// Build WoW item link: |cff<qualHex>|Hitem:<id>:0:0:0:0:0:0:0:0|h[<name>]|h|r
const char* qualHex = "9d9d9d";
switch (item.quality) {
case game::ItemQuality::COMMON: qualHex = "ffffff"; break;
case game::ItemQuality::UNCOMMON: qualHex = "1eff00"; break;
case game::ItemQuality::RARE: qualHex = "0070dd"; break;
case game::ItemQuality::EPIC: qualHex = "a335ee"; break;
case game::ItemQuality::LEGENDARY: qualHex = "ff8000"; break;
default: break;
}
char linkBuf[512];
snprintf(linkBuf, sizeof(linkBuf),
"|cff%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r",
qualHex, item.itemId, item.name.c_str());
pendingChatItemLink_ = linkBuf;
}
if (ImGui::IsItemHovered() && !holdingItem) {
// Pass inventory for backpack/bag items only; equipped items compare against themselves otherwise
const game::Inventory* tooltipInv = (kind == SlotKind::EQUIPMENT) ? nullptr : &inventory;