From 5a91422f9946b0e0034cbafdbc1f1d5553617b03 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 28 Jun 2020 12:42:22 +0200 Subject: [PATCH] unitframes: clickcasting option for target or menu --- api/config.lua | 9 ++----- api/unitframes.lua | 65 +++++++++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/api/config.lua b/api/config.lua index b40b0daa..458174b0 100644 --- a/api/config.lua +++ b/api/config.lua @@ -205,17 +205,12 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", nil, "selfinraid", "0") pfUI:UpdateConfig("unitframes", nil, "raidforgroup", "0") - pfUI:UpdateConfig("unitframes", nil, "clickcast", "") + pfUI:UpdateConfig("unitframes", nil, "clickcast", "target") pfUI:UpdateConfig("unitframes", nil, "clickcast_shift", "") pfUI:UpdateConfig("unitframes", nil, "clickcast_alt", "") pfUI:UpdateConfig("unitframes", nil, "clickcast_ctrl", "") - pfUI:UpdateConfig("unitframes", nil, "clickcast", "") - pfUI:UpdateConfig("unitframes", nil, "clickcast_shift", "") - pfUI:UpdateConfig("unitframes", nil, "clickcast_alt", "") - pfUI:UpdateConfig("unitframes", nil, "clickcast_ctrl", "") - - pfUI:UpdateConfig("unitframes", nil, "clickcast2", "") + pfUI:UpdateConfig("unitframes", nil, "clickcast2", "menu") pfUI:UpdateConfig("unitframes", nil, "clickcast2_shift", "") pfUI:UpdateConfig("unitframes", nil, "clickcast2_alt", "") pfUI:UpdateConfig("unitframes", nil, "clickcast2_ctrl", "") diff --git a/api/unitframes.lua b/api/unitframes.lua index 3eb6a257..c42db6d4 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -1700,12 +1700,19 @@ function pfUI.uf:EnableClickCast() self:SetAttribute(prefix.."type"..bid, "macro") self:SetAttribute(prefix.."macrotext"..bid, pfUI_config.unitframes["clickcast"..bconf..mconf]) self:SetAttribute(prefix.."spell"..bid, nil) + elseif string.find(pfUI_config.unitframes["clickcast"..bconf..mconf], "^target") then + self:SetAttribute(prefix.."type"..bid, "target") + self:SetAttribute(prefix.."macrotext"..bid, nil) + self:SetAttribute(prefix.."spell"..bid, nil) + elseif string.find(pfUI_config.unitframes["clickcast"..bconf..mconf], "^menu") then + self:SetAttribute(prefix.."type"..bid, "showmenu") + self:SetAttribute(prefix.."macrotext"..bid, nil) + self:SetAttribute(prefix.."spell"..bid, nil) else self:SetAttribute(prefix.."type"..bid, "spell") self:SetAttribute(prefix.."spell"..bid, pfUI_config.unitframes["clickcast"..bconf..mconf]) self:SetAttribute(prefix.."macro"..bid, nil) end - else -- fill clickaction table for vanillla self.clickactions = self.clickactions or {} @@ -1720,7 +1727,7 @@ function pfUI.uf:ClickAction(button) local label = this.label or "" local id = this.id or "" local unitstr = label .. id - + local showmenu = button == "RightButton" and true or nil if SpellIsTargeting() and button == "RightButton" then SpellStopTargeting() return @@ -1739,35 +1746,45 @@ function pfUI.uf:ClickAction(button) modstring = IsShiftKeyDown() and modstring.."shift" or modstring modstring = modstring..button if this.clickactions and this.clickactions[modstring] then - local tswitch = UnitIsUnit(unitstr, "target") - TargetUnit(unitstr) - - if string.find(this.clickactions[modstring], "^%/(.+)") then - RunMacroText(this.clickactions[modstring]) + if string.find(this.clickactions[modstring], "^menu") then + -- show menu + showmenu = true + elseif string.find(this.clickactions[modstring], "^target") then + -- target unit + showmenu = nil else - CastSpellByName(this.clickactions[modstring]) - end + -- run click cast action + local tswitch = UnitIsUnit(unitstr, "target") + TargetUnit(unitstr) - if not tswitch then TargetLastTarget() end - return + if string.find(this.clickactions[modstring], "^%/(.+)") then + RunMacroText(this.clickactions[modstring]) + else + CastSpellByName(this.clickactions[modstring]) + end + + if not tswitch then TargetLastTarget() end + return + end end -- dropdown menus - if button == "RightButton" then + if showmenu then pfUI.uf:RightClickAction(label) - else - -- drop food on petframe - if label == "pet" and CursorHasItem() then - local _, playerClass = UnitClass("player") - if playerClass == "HUNTER" then - DropItemOnUnit("pet") - return - end - end - - -- default click - TargetUnit(unitstr) + return end + + -- drop food on petframe + if label == "pet" and CursorHasItem() then + local _, playerClass = UnitClass("player") + if playerClass == "HUNTER" then + DropItemOnUnit("pet") + return + end + end + + -- default click + TargetUnit(unitstr) end function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks)