diff --git a/NewAge/CataAuraBar/INIT.lua b/NewAge/CataAuraBar/INIT.lua new file mode 100644 index 0000000..de31613 --- /dev/null +++ b/NewAge/CataAuraBar/INIT.lua @@ -0,0 +1,98 @@ +local Aura = { + New = function(self, spellName, index) + o = { + ["name"] = spellName, + ["index"] = index or 1, + } + setmetatable(o, self) + self.__index = self + return o + end, + IsActive = function(self) + aura = self:GetAuraName() + print(UnitAura("player", aura)) + return UnitAura("player", aura) ~= nil + end, + IsOnCooldown = function(self) + return GetSpellCooldown(self.name) > 0 + end, + GetAuraName = function(self) + aura = self.aura + if aura == nil then + aura = self.name + end + return aura + end, + AddAsAura = function(self, allstates) + aura = self:GetAuraName() + duration = select(6, UnitAura("player", aura)) + expirationTime = select(7, UnitAura("player", aura)) + icon = self:GetAuraIcon() + allstates[self.name] = { + changed = true, + show = true, + resort = true, + progressType = "timed", + duration = duration, + expirationTime = expirationTime, + index = self.index, + icon = icon, + } + end, + AddAsCooldown = function(self, allstates) + startTime, duration = GetSpellCooldown(self.name) + icon = self:GetSpellIcon() + allstates[self.name] = { + changed = true, + show = true, + resort = true, + progressType = "timed", + duration = duration, + expirationTime = startTime + duration, + index = self.index, + icon = icon, + } + end, + AddAsIcon = function(self, allstates) + icon = self:GetSpellIcon() + allstates[self.name] = { + changed = true, + show = true, + resort = true, + progressType = "static", + value = 1, + total = 1, + index = self.index, + icon = icon, + } + end, + GetSpellIcon = function(self) + return select(3, GetSpellInfo(self.name)) + end, + GetAuraIcon = function(self) + aura = self:GetAuraName() + spellID = select(11, UnitAura("player", aura)) + return select(3, GetSpellInfo(spellID)) + end, +} + +aura_env.auras = {} +for name in string.gmatch(aura_env.config.spellList, "([a-zA-Z ]+)") do + name = name:gsub("^[ ]+", "") + name = name:gsub("\n$", "") + name = name:gsub("[ ]+$", "") + auraObj = Aura:New(name, #aura_env.auras + 1) + aura_env.auras[#aura_env.auras + 1] = auraObj +end + +aura_env.HandleEvent = function(allstates) + for k, v in ipairs(aura_env.auras) do + if v:IsActive() then + v:AddAsAura(allstates) + elseif v:IsOnCooldown() and not v:IsActive() then + v:AddAsCooldown(allstates) + elseif not v:IsOnCooldown() and not v:IsActive() then + v:AddAsIcon(allstates) + end + end +end \ No newline at end of file diff --git a/NewAge/CataAuraBar/README.md b/NewAge/CataAuraBar/README.md new file mode 100644 index 0000000..528ead0 --- /dev/null +++ b/NewAge/CataAuraBar/README.md @@ -0,0 +1,11 @@ +## While aura is active show aura + +## While aura is inactive and off cooldown show icon + +## While aura is inactive and on cooldown show cooldown + +## Use tsu + +### ACTIONBAR_UPDATE_COOLDOWN when anything on bar goes on cooldown + +### UNIT_AURA with one argument which is unit when aura fades/gets applied \ No newline at end of file diff --git a/NewAge/CataAuraBar/TSU.lua b/NewAge/CataAuraBar/TSU.lua new file mode 100644 index 0000000..a2fc638 --- /dev/null +++ b/NewAge/CataAuraBar/TSU.lua @@ -0,0 +1,12 @@ +function(allstates, e, ...) + for _,v in pairs(allstates) do + v.show = false + v.changed = true + end + + aura_env.HandleEvent(allstates) + return true +end + +-- /run WeakAuras.ScanEvents("SPELL_UPDATE_COOLDOWN") +-- /dump UnitAura("player", "Blessing of Might") \ No newline at end of file