Advertisement
Guest User

Untitled

a guest
Nov 10th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.01 KB | None | 0 0
  1. local bufficons = {
  2.     'Interface\\Icons\\spell_nature_regeneration',            --stats
  3.     'Interface\\Icons\\spell_holy_wordfortitude',             --stamina
  4.     'Interface\\Icons\\ability_warrior_battleshout',          --attack power
  5.     'Interface\\Icons\\ability_rogue_disembowel',                     --haste
  6.     'Interface\\Icons\\spell_holy_magicalsentry',                     --spell power
  7.     'Interface\\Icons\\spell_nature_unyeildingstamina',       --crit
  8.     'Interface\\Icons\\spell_holy_greaterblessingofkings',--mastery
  9.     'Interface\\Icons\\inv_elemental_mote_air01',                     --multistrike
  10.     'Interface\\Icons\\spell_holy_mindvision',                        --versatility
  11.     'Interface\\Icons\\trade_alchemy_dpotion_c12',            --flask
  12.     'Interface\\Icons\\spell_misc_food',                                      --well fed
  13. }
  14.  
  15. local MMCBFrame = CreateFrame("Frame", nil, UIParent)   --parent it to minimap so whenever the minimap hides (pet battles) this hides too, even if we're in a group
  16. MMCBFrame:SetSize(18,1)                                                                --should always be 2 + the size of the icon in spellicons table to keep 1 px border
  17. MMCBFrame:SetPoint("TOPRIGHT", Minimap, "TOPLEFT", 6, 1)       --account for the 1px backdrop around minimap
  18. MMCBFrame:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMLEFT", 6, -1)        --account for the 1px backdrop around minimap
  19. MMCBFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
  20. MMCBFrame:RegisterEvent("GROUP_ROSTER_UPDATE")                  --register these two events to match blizz functionality for the consolidated buffsrame
  21. MMCBFrame:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
  22. MMCBFrame:SetBackdrop(backdrop)
  23. MMCBFrame:SetBackdropColor(0, 0, 0)
  24. MMCBFrame:SetBackdropBorderColor(0, 0, 0)
  25.  
  26. local function CreateButton(i)
  27.     local iconFrame = CreateFrame("Frame", "MMCBButton"..i, MMCBFrame)
  28.     iconFrame:SetFrameStrata("Medium")
  29.     iconFrame:SetSize(18, 18)
  30.    
  31.     local iconTexture = iconFrame:CreateTexture(nil,"OVERLAY")
  32.     iconTexture:SetAllPoints(iconFrame)
  33.     iconTexture:SetTexture(bufficons[i])
  34.     iconTexture:SetTexCoord(0.07, 0.93, 0.07, 0.93)
  35.     return iconFrame
  36. end
  37.  
  38. for i = 1, 9 do --9 is number of buff categories
  39.     MMCBFrame[i] = CreateButton(i)
  40.     if i == 1 then
  41.         MMCBFrame[i]:SetPoint("TOP", MMCBFrame, "TOP", -1, 0)    --start with the first one 1 pixel left
  42.     else
  43.         MMCBFrame[i]:SetPoint("TOP", MMCBFrame[i-1], "BOTTOM", 0, -1)   --space each one 1 pxl down
  44.     end
  45. end
  46.  
  47. MMCBFrame:SetScript('OnEvent', function(self, event)
  48.     if event == "UNIT_AURA" or (event == "PLAYER_ENTERING_WORLD" and ShouldShowConsolidatedBuffFrame()) then
  49.         for i = 1, 9 do
  50.             local spellName = GetRaidBuffTrayAuraInfo(i)
  51.             if spellName then                                                               --indicative that we have this buff, therefore, we want to make the icon not bright
  52.                 MMCBFrame[i]:SetAlpha(0.3)
  53.             else
  54.                 MMCBFrame[i]:SetAlpha(1)                                       --indicative that we are missing the buff, make the icon bright, alerting us to request buff
  55.             end
  56.         end
  57.     else                                                                                                    --should fire when our comp changes or i switch specs? I don't get why blizzard registered the spec swap in the check for their conoslidatedbuffs:show/hide code
  58.         if ShouldShowConsolidatedBuffFrame() then                               --we're in a group want to start looking at buffs
  59.             MMCBFrame:RegisterUnitEvent("UNIT_AURA", "player")      --unit register unitaura for the player only
  60.             MMCBFrame:Show()                                                                        --show the frame, cause you know, we dont code 40 lines for nothing
  61.         else
  62.             MMCBFrame:UnregisterEvent("UNIT_AURA")                          --we either left the group or the group disbanded, no senseless polling of cpu resources
  63.             MMCBFrame:Hide()                                                                        --hide the frame, cause, it doesn't help us visually during solo
  64.         end
  65.     end
  66. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement