mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-26 00:40:15 +00:00
Add shift-click spell linking to chat from spellbook
This commit is contained in:
parent
25c5d257ae
commit
f5de4d2031
3 changed files with 36 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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:<spellId>|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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue