A Deviate Faerie Dragon
Join Date: Jul 2012
Posts: 11
|
gxCD: few Spells not showing
gxCooldowns isn't showing a few Spells such as:
- Nature's Swiftness(ID#132158)
- Incarnation: Tree of Life (ID#5420/81097/81098)
- Chi Torpedo: (ID#124040/117993) Roll works tho (ID#109132) (I think Chi Torpedo is modified by an Talent, but idk, never touched a Monk so far)
- Tranquility via Symbiosis: (ID#113277)
I've tried to look into this, and as LuA noob I'm certainly facing my limits right now.
I already tried adding the spells via name/id in the White list, but it didn't worked.
Anyone got some tips how i can fix it? Also some guidance would be nice (if its not to much to ask for) so i can fix it next time myself (and learn from it as well)
configuration.lua
Lua Code:
local aName, aTable = ... local floor = math.floor local format = string.format local tinsert = table.insert local next = next local tremove = table.remove local select = select local sort = table.sort local tonumber = tonumber local Button = LibStub("tekKonfig-Button") local Dropdown = LibStub("tekKonfig-Dropdown") local Group = LibStub("tekKonfig-Group") local Heading = LibStub("tekKonfig-Heading") local Scroll = LibStub("tekKonfig-Scroll") local Slider = LibStub("tekKonfig-Slider") local GetItemInfo = GetItemInfo local GetItemSpell = GetItemSpell local GetSpellInfo = GetSpellInfo local GetSpellLink = GetSpellLink local defaults = { blacklist = {}, minDuration = 1.5, maxDuration = 3600, items = { }, style = { "Blizzard", -- Skin name 0.5, -- Gloss alpha true -- Use backdrop }, scale = 1, gap = 10, growth = "Left and Right", xOffset = 0, yOffset = 0, } local addMainOptions = function(self) local title = Heading.new(self, "gxCooldowns") local mainGroup = Group.new(self, "Settings") mainGroup:SetPoint("TOP", title, "BOTTOM", 0, -20) mainGroup:SetPoint("BOTTOMLEFT", 16, 16) mainGroup:SetPoint("BOTTOMRIGHT", -16, 16) local dropdown, dText = Dropdown.new(mainGroup, "Growth", "TOPLEFT", mainGroup, "TOPLEFT", 15, -10) dText:SetText(gxCooldownsDB.growth) local OnClick = function(self) UIDropDownMenu_SetSelectedValue(dropdown, self.value) dText:SetText(self.value) aTable.updateFrames(self.value) end UIDropDownMenu_Initialize(dropdown, function() local selected, info = UIDropDownMenu_GetSelectedValue(dropdown) or gxCooldownsDB.growth, UIDropDownMenu_CreateInfo() for name in next, aTable.growthValues do info.text = name info.value = name info.func = OnClick info.checked = name == selected UIDropDownMenu_AddButton(info) end end) local scale, scaleText = Slider.new(mainGroup, format("Scale: %.2f", gxCooldownsDB.scale), 0.5, 2) scale:SetPoint("TOPLEFT", mainGroup, "TOPLEFT", 20, -90) scale:SetPoint("TOPRIGHT", mainGroup, "TOP", -15, -90) scale:SetValue(gxCooldownsDB.scale) scale:SetValueStep(.05) scale:SetScript("OnValueChanged", function(self) local scale = self:GetValue() scaleText:SetText(format("Scale: %.2f", scale)) aTable.setScale(scale) end) local gap, gapText = Slider.new(mainGroup, "Gap: " .. gxCooldownsDB.gap, -10, 25) gap:SetPoint("TOPRIGHT", mainGroup, "TOPRIGHT", -20, -90) gap:SetPoint("TOPLEFT", mainGroup, "TOP", 15, -90) gap:SetValue(gxCooldownsDB.gap) gap:SetValueStep(1) gap:SetScript("OnValueChanged", function(self) local gap = self:GetValue() gapText:SetText("Gap: " .. gap) aTable.setGap(gap) end) local minDur, minDurText = Slider.new(mainGroup, "Minimum duration: " .. gxCooldownsDB.minDuration, 1.5, 10) minDur:SetPoint("TOPLEFT", scale, "BOTTOMLEFT", 0, -40) minDur:SetPoint("TOPRIGHT", scale, "BOTTOMRIGHT", 0, -40) minDur:SetValue(gxCooldownsDB.minDuration) minDur:SetValueStep(.5) minDur:SetScript("OnValueChanged", function(self) local dur = self:GetValue() minDurText:SetText("Minimum duration: " .. dur) gxCooldownsDB.minDuration = dur end) local maxDur, maxDurText = Slider.new(mainGroup, format("Maximum duration: %.1fm", gxCooldownsDB.maxDuration/60), 10, 60*60) maxDur:SetPoint("TOPLEFT", gap, "BOTTOMLEFT", 0, -40) maxDur:SetPoint("TOPRIGHT", gap, "BOTTOMRIGHT", 0, -40) maxDur:SetValue(gxCooldownsDB.maxDuration) maxDur:SetValueStep(5) maxDur:SetScript("OnValueChanged", function(self) local dur = self:GetValue() maxDurText:SetText(format("Maximum duration: %.1fm", dur/60)) gxCooldownsDB.maxDuration = dur end) local x = CreateFrame("EditBox", "gxCooldownsConfigX", mainGroup, "InputBoxTemplate") x:SetPoint("TOPLEFT", minDur, "BOTTOMLEFT", 0, -40) x:SetPoint("TOPRIGHT", minDur, "BOTTOMRIGHT", 0, -40) x:SetHeight(30) x:SetAutoFocus(false) x:SetText(gxCooldownsDB.xOffset) x:SetScript("OnEscapePressed", function(self) self:ClearFocus() self:SetText(gxCooldownsDB.xOffset) end) x:SetScript("OnEnterPressed", function(self) self:ClearFocus() end) local xlabel = x:CreateFontString(nil, "ARTWORK", "GameFontNormal") xlabel:SetText("X") xlabel:SetPoint("BOTTOMLEFT", x, "TOPLEFT") local y = CreateFrame("EditBox", "gxCooldownsConfigY", mainGroup, "InputBoxTemplate") y:SetPoint("TOPLEFT", maxDur, "BOTTOMLEFT", 0, -40) y:SetPoint("TOPRIGHT", maxDur, "BOTTOMRIGHT", 0, -40) y:SetHeight(30) y:SetAutoFocus(false) y:SetText(gxCooldownsDB.yOffset) y:SetScript("OnEscapePressed", function(self) self:ClearFocus() self:SetText(gxCooldownsDB.yOffset) end) y:SetScript("OnEnterPressed", function(self) self:ClearFocus() end) local ylabel = y:CreateFontString(nil, "ARTWORK", "GameFontNormal") ylabel:SetText("Y") ylabel:SetPoint("BOTTOMLEFT", y, "TOPLEFT") local callbackXY = function() x:SetText(gxCooldownsDB.xOffset) y:SetText(gxCooldownsDB.yOffset) end local apply = Button.new(mainGroup, "TOPRIGHT", y, "BOTTOMRIGHT", 0, -5) apply:SetWidth(75) apply:SetHeight(25) apply.tiptext = "Click to apply the coordinates." apply:SetText("Apply") apply:SetScript("OnClick", function(self) local x, y = x:GetText(), y:GetText() if (not tonumber(x) or not tonumber(y)) then return end aTable.setPosition(x, y) end) local lock = Button.new(mainGroup, "TOPLEFT", x, "BOTTOMLEFT", -5, -5) lock:SetWidth(75) lock:SetHeight(25) lock.tiptext = "Lock/unlock the anchor." lock:SetText("Unlock") local callbackLock = function() if (aTable.locked) then lock:SetText("Unlock") end end lock:SetScript("OnClick", function(self) if (aTable.locked) then self:SetText("Lock") aTable.locked = false else self:SetText("Unlock") aTable.locked = true end aTable.toggleLock(callbackLock, callbackXY) end) aTable.locked = true self:SetScript("OnShow", nil) end local scanLostCache = function() local result = "" for itemSpell, itemID in next, gxCooldownsDB.items do if (not GetItemInfo(itemID)) then result = result .. itemID .. ", " gxCooldownsDB.items[itemSpell] = nil end end result = string.sub(result, 1, -3) print("|cffffaa00gx|r|cff999999Cooldowns:|r The following items are removed since they are no longer stored in your local cache: " .. result) end local updateItemList = function(group) local name, id local numItems = #(group.items) local maxOffset if (numItems > group.maxButtons) then maxOffset = numItems - group.maxButtons else maxOffset = 0 end group.scrollbar:SetMinMaxValues(0, maxOffset) local offset = floor(group.scrollbar:GetValue()) local i = offset + 1 for _, button in next, group.buttons do if (i > (group.maxButtons + offset)) then break end name = group.items[i] if (not name) then button:Hide() else button:Show() id = group.itemNameToID[name] button.icon:SetTexture(select(10, GetItemInfo(id))) button.text:SetText(select(2, GetItemInfo(id))) button.itemSpellName = GetItemSpell(id) button.itemID = id end i = i + 1 end end local removeItem = function(button, group) local name = GetItemInfo(button.itemID) local spell = button.itemSpellName button.itemID = nil button.icon:SetTexture(nil) button.text:SetText() for i, item in next, group.items do if (item == name) then tremove(group.items, i) break end end group.itemNameToID[name] = nil sort(group.items) updateItemList(group) gxCooldownsDB.items[spell] = nil end local buttonEnter = function(self) self.texture:Show() end local buttonLeave = function(self) self.texture:Hide() end local createButton = function(i, group, f) local button = CreateFrame("Button", nil, group) button:SetHeight(25) if (i ~= 1) then button:SetPoint("TOPLEFT", group.buttons[i - 1], "BOTTOMLEFT") button:SetPoint("TOPRIGHT", group.buttons[i - 1], "BOTTOMRIGHT") else button:SetPoint("TOPLEFT", group, "TOPLEFT", 4, -6) button:SetPoint("TOPRIGHT", group.scrollbar, "TOPLEFT", -4, -6) end button:RegisterForClicks("RightButtonUp") button:SetScript("OnClick", function(self) f(self, group) end) button:SetScript("OnEnter", buttonEnter) button:SetScript("OnLeave", buttonLeave) local icon = button:CreateTexture(nil, "ARTWORK") icon:SetPoint("TOPLEFT", 2, 0) icon:SetPoint("BOTTOMLEFT", 2, 0) icon:SetWidth(25) button.icon = icon local text = button:CreateFontString(nil, "ARTWORK", "GameFontNormal") text:SetPoint("LEFT", icon, "RIGHT", 5, 0) button.text = text local texture = button:CreateTexture(nil, "BACKGROUND") texture:SetAllPoints(button) texture:SetTexture([=[Interface\QuestFrame\UI-QuestLogTitleHighlight]=]) texture:SetBlendMode("ADD") texture:SetAlpha(.5) texture:Hide() button.texture = texture group.buttons[i] = button end local addItem = function(item, itemSpell, group) local name, link = GetItemInfo(item) local itemID = tonumber(string.match(link, "Hitem:(%d+)")) tinsert(group.items, name) group.itemNameToID[name] = itemID sort(group.items) local numButtons = #(group.buttons) if (numButtons < group.maxButtons) then createButton(numButtons + 1, group, removeItem) end updateItemList(group) gxCooldownsDB.items[itemSpell] = itemID end local addItemsOptions = function(self) local title, subtitle = Heading.new(self, "gxCooldowns - Add Items", "Here you can add whatever items which cooldowns you wish to watch. Both item ID and name are valid. You will have to use item ID to add items you don't have in your inventory.") local mainGroup = Group.new(self, "Items") mainGroup:SetPoint("TOP", subtitle, "BOTTOM", 0, -8) mainGroup:SetPoint("BOTTOMLEFT", 16, 16) mainGroup:SetPoint("BOTTOMRIGHT", -16, 16) local input = CreateFrame("EditBox", nil, mainGroup, "InputBoxTemplate") input:SetPoint("TOPLEFT", mainGroup, "TOPLEFT", 24, -16) input:SetHeight(30) input:SetWidth(250) input:SetAutoFocus(false) input:SetScript("OnEscapePressed", function(self) self:ClearFocus() end) input:SetScript("OnEnterPressed", function(self) local item = self:GetText() local itemSpell = GetItemSpell(item) if (itemSpell) then item = GetItemInfo(item) if (not self.group.itemNameToID[item]) then addItem(item, itemSpell, self.group) end else self:ClearFocus() end end) hooksecurefunc("ChatEdit_InsertLink", function(text) if (self:IsShown()) then input:SetText(text) end end) local add = Button.new(self, "LEFT", input, "RIGHT", 12, 0) add:SetWidth(75) add:SetHeight(25) add.tiptext = "Click to add this item to the list." add:SetText("Add item") add:SetScript("OnClick", function(self) local item = input:GetText() local itemSpell = GetItemSpell(item) if (itemSpell) then item = GetItemInfo(item) if (not self.group.itemNameToID[item]) then addItem(item, itemSpell, self.group) end else input:ClearFocus() end end) local group = Group.new(self) group:SetPoint("TOP", input, "BOTTOM", 0, -8) group:SetPoint("BOTTOMLEFT", mainGroup, 16, 16) group:SetPoint("BOTTOMRIGHT", mainGroup, -16, 16) group.buttons = {} group.itemNameToID = {} group.items = {} group.maxButtons = floor((group:GetHeight() - 10) / 25) add.group = group input.group = group local scroll = Scroll.new(group, 6, 1) local func = scroll:GetScript("OnValueChanged") scroll:SetScript("OnValueChanged", function(self, value, ...) updateItemList(group) return func(self, value, ...) end) group.scrollbar = scroll local itemName local i = 1 for _, itemID in next, gxCooldownsDB.items do itemName = GetItemInfo(itemID) if (not itemName) then scanLostCache() break end group.itemNameToID[itemName] = itemID group.items[i] = itemName i = i + 1 end sort(group.items) for i in next, group.items do if (i <= group.maxButtons) then createButton(i, group, removeItem) end end updateItemList(group) self:EnableMouseWheel() self:SetScript("OnMouseWheel", function(self, val) scroll:SetValue(scroll:GetValue() - val) end) local numItems = #(group.items) local maxOffset if (numItems > group.maxButtons) then maxOffset = numItems - group.maxButtons else maxOffset = 0 end scroll:SetMinMaxValues(0, maxOffset) scroll:SetValue(0) self:SetScript("OnShow", nil) end local updateBlacklist = function(group) local name, id local numSpells = #(group.spells) local maxOffset if (numSpells > group.maxButtons) then maxOffset = numSpells - group.maxButtons else maxOffset = 0 end group.scrollbar:SetMinMaxValues(0, maxOffset) local offset = floor(group.scrollbar:GetValue()) local i = offset + 1 for _, button in next, group.buttons do if (i > (group.maxButtons + offset)) then break end name = group.spells[i] if (not name) then button:Hide() else button:Show() id = group.spellNameToID[name] button.icon:SetTexture(select(3, GetSpellInfo(id))) button.text:SetText(GetSpellLink(id)) button.itemID = id end i = i + 1 end end local removeSpell = function(button, group) local name = GetSpellInfo(button.itemID) button.itemID = nil button.icon:SetTexture(nil) button.text:SetText() for i, spell in next, group.spells do if (spell == name) then tremove(group.spells, i) break end end group.spellNameToID[name] = nil sort(group.spells) updateBlacklist(group) gxCooldownsDB.blacklist[name] = nil end local addSpell = function(spellLink, group) local spellID = tonumber(string.match(spellLink, "Hspell:(%d+)")) local name = GetSpellInfo(spellID) tinsert(group.spells, name) group.spellNameToID[name] = spellID sort(group.spells) local numButtons = #(group.buttons) if (numButtons < group.maxButtons) then createButton(numButtons + 1, group, removeSpell) end updateBlacklist(group) gxCooldownsDB.blacklist[name] = spellID end local addBlacklistOptions = function(self) local title, subtitle = Heading.new(self, "gxCooldowns - Blacklist", "Here you can add whatever cooldowns you do not wish to watch.") local mainGroup = Group.new(self, "Blacklist") mainGroup:SetPoint("TOP", subtitle, "BOTTOM", 0, -8) mainGroup:SetPoint("BOTTOMLEFT", 16, 16) mainGroup:SetPoint("BOTTOMRIGHT", -16, 16) local input = CreateFrame("EditBox", nil, mainGroup, "InputBoxTemplate") input:SetPoint("TOPLEFT", mainGroup, "TOPLEFT", 24, -16) input:SetHeight(30) input:SetWidth(250) input:SetAutoFocus(false) input:SetScript("OnEscapePressed", function(self) self:ClearFocus() end) input:SetScript("OnEnterPressed", function(self) local name local spellID = tonumber(string.match(self:GetText(), "Hspell:(%d+)")) if (spellID) then name = GetSpellInfo(spellID) else name = GetSpellInfo(self:GetText()) end if (not name) then self:ClearFocus() return end local spell = GetSpellLink(name) if (spell and not self.group.spellNameToID[name]) then addSpell(spell, self.group) end end) hooksecurefunc("ChatEdit_InsertLink", function(text) if (self:IsShown()) then input:SetText(text) end end) local add = Button.new(self, "LEFT", input, "RIGHT", 12, 0) add:SetWidth(75) add:SetHeight(25) add.tiptext = "Click to blacklist this spell." add:SetText("Add spell") add:SetScript("OnClick", function(self) local name local spellID = tonumber(string.match(input:GetText(), "Hspell:(%d+)")) if (spellID) then name = GetSpellInfo(spellID) else name = GetSpellInfo(input:GetText()) end if (not name) then input:ClearFocus() return end local spell = GetSpellLink(name) if (spell and not self.group.spellNameToID[name]) then addSpell(spell, self.group) end end) local group = Group.new(self) group:SetPoint("TOP", input, "BOTTOM", 0, -8) group:SetPoint("BOTTOMLEFT", mainGroup, 16, 16) group:SetPoint("BOTTOMRIGHT", mainGroup, -16, 16) group.buttons = {} group.spells = {} group.spellNameToID = {} group.maxButtons = floor((group:GetHeight() - 10) / 25) add.group = group input.group = group local scroll = Scroll.new(group, 6, 1) local f = scroll:GetScript("OnValueChanged") scroll:SetScript("OnValueChanged", function(self, value, ...) updateBlacklist(group) return f(self, value, ...) end) group.scrollbar = scroll local i = 1 for spellName, spellID in next, gxCooldownsDB.blacklist do group.spells[i] = spellName group.spellNameToID[spellName] = spellID i = i + 1 end sort(group.spells) for i in next, group.spells do if (i <= group.maxButtons) then createButton(i, group, removeSpell) end end updateBlacklist(group) self:EnableMouseWheel() self:SetScript("OnMouseWheel", function(self, val) scroll:SetValue(scroll:GetValue() - val) end) local numSpells = #(group.spells) local maxOffset if (numSpells > group.maxButtons) then maxOffset = numSpells - group.maxButtons else maxOffset = 0 end scroll:SetMinMaxValues(0, maxOffset) scroll:SetValue(0) self:SetScript("OnShow", nil) end local setup = function(self) gxCooldownsDB = gxCooldownsDB or {} for k, v in next, defaults do if (type(gxCooldownsDB[k]) == "nil") then gxCooldownsDB[k] = v end end defaults = nil local main = CreateFrame("Frame", "gxCooldownsConfig", InterfaceOptionsFramePanelContainer) main.name = "gxCooldowns" main:Hide() main:SetScript("OnShow", addMainOptions) InterfaceOptions_AddCategory(main) local items = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer) items.name = "Add Items" items.parent = "gxCooldowns" items:Hide() items:SetScript("OnShow", addItemsOptions) InterfaceOptions_AddCategory(items) local blacklist = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer) blacklist.name = "Blacklist" blacklist.parent = "gxCooldowns" blacklist:Hide() blacklist:SetScript("OnShow", addBlacklistOptions) InterfaceOptions_AddCategory(blacklist) SlashCmdList["GXCOOLDOWNS"] = function() InterfaceOptionsFrame_OpenToCategory("gxCooldowns") end SLASH_GXCOOLDOWNS1 = "/gxcooldowns" SLASH_GXCOOLDOWNS2 = "/gxcd" end aTable.setupConfiguration = setup
cooldown.lua
Lua Code:
local aName, aTable = ... local LBF, buttonGroup local Shiner = LibStub("tekShiner") local match = string.match local next = next local select = select local split = string.split local tinsert = table.insert local tremove = table.remove local unpack = unpack local GetInventoryItemCooldown = GetInventoryItemCooldown local GetInventoryItemTexture = GetInventoryItemTexture local GetItemCooldown = GetItemCooldown local GetItemInfo = GetItemInfo local GetPetActionCooldown = GetPetActionCooldown local GetSpellCooldown = GetSpellCooldown local GetSpellTexture = GetSpellTexture -- We limit the schools to double schools for now. (Only frostfire is available to players atm.) [url]http://www.wowwiki.com/API_COMBAT_LOG_EVENT[/url] local spellSchoolColors = { [SCHOOL_MASK_PHYSICAL] = {1,1,0}, -- Physical 1 [SCHOOL_MASK_HOLY] = {1,.9,.5}, -- Holy 2 [SCHOOL_MASK_HOLY + SCHOOL_MASK_PHYSICAL] = { -- Holystrike 3 {1,.9,.5}, {1,1,0} }, [SCHOOL_MASK_FIRE] = {1,.5,0}, -- Fire 4 [SCHOOL_MASK_FIRE + SCHOOL_MASK_PHYSICAL] = { -- Flamestrike 5 {1,.5,0}, {1,1,0} }, [SCHOOL_MASK_HOLY + SCHOOL_MASK_FIRE] = { -- Holyfire 6 {1,.9,.5}, {1,.5,0} }, [SCHOOL_MASK_NATURE] = {.3,1,.3}, -- Nature 8 [SCHOOL_MASK_NATURE + SCHOOL_MASK_PHYSICAL] = { -- Stormstrike 9 {.3,1,.3}, {1,1,0} }, [SCHOOL_MASK_NATURE + SCHOOL_MASK_HOLY] = { -- Holystorm 10 {.3,1,.3}, {1,.9,.5} }, [SCHOOL_MASK_NATURE + SCHOOL_MASK_FIRE] = { -- Firestorm 12 {.3,1,.3}, {1,.5,0} }, [SCHOOL_MASK_FROST] = {.5,1,1}, -- Frost 16 [SCHOOL_MASK_FROST + SCHOOL_MASK_PHYSICAL] = { -- Froststrike 17 {.5,1,1}, {1,1,0} }, [SCHOOL_MASK_FROST + SCHOOL_MASK_HOLY] = { -- Holyfrost 18 {.5,1,1}, {1,.9,.5} }, [SCHOOL_MASK_FROST + SCHOOL_MASK_FIRE] = { -- Frostfire 20 {.5,1,1}, {1,.5,0} }, [SCHOOL_MASK_FROST + SCHOOL_MASK_NATURE] = { -- Froststorm 24 {.5,1,1}, {.3,1,.3} }, [SCHOOL_MASK_SHADOW] = {.5,.5,1}, -- Shadow 32 [SCHOOL_MASK_SHADOW + SCHOOL_MASK_PHYSICAL] = { -- Shadowstrike 33 {.5,.5,1}, {1,1,0} }, [SCHOOL_MASK_SHADOW + SCHOOL_MASK_HOLY] = { -- Twilight 34 {.5,.5,1}, {1,.9,.5} }, [SCHOOL_MASK_SHADOW + SCHOOL_MASK_FIRE] = { -- Shadowflame 36 {.5,.5,1}, {1,.5,0} }, [SCHOOL_MASK_SHADOW + SCHOOL_MASK_NATURE] = { -- Plague 40 {.5,.5,1}, {.3,1,.3} }, [SCHOOL_MASK_SHADOW + SCHOOL_MASK_FROST] = { -- Shadowfrost 48 {.5,.5,1}, {.5,1,1} }, [SCHOOL_MASK_ARCANE] = {1,.5,1}, -- Arcane 64 [SCHOOL_MASK_ARCANE + SCHOOL_MASK_PHYSICAL] = { -- Spellstrike 65 {1,.5,1}, {1,1,0} }, [SCHOOL_MASK_ARCANE + SCHOOL_MASK_HOLY] = { -- Divine 66 {1,.5,1}, {1,.9,.5} }, [SCHOOL_MASK_ARCANE + SCHOOL_MASK_FIRE] = { -- Spellfire 68 {1,.5,1}, {1,.5,0} }, [SCHOOL_MASK_ARCANE + SCHOOL_MASK_NATURE] = { -- Spellstorm 72 {1,.5,1}, {.3,1,.3} }, [SCHOOL_MASK_ARCANE + SCHOOL_MASK_FROST] = { -- Spellfrost 80 {1,.5,1}, {.5,1,1} }, [SCHOOL_MASK_ARCANE + SCHOOL_MASK_SHADOW] = { -- Spellshadow 80 {1,.5,1}, {.5,.5,1} }, } local FD = GetSpellInfo(5384) -- Feign Death can't be tracked through CLEU :( local sharedCooldowns = { [GetSpellInfo(49376)] = GetSpellInfo(16979) -- 'Feral Charge - Cat' refreshes 'Feral Charge - Bear' } local spellNameToSlotID = {} local enchantIDToSpellName = { [3601] = GetSpellInfo(54793), -- Frag Belt [3603] = GetSpellInfo(54998), -- Hand-Mounted Pyro Rocket [3604] = GetSpellInfo(54999), -- Hyperspeed Accelerators [3606] = GetSpellInfo(55016), -- Nitro Boosts } local specialOccasions = { [GetSpellInfo(11129)] = true, -- Combustion [GetSpellInfo(16166)] = true, -- Elemental Mastery [GetSpellInfo(89485)] = true, -- Inner Focus [GetSpellInfo(132158)] = true, -- Nature's Swiftness [GetSpellInfo(12043)] = true -- Presence of Mind } local addon = CreateFrame("Frame", aName .. "Anchor", UIParent) addon:SetClampedToScreen(true) addon:RegisterEvent("BAG_UPDATE_COOLDOWN") addon:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") addon:RegisterEvent("PLAYER_EQUIPMENT_CHANGED") addon:RegisterEvent("PLAYER_LOGIN") addon:RegisterEvent("SPELL_UPDATE_COOLDOWN") addon:RegisterEvent("SPELL_UPDATE_USABLE") addon:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") addon.active = {} addon.pool = {} aTable.growthValues = { ["Down"] = { point = "TOP", horizontal = false }, ["Left"] = { point = "RIGHT", horizontal = true }, ["Left and Right"] = { point = "CENTER", horizontal = true }, ["Right"] = { point = "LEFT", horizontal = true }, ["Up"] = { point = "BOTTOM", horizontal = false }, ["Up and Down"] = { point = "CENTER", horizontal = false } } local tex = addon:CreateTexture(aName .. "AnchorTexture", "OVERLAY") tex:SetAllPoints(addon) tex:SetTexture(.6, .6, .6, .6) tex:Hide() addon.anchor = tex local repositionFrames = function(self) local gap = gxCooldownsDB.gap local point, rel, anchor, x, y local numActive, prev = 0 for _, frame in next, self.active do frame:ClearAllPoints() if (aTable.growthValues[gxCooldownsDB.growth].horizontal) then if (prev) then rel, anchor, x = prev, "RIGHT", gap else rel, anchor, x = self, "LEFT", 0 end point, y = "LEFT", 0 else if (prev) then rel, anchor, y = prev, "TOP", gap else rel, anchor, y = self, "BOTTOM", 0 end point, x = "BOTTOM", 0 end frame:SetPoint(point, rel, anchor, x, y) numActive = numActive + 1 prev = frame end local length = numActive * (36 + gap) - gap if (length < 36) then length = 36 end if (aTable.growthValues[gxCooldownsDB.growth].horizontal) then self:SetWidth(length) else self:SetHeight(length) end end do local frameNum = 1 local loadFrame = function(self) if (#(self.pool) > 0) then return tremove(self.pool, 1) end local name = aName .. "Icon" .. frameNum local frame = CreateFrame("Button", name, self, "ActionButtonTemplate") frame:EnableMouse(nil) frame:SetFrameStrata("LOW") frame:Hide() frame.parent = self local model = Shiner.new(frame) for _, sparkle in next, model.sparkles do sparkle:SetHeight(sparkle:GetHeight() * 3) sparkle:SetWidth(sparkle:GetWidth() * 3) end model:SetAllPoints(frame) model:Hide() frame:SetScript("OnUpdate", function(self, elapsed) if (elapsed > 3) then -- OnUpdate runs [fps] times in a second, if elapsed is 3 the fps would be 0.33..., we assume that will never happen. elapsed = elapsed - floor(elapsed) -- elapsed is 5+ right when you log in, we try to reset it here because it would bug out the duration. self.elapseFix = nil end local duration = self.duration - elapsed if (duration <= 0) then self.parent:dropCooldown(self.name) return end self.duration = duration end) frame.Cooldown = _G[name.."Cooldown"] frame.Icon = _G[name.."Icon"] frame.Model = model if (LBF) then buttonGroup:AddButton(frame) end frameNum = frameNum + 1 return frame end addon.newCooldown = function(self, cooldownName, startTime, seconds, tex, aType, elapseFix) if (self.active[cooldownName]) then return end local frame = loadFrame(self) local duration = seconds - (GetTime() - startTime) frame.start = startTime frame.elapseFix = elapseFix frame.duration = duration frame.max = seconds frame.name = cooldownName frame.type = aType frame.Icon:SetTexture(tex) frame.Cooldown:SetCooldown(startTime, seconds) frame:Show() if (self.interrupted) then frame.Model:Show() if (type(spellSchoolColors[self.spellSchoolID][1]) == "table") then local i = 1 for _, sparkle in next, frame.Model.sparkles do sparkle:SetVertexColor(unpack(spellSchoolColors[self.spellSchoolID][i])) if (i == 1) then i = i + 1 else i = i - 1 end end else for _, sparkle in next, frame.Model.sparkles do sparkle:SetVertexColor(unpack(spellSchoolColors[self.spellSchoolID])) end end self.interrupted = nil end self.active[cooldownName] = frame repositionFrames(self) end addon.dropCooldown = function(self, cooldownName) local frame = self.active[cooldownName] if (frame) then frame:Hide() tinsert(self.pool, frame) self.active[cooldownName] = nil if (frame.Model:IsShown()) then frame.Model:Hide() end repositionFrames(self) return true end return end end aTable.updateFrames = function(growth) gxCooldownsDB.growth = growth addon:SetHeight(36) addon:SetWidth(36) -- Reset the dimensions before we engage repositionFrames repositionFrames(addon) addon:ClearAllPoints() addon:SetPoint(aTable.growthValues[gxCooldownsDB.growth].point, UIParent, "CENTER", gxCooldownsDB.xOffset, gxCooldownsDB.yOffset) end aTable.setScale = function(scale) gxCooldownsDB.scale = scale addon:SetScale(scale) end aTable.setGap = function(gap) gxCooldownsDB.gap = gap repositionFrames(addon) end aTable.setPosition = function(x, y) gxCooldownsDB.xOffset, gxCooldownsDB.yOffset = x, y addon:ClearAllPoints() addon:SetPoint(aTable.growthValues[gxCooldownsDB.growth].point, UIParent, "CENTER", gxCooldownsDB.xOffset, gxCooldownsDB.yOffset) end do local x, y local coords = {[1] = {}, [2] = {}, [3] = {}} local startMoving = function(self, button) if (button == "RightButton") then aTable.locked = true aTable.toggleLock() return end _, _, _, x, y = self:GetPoint() coords[1].x = x coords[1].y = y self:StartMoving() _, _, _, x, y = self:GetPoint() coords[2].x = x coords[2].y = y end local stopMoving = function(self, button) if (button == "RightButton") then return end _, _, _, x, y = self:GetPoint() coords[3].x = x coords[3].y = y self:StopMovingOrSizing() x = floor((coords[3].x - coords[2].x) + coords[1].x) y = floor((coords[3].y - coords[2].y) + coords[1].y) gxCooldownsDB.xOffset = x gxCooldownsDB.yOffset = y self:ClearAllPoints() self:SetPoint(aTable.growthValues[gxCooldownsDB.growth].point, UIParent, "CENTER", x, y) end aTable.toggleLock = function(callbackLock, callbackXY) if (aTable.locked) then addon.anchor:Hide() addon:EnableMouse(nil) addon:SetMovable(nil) addon:SetScript("OnMouseDown", nil) addon:SetScript("OnMouseUp", nil) else addon.anchor:Show() addon:EnableMouse(true) addon:SetMovable(true) addon:SetScript("OnMouseDown", startMoving) addon:HookScript("OnMouseDown", callbackLock) addon:SetScript("OnMouseUp", stopMoving) addon:HookScript("OnMouseUp", callbackXY) end end end do local scanCooldowns = function(self) local spellName, startTime, duration, enabled, texture for spellNum = 1, 500 do spellName = GetSpellTabInfo(spellNum, BOOKTYPE_SPELL) if (not spellName) then break end startTime, duration, enabled = GetSpellCooldown(spellName) if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then self:newCooldown(spellName, startTime, duration, GetSpellTexture(spellName), "SPELL", true) end end for _, item in next, gxCooldownsDB.items do startTime, duration, enabled = GetItemCooldown(item) if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then texture = select(10, GetItemInfo(item)) self:newCooldown(item, startTime, duration, texture, "ITEM", true) elseif (enabled == 0 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then self.queuedItem = self.updateItem end end for _, id in next, spellNameToSlotID do startTime, duration, enabled = GetInventoryItemCooldown("player", id) if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then texture = GetInventoryItemTexture("player", id) self:newCooldown(id, startTime, duration, texture, "INVENTORY", true) end end end addon.PLAYER_LOGIN = function(self, addon) aTable.setupConfiguration() self:SetHeight(36) self:SetWidth(36) self:SetScale(gxCooldownsDB.scale) self:SetPoint(aTable.growthValues[gxCooldownsDB.growth].point, UIParent, "CENTER", gxCooldownsDB.xOffset, gxCooldownsDB.yOffset) if (LibStub) then LBF = LibStub("LibButtonFacade",true) if (LBF) then local skinChanged = function(self, skinName, gloss, backdrop, group, _, colors) gxCooldownsDB.style[1] = skinName gxCooldownsDB.style[2] = gloss gxCooldownsDB.style[3] = backdrop gxCooldownsDB.style[4] = colors end LBF:RegisterSkinCallback("gxCooldowns", skinChanged, self) buttonGroup = LBF:Group("gxCooldowns") buttonGroup:Skin(unpack(gxCooldownsDB.style)) end end self.playerGUID = UnitGUID("player") for i = 1, 19 do self:PLAYER_EQUIPMENT_CHANGED(i, true) end scanCooldowns(self) self:UnregisterEvent("PLAYER_LOGIN") self.PLAYER_LOGIN = nil end end addon.SPELL_UPDATE_COOLDOWN = function(self) local startTime, duration, enabled, texture if (self.updateNext) then startTime, duration, enabled = GetSpellCooldown(self.updateNext) if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then texture = GetSpellTexture(self.updateNext) self:newCooldown(self.updateNext, startTime, duration, texture, "SPELL") self.updateNext = nil end end if (self.updateSpecial) then startTime, duration, enabled = GetSpellCooldown(self.updateSpecial) if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then texture = GetSpellTexture(self.updateSpecial) self:newCooldown(self.updateSpecial, startTime, duration, texture, "SPELL") self.updateSpecial = nil end end if (self.updateShared) then texture = GetSpellTexture(self.updateShared) startTime, duration, enabled = GetSpellCooldown(self.updateShared) self:newCooldown(self.updateShared, startTime, duration, texture, "SPELL") self.updateShared = nil end if (not self.updateAbility) then return end local unit, abilityName = split(",", self.updateAbility) if (FD == abilityName) then self.updateNext = abilityName return end local type if (unit == "player") then type = "SPELL" texture = GetSpellTexture(abilityName) startTime, duration, enabled = GetSpellCooldown(abilityName) else local petAction for i = 1, NUM_PET_ACTION_SLOTS do petAction = GetPetActionInfo(i) if (abilityName == petAction) then abilityName = i type = "PET" texture = select(3, GetPetActionInfo(i)) startTime, duration, enabled = GetPetActionCooldown(i) break end end end if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then self:newCooldown(abilityName, startTime, duration, texture, type) elseif (enabled == 1 and self.interrupted) then self.updateNext = abilityName end self.updateAbility = nil end addon.BAG_UPDATE_COOLDOWN = function(self) local startTime, duration, enabled, texture if (self.queuedItem) then -- For items with a cooldown that doesn't start before leaving combat! startTime, duration, enabled = GetItemCooldown(self.queuedItem) if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then texture = select(10, GetItemInfo(self.queuedItem)) self:newCooldown(self.queuedItem, startTime, duration, texture, "ITEM") self.queuedItem = nil end end if (self.updateItem) then startTime, duration, enabled = GetItemCooldown(self.updateItem) if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then texture = select(10, GetItemInfo(self.updateItem)) self:newCooldown(self.updateItem, startTime, duration, texture, "ITEM") self.updateItem = nil elseif (enabled == 0 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then self.queuedItem = self.updateItem self.updateItem = nil end end if (self.updateSlotID) then startTime, duration, enabled = GetInventoryItemCooldown("player", self.updateSlotID) if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then texture = GetInventoryItemTexture("player", self.updateSlotID) self:newCooldown(self.updateSlotID, startTime, duration, texture, "INVENTORY") self.updateSlotID = nil end end end addon.PLAYER_EQUIPMENT_CHANGED = function(self, slotID, beingEquipped) if (not beingEquipped) then for spellName, id in next, spellNameToSlotID do if (id and id == slotID) then spellNameToSlotID[spellName] = nil break end end return end local itemLink = GetInventoryItemLink("player", slotID) if (itemLink) then local _, enchantID = match(itemLink, "Hitem:(%d+):(%d+)") enchantID = tonumber(enchantID) if (enchantIDToSpellName[enchantID]) then local spellName = enchantIDToSpellName[enchantID] spellNameToSlotID[spellName] = slotID end end end addon.UNIT_SPELLCAST_SUCCEEDED = function(self, unit, spellName) if ((unit ~= "player" and unit ~= "pet") or gxCooldownsDB.blacklist[spellName]) then return end local item = gxCooldownsDB.items[spellName] if (item) then self.updateItem = item return end local slotID = spellNameToSlotID[spellName] if (slotID) then self.updateSlotID = slotID return end if (sharedCooldowns[spellName]) then -- This should be druids only self.updateShared = sharedCooldowns[spellName] end self.updateAbility = unit..","..spellName end addon.SPELL_UPDATE_USABLE = function(self) for name, frame in next, self.active do local startTime, dur if (frame.type == "SPELL") then start, dur = GetSpellCooldown(name) elseif (frame.type == "ITEM") then start, dur = GetItemCooldown(name) elseif (frame.type == "INVENTORY") then start, dur = GetInventoryItemCooldown("player", name) elseif (frame.type == "PET") then start, dur = GetPetActionCooldown(name) end if (not start and not dur) then -- Calling Get'Something'Cooldown right after talent swap returns a nil value self:dropCooldown(name) return end if (dur <= 1 and frame.type == "SPELL") then -- For abilities like Readiness, dur will be lowered to 1 or 0 self:dropCooldown(name) return end if (frame.start > start or frame.max > dur) then local duration = start - GetTime() + dur frame.start = start frame.duration = duration frame.max = dur frame.Cooldown:SetCooldown(start, dur) end end end addon.COMBAT_LOG_EVENT_UNFILTERED = function(self, _, event, sourceGUID, _, _, destGUID, _, _, ...) local _, spellName, _, _, iSpellName, spellSchoolID = ... if (event == "SPELL_AURA_REMOVED" and sourceGUID == self.playerGUID and specialOccasions[spellName] and not gxCooldownsDB.blacklist[spellName]) then self.updateSpecial = spellName elseif (event == "SPELL_INTERRUPT" and destGUID == self.playerGUID) then self.spellSchoolID = spellSchoolID self.interrupted = true self.updateAbility = "player,"..iSpellName end end do -- Stealth and Prowl apparently trigger SPELL_UPDATE_COOLDOWN before the aura is removed sometimes :( local class = select(2, UnitClass("player")) if (class == "ROGUE" or class == "DRUID") then local stealth = class == "ROGUE" and GetSpellInfo(1784) or GetSpellInfo(5215) addon:RegisterEvent("UPDATE_STEALTH") addon.UPDATE_STEALTH = function(self) local startTime, duration, enabled = GetSpellCooldown(stealth) if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then local texture = GetSpellTexture(stealth) self:newCooldown(stealth, startTime, duration, texture, "SPELL") end end end end addon:SetScript("OnEvent", function(self, event, ...) if (self[event]) then self[event](self, ...) end end)
Entire file can be downloaded here: click
Thanks in advance for looking into it, I'm reallly appreciating it.
|