From 43c239ee2f1d8fa2a2f358307c13321f270f9f2b Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 11 Mar 2026 21:09:42 -0700 Subject: [PATCH] Shift-click bag items to insert item links into chat input --- include/ui/inventory_screen.hpp | 10 ++++++++++ src/ui/game_screen.cpp | 13 +++++++++++++ src/ui/inventory_screen.cpp | 22 ++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/include/ui/inventory_screen.hpp b/include/ui/inventory_screen.hpp index bfca779f..9d4f18ef 100644 --- a/include/ui/inventory_screen.hpp +++ b/include/ui/inventory_screen.hpp @@ -176,6 +176,9 @@ private: int dropBackpackIndex_ = -1; std::string dropItemName_; + // Pending chat item link from shift-click + std::string pendingChatItemLink_; + public: static ImVec4 getQualityColor(game::ItemQuality quality); @@ -190,6 +193,13 @@ public: /// Drop the currently held item into a specific equipment slot. /// Returns true if the drop was accepted and consumed. bool dropHeldItemToEquipSlot(game::Inventory& inv, game::EquipSlot slot); + /// Returns a WoW item link string if the user shift-clicked a bag item, then clears it. + std::string getAndClearPendingChatLink() { + std::string out = std::move(pendingChatItemLink_); + pendingChatItemLink_.clear(); + return out; + } + /// Drop the currently held item into a bank slot via CMSG_SWAP_ITEM. void dropIntoBankSlot(game::GameHandler& gh, uint8_t dstBag, uint8_t dstSlot); /// Pick up an item from main bank slot (click-and-hold from bank window). diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index bd22b369..4a14980b 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -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); diff --git a/src/ui/inventory_screen.cpp b/src/ui/inventory_screen.cpp index 7899d654..12c8ff9f 100644 --- a/src/ui/inventory_screen.cpp +++ b/src/ui/inventory_screen.cpp @@ -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|Hitem::0:0:0:0:0:0:0:0|h[]|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;