diff --git a/include/ui/spellbook_screen.hpp b/include/ui/spellbook_screen.hpp index 470cb233..6cc13270 100644 --- a/include/ui/spellbook_screen.hpp +++ b/include/ui/spellbook_screen.hpp @@ -54,6 +54,13 @@ public: uint32_t getDragSpellId() const { return dragSpellId_; } void consumeDragSpell() { draggingSpell_ = false; dragSpellId_ = 0; dragSpellIconTex_ = VK_NULL_HANDLE; } + /// Returns a WoW spell link string if the user shift-clicked a spell, then clears it. + std::string getAndClearPendingChatLink() { + std::string out = std::move(pendingChatSpellLink_); + pendingChatSpellLink_.clear(); + return out; + } + private: bool open = false; bool pKeyWasDown = false; @@ -87,6 +94,9 @@ private: uint32_t dragSpellId_ = 0; VkDescriptorSet dragSpellIconTex_ = VK_NULL_HANDLE; + // Pending chat spell link from shift-click + std::string pendingChatSpellLink_; + void loadSpellDBC(pipeline::AssetManager* assetManager); void loadSpellIconDBC(pipeline::AssetManager* assetManager); void loadSkillLineDBCs(pipeline::AssetManager* assetManager); diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 2bce02a7..99c0fe77 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -476,6 +476,19 @@ void GameScreen::render(game::GameHandler& gameHandler) { // Spellbook (P key toggle handled inside) spellbookScreen.render(gameHandler, core::Application::getInstance().getAssetManager()); + // Insert spell link into chat if player shift-clicked a spellbook entry + { + std::string pendingSpellLink = spellbookScreen.getAndClearPendingChatLink(); + if (!pendingSpellLink.empty()) { + size_t curLen = strlen(chatInputBuffer); + if (curLen + pendingSpellLink.size() + 1 < sizeof(chatInputBuffer)) { + strncat(chatInputBuffer, pendingSpellLink.c_str(), sizeof(chatInputBuffer) - curLen - 1); + chatInputMoveCursorToEnd = true; + refocusChatInput = true; + } + } + } + // Talents (N key toggle handled inside) talentScreen.render(gameHandler); diff --git a/src/ui/spellbook_screen.cpp b/src/ui/spellbook_screen.cpp index 8f3edb0f..bed0dbf0 100644 --- a/src/ui/spellbook_screen.cpp +++ b/src/ui/spellbook_screen.cpp @@ -757,15 +757,25 @@ void SpellbookScreen::render(game::GameHandler& gameHandler, pipeline::AssetMana // Interaction if (rowHovered) { - // Start drag on click (not passive) - if (rowClicked && !isPassive) { + // Shift-click to insert spell link into chat + if (rowClicked && ImGui::GetIO().KeyShift && !info->name.empty()) { + // WoW spell link format: |cffffd000|Hspell:|h[Name]|h|r + char linkBuf[256]; + snprintf(linkBuf, sizeof(linkBuf), + "|cffffd000|Hspell:%u|h[%s]|h|r", + info->spellId, info->name.c_str()); + pendingChatSpellLink_ = linkBuf; + } + // Start drag on click (not passive, not shift-click) + else if (rowClicked && !isPassive && !ImGui::GetIO().KeyShift) { draggingSpell_ = true; dragSpellId_ = info->spellId; dragSpellIconTex_ = iconTex; } // Double-click to cast - if (ImGui::IsMouseDoubleClicked(0) && !isPassive && !onCooldown) { + if (ImGui::IsMouseDoubleClicked(0) && !isPassive && !onCooldown + && !ImGui::GetIO().KeyShift) { draggingSpell_ = false; dragSpellId_ = 0; dragSpellIconTex_ = VK_NULL_HANDLE;