diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index cd26525..7f727e6 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -3214,6 +3214,70 @@ function Private.ExecEnv.CheckTotemName(totemName, triggerTotemName, triggerTote return true end +-- Queueable Spells +local queueableSpells +local classQueueableSpells = { + ["WARRIOR"] = { + (select(1, GetSpellInfo(78))), -- Heroic Strike + (select(1, GetSpellInfo(845))), -- Cleave + }, + ["HUNTER"] = { + (select(1, GetSpellInfo(2973))), -- Raptor Strike + }, + ["DRUID"] = { + (select(1, GetSpellInfo(6807))), -- Maul + }, + ["DEATHKNIGHT"] = { + (select(1, GetSpellInfo(56815))), -- Rune Strike + }, +} +local class = select(2, UnitClass("player")) +queueableSpells = classQueueableSpells[class] + +local queuedSpellFrame +function WeakAuras.WatchForQueuedSpell() + if not queuedSpellFrame then + queuedSpellFrame = CreateFrame("Frame") + Private.frames["Queued Spell Handler"] = queuedSpellFrame + queuedSpellFrame:RegisterEvent("CURRENT_SPELL_CAST_CHANGED") + + queuedSpellFrame:SetScript("OnEvent", function(self) + local newQueuedSpell + if queueableSpells then + for _, spellName in ipairs(queueableSpells) do + if IsCurrentSpell(spellName) then + newQueuedSpell = spellName + break + end + end + end + if newQueuedSpell ~= self.queuedSpell then + self.queuedSpell = newQueuedSpell + Private.ScanEvents("WA_UNIT_QUEUED_SPELL_CHANGED", "player") + end + end) + end +end + +function WeakAuras.GetQueuedSpell() + return queuedSpellFrame and queuedSpellFrame.queuedSpell +end + +function WeakAuras.GetSpellCost(powerTypeToCheck) + local spellName = UnitCastingInfo("player") + if not spellName then -- not casting so check if it is queued + spellName = WeakAuras.GetQueuedSpell() + end + if spellName then + local _, _, _, powerCost, _, powerType = GetSpellInfo(spellName); + if powerType and powerCost then + if powerType == powerTypeToCheck then + return powerCost; + end + end + end +end + -- Weapon Enchants do local mh = GetInventorySlotInfo("MainHandSlot") diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 87f314d..6fae78a 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -2233,6 +2233,14 @@ Private.event_prototypes = { if trigger.use_ignoreDead or trigger.use_ignoreDisconnected then AddUnitEventForEvents(result, unit, "UNIT_FLAGS") end + -- The api for spell power costs is not meant to be for other units + if trigger.use_showCost and trigger.unit == "player" then + AddUnitEventForEvents(result, "player", "UNIT_SPELLCAST_START") + AddUnitEventForEvents(result, "player", "UNIT_SPELLCAST_STOP") + AddUnitEventForEvents(result, "player", "UNIT_SPELLCAST_FAILED") + AddUnitEventForEvents(result, "player", "UNIT_SPELLCAST_SUCCEEDED") + AddUnitEventForEvents(result, "player", "UPDATE_SHAPESHIFT_FORM") + end if unit and not Private.multiUnitUnits[unit] then if not result.events then result.events = {} @@ -2255,9 +2263,15 @@ Private.event_prototypes = { if trigger.use_specId then AddUnitSpecChangeInternalEvents(unit, result) end + if trigger.use_showCost and trigger.unit == "player" then + tinsert(result, "WA_UNIT_QUEUED_SPELL_CHANGED"); + end return result end, loadFunc = function(trigger) + if trigger.use_showCost and trigger.unit == "player" then + WeakAuras.WatchForQueuedSpell() + end local includePets = trigger.use_includePets == true and trigger.includePets or nil AddWatchedUnits(trigger.unit, includePets) end, @@ -2277,6 +2291,25 @@ Private.event_prototypes = { table.insert(ret, unitHelperFunctions.SpecificUnitCheck(trigger)) + local canEnableShowCost = (not trigger.use_powertype) and trigger.unit == "player"; + if (canEnableShowCost and trigger.use_showCost) then + table.insert(ret, [[ + if (event == "UPDATE_SHAPESHIFT_FORM") then + local cost = WeakAuras.GetSpellCost(powerTypeToCheck) + if state.cost ~= cost then + state.cost = cost + state.changed = true + end + elseif ( (event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_SUCCEEDED") and unit == "player") or event == "WA_UNIT_QUEUED_SPELL_CHANGED" then + local cost = WeakAuras.GetSpellCost(powerTypeToCheck) + if state.cost ~= cost then + state.cost = cost + state.changed = true + end + end + ]]) + end + return table.concat(ret) end, statesParameter = "unit", @@ -2312,6 +2345,16 @@ Private.event_prototypes = { return trigger.use_powertype end, }, + { + name = "showCost", + display = L["Overlay Cost of Casts"], + type = "toggle", + test = "true", + enable = function(trigger) + return (not trigger.use_powertype) and trigger.unit == "player"; + end, + reloadOptions = true + }, { name = "power", display = L["Power"], @@ -2574,6 +2617,17 @@ Private.event_prototypes = { test = "WeakAuras.UnitExistsFixed(unit, smart) and specificUnitCheck" } }, + overlayFuncs = { + { + name = L["Spell Cost"], + func = function(trigger, state) + return "back", type(state.cost) == "number" and state.cost; + end, + enable = function(trigger) + return trigger.use_showCost and (not trigger.use_powertype) and trigger.unit == "player"; + end + }, + }, automaticrequired = true }, ["Combat Log"] = { diff --git a/WeakAurasOptions/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua b/WeakAurasOptions/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua index ebc94a7..db4ae7a 100644 --- a/WeakAurasOptions/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua +++ b/WeakAurasOptions/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua @@ -1,4 +1,4 @@ -local Type, Version = "MultiLineEditBox", 28 +local Type, Version = "MultiLineEditBox", 33 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end @@ -10,10 +10,6 @@ local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, Cl local CreateFrame, UIParent = CreateFrame, UIParent local _G = _G --- Global vars/functions that we don't upvalue since they might get hooked, or upgraded --- List them here for Mikk's FindGlobals script --- GLOBALS: ACCEPT, ChatFontNormal - --[[----------------------------------------------------------------------------- Support functions -------------------------------------------------------------------------------]] @@ -145,6 +141,14 @@ local function OnVerticalScroll(self, offset) editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight()) end +local function OnScrollRangeChanged(self, xrange, yrange) + if yrange == 0 then + self.obj.editBox:SetHitRectInsets(0, 0, 0, 0) + else + OnVerticalScroll(self, self:GetVerticalScroll()) + end +end + local function OnShowFocus(frame) frame.obj.editBox:SetFocus() frame:SetScript("OnShow", nil) @@ -257,8 +261,6 @@ local methods = { ["SetCursorPosition"] = function(self, ...) return self.editBox:SetCursorPosition(...) end, - - } --[[----------------------------------------------------------------------------- @@ -283,7 +285,7 @@ local function Constructor() label:SetText(ACCEPT) label:SetHeight(10) - local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate2") + local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate") button:SetPoint("BOTTOMLEFT", 0, 4) button:SetHeight(22) button:SetWidth(label:GetStringWidth() + 24) @@ -321,6 +323,7 @@ local function Constructor() scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag) scrollFrame:SetScript("OnSizeChanged", OnSizeChanged) scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll) + scrollFrame:HookScript("OnScrollRangeChanged", OnScrollRangeChanged) local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame) editBox:SetAllPoints() diff --git a/WeakAurasOptions/OptionsFrames/TextEditor.lua b/WeakAurasOptions/OptionsFrames/TextEditor.lua index ccf294c..c4e932f 100644 --- a/WeakAurasOptions/OptionsFrames/TextEditor.lua +++ b/WeakAurasOptions/OptionsFrames/TextEditor.lua @@ -509,7 +509,6 @@ local function ConstructTextEditor(frame) "OnKeyDown", function(self, key) -- CTRL + S saves and closes - print(IsControlKeyDown(), key) if IsControlKeyDown() and key == "S" then group:Close() elseif IsControlKeyDown() and key == "Z" then