Thread Tools Display Modes
10-16-12, 05:48 AM   #1
Linayo
A Deviate Faerie Dragon
AddOn Author - Click to view addons
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:
  1. local aName, aTable = ...
  2.  
  3. local floor = math.floor
  4. local format = string.format
  5. local tinsert = table.insert
  6. local next = next
  7. local tremove = table.remove
  8. local select = select
  9. local sort = table.sort
  10. local tonumber = tonumber
  11.  
  12. local Button = LibStub("tekKonfig-Button")
  13. local Dropdown = LibStub("tekKonfig-Dropdown")
  14. local Group = LibStub("tekKonfig-Group")
  15. local Heading = LibStub("tekKonfig-Heading")
  16. local Scroll = LibStub("tekKonfig-Scroll")
  17. local Slider = LibStub("tekKonfig-Slider")
  18.  
  19. local GetItemInfo = GetItemInfo
  20. local GetItemSpell = GetItemSpell
  21. local GetSpellInfo = GetSpellInfo
  22. local GetSpellLink = GetSpellLink
  23.  
  24. local defaults = {
  25.     blacklist = {},
  26.     minDuration = 1.5,
  27.     maxDuration = 3600,
  28.     items = {
  29.     },
  30.    
  31.     style = {
  32.         "Blizzard", -- Skin name
  33.         0.5,        -- Gloss alpha
  34.         true        -- Use backdrop
  35.     },
  36.    
  37.     scale = 1,
  38.     gap = 10,
  39.     growth = "Left and Right",
  40.     xOffset = 0,
  41.     yOffset = 0,
  42. }
  43.  
  44. local addMainOptions = function(self)
  45.     local title = Heading.new(self, "gxCooldowns")
  46.    
  47.     local mainGroup = Group.new(self, "Settings")
  48.     mainGroup:SetPoint("TOP", title, "BOTTOM", 0, -20)
  49.     mainGroup:SetPoint("BOTTOMLEFT", 16, 16)
  50.     mainGroup:SetPoint("BOTTOMRIGHT", -16, 16)
  51.    
  52.     local dropdown, dText = Dropdown.new(mainGroup, "Growth", "TOPLEFT", mainGroup, "TOPLEFT", 15, -10)
  53.     dText:SetText(gxCooldownsDB.growth)
  54.     local OnClick = function(self)
  55.         UIDropDownMenu_SetSelectedValue(dropdown, self.value)
  56.         dText:SetText(self.value)
  57.         aTable.updateFrames(self.value)
  58.     end
  59.     UIDropDownMenu_Initialize(dropdown, function()
  60.         local selected, info = UIDropDownMenu_GetSelectedValue(dropdown) or gxCooldownsDB.growth, UIDropDownMenu_CreateInfo()
  61.        
  62.         for name in next, aTable.growthValues do
  63.             info.text = name
  64.             info.value = name
  65.             info.func = OnClick
  66.             info.checked = name == selected
  67.             UIDropDownMenu_AddButton(info)
  68.         end
  69.     end)
  70.    
  71.    
  72.     local scale, scaleText = Slider.new(mainGroup, format("Scale: %.2f", gxCooldownsDB.scale), 0.5, 2)
  73.     scale:SetPoint("TOPLEFT", mainGroup, "TOPLEFT", 20, -90)
  74.     scale:SetPoint("TOPRIGHT", mainGroup, "TOP", -15, -90)
  75.     scale:SetValue(gxCooldownsDB.scale)
  76.     scale:SetValueStep(.05)
  77.     scale:SetScript("OnValueChanged", function(self)
  78.         local scale = self:GetValue()
  79.         scaleText:SetText(format("Scale: %.2f", scale))
  80.         aTable.setScale(scale)
  81.     end)
  82.    
  83.     local gap, gapText = Slider.new(mainGroup, "Gap: " .. gxCooldownsDB.gap, -10, 25)
  84.     gap:SetPoint("TOPRIGHT", mainGroup, "TOPRIGHT", -20, -90)
  85.     gap:SetPoint("TOPLEFT", mainGroup, "TOP", 15, -90)
  86.     gap:SetValue(gxCooldownsDB.gap)
  87.     gap:SetValueStep(1)
  88.     gap:SetScript("OnValueChanged", function(self)
  89.         local gap = self:GetValue()
  90.         gapText:SetText("Gap: " .. gap)
  91.         aTable.setGap(gap)
  92.     end)
  93.    
  94.     local minDur, minDurText = Slider.new(mainGroup, "Minimum duration: " .. gxCooldownsDB.minDuration, 1.5, 10)
  95.     minDur:SetPoint("TOPLEFT", scale, "BOTTOMLEFT", 0, -40)
  96.     minDur:SetPoint("TOPRIGHT", scale, "BOTTOMRIGHT", 0, -40)
  97.     minDur:SetValue(gxCooldownsDB.minDuration)
  98.     minDur:SetValueStep(.5)
  99.     minDur:SetScript("OnValueChanged", function(self)
  100.         local dur = self:GetValue()
  101.         minDurText:SetText("Minimum duration: " .. dur)
  102.         gxCooldownsDB.minDuration = dur
  103.     end)
  104.    
  105.     local maxDur, maxDurText = Slider.new(mainGroup, format("Maximum duration: %.1fm", gxCooldownsDB.maxDuration/60), 10, 60*60)
  106.     maxDur:SetPoint("TOPLEFT", gap, "BOTTOMLEFT", 0, -40)
  107.     maxDur:SetPoint("TOPRIGHT", gap, "BOTTOMRIGHT", 0, -40)
  108.     maxDur:SetValue(gxCooldownsDB.maxDuration)
  109.     maxDur:SetValueStep(5)
  110.     maxDur:SetScript("OnValueChanged", function(self)
  111.         local dur = self:GetValue()
  112.         maxDurText:SetText(format("Maximum duration: %.1fm", dur/60))
  113.         gxCooldownsDB.maxDuration = dur
  114.     end)
  115.    
  116.     local x = CreateFrame("EditBox", "gxCooldownsConfigX", mainGroup, "InputBoxTemplate")
  117.     x:SetPoint("TOPLEFT", minDur, "BOTTOMLEFT", 0, -40)
  118.     x:SetPoint("TOPRIGHT", minDur, "BOTTOMRIGHT", 0, -40)
  119.     x:SetHeight(30)
  120.     x:SetAutoFocus(false)
  121.     x:SetText(gxCooldownsDB.xOffset)
  122.     x:SetScript("OnEscapePressed", function(self)
  123.         self:ClearFocus()
  124.         self:SetText(gxCooldownsDB.xOffset)
  125.     end)
  126.     x:SetScript("OnEnterPressed", function(self)
  127.         self:ClearFocus()
  128.     end)
  129.    
  130.     local xlabel = x:CreateFontString(nil, "ARTWORK", "GameFontNormal")
  131.     xlabel:SetText("X")
  132.     xlabel:SetPoint("BOTTOMLEFT", x, "TOPLEFT")
  133.    
  134.     local y = CreateFrame("EditBox", "gxCooldownsConfigY", mainGroup, "InputBoxTemplate")
  135.     y:SetPoint("TOPLEFT", maxDur, "BOTTOMLEFT", 0, -40)
  136.     y:SetPoint("TOPRIGHT", maxDur, "BOTTOMRIGHT", 0, -40)
  137.     y:SetHeight(30)
  138.     y:SetAutoFocus(false)
  139.     y:SetText(gxCooldownsDB.yOffset)
  140.     y:SetScript("OnEscapePressed", function(self)
  141.         self:ClearFocus()
  142.         self:SetText(gxCooldownsDB.yOffset)
  143.     end)
  144.     y:SetScript("OnEnterPressed", function(self)
  145.         self:ClearFocus()
  146.     end)
  147.    
  148.     local ylabel = y:CreateFontString(nil, "ARTWORK", "GameFontNormal")
  149.     ylabel:SetText("Y")
  150.     ylabel:SetPoint("BOTTOMLEFT", y, "TOPLEFT")
  151.    
  152.     local callbackXY = function()
  153.         x:SetText(gxCooldownsDB.xOffset)
  154.         y:SetText(gxCooldownsDB.yOffset)
  155.     end
  156.    
  157.     local apply = Button.new(mainGroup, "TOPRIGHT", y, "BOTTOMRIGHT", 0, -5)
  158.     apply:SetWidth(75)
  159.     apply:SetHeight(25)
  160.     apply.tiptext = "Click to apply the coordinates."
  161.     apply:SetText("Apply")
  162.     apply:SetScript("OnClick", function(self)
  163.         local x, y = x:GetText(), y:GetText()
  164.         if (not tonumber(x) or not tonumber(y)) then
  165.             return
  166.         end
  167.        
  168.         aTable.setPosition(x, y)
  169.     end)
  170.    
  171.     local lock = Button.new(mainGroup, "TOPLEFT", x, "BOTTOMLEFT", -5, -5)
  172.     lock:SetWidth(75)
  173.     lock:SetHeight(25)
  174.     lock.tiptext = "Lock/unlock the anchor."
  175.     lock:SetText("Unlock")
  176.    
  177.     local callbackLock = function()
  178.         if (aTable.locked) then
  179.             lock:SetText("Unlock")
  180.         end
  181.     end
  182.    
  183.     lock:SetScript("OnClick", function(self)
  184.         if (aTable.locked) then
  185.             self:SetText("Lock")
  186.             aTable.locked = false
  187.         else
  188.             self:SetText("Unlock")
  189.             aTable.locked = true
  190.         end
  191.        
  192.         aTable.toggleLock(callbackLock, callbackXY)
  193.     end)
  194.     aTable.locked = true
  195.    
  196.     self:SetScript("OnShow", nil)
  197. end
  198.  
  199. local scanLostCache = function()
  200.     local result = ""
  201.     for itemSpell, itemID in next, gxCooldownsDB.items do
  202.         if (not GetItemInfo(itemID)) then
  203.             result = result .. itemID .. ", "
  204.            
  205.             gxCooldownsDB.items[itemSpell] = nil
  206.         end
  207.     end
  208.     result = string.sub(result, 1, -3)
  209.     print("|cffffaa00gx|r|cff999999Cooldowns:|r The following items are removed since they are no longer stored in your local cache: " .. result)
  210. end
  211.  
  212. local updateItemList = function(group)
  213.     local name, id
  214.    
  215.     local numItems = #(group.items)
  216.     local maxOffset
  217.     if (numItems > group.maxButtons) then
  218.         maxOffset = numItems - group.maxButtons
  219.     else
  220.         maxOffset = 0
  221.     end
  222.     group.scrollbar:SetMinMaxValues(0, maxOffset)
  223.    
  224.     local offset = floor(group.scrollbar:GetValue())
  225.     local i = offset + 1
  226.     for _, button in next, group.buttons do
  227.         if (i > (group.maxButtons + offset)) then
  228.             break
  229.         end
  230.         name = group.items[i]
  231.         if (not name) then
  232.             button:Hide()
  233.         else
  234.             button:Show()
  235.             id = group.itemNameToID[name]
  236.            
  237.             button.icon:SetTexture(select(10, GetItemInfo(id)))
  238.             button.text:SetText(select(2, GetItemInfo(id)))
  239.            
  240.             button.itemSpellName = GetItemSpell(id)
  241.             button.itemID = id
  242.         end
  243.        
  244.         i = i + 1
  245.     end
  246. end
  247.  
  248. local removeItem = function(button, group)
  249.     local name = GetItemInfo(button.itemID)
  250.     local spell = button.itemSpellName
  251.     button.itemID = nil
  252.     button.icon:SetTexture(nil)
  253.     button.text:SetText()
  254.     for i, item in next, group.items do
  255.         if (item == name) then
  256.             tremove(group.items, i)
  257.             break
  258.         end
  259.     end
  260.     group.itemNameToID[name] = nil
  261.    
  262.     sort(group.items)
  263.    
  264.     updateItemList(group)
  265.    
  266.     gxCooldownsDB.items[spell] = nil
  267. end
  268.  
  269. local buttonEnter = function(self)
  270.     self.texture:Show()
  271. end
  272.  
  273. local buttonLeave = function(self)
  274.     self.texture:Hide()
  275. end
  276.  
  277. local createButton = function(i, group, f)
  278.     local button = CreateFrame("Button", nil, group)
  279.     button:SetHeight(25)
  280.    
  281.     if (i ~= 1) then
  282.         button:SetPoint("TOPLEFT", group.buttons[i - 1], "BOTTOMLEFT")
  283.         button:SetPoint("TOPRIGHT", group.buttons[i - 1], "BOTTOMRIGHT")
  284.     else
  285.         button:SetPoint("TOPLEFT", group, "TOPLEFT", 4, -6)
  286.         button:SetPoint("TOPRIGHT", group.scrollbar, "TOPLEFT", -4, -6)
  287.     end
  288.    
  289.     button:RegisterForClicks("RightButtonUp")
  290.     button:SetScript("OnClick", function(self)
  291.         f(self, group)
  292.     end)
  293.     button:SetScript("OnEnter", buttonEnter)
  294.     button:SetScript("OnLeave", buttonLeave)
  295.    
  296.     local icon = button:CreateTexture(nil, "ARTWORK")
  297.     icon:SetPoint("TOPLEFT", 2, 0)
  298.     icon:SetPoint("BOTTOMLEFT", 2, 0)
  299.     icon:SetWidth(25)
  300.     button.icon = icon
  301.    
  302.     local text = button:CreateFontString(nil, "ARTWORK", "GameFontNormal")
  303.     text:SetPoint("LEFT", icon, "RIGHT", 5, 0)
  304.     button.text = text
  305.    
  306.     local texture = button:CreateTexture(nil, "BACKGROUND")
  307.     texture:SetAllPoints(button)
  308.     texture:SetTexture([=[Interface\QuestFrame\UI-QuestLogTitleHighlight]=])
  309.     texture:SetBlendMode("ADD")
  310.     texture:SetAlpha(.5)
  311.     texture:Hide()
  312.     button.texture = texture
  313.    
  314.     group.buttons[i] = button
  315. end
  316.  
  317. local addItem = function(item, itemSpell, group)
  318.     local name, link = GetItemInfo(item)
  319.     local itemID = tonumber(string.match(link, "Hitem:(%d+)"))
  320.    
  321.     tinsert(group.items, name)
  322.     group.itemNameToID[name] = itemID
  323.    
  324.     sort(group.items)
  325.    
  326.     local numButtons = #(group.buttons)
  327.     if (numButtons < group.maxButtons) then
  328.         createButton(numButtons + 1, group, removeItem)
  329.     end
  330.     updateItemList(group)
  331.    
  332.     gxCooldownsDB.items[itemSpell] = itemID
  333. end
  334.  
  335. local addItemsOptions = function(self)
  336.     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.")
  337.    
  338.     local mainGroup = Group.new(self, "Items")
  339.     mainGroup:SetPoint("TOP", subtitle, "BOTTOM", 0, -8)
  340.     mainGroup:SetPoint("BOTTOMLEFT", 16, 16)
  341.     mainGroup:SetPoint("BOTTOMRIGHT", -16, 16)
  342.    
  343.     local input = CreateFrame("EditBox", nil, mainGroup, "InputBoxTemplate")
  344.     input:SetPoint("TOPLEFT", mainGroup, "TOPLEFT", 24, -16)
  345.     input:SetHeight(30)
  346.     input:SetWidth(250)
  347.     input:SetAutoFocus(false)
  348.     input:SetScript("OnEscapePressed", function(self)
  349.         self:ClearFocus()
  350.     end)
  351.     input:SetScript("OnEnterPressed", function(self)
  352.         local item = self:GetText()
  353.         local itemSpell = GetItemSpell(item)
  354.         if (itemSpell) then
  355.             item = GetItemInfo(item)
  356.             if (not self.group.itemNameToID[item]) then
  357.                 addItem(item, itemSpell, self.group)
  358.             end
  359.         else
  360.             self:ClearFocus()
  361.         end
  362.     end)
  363.     hooksecurefunc("ChatEdit_InsertLink", function(text)
  364.         if (self:IsShown()) then
  365.             input:SetText(text)
  366.         end
  367.     end)
  368.    
  369.     local add = Button.new(self, "LEFT", input, "RIGHT", 12, 0)
  370.     add:SetWidth(75)
  371.     add:SetHeight(25)
  372.     add.tiptext = "Click to add this item to the list."
  373.     add:SetText("Add item")
  374.     add:SetScript("OnClick", function(self)
  375.         local item = input:GetText()
  376.         local itemSpell = GetItemSpell(item)
  377.         if (itemSpell) then
  378.             item = GetItemInfo(item)
  379.             if (not self.group.itemNameToID[item]) then
  380.                 addItem(item, itemSpell, self.group)
  381.             end
  382.         else
  383.             input:ClearFocus()
  384.         end
  385.     end)
  386.    
  387.     local group = Group.new(self)
  388.     group:SetPoint("TOP", input, "BOTTOM", 0, -8)
  389.     group:SetPoint("BOTTOMLEFT", mainGroup, 16, 16)
  390.     group:SetPoint("BOTTOMRIGHT", mainGroup, -16, 16)
  391.     group.buttons = {}
  392.     group.itemNameToID = {}
  393.     group.items = {}
  394.     group.maxButtons = floor((group:GetHeight() - 10) / 25)
  395.    
  396.     add.group = group
  397.     input.group = group
  398.    
  399.     local scroll = Scroll.new(group, 6, 1)
  400.     local func = scroll:GetScript("OnValueChanged")
  401.     scroll:SetScript("OnValueChanged", function(self, value, ...)
  402.         updateItemList(group)
  403.         return func(self, value, ...)
  404.     end)
  405.     group.scrollbar = scroll
  406.    
  407.     local itemName
  408.     local i = 1
  409.     for _, itemID in next, gxCooldownsDB.items do
  410.         itemName = GetItemInfo(itemID)
  411.         if (not itemName) then
  412.             scanLostCache()
  413.             break
  414.         end
  415.         group.itemNameToID[itemName] = itemID
  416.         group.items[i] = itemName
  417.         i = i + 1
  418.     end
  419.     sort(group.items)
  420.    
  421.     for i in next, group.items do
  422.         if (i <= group.maxButtons) then
  423.             createButton(i, group, removeItem)
  424.         end
  425.     end
  426.     updateItemList(group)
  427.    
  428.     self:EnableMouseWheel()
  429.     self:SetScript("OnMouseWheel", function(self, val)
  430.         scroll:SetValue(scroll:GetValue() - val)
  431.     end)
  432.     local numItems = #(group.items)
  433.     local maxOffset
  434.     if (numItems > group.maxButtons) then
  435.         maxOffset = numItems - group.maxButtons
  436.     else
  437.         maxOffset = 0
  438.     end
  439.     scroll:SetMinMaxValues(0, maxOffset)
  440.     scroll:SetValue(0)
  441.    
  442.     self:SetScript("OnShow", nil)
  443. end
  444.  
  445. local updateBlacklist = function(group)
  446.     local name, id
  447.    
  448.     local numSpells = #(group.spells)
  449.     local maxOffset
  450.     if (numSpells > group.maxButtons) then
  451.         maxOffset = numSpells - group.maxButtons
  452.     else
  453.         maxOffset = 0
  454.     end
  455.     group.scrollbar:SetMinMaxValues(0, maxOffset)
  456.    
  457.     local offset = floor(group.scrollbar:GetValue())
  458.     local i = offset + 1
  459.     for _, button in next, group.buttons do
  460.         if (i > (group.maxButtons + offset)) then
  461.             break
  462.         end
  463.         name = group.spells[i]
  464.         if (not name) then
  465.             button:Hide()
  466.         else
  467.             button:Show()
  468.             id = group.spellNameToID[name]
  469.            
  470.             button.icon:SetTexture(select(3, GetSpellInfo(id)))
  471.             button.text:SetText(GetSpellLink(id))
  472.            
  473.             button.itemID = id
  474.         end
  475.        
  476.         i = i + 1
  477.     end
  478. end
  479.  
  480. local removeSpell = function(button, group)
  481.     local name = GetSpellInfo(button.itemID)
  482.     button.itemID = nil
  483.     button.icon:SetTexture(nil)
  484.     button.text:SetText()
  485.     for i, spell in next, group.spells do
  486.         if (spell == name) then
  487.             tremove(group.spells, i)
  488.             break
  489.         end
  490.     end
  491.     group.spellNameToID[name] = nil
  492.    
  493.     sort(group.spells)
  494.    
  495.     updateBlacklist(group)
  496.    
  497.     gxCooldownsDB.blacklist[name] = nil
  498. end
  499.  
  500. local addSpell = function(spellLink, group)
  501.     local spellID = tonumber(string.match(spellLink, "Hspell:(%d+)"))
  502.     local name = GetSpellInfo(spellID)
  503.    
  504.     tinsert(group.spells, name)
  505.     group.spellNameToID[name] = spellID
  506.    
  507.     sort(group.spells)
  508.    
  509.     local numButtons = #(group.buttons)
  510.     if (numButtons < group.maxButtons) then
  511.         createButton(numButtons + 1, group, removeSpell)
  512.     end
  513.     updateBlacklist(group)
  514.    
  515.     gxCooldownsDB.blacklist[name] = spellID
  516. end
  517.  
  518. local addBlacklistOptions = function(self)
  519.     local title, subtitle = Heading.new(self, "gxCooldowns - Blacklist", "Here you can add whatever cooldowns you do not wish to watch.")
  520.    
  521.     local mainGroup = Group.new(self, "Blacklist")
  522.     mainGroup:SetPoint("TOP", subtitle, "BOTTOM", 0, -8)
  523.     mainGroup:SetPoint("BOTTOMLEFT", 16, 16)
  524.     mainGroup:SetPoint("BOTTOMRIGHT", -16, 16)
  525.    
  526.     local input = CreateFrame("EditBox", nil, mainGroup, "InputBoxTemplate")
  527.     input:SetPoint("TOPLEFT", mainGroup, "TOPLEFT", 24, -16)
  528.     input:SetHeight(30)
  529.     input:SetWidth(250)
  530.     input:SetAutoFocus(false)
  531.     input:SetScript("OnEscapePressed", function(self)
  532.         self:ClearFocus()
  533.     end)
  534.     input:SetScript("OnEnterPressed", function(self)
  535.         local name
  536.         local spellID = tonumber(string.match(self:GetText(), "Hspell:(%d+)"))
  537.         if (spellID) then
  538.             name = GetSpellInfo(spellID)
  539.         else
  540.             name = GetSpellInfo(self:GetText())
  541.         end
  542.        
  543.         if (not name) then
  544.             self:ClearFocus()
  545.             return
  546.         end
  547.        
  548.         local spell = GetSpellLink(name)
  549.         if (spell and not self.group.spellNameToID[name]) then
  550.             addSpell(spell, self.group)
  551.         end
  552.     end)
  553.     hooksecurefunc("ChatEdit_InsertLink", function(text)
  554.         if (self:IsShown()) then
  555.             input:SetText(text)
  556.         end
  557.     end)
  558.    
  559.     local add = Button.new(self, "LEFT", input, "RIGHT", 12, 0)
  560.     add:SetWidth(75)
  561.     add:SetHeight(25)
  562.     add.tiptext = "Click to blacklist this spell."
  563.     add:SetText("Add spell")
  564.     add:SetScript("OnClick", function(self)
  565.         local name
  566.         local spellID = tonumber(string.match(input:GetText(), "Hspell:(%d+)"))
  567.         if (spellID) then
  568.             name = GetSpellInfo(spellID)
  569.         else
  570.             name = GetSpellInfo(input:GetText())
  571.         end
  572.        
  573.         if (not name) then
  574.             input:ClearFocus()
  575.             return
  576.         end
  577.        
  578.         local spell = GetSpellLink(name)
  579.         if (spell and not self.group.spellNameToID[name]) then
  580.             addSpell(spell, self.group)
  581.         end
  582.     end)
  583.    
  584.     local group = Group.new(self)
  585.     group:SetPoint("TOP", input, "BOTTOM", 0, -8)
  586.     group:SetPoint("BOTTOMLEFT", mainGroup, 16, 16)
  587.     group:SetPoint("BOTTOMRIGHT", mainGroup, -16, 16)
  588.     group.buttons = {}
  589.     group.spells = {}
  590.     group.spellNameToID = {}
  591.     group.maxButtons = floor((group:GetHeight() - 10) / 25)
  592.    
  593.     add.group = group
  594.     input.group = group
  595.    
  596.     local scroll = Scroll.new(group, 6, 1)
  597.     local f = scroll:GetScript("OnValueChanged")
  598.     scroll:SetScript("OnValueChanged", function(self, value, ...)
  599.         updateBlacklist(group)
  600.         return f(self, value, ...)
  601.     end)
  602.     group.scrollbar = scroll
  603.    
  604.    
  605.     local i = 1
  606.     for spellName, spellID in next, gxCooldownsDB.blacklist do
  607.         group.spells[i] = spellName
  608.         group.spellNameToID[spellName] = spellID
  609.        
  610.         i = i + 1
  611.     end
  612.     sort(group.spells)
  613.    
  614.     for i in next, group.spells do
  615.         if (i <= group.maxButtons) then
  616.             createButton(i, group, removeSpell)
  617.         end
  618.     end
  619.     updateBlacklist(group)
  620.    
  621.     self:EnableMouseWheel()
  622.     self:SetScript("OnMouseWheel", function(self, val)
  623.         scroll:SetValue(scroll:GetValue() - val)
  624.     end)
  625.     local numSpells = #(group.spells)
  626.     local maxOffset
  627.     if (numSpells > group.maxButtons) then
  628.         maxOffset = numSpells - group.maxButtons
  629.     else
  630.         maxOffset = 0
  631.     end
  632.     scroll:SetMinMaxValues(0, maxOffset)
  633.     scroll:SetValue(0)
  634.    
  635.     self:SetScript("OnShow", nil)
  636. end
  637.  
  638. local setup = function(self)
  639.     gxCooldownsDB = gxCooldownsDB or {}
  640.     for k, v in next, defaults do
  641.         if (type(gxCooldownsDB[k]) == "nil") then
  642.             gxCooldownsDB[k] = v
  643.         end
  644.     end
  645.     defaults = nil
  646.    
  647.     local main = CreateFrame("Frame", "gxCooldownsConfig", InterfaceOptionsFramePanelContainer)
  648.     main.name = "gxCooldowns"
  649.     main:Hide()
  650.     main:SetScript("OnShow", addMainOptions)
  651.     InterfaceOptions_AddCategory(main)
  652.    
  653.     local items = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
  654.     items.name = "Add Items"
  655.     items.parent = "gxCooldowns"
  656.     items:Hide()
  657.     items:SetScript("OnShow", addItemsOptions)
  658.     InterfaceOptions_AddCategory(items)
  659.    
  660.     local blacklist = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
  661.     blacklist.name = "Blacklist"
  662.     blacklist.parent = "gxCooldowns"
  663.     blacklist:Hide()
  664.     blacklist:SetScript("OnShow", addBlacklistOptions)
  665.     InterfaceOptions_AddCategory(blacklist)
  666.    
  667.     SlashCmdList["GXCOOLDOWNS"] = function()
  668.         InterfaceOptionsFrame_OpenToCategory("gxCooldowns")
  669.     end
  670.     SLASH_GXCOOLDOWNS1 = "/gxcooldowns"
  671.     SLASH_GXCOOLDOWNS2 = "/gxcd"
  672. end
  673. aTable.setupConfiguration = setup
cooldown.lua
Lua Code:
  1. local aName, aTable = ...
  2.  
  3. local LBF, buttonGroup
  4. local Shiner = LibStub("tekShiner")
  5.  
  6. local match = string.match
  7. local next = next
  8. local select = select
  9. local split = string.split
  10. local tinsert = table.insert
  11. local tremove = table.remove
  12. local unpack = unpack
  13.  
  14. local GetInventoryItemCooldown = GetInventoryItemCooldown
  15. local GetInventoryItemTexture = GetInventoryItemTexture
  16. local GetItemCooldown = GetItemCooldown
  17. local GetItemInfo = GetItemInfo
  18. local GetPetActionCooldown = GetPetActionCooldown
  19. local GetSpellCooldown = GetSpellCooldown
  20. local GetSpellTexture = GetSpellTexture
  21.  
  22. -- 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]
  23. local spellSchoolColors = {
  24.     [SCHOOL_MASK_PHYSICAL] = {1,1,0},               -- Physical     1
  25.     [SCHOOL_MASK_HOLY] = {1,.9,.5},                 -- Holy         2
  26.     [SCHOOL_MASK_HOLY + SCHOOL_MASK_PHYSICAL] = {   -- Holystrike   3
  27.         {1,.9,.5},
  28.         {1,1,0}
  29.     },
  30.     [SCHOOL_MASK_FIRE] = {1,.5,0},                  -- Fire         4
  31.     [SCHOOL_MASK_FIRE + SCHOOL_MASK_PHYSICAL] = {   -- Flamestrike  5
  32.         {1,.5,0},
  33.         {1,1,0}
  34.     },
  35.     [SCHOOL_MASK_HOLY + SCHOOL_MASK_FIRE] = {       -- Holyfire     6
  36.         {1,.9,.5},
  37.         {1,.5,0}
  38.     },
  39.     [SCHOOL_MASK_NATURE] = {.3,1,.3},               -- Nature       8
  40.     [SCHOOL_MASK_NATURE + SCHOOL_MASK_PHYSICAL] = { -- Stormstrike  9
  41.         {.3,1,.3},
  42.         {1,1,0}
  43.     },
  44.     [SCHOOL_MASK_NATURE + SCHOOL_MASK_HOLY] = {     -- Holystorm    10
  45.         {.3,1,.3},
  46.         {1,.9,.5}
  47.     },
  48.     [SCHOOL_MASK_NATURE + SCHOOL_MASK_FIRE] = {     -- Firestorm    12
  49.         {.3,1,.3},
  50.         {1,.5,0}
  51.     },
  52.     [SCHOOL_MASK_FROST] = {.5,1,1},                 -- Frost        16
  53.     [SCHOOL_MASK_FROST + SCHOOL_MASK_PHYSICAL] = {  -- Froststrike  17
  54.         {.5,1,1},
  55.         {1,1,0}
  56.     },
  57.     [SCHOOL_MASK_FROST + SCHOOL_MASK_HOLY] = {      -- Holyfrost    18
  58.         {.5,1,1},
  59.         {1,.9,.5}
  60.     },
  61.     [SCHOOL_MASK_FROST + SCHOOL_MASK_FIRE] = {      -- Frostfire    20
  62.         {.5,1,1},
  63.         {1,.5,0}
  64.     },
  65.     [SCHOOL_MASK_FROST + SCHOOL_MASK_NATURE] = {    -- Froststorm   24
  66.         {.5,1,1},
  67.         {.3,1,.3}
  68.     },
  69.     [SCHOOL_MASK_SHADOW] = {.5,.5,1},               -- Shadow       32
  70.     [SCHOOL_MASK_SHADOW + SCHOOL_MASK_PHYSICAL] = { -- Shadowstrike 33
  71.         {.5,.5,1},
  72.         {1,1,0}
  73.     },
  74.     [SCHOOL_MASK_SHADOW + SCHOOL_MASK_HOLY] = {     -- Twilight     34
  75.         {.5,.5,1},
  76.         {1,.9,.5}
  77.     },
  78.     [SCHOOL_MASK_SHADOW + SCHOOL_MASK_FIRE] = {     -- Shadowflame  36
  79.         {.5,.5,1},
  80.         {1,.5,0}
  81.     },
  82.     [SCHOOL_MASK_SHADOW + SCHOOL_MASK_NATURE] = {   -- Plague       40
  83.         {.5,.5,1},
  84.         {.3,1,.3}
  85.     },
  86.     [SCHOOL_MASK_SHADOW + SCHOOL_MASK_FROST] = {    -- Shadowfrost  48
  87.         {.5,.5,1},
  88.         {.5,1,1}
  89.     },
  90.     [SCHOOL_MASK_ARCANE] = {1,.5,1},                -- Arcane       64
  91.     [SCHOOL_MASK_ARCANE + SCHOOL_MASK_PHYSICAL] = { -- Spellstrike  65
  92.         {1,.5,1},
  93.         {1,1,0}
  94.     },
  95.     [SCHOOL_MASK_ARCANE + SCHOOL_MASK_HOLY] = {     -- Divine       66
  96.         {1,.5,1},
  97.         {1,.9,.5}
  98.     },
  99.     [SCHOOL_MASK_ARCANE + SCHOOL_MASK_FIRE] = {     -- Spellfire    68
  100.         {1,.5,1},
  101.         {1,.5,0}
  102.     },
  103.     [SCHOOL_MASK_ARCANE + SCHOOL_MASK_NATURE] = {   -- Spellstorm   72
  104.         {1,.5,1},
  105.         {.3,1,.3}
  106.     },
  107.     [SCHOOL_MASK_ARCANE + SCHOOL_MASK_FROST] = {    -- Spellfrost   80
  108.         {1,.5,1},
  109.         {.5,1,1}
  110.     },
  111.     [SCHOOL_MASK_ARCANE + SCHOOL_MASK_SHADOW] = {   -- Spellshadow  80
  112.         {1,.5,1},
  113.         {.5,.5,1}
  114.     },
  115. }
  116. local FD = GetSpellInfo(5384)   -- Feign Death can't be tracked through CLEU :(
  117. local sharedCooldowns = {
  118.     [GetSpellInfo(49376)] = GetSpellInfo(16979) -- 'Feral Charge - Cat' refreshes 'Feral Charge - Bear'
  119. }
  120. local spellNameToSlotID = {}
  121. local enchantIDToSpellName = {
  122.     [3601] = GetSpellInfo(54793),   -- Frag Belt
  123.     [3603] = GetSpellInfo(54998),   -- Hand-Mounted Pyro Rocket
  124.     [3604] = GetSpellInfo(54999),   -- Hyperspeed Accelerators
  125.     [3606] = GetSpellInfo(55016),   -- Nitro Boosts
  126.  
  127. }
  128. local specialOccasions = {
  129.     [GetSpellInfo(11129)] = true,   -- Combustion
  130.     [GetSpellInfo(16166)] = true,   -- Elemental Mastery
  131.     [GetSpellInfo(89485)] = true,   -- Inner Focus
  132.     [GetSpellInfo(132158)] = true-- Nature's Swiftness
  133.     [GetSpellInfo(12043)] = true    -- Presence of Mind
  134. }
  135.  
  136. local addon = CreateFrame("Frame", aName .. "Anchor", UIParent)
  137. addon:SetClampedToScreen(true)
  138. addon:RegisterEvent("BAG_UPDATE_COOLDOWN")
  139. addon:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  140. addon:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
  141. addon:RegisterEvent("PLAYER_LOGIN")
  142. addon:RegisterEvent("SPELL_UPDATE_COOLDOWN")
  143. addon:RegisterEvent("SPELL_UPDATE_USABLE")
  144. addon:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  145. addon.active = {}
  146. addon.pool = {}
  147.  
  148. aTable.growthValues = {
  149.     ["Down"] = {
  150.         point = "TOP",
  151.         horizontal = false
  152.     },
  153.     ["Left"] = {
  154.         point = "RIGHT",
  155.         horizontal = true
  156.     },
  157.     ["Left and Right"] = {
  158.         point = "CENTER",
  159.         horizontal = true
  160.     },
  161.     ["Right"] = {
  162.         point = "LEFT",
  163.         horizontal = true
  164.     },
  165.     ["Up"] = {
  166.         point = "BOTTOM",
  167.         horizontal = false
  168.     },
  169.     ["Up and Down"] = {
  170.         point = "CENTER",
  171.         horizontal = false
  172.     }
  173. }
  174.  
  175. local tex = addon:CreateTexture(aName .. "AnchorTexture", "OVERLAY")
  176. tex:SetAllPoints(addon)
  177. tex:SetTexture(.6, .6, .6, .6)
  178. tex:Hide()
  179. addon.anchor = tex
  180.  
  181. local repositionFrames = function(self)
  182.     local gap = gxCooldownsDB.gap
  183.    
  184.     local point, rel, anchor, x, y
  185.     local numActive, prev = 0
  186.     for _, frame in next, self.active do
  187.         frame:ClearAllPoints()
  188.         if (aTable.growthValues[gxCooldownsDB.growth].horizontal) then
  189.             if (prev) then
  190.                 rel, anchor, x = prev, "RIGHT", gap
  191.             else
  192.                 rel, anchor, x = self, "LEFT", 0
  193.             end
  194.             point, y = "LEFT", 0
  195.         else
  196.             if (prev) then
  197.                 rel, anchor, y = prev, "TOP", gap
  198.             else
  199.                 rel, anchor, y = self, "BOTTOM", 0
  200.             end
  201.             point, x = "BOTTOM", 0
  202.         end
  203.        
  204.         frame:SetPoint(point, rel, anchor, x, y)
  205.        
  206.         numActive = numActive + 1
  207.         prev = frame
  208.     end
  209.    
  210.     local length = numActive * (36 + gap) - gap
  211.     if (length < 36) then
  212.         length = 36
  213.     end
  214.    
  215.     if (aTable.growthValues[gxCooldownsDB.growth].horizontal) then
  216.         self:SetWidth(length)
  217.     else
  218.         self:SetHeight(length)
  219.     end
  220. end
  221.  
  222. do
  223.     local frameNum = 1
  224.     local loadFrame = function(self)
  225.         if (#(self.pool) > 0) then
  226.             return tremove(self.pool, 1)
  227.         end
  228.        
  229.         local name = aName .. "Icon" .. frameNum
  230.        
  231.         local frame = CreateFrame("Button", name, self, "ActionButtonTemplate")
  232.         frame:EnableMouse(nil)
  233.         frame:SetFrameStrata("LOW")
  234.         frame:Hide()
  235.         frame.parent = self
  236.        
  237.         local model = Shiner.new(frame)
  238.         for _, sparkle in next, model.sparkles do
  239.             sparkle:SetHeight(sparkle:GetHeight() * 3)
  240.             sparkle:SetWidth(sparkle:GetWidth() * 3)
  241.         end
  242.         model:SetAllPoints(frame)
  243.         model:Hide()
  244.        
  245.         frame:SetScript("OnUpdate", function(self, elapsed)
  246.             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.
  247.                 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.
  248.                 self.elapseFix = nil
  249.             end
  250.            
  251.             local duration = self.duration - elapsed
  252.             if (duration <= 0) then
  253.                 self.parent:dropCooldown(self.name)
  254.                
  255.                 return
  256.             end
  257.            
  258.             self.duration = duration
  259.         end)
  260.        
  261.         frame.Cooldown = _G[name.."Cooldown"]
  262.         frame.Icon = _G[name.."Icon"]
  263.         frame.Model = model
  264.        
  265.         if (LBF) then
  266.             buttonGroup:AddButton(frame)
  267.         end
  268.        
  269.         frameNum = frameNum + 1
  270.        
  271.         return frame
  272.     end
  273.    
  274.     addon.newCooldown = function(self, cooldownName, startTime, seconds, tex, aType, elapseFix)
  275.         if (self.active[cooldownName]) then
  276.             return
  277.         end
  278.        
  279.         local frame = loadFrame(self)
  280.        
  281.         local duration = seconds - (GetTime() - startTime)
  282.         frame.start = startTime
  283.         frame.elapseFix = elapseFix
  284.         frame.duration = duration
  285.         frame.max = seconds
  286.        
  287.         frame.name = cooldownName
  288.         frame.type = aType
  289.        
  290.         frame.Icon:SetTexture(tex)
  291.         frame.Cooldown:SetCooldown(startTime, seconds)
  292.         frame:Show()
  293.        
  294.         if (self.interrupted) then
  295.             frame.Model:Show()
  296.             if (type(spellSchoolColors[self.spellSchoolID][1]) == "table") then
  297.                 local i = 1
  298.                 for _, sparkle in next, frame.Model.sparkles do
  299.                     sparkle:SetVertexColor(unpack(spellSchoolColors[self.spellSchoolID][i]))
  300.                    
  301.                     if (i == 1) then
  302.                         i = i + 1
  303.                     else
  304.                         i = i - 1
  305.                     end
  306.                 end
  307.             else
  308.                 for _, sparkle in next, frame.Model.sparkles do
  309.                     sparkle:SetVertexColor(unpack(spellSchoolColors[self.spellSchoolID]))
  310.                 end
  311.             end
  312.            
  313.             self.interrupted = nil
  314.         end
  315.        
  316.         self.active[cooldownName] = frame
  317.        
  318.         repositionFrames(self)
  319.     end
  320.    
  321.     addon.dropCooldown = function(self, cooldownName)
  322.         local frame = self.active[cooldownName]
  323.         if (frame) then
  324.             frame:Hide()
  325.             tinsert(self.pool, frame)
  326.             self.active[cooldownName] = nil
  327.            
  328.             if (frame.Model:IsShown()) then
  329.                 frame.Model:Hide()
  330.             end
  331.            
  332.             repositionFrames(self)
  333.             return true
  334.         end
  335.        
  336.         return
  337.     end
  338. end
  339.  
  340. aTable.updateFrames = function(growth)
  341.     gxCooldownsDB.growth = growth
  342.     addon:SetHeight(36)
  343.     addon:SetWidth(36) -- Reset the dimensions before we engage repositionFrames
  344.     repositionFrames(addon)
  345.    
  346.     addon:ClearAllPoints()
  347.     addon:SetPoint(aTable.growthValues[gxCooldownsDB.growth].point, UIParent, "CENTER", gxCooldownsDB.xOffset, gxCooldownsDB.yOffset)
  348. end
  349.  
  350. aTable.setScale = function(scale)
  351.     gxCooldownsDB.scale = scale
  352.     addon:SetScale(scale)
  353. end
  354.  
  355. aTable.setGap = function(gap)
  356.     gxCooldownsDB.gap = gap
  357.     repositionFrames(addon)
  358. end
  359.  
  360. aTable.setPosition = function(x, y)
  361.     gxCooldownsDB.xOffset, gxCooldownsDB.yOffset = x, y
  362.    
  363.     addon:ClearAllPoints()
  364.     addon:SetPoint(aTable.growthValues[gxCooldownsDB.growth].point, UIParent, "CENTER", gxCooldownsDB.xOffset, gxCooldownsDB.yOffset)
  365. end
  366.  
  367. do
  368.     local x, y
  369.     local coords = {[1] = {}, [2] = {}, [3] = {}}
  370.     local startMoving = function(self, button)
  371.         if (button == "RightButton") then
  372.             aTable.locked = true
  373.             aTable.toggleLock()
  374.             return
  375.         end
  376.        
  377.         _, _, _, x, y = self:GetPoint()
  378.         coords[1].x = x
  379.         coords[1].y = y
  380.        
  381.         self:StartMoving()
  382.        
  383.         _, _, _, x, y = self:GetPoint()
  384.         coords[2].x = x
  385.         coords[2].y = y
  386.     end
  387.  
  388.     local stopMoving = function(self, button)
  389.         if (button == "RightButton") then
  390.             return
  391.         end
  392.        
  393.         _, _, _, x, y = self:GetPoint()
  394.         coords[3].x = x
  395.         coords[3].y = y
  396.         self:StopMovingOrSizing()
  397.        
  398.         x = floor((coords[3].x - coords[2].x) + coords[1].x)
  399.         y = floor((coords[3].y - coords[2].y) + coords[1].y)
  400.        
  401.         gxCooldownsDB.xOffset = x
  402.         gxCooldownsDB.yOffset = y
  403.        
  404.         self:ClearAllPoints()
  405.         self:SetPoint(aTable.growthValues[gxCooldownsDB.growth].point, UIParent, "CENTER", x, y)
  406.     end
  407.    
  408.     aTable.toggleLock = function(callbackLock, callbackXY)
  409.         if (aTable.locked) then
  410.             addon.anchor:Hide()
  411.             addon:EnableMouse(nil)
  412.             addon:SetMovable(nil)
  413.            
  414.             addon:SetScript("OnMouseDown", nil)
  415.             addon:SetScript("OnMouseUp", nil)
  416.         else
  417.             addon.anchor:Show()
  418.             addon:EnableMouse(true)
  419.             addon:SetMovable(true)
  420.            
  421.             addon:SetScript("OnMouseDown", startMoving)
  422.             addon:HookScript("OnMouseDown", callbackLock)
  423.             addon:SetScript("OnMouseUp", stopMoving)
  424.             addon:HookScript("OnMouseUp", callbackXY)
  425.         end
  426.     end
  427. end
  428.  
  429. do
  430.     local scanCooldowns = function(self)
  431.         local spellName, startTime, duration, enabled, texture
  432.  
  433.         for spellNum = 1, 500 do
  434.             spellName = GetSpellTabInfo(spellNum, BOOKTYPE_SPELL)
  435.            
  436.             if (not spellName) then
  437.                 break
  438.             end
  439.            
  440.             startTime, duration, enabled = GetSpellCooldown(spellName)
  441.             if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  442.                 self:newCooldown(spellName, startTime, duration, GetSpellTexture(spellName), "SPELL", true)
  443.             end
  444.         end
  445.        
  446.         for _, item in next, gxCooldownsDB.items do
  447.             startTime, duration, enabled = GetItemCooldown(item)
  448.             if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  449.                 texture = select(10, GetItemInfo(item))
  450.                 self:newCooldown(item, startTime, duration, texture, "ITEM", true)
  451.             elseif (enabled == 0 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  452.                 self.queuedItem = self.updateItem
  453.             end
  454.         end
  455.        
  456.         for _, id in next, spellNameToSlotID do
  457.             startTime, duration, enabled = GetInventoryItemCooldown("player", id)
  458.             if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  459.                 texture = GetInventoryItemTexture("player", id)
  460.                 self:newCooldown(id, startTime, duration, texture, "INVENTORY", true)
  461.             end
  462.         end
  463.     end
  464.    
  465.     addon.PLAYER_LOGIN = function(self, addon)
  466.         aTable.setupConfiguration()
  467.        
  468.         self:SetHeight(36)
  469.         self:SetWidth(36)
  470.         self:SetScale(gxCooldownsDB.scale)
  471.         self:SetPoint(aTable.growthValues[gxCooldownsDB.growth].point, UIParent, "CENTER", gxCooldownsDB.xOffset, gxCooldownsDB.yOffset)
  472.        
  473.         if (LibStub) then
  474.             LBF = LibStub("LibButtonFacade",true)
  475.             if (LBF) then
  476.                 local skinChanged = function(self, skinName, gloss, backdrop, group, _, colors)
  477.                     gxCooldownsDB.style[1] = skinName
  478.                     gxCooldownsDB.style[2] = gloss
  479.                     gxCooldownsDB.style[3] = backdrop
  480.                     gxCooldownsDB.style[4] = colors
  481.                 end
  482.                
  483.                 LBF:RegisterSkinCallback("gxCooldowns", skinChanged, self)
  484.                 buttonGroup = LBF:Group("gxCooldowns")
  485.                 buttonGroup:Skin(unpack(gxCooldownsDB.style))
  486.             end
  487.         end
  488.        
  489.         self.playerGUID = UnitGUID("player")
  490.        
  491.         for i = 1, 19 do
  492.             self:PLAYER_EQUIPMENT_CHANGED(i, true)
  493.         end
  494.        
  495.         scanCooldowns(self)
  496.        
  497.         self:UnregisterEvent("PLAYER_LOGIN")
  498.         self.PLAYER_LOGIN = nil
  499.     end
  500. end
  501.  
  502. addon.SPELL_UPDATE_COOLDOWN = function(self)
  503.     local startTime, duration, enabled, texture
  504.     if (self.updateNext) then
  505.         startTime, duration, enabled = GetSpellCooldown(self.updateNext)
  506.         if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  507.             texture = GetSpellTexture(self.updateNext)
  508.             self:newCooldown(self.updateNext, startTime, duration, texture, "SPELL")
  509.             self.updateNext = nil
  510.         end
  511.     end
  512.    
  513.     if (self.updateSpecial) then
  514.         startTime, duration, enabled = GetSpellCooldown(self.updateSpecial)
  515.         if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  516.             texture = GetSpellTexture(self.updateSpecial)
  517.             self:newCooldown(self.updateSpecial, startTime, duration, texture, "SPELL")
  518.             self.updateSpecial = nil
  519.         end
  520.     end
  521.    
  522.     if (self.updateShared) then
  523.         texture = GetSpellTexture(self.updateShared)
  524.         startTime, duration, enabled = GetSpellCooldown(self.updateShared)
  525.         self:newCooldown(self.updateShared, startTime, duration, texture, "SPELL")
  526.        
  527.         self.updateShared = nil
  528.     end
  529.    
  530.     if (not self.updateAbility) then
  531.         return
  532.     end
  533.    
  534.     local unit, abilityName = split(",", self.updateAbility)
  535.     if (FD == abilityName) then
  536.         self.updateNext = abilityName
  537.         return
  538.     end
  539.    
  540.     local type
  541.     if (unit == "player") then
  542.         type = "SPELL"
  543.         texture = GetSpellTexture(abilityName)
  544.         startTime, duration, enabled = GetSpellCooldown(abilityName)
  545.     else
  546.         local petAction
  547.         for i = 1, NUM_PET_ACTION_SLOTS do
  548.             petAction = GetPetActionInfo(i)
  549.             if (abilityName == petAction) then
  550.                 abilityName = i
  551.                 type = "PET"
  552.                 texture = select(3, GetPetActionInfo(i))
  553.                 startTime, duration, enabled = GetPetActionCooldown(i)
  554.                
  555.                 break
  556.             end
  557.         end
  558.     end
  559.    
  560.     if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  561.         self:newCooldown(abilityName, startTime, duration, texture, type)
  562.     elseif (enabled == 1 and self.interrupted) then
  563.         self.updateNext = abilityName
  564.     end
  565.    
  566.     self.updateAbility = nil
  567. end
  568.  
  569. addon.BAG_UPDATE_COOLDOWN = function(self)
  570.     local startTime, duration, enabled, texture
  571.    
  572.     if (self.queuedItem) then   -- For items with a cooldown that doesn't start before leaving combat!
  573.         startTime, duration, enabled = GetItemCooldown(self.queuedItem)
  574.         if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  575.             texture = select(10, GetItemInfo(self.queuedItem))
  576.             self:newCooldown(self.queuedItem, startTime, duration, texture, "ITEM")
  577.            
  578.             self.queuedItem = nil
  579.         end
  580.     end
  581.    
  582.     if (self.updateItem) then
  583.         startTime, duration, enabled = GetItemCooldown(self.updateItem)
  584.         if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  585.             texture = select(10, GetItemInfo(self.updateItem))
  586.             self:newCooldown(self.updateItem, startTime, duration, texture, "ITEM")
  587.             self.updateItem = nil
  588.         elseif (enabled == 0 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  589.             self.queuedItem = self.updateItem
  590.             self.updateItem = nil
  591.         end
  592.     end
  593.    
  594.     if (self.updateSlotID) then
  595.         startTime, duration, enabled = GetInventoryItemCooldown("player", self.updateSlotID)
  596.         if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  597.             texture = GetInventoryItemTexture("player", self.updateSlotID)
  598.             self:newCooldown(self.updateSlotID, startTime, duration, texture, "INVENTORY")
  599.            
  600.             self.updateSlotID = nil
  601.         end
  602.     end
  603. end
  604.  
  605. addon.PLAYER_EQUIPMENT_CHANGED = function(self, slotID, beingEquipped)
  606.     if (not beingEquipped) then
  607.         for spellName, id in next, spellNameToSlotID do
  608.             if (id and id == slotID) then
  609.                 spellNameToSlotID[spellName] = nil
  610.                
  611.                 break
  612.             end
  613.         end
  614.        
  615.         return
  616.     end
  617.    
  618.     local itemLink = GetInventoryItemLink("player", slotID)
  619.     if (itemLink) then
  620.         local _, enchantID = match(itemLink, "Hitem:(%d+):(%d+)")
  621.         enchantID = tonumber(enchantID)
  622.        
  623.         if (enchantIDToSpellName[enchantID]) then
  624.             local spellName = enchantIDToSpellName[enchantID]
  625.             spellNameToSlotID[spellName] = slotID
  626.         end
  627.     end
  628. end
  629.  
  630. addon.UNIT_SPELLCAST_SUCCEEDED = function(self, unit, spellName)
  631.     if ((unit ~= "player" and unit ~= "pet") or gxCooldownsDB.blacklist[spellName]) then
  632.         return
  633.     end
  634.    
  635.     local item = gxCooldownsDB.items[spellName]
  636.     if (item) then
  637.         self.updateItem = item
  638.        
  639.         return
  640.     end
  641.    
  642.     local slotID = spellNameToSlotID[spellName]
  643.     if (slotID) then
  644.         self.updateSlotID = slotID
  645.        
  646.         return
  647.     end
  648.    
  649.     if (sharedCooldowns[spellName]) then -- This should be druids only
  650.         self.updateShared = sharedCooldowns[spellName]
  651.     end
  652.    
  653.     self.updateAbility = unit..","..spellName
  654. end
  655.  
  656. addon.SPELL_UPDATE_USABLE = function(self)
  657.     for name, frame in next, self.active do
  658.         local startTime, dur
  659.         if (frame.type == "SPELL") then
  660.             start, dur = GetSpellCooldown(name)
  661.         elseif (frame.type == "ITEM") then
  662.             start, dur = GetItemCooldown(name)
  663.         elseif (frame.type == "INVENTORY") then
  664.             start, dur = GetInventoryItemCooldown("player", name)
  665.         elseif (frame.type == "PET") then
  666.             start, dur = GetPetActionCooldown(name)
  667.         end
  668.        
  669.         if (not start and not dur) then -- Calling Get'Something'Cooldown right after talent swap returns a nil value
  670.             self:dropCooldown(name)
  671.             return
  672.         end
  673.        
  674.         if (dur <= 1 and frame.type == "SPELL") then -- For abilities like Readiness, dur will be lowered to 1 or 0
  675.             self:dropCooldown(name)
  676.             return
  677.         end
  678.        
  679.         if (frame.start > start or frame.max > dur) then
  680.             local duration = start - GetTime() + dur
  681.             frame.start = start
  682.             frame.duration = duration
  683.             frame.max = dur
  684.            
  685.             frame.Cooldown:SetCooldown(start, dur)
  686.         end
  687.     end
  688. end
  689.  
  690. addon.COMBAT_LOG_EVENT_UNFILTERED = function(self, _, event, sourceGUID, _, _, destGUID, _, _, ...)
  691.     local _, spellName, _, _, iSpellName, spellSchoolID = ...
  692.     if (event == "SPELL_AURA_REMOVED" and sourceGUID == self.playerGUID and specialOccasions[spellName] and not gxCooldownsDB.blacklist[spellName]) then
  693.         self.updateSpecial = spellName
  694.     elseif (event == "SPELL_INTERRUPT" and destGUID == self.playerGUID) then
  695.         self.spellSchoolID = spellSchoolID
  696.         self.interrupted = true
  697.         self.updateAbility = "player,"..iSpellName
  698.     end
  699. end
  700.  
  701. do  -- Stealth and Prowl apparently trigger SPELL_UPDATE_COOLDOWN before the aura is removed sometimes :(
  702.     local class = select(2, UnitClass("player"))
  703.     if (class == "ROGUE" or class == "DRUID") then
  704.         local stealth = class == "ROGUE" and GetSpellInfo(1784) or GetSpellInfo(5215)
  705.         addon:RegisterEvent("UPDATE_STEALTH")
  706.         addon.UPDATE_STEALTH = function(self)
  707.             local startTime, duration, enabled = GetSpellCooldown(stealth)
  708.             if (enabled == 1 and duration > gxCooldownsDB.minDuration and (duration < gxCooldownsDB.maxDuration or gxCooldownsDB.maxDuration == 3600)) then
  709.                 local texture = GetSpellTexture(stealth)
  710.                 self:newCooldown(stealth, startTime, duration, texture, "SPELL")
  711.             end
  712.         end
  713.     end
  714. end
  715.  
  716. addon:SetScript("OnEvent", function(self, event, ...)
  717.     if (self[event]) then
  718.         self[event](self, ...)
  719.     end
  720. end)

Entire file can be downloaded here: click

Thanks in advance for looking into it, I'm reallly appreciating it.
  Reply With Quote
10-16-12, 07:14 AM   #2
Aryae
A Fallenroot Satyr
Join Date: Oct 2010
Posts: 24
I'm not very skilled with LUA but it seems this addon hasn't been updated in a long while.
You may be able to eventually get it to work but what if another patch breaks its and still no update?
Besides that the issue can be a lot more then a few lines of code, may want to begin searching for a replacement. Went ahead and googled possible gxCD replacements, found someones forum post, several suggestions on there you might want to try out if you decide to go that route.
http://neriak_x.wowinterface.com/for...ad.php?t=42575

Last edited by Aryae : 10-16-12 at 07:20 AM.
  Reply With Quote
10-16-12, 07:53 AM   #3
Linayo
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 11
I've seen this post few months ago, tested few on Beta (like chill) and didn't liked it.
Went to update gxcd myself. I know the initial addon author stopped and as said, most cooldowns work including the new ones such as Tier90 Talents and even most of the monk ones. just not those 4 i mentioned above thats why im trying to find a solution for it.

Thanks tho :)

Last edited by Linayo : 10-16-12 at 07:53 AM. Reason: typo
  Reply With Quote
10-16-12, 06:01 PM   #4
Aryae
A Fallenroot Satyr
Join Date: Oct 2010
Posts: 24
No worries, sorry I couldn't be more of an assistance.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » gxCD: few Spells not showing


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off