Advertisement
Guest User

core

a guest
Jul 23rd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.35 KB | None | 0 0
  1. local _,ns = ...
  2. EHVitals = ns
  3. ns.config = {}
  4. ns.backdrop = {}
  5.  
  6. local EventsToRegister = {}
  7. local ModuleEventsToRegister = {}
  8.  
  9. local class = select(2,UnitClass('player'))
  10.  
  11. local frame = CreateFrame('Frame','EventHorizon_VitalsFrame',UIParent)
  12. local slave = CreateFrame('Frame',nil,frame)
  13.  
  14. local left = frame:CreateFontString(nil,'OVERLAY')
  15. local center = frame:CreateFontString(nil,'OVERLAY')
  16. local right = {}
  17. local rune = {}
  18.  
  19. local centerexclusive, rightexclusive
  20.  
  21. local function printhelp(...)
  22.   if select('#',...)>0 then
  23.     return tostring((...)), printhelp(select(2,...))
  24.   end
  25. end
  26.  
  27. local function print(...)
  28.   ChatFrame1:AddMessage('EventHorizon_Vitals: '..strjoin(',',printhelp(...)))
  29. end
  30.  
  31. local time = GetTime()
  32. local TTL, tTTL, hTTL = 0.05, 0.10, 1
  33. local TSLU, tTSLU, hTSLU = 0, 0, 0
  34. local powerunit
  35. local runeCD
  36.  
  37. local rounding = 60000
  38.  
  39. ns.powerTypePrimary = {
  40.   DEATHKNIGHT = 6,
  41.   HUNTER = 2,
  42.   ROGUE = 3,
  43.   WARRIOR = 1,
  44. }
  45.  
  46. ns.powerTypeSecondary = {
  47.   DRUID = 'COMBO_POINTS',
  48.   PALADIN = 'HOLY_POWER',
  49.   WARLOCK = 'SOUL_SHARDS',
  50.   ROGUE = "COMBO_POINTS"
  51. }
  52.  
  53. ns.secondaryPowerTypes = {
  54.   SOUL_SHARDS = 7,
  55. --  ECLIPSE = 8,
  56.   HOLY_POWER = 9,
  57. }
  58.  
  59. ns.auras = {
  60.   PRIEST = {
  61.     armor = {588,73413},
  62.     orb = 77487,
  63.     fort = {21562,469,90364},
  64.     ve = 15286,
  65.   },
  66.   SHAMAN = {
  67.     shield = {52127,974,324},
  68.   },
  69.   WARRIOR = {
  70.     battle = {19740,6673},
  71.     commanding = {21562,469,90364},
  72.   },
  73.   DRUID = {
  74.     solar = 48517,
  75.     lunar = 48518,
  76.   },
  77. }
  78.  
  79. for i=1,6 do
  80.   rune[i] = CreateFrame('Frame',nil,frame)
  81.   rune[i].TTL = tTTL
  82.   rune[i].TSLU = 0
  83.   rune[i].id = i
  84.   rune[i].text = frame:CreateFontString(nil,'OVERLAY')
  85.   if i <= 3 then
  86.     right[i] = frame:CreateFontString(nil,'OVERLAY')
  87.   end
  88. end
  89.  
  90. local function EventHandler(self, event, ...)
  91.   local f = self[event]
  92.   if f then
  93.     f(self,...)
  94.   end
  95. end
  96.  
  97. local function Clone(t)
  98.   local new = {}
  99.   local i, v = next(t, nil) -- i is an index of t, v = t[i]
  100.   while i do
  101.     new[i] = v
  102.     i, v = next(t, i)
  103.   end
  104.   return new
  105. end
  106.  
  107. local function Round(num,idp)
  108.   if idp and idp>0 then
  109.     local mult = 10^idp
  110.     return math.floor(num * mult + 0.5) / mult
  111.   end
  112.   return math.floor(num + 0.5)
  113. end
  114.  
  115. local UpdateCP = function (self)
  116.   if centerexclusive and powerunit == 'player' then return end
  117.   local c = UnitPower(powerunit, 4)
  118.   if (c > 0) then
  119.     center:SetText(c)
  120.     center:SetVertexColor(unpack(ns.color["combo"..c]))
  121.   else
  122.     center:SetText("")
  123.     center:SetVertexColor(unpack(ns.color["combo"..c]))
  124.   end
  125. end
  126.  
  127. local SpawnStyleFrame = function ()
  128.   local sf = CreateFrame('Frame','EventHorizon_VitalsBG',EventHorizon_VitalsFrame)
  129.  
  130.   sf:SetFrameStrata('BACKGROUND')
  131.   local eh = EventHorizon.config
  132.   if eh.backdrop == true then
  133.     sf:SetPoint('TOPRIGHT', EventHorizon_VitalsFrame, 'TOPRIGHT', eh.padding, eh.padding)
  134.     sf:SetPoint('BOTTOMLEFT', EventHorizon_VitalsFrame, 'BOTTOMLEFT', -eh.padding, -eh.padding)
  135.     sf:SetBackdrop({
  136.       bgFile = eh.bg,
  137.       edgeFile = eh.border, tileSize = 0, edgeSize = eh.edgesize,
  138.       insets = eh.inset,
  139.     })
  140.     sf:SetBackdropColor(unpack(EventHorizon.colors.bgcolor))
  141.     sf:SetBackdropBorderColor(unpack(EventHorizon.colors.bordercolor))
  142.   else return end
  143. end
  144.  
  145. local ApplyFonts = function (fs,j,flag)   -- Ex: ApplyFonts(fontstring1,"LEFT")
  146.   if flag == 'rune' then
  147.     fs:SetFont(ns.config.runeFont,ns.config.fontSizeRune)
  148.   elseif flag == 'right' then
  149.     fs:SetFont(ns.config.font,ns.config.fontSizeRight)
  150.   elseif flag == 'center' then
  151.     fs:SetFont(ns.config.font,ns.config.fontSizeCenter)
  152.   else
  153.     fs:SetFont(ns.config.font,ns.config.fontSizeLeft)
  154.   end
  155.  
  156.   fs:SetJustifyH(j)
  157.   fs:SetHeight(ns.config.height)
  158.   local sfs = ns.config.FontShadow and (type(ns.config.FontShadow) == 'table' and ns.config.FontShadow or {0,0,0,0.5}) or nil
  159.   local sfso = (ns.config.FontShadowOffset and type(ns.config.FontShadowOffset) == 'table') and ns.config.FontShadowOffset or {1,-1}
  160.   if sfs then
  161.     fs:SetShadowColor(unpack(sfs))
  162.     fs:SetShadowOffset(unpack(sfso))
  163.   end
  164.   fs:Show()
  165. end
  166.  
  167. local ApplyConfig = function ()
  168.  
  169. end
  170.  
  171. local CheckPower = function ()
  172.   powerunit = (UnitPower('vehicle') > 0 and UnitHasVehicleUI('player')) and 'vehicle' or 'player'
  173.  
  174.   local c = {}
  175.   local p = UnitPower(powerunit)
  176.   local pm = UnitPowerMax(powerunit)
  177.   local pt, pts = UnitPowerType(powerunit)
  178.  
  179.   if ns.color.useClassColor and type(ns.color.useClassColor) == "table" then
  180.     c = {r = ns.color.useClassColor[1], g = ns.color.useClassColor[2], b = ns.color.useClassColor[3]}
  181.   elseif ns.color.useClassColor and (powerunit == 'player' and ((ns.powerTypePrimary[class] and pt == ns.powerTypePrimary[class]) or pt == 0)) then
  182.     c = {r = ns.classcolor[1], g = ns.classcolor[2], b = ns.classcolor[3]}
  183.   elseif PowerBarColor[pt] then
  184.     c = PowerBarColor[pt]
  185.   else
  186.     c = {r = 1, g = 1, b = 1}
  187.   end
  188.  
  189.   if p and pt then
  190.     left:SetVertexColor(c.r,c.g,c.b)
  191.   else
  192.     left:SetVertexColor(1,1,1)
  193.   end
  194.  
  195.   if ns.powerTypeSecondary[class] then
  196.     frame:UNIT_POWER('player',ns.secondaryPowerTypes[ns.powerTypeSecondary[class]])
  197.   end
  198.   UpdateCP()
  199. end
  200.  
  201. local OnUpdate_Enchant = function (self,elapsed)
  202.   self.TSLU = self.TSLU + elapsed
  203.   while (self.TSLU >= self.TTL) do
  204.    
  205.     local mh,mhEx,_,oh,ohEx,_ = GetWeaponEnchantInfo()
  206.     --print(mh,mhEx,oh,ohEx)
  207.     if mh then
  208.       --print(r)
  209.       local mt = Round(mhEx/rounding)
  210.       right[3]:SetText(mt)
  211.       if mt <= 5 then
  212.         right[3]:SetVertexColor(unpack(ns.color.enchantExpiring))
  213.       else
  214.         right[3]:SetVertexColor(unpack(ns.color.useClassColor and ns.color.enchantFresh or ns.color.default))
  215.       end
  216.     else
  217.       right[3]:SetText('')
  218.     end
  219.     if oh then
  220.       local ot = Round(ohEx/rounding)
  221.       right[1]:SetText(ot)
  222.       if ot <= 5 then
  223.         right[1]:SetVertexColor(unpack(ns.color.enchantExpiring))
  224.       else
  225.         right[1]:SetVertexColor(unpack(ns.color.useClassColor and ns.color.enchantFresh or ns.color.default))
  226.       end
  227.     else
  228.       right[1]:SetText('')
  229.     end
  230.  
  231.     self.TSLU = self.TSLU - self.TTL
  232.   end
  233. end
  234.  
  235. local OnUpdate_Rune = function (self,elapsed)
  236.   self.TSLU = self.TSLU + elapsed
  237.     -- Highly throttled updates for DK runes
  238.   while (self.TSLU >= self.TTL) do
  239.     local start,duration,ready = GetRuneCooldown(self.id)
  240.    
  241.     if (ready == true) then
  242.       self.text:SetText(ns.config.runeReady)
  243.       self.text:SetAlpha(1)
  244.       self.TSLU = 0
  245.       self:SetScript("OnUpdate",nil)
  246.       return
  247.     else
  248.       local cd = Round(start + duration - GetTime())
  249.       if cd < 0 then
  250.         cd = 0
  251.       end
  252.       --[[if cd >= 10 then
  253.         self.text:SetText(ns.config.runeReady)
  254.         self.text:SetAlpha(1)
  255.         self.TSLU = 0
  256.         self:SetScript("OnUpdate",nil)
  257.         return
  258.       end]]-- Why is this here???
  259.       self.text:SetText((cd <= runeCD) and cd or ns.config.runeCooling)
  260.       self.text:SetAlpha(math.min(1, 1-(cd*ns.config.runeAlphaStep)))
  261.       --print(1-(cd*ns.config.runeAlphaStep))
  262.     end
  263.     self.TSLU = self.TSLU - self.TTL
  264.   end
  265.  
  266. end
  267.  
  268. local OnUpdate_Power = function (self,elapsed)
  269.   self.TSLU = self.TSLU + elapsed
  270.  
  271.   while (self.TSLU >= self.TTL) do
  272.     local p = UnitPower(powerunit)
  273.     local pm = UnitPowerMax(powerunit)
  274.     local pt, pts = UnitPowerType(powerunit)
  275.  
  276.     if PowerBarColor[pt] or PowerBarColor[pts] then
  277.       left:SetText(p)
  278.     else
  279.       left:SetText("")
  280.     end
  281.  
  282.     if p == 0 and ((pt == 1) or (pt == 6)) then
  283.       left:SetAlpha(ns.color.fade)
  284.     elseif p == pm then
  285.       left:SetAlpha(ns.color.fade)
  286.     else
  287.       left:SetAlpha(ns.color.normal)
  288.     end
  289.    
  290.     self.TSLU = self.TSLU - TTL
  291.   end  
  292. end
  293.  
  294. local UpdateRune = function (self,runeid,usable)
  295.   if runeid ~= self.id then return end
  296.   local start,duration,ready = GetRuneCooldown(runeid)
  297.   local rC = ns.config.runeCooldown or 0
  298.   --print(runeid,usable)
  299.  
  300.   if ready == true then
  301.     self.text:SetText(ns.config.runeReady)
  302.   else
  303.     self.TSLU = 0
  304.     self:SetScript('OnUpdate',OnUpdate_Rune)
  305.     local cd = start + duration - GetTime()
  306.     cd = Round(cd)
  307.     if ((rC > 0) and (cd <= rC)) then
  308.       self.text:SetText(cd)
  309.     else
  310.       self.text:SetText(ns.config.runeCooling)
  311.     end    
  312.   end
  313. end
  314.  
  315. local UpdateRuneType = function (self,runeid)
  316.   if runeid ~= self.id then return end
  317.   local rt = GetRuneType(runeid)
  318.   self.text:SetVertexColor(unpack(ns.color["rune"..rt]))
  319.   UpdateRune(self,runeid)
  320. end
  321.  
  322. local UpdateSecondaryPower = function (self,unit,powertype)
  323.   if unit ~= 'player' then return end
  324.   if ((class == "ROGUE") or (class == "DRUID")) then
  325.     UpdateCP()
  326.     return
  327.   end
  328.   local cpt
  329.   if powertype then
  330.     cpt = powertype and (powertype == ns.powerTypeSecondary[class]) and ns.secondaryPowerTypes[powertype]
  331.   else
  332.     cpt = ns.secondaryPowerTypes[ns.powerTypeSecondary[class]]
  333.   end
  334.   local p = UnitPower('player',ns.secondaryPowerTypes[ns.powerTypeSecondary[class]])
  335.   center:SetText(p)
  336.  
  337.   center:SetVertexColor(unpack(ns.color.useClassColor and ns.color.enchantFresh or ns.color.default))
  338. end
  339.  
  340. local Init = function ()
  341.   local cc = ns.config
  342.   local eh = EventHorizon.config
  343.   local offset = cc.offset
  344.  
  345.   local classcolors = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS
  346.   local classcolor = Clone(classcolors[select(2,UnitClass('player'))])
  347.   ns.classcolor = {classcolor.r,classcolor.g,classcolor.b}
  348.  
  349.   for colorid,color in pairs(ns.color) do
  350.     if type(color) == 'table' and color[1] == true then
  351.       if color[2] then
  352.         ns.color[colorid] = {classcolor.r * color[2], classcolor.g * color[2], classcolor.b * color[2], color[3] or 1}
  353.       else
  354.         ns.color[colorid] = {classcolor.r, classcolor.g, classcolor.b, 1}
  355.       end
  356.     end
  357.   end
  358.  
  359.   frame:SetHeight(cc.height)
  360.   if type(cc.position) == 'table' then
  361.     frame:SetPoint(unpack(cc.position))
  362.   elseif cc.position == 'bottom' then
  363.     frame:SetPoint("TOPLEFT", EventHorizon.mainframe, "BOTTOMLEFT", 0, -offset)
  364.     frame:SetPoint("TOPRIGHT", EventHorizon.mainframe, "BOTTOMRIGHT", 0, -offset)
  365.   else
  366.     frame:SetPoint("BOTTOMLEFT", EventHorizon.mainframe, "TOPLEFT", 0, offset)
  367.     frame:SetPoint("BOTTOMRIGHT", EventHorizon.mainframe, "TOPRIGHT", 0, offset)
  368.   end
  369.  
  370.   ApplyFonts(left,"LEFT")
  371.   ApplyFonts(center,"LEFT",'center')
  372.   ApplyFonts(right[1],'RIGHT','right')
  373.   ApplyFonts(right[2],'RIGHT','right')
  374.   ApplyFonts(right[3],'RIGHT','right')
  375.    
  376.   for i=1,6 do
  377.     ApplyFonts(rune[i].text,"LEFT",'rune')
  378.   end
  379.  
  380.   local toffx = cc.textOffset[1]
  381.   local toffy = cc.textOffset[2]
  382.  
  383.   left:SetPoint("LEFT", EventHorizon_VitalsFrame, "LEFT", toffx, toffy)
  384.   center:SetPoint("CENTER", EventHorizon_VitalsFrame, "CENTER", 0, toffy)
  385.   right[1]:SetPoint("RIGHT",frame,"RIGHT",-toffx,toffy)
  386.   right[2]:SetPoint("RIGHT",right[1],"LEFT",-toffx,0)
  387.   right[3]:SetPoint("RIGHT",right[2],"LEFT",-toffx,0)
  388.  
  389.   if class == "DEATHKNIGHT" then
  390.     runeCD = cc.runeCooldown
  391.     for i=1,6 do
  392.       if i == 1 then
  393.         rune[6].text:SetPoint("RIGHT", EventHorizon_VitalsFrame, "RIGHT", -toffx, cc.runeOffset + toffy)
  394.       else
  395.         rune[7-i].text:SetPoint("RIGHT", rune[8-i].text, "LEFT", -cc.runeSpacing, 0)
  396.       end
  397.       rune[i]:SetScript("OnEvent",EventHandler)
  398.       UpdateRuneType(rune[i],i)
  399.     end
  400.   else
  401.     for i=1,6 do
  402.       rune[i].text:Hide()
  403.     end
  404.   end
  405.  
  406.   SpawnStyleFrame()
  407.   CheckPower()
  408.  
  409.   frame:Show()
  410.   frame:SetScript("OnUpdate", OnUpdate_Power)
  411.   frame:SetScript("OnEvent", EventHandler)
  412.   for k,v in pairs(EventsToRegister) do
  413.     frame:RegisterEvent(k)
  414.   end
  415.   if ModuleEventsToRegister['UNIT_AURA'] then
  416.     for k,v in pairs(ns.auras[class]) do
  417.       if type(v) == 'table' then
  418.         for i,aura in pairs(v) do
  419.           local spellname = GetSpellInfo(aura)
  420.           ns.auras[class][k][i] = spellname
  421.         end
  422.       else
  423.         local spellname = GetSpellInfo(v)
  424.         ns.auras[class][k] = {spellname}
  425.       end
  426.     --  print(ns.auras[class][k])
  427.     end
  428.   end
  429.   if EventsToRegister['UNIT_POWER'] then frame:UNIT_POWER('player',ns.secondaryPowerTypes[ns.powerTypeSecondary[class]]) end
  430.   if EventsToRegister['UNIT_INVENTORY_CHANGED'] then frame:UNIT_INVENTORY_CHANGED('player') end
  431.  
  432.   ns.isReady = true
  433. end
  434.  
  435. local UpdateInventory = function (self,u)
  436.   if u ~= 'player' then return end
  437.   local mh,mhEx,_,oh,ohEx,_ = GetWeaponEnchantInfo()
  438.  
  439.   if (mh and mhEx) or (oh and ohEx) then
  440.     slave.TTL = hTTL
  441.     slave.TSLU = 0
  442.     slave:SetScript('OnUpdate',OnUpdate_Enchant)
  443.   else
  444.     slave:SetScript('OnUpdate',nil)
  445.   end
  446.  
  447.   if not mh then
  448.     right[3]:SetText('')
  449.   end
  450.   if not oh then
  451.     right[1]:SetText('')
  452.   end
  453. end
  454.  
  455. local GetAuraInfo = function (auras)
  456.   local name, text, icon, count, dispelType, duration, expires, caster
  457.   for i,aura in pairs(auras) do
  458.     name, text, icon, count, dispelType, duration, expires, caster = UnitBuff('player',aura)
  459.     if name then
  460.       return name, text, icon, count, dispelType, duration, expires, caster
  461.     end
  462.   end
  463. end
  464.  
  465. local UnitAuraCS = {
  466.   ["PRIEST"] = function (self,u)
  467.     if u ~= 'player' then return end
  468.     centerexclusive = true
  469.    
  470.     local lvl = EventHorizon.vars.currentLevel
  471.     local armor = GetAuraInfo(ns.auras[class].armor)
  472.     local ve = GetAuraInfo(ns.auras[class].ve) or (EventHorizon.vars.activeTree ~= 3) or lvl < 39
  473.    
  474.     if armor then
  475.       right[1]:SetText('')
  476.     else
  477.       right[1]:SetText('IF')
  478.       right[1]:SetVertexColor(unpack(ns.color.enchantExpiring))
  479.     end
  480.    
  481.     if ve then
  482.       right[3]:SetText('')
  483.     else
  484.       right[3]:SetText('VE')
  485.       right[3]:SetVertexColor(unpack(ns.color.enchantExpiring))
  486.     end
  487.   end,
  488.  
  489.   ["WARRIOR"] = function (self,u)
  490.     if u ~= 'player' then return end
  491.     right[1]:SetVertexColor(unpack(ns.color.enchantExpiring))
  492.     local _,_,_,_,_,_,_,hp = GetAuraInfo(ns.auras[class].commanding)
  493.     local _,_,_,_,_,_,_,ap = GetAuraInfo(ns.auras[class].battle)
  494.    
  495.     local lvl = EventHorizon.vars.currentLevel
  496.    
  497.     local mine = (hp == 'player') or (ap == 'player')
  498.     local txt
  499.     if mine or (hp and ap) then
  500.       txt = ''
  501.     else
  502.       txt = (lvl >= 20 and hp and 'BS') or (lvl >= 68 and ap and 'CS') or lvl >= 20 and 'shout'
  503.     end
  504.     --print(hp,ap,mine)
  505.     right[1]:SetText(txt)
  506.   end,
  507.  
  508.   ["SHAMAN"] = function (self,u)
  509.     if u ~= 'player' then return end
  510.     local shielded
  511.     centerexclusive = true
  512.     local _,_,_,count,_,_,_,source = GetAuraInfo(ns.auras[class].shield)
  513.    
  514.     if source == 'player' and count > 0 then
  515.       center:SetText(count)
  516.     else
  517.       center:SetText('shield')
  518.     end
  519.    
  520.     if not(count) or count == 1 then
  521.       center:SetVertexColor(unpack(ns.color.enchantExpiring))
  522.     else
  523.       center:SetVertexColor(unpack(ns.color.useClassColor and ns.color.enchantFresh or ns.color.default))
  524.     end
  525.   end,
  526. }
  527.  
  528. EventsToRegister['UNIT_ENTERED_VEHICLE'] = true
  529. EventsToRegister['UNIT_EXITED_VEHICLE'] = true
  530. EventsToRegister['UPDATE_SHAPESHIFT_FORM'] = true
  531. frame.UPDATE_SHAPESHIFT_FORM = CheckPower
  532. frame.TSLU = 0
  533. frame.TTL = TTL
  534.  
  535. if UnitAuraCS[class] then
  536.   ModuleEventsToRegister['UNIT_AURA'] = true
  537.   ns.UNIT_AURA = UnitAuraCS[class]
  538.   ns.CheckTalents = function ()
  539.     --print('CheckTalents')
  540.     return EventHorizon.mainframe:UNIT_AURA('player') end
  541. end
  542.  
  543. function frame:UNIT_ENTERED_VEHICLE(unit)
  544.   if unit ~= 'player' then return end
  545.   return CheckPower()
  546. end
  547.  
  548. function frame:UNIT_EXITED_VEHICLE(unit)
  549.   if unit ~= 'player' then return end
  550.   return CheckPower()
  551. end
  552.  
  553. if class == "DEATHKNIGHT" then
  554.   for i=1,6 do
  555.     rune[i]:RegisterEvent('RUNE_POWER_UPDATE')
  556.     rune[i]:RegisterEvent('RUNE_TYPE_UPDATE')
  557.  
  558.     rune[i].RUNE_POWER_UPDATE = UpdateRune
  559.     rune[i].RUNE_TYPE_UPDATE = UpdateRuneType
  560.   end
  561. end
  562.  
  563. if (class == "WARLOCK" or class == "ROGUE" or class == "SHAMAN") then
  564.   EventsToRegister['UNIT_INVENTORY_CHANGED'] = true
  565.   frame.UNIT_INVENTORY_CHANGED = UpdateInventory
  566. end
  567.  
  568. if ns.powerTypeSecondary[class] then
  569.   EventsToRegister['UNIT_POWER'] = true
  570.   frame.UNIT_POWER = UpdateSecondaryPower
  571. end
  572.  
  573. local Enable = function (slash)
  574.   if slash and ns.config.slashDisable ~= true then return end
  575.  
  576.   CheckPower() -- Get everything set up properly before reenabling everything.
  577.  
  578.   frame:Show()
  579.   frame:SetScript("OnEvent", EventHandler)
  580.   frame:SetScript("OnUpdate", OnUpdate_Power)
  581.   if ModuleEventsToRegister['UNIT_AURA'] then EventHorizon.mainframe:UNIT_AURA('player') end
  582.   if EventsToRegister['UNIT_POWER'] then frame:UNIT_POWER('player',ns.secondaryPowerTypes[ns.powerTypeSecondary[class]]) end
  583.   if EventsToRegister['UNIT_INVENTORY_CHANGED'] then frame:UNIT_INVENTORY_CHANGED('player') end
  584.   if class == "DEATHKNIGHT" then
  585.     for i=1,6 do
  586.       rune[i]:SetScript("OnEvent",EventHandler)
  587.       UpdateRuneType(rune[i],i)
  588.     end
  589.   end
  590.   ns.isActive = true
  591. end
  592.  
  593. local Disable = function (slash)
  594.   if slash and ns.config.slashDisable ~= true then return end
  595.  
  596.   frame:Hide()
  597.   frame:SetScript('OnEvent',nil)
  598.   frame:SetScript('OnUpdate',nil)
  599.   if EventsToRegister['UNIT_INVENTORY_CHANGED'] then slave:SetScript('OnUpdate',nil) end
  600.   if class == "DEATHKNIGHT" then
  601.     for i=1,6 do
  602.       rune[i]:SetScript('OnEvent',nil)
  603.       rune[i]:SetScript('OnUpdate',nil)
  604.     end
  605.   end
  606.   ns.isActive = false
  607. end
  608.  
  609. ns.Init = Init
  610. ns.Enable = Enable
  611. ns.Disable = Disable
  612.  
  613. EventHorizon:RegisterModule('vitals',ns)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement