Advertisement
Guest User

lib.lua

a guest
Mar 23rd, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 39.65 KB | None | 0 0
  1.   local addon, ns = ...
  2.   local cfg = ns.cfg
  3.   local cast = ns.cast
  4.   local lib = CreateFrame("Frame")  
  5.   local _, playerClass = UnitClass("player")
  6.  
  7.   oUF.colors.power['MANA'] = {0.0, 0.56, 1.0}
  8.   oUF.colors.power['RAGE'] = {1.0,0,0}
  9.   oUF.colors.power['FOCUS'] = {1.0,0.75,0.25}
  10.   oUF.colors.power['ENERGY'] = {1.0, 0.9, 0.35}
  11.   oUF.colors.power['RUNIC_POWER'] = {0.44,0.44,0.44}
  12.   local _, pType = UnitPowerType("player")
  13.   local pcolor = oUF.colors.power[pType] or {.3,.45,.65}
  14.   oUF.colors.runes = {{196/255, 30/255, 58/255};{173/255, 217/255, 25/255};{35/255, 127/255, 255/255};{178/255, 53/255, 240/255};}
  15.    
  16.     ns.colors = setmetatable({
  17.         power = setmetatable({
  18.             ['MANA'] = {0.0, 0.56, 1.0},
  19.             ['RAGE'] = {1.0,0,0},
  20.             ['FOCUS'] = {1.0,0.75,0.25},
  21.             ['ENERGY'] = {1.0, 0.9, 0.35},
  22.             ['RUNIC_POWER'] = {0.44,0.44,0.44},
  23.         }, {__index = oUF.colors.power}),
  24.     }, {__index = oUF.colors})
  25.  
  26.     -- FUNCTIONS
  27.  
  28.  local retVal = function(f, val1, val2, val3)
  29.     if f.mystyle == "player" or f.mystyle == "target" then
  30.         return val1
  31.     elseif f.mystyle == "raid" or f.mystyle == "party" then
  32.         return val3
  33.     else
  34.         return val2
  35.     end
  36. end
  37.  
  38.   --status bar filling fix (from oUF_Mono)
  39.   local fixStatusbar = function(b)
  40.     b:GetStatusBarTexture():SetHorizTile(false)
  41.     b:GetStatusBarTexture():SetVertTile(false)
  42.   end
  43.  
  44.   --backdrop table
  45.   local backdrop_tab = {
  46.     bgFile = cfg.backdrop_texture,
  47.     edgeFile = cfg.backdrop_edge_texture,
  48.     tile = false,
  49.     tileSize = 0,
  50.     edgeSize = 5,
  51.     insets = {
  52.       left = 3,
  53.       right = 3,
  54.       top = 3,
  55.       bottom = 3,
  56.     },
  57.   }
  58.  
  59. -- backdrop func
  60. lib.gen_backdrop = function(f)
  61.     f:SetBackdrop(backdrop_tab);
  62.     f:SetBackdropColor(0,0,0,1)
  63.     f:SetBackdropBorderColor(0,0,0,0.8)
  64. end
  65.  
  66. lib.gen_castbackdrop = function(f)
  67.     f:SetBackdrop(backdrop_tab);
  68.     f:SetBackdropColor(0,0,0,0.6)
  69.     f:SetBackdropBorderColor(0,0,0,1)
  70. end
  71.  
  72. lib.gen_totemback = function(f)
  73.     f:SetBackdrop(backdrop_tab);
  74.     f:SetBackdropColor(0,0,0,0.6)
  75.     f:SetBackdropBorderColor(0,0,0,0.8)
  76. end
  77.  
  78. -- Right Click Menu
  79. lib.spawnMenu = function(self)
  80.     local unit = self.unit:sub(1, -2)
  81.     local cunit = self.unit:gsub("^%l", string.upper)
  82.  
  83.     if(cunit == "Vehicle") then
  84.         cunit = "Pet"
  85.     end
  86.  
  87.     if(unit == "party") then
  88.         ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor", 0, 0)
  89.     elseif(_G[cunit.."FrameDropDown"]) then
  90.         ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0)
  91.     elseif unit == "raid" then
  92.         FriendsDropDown.unit = self.unit
  93.         FriendsDropDown.id = self.id
  94.         FriendsDropDown.initialize = RaidFrameDropDown_Initialize
  95.         ToggleDropDownMenu(1,nil,FriendsDropDown,"cursor")     
  96.     end
  97. end
  98.  
  99.   --fontstring func
  100.   lib.gen_fontstring = function(f, name, size, outline)
  101.     local fs = f:CreateFontString(nil, "OVERLAY")
  102.     fs:SetFont(name, size, outline)
  103.     fs:SetShadowColor(0,0,0,0.8)
  104.     fs:SetShadowOffset(1,-1)
  105.     return fs
  106.   end  
  107.  
  108. -- Power Bar Arrow function
  109.  
  110. local arrow = {[[Interface\Addons\oUF_Fail\media\textureArrow]]}
  111.  
  112. --set color -- Huge thanks to Zork and Rainrider for helping me figure this out.
  113. lib.setArrowColor = function(self)
  114.     local _, pType = UnitPowerType("player")
  115.     local pcolor = oUF.colors.power[pType] or {.3,.45,.65}
  116.     self.Power.arrow:SetVertexColor(unpack(pcolor))
  117. end
  118.  
  119. local fixTex = function(tex)
  120.     local ULx,ULy,LLx,LLy,URx,URy,LRx,LRy = tex:GetTexCoord()
  121.     tex:SetTexCoord(ULy,ULx,LLy,LLx,URy,URx,LRy,LRx)
  122. end
  123.  
  124.   --gen healthbar func
  125.   lib.gen_hpbar = function(f)
  126.     --statusbar
  127.     local s = CreateFrame("StatusBar", nil, f)
  128.     s:SetStatusBarTexture(cfg.statusbar_texture)
  129.     fixStatusbar(s)
  130.     if f.mystyle == "focus" or f.mystyle =="focustarget" then
  131.         s:SetHeight(30)
  132.     elseif f.mystyle =="pet" then
  133.         s:SetHeight(28)
  134.     else
  135.         s:SetHeight(retVal(f,28,24,20))
  136.     end
  137.     s:SetWidth(f:GetWidth())
  138.     s:SetPoint("BOTTOM",0,0)
  139.     s:SetFrameLevel(4)
  140.     --helper
  141.     local h = CreateFrame("Frame", nil, s)
  142.     h:SetFrameLevel(3)
  143.     h:SetPoint("TOPLEFT",-5,5)
  144.     h:SetPoint("BOTTOMRIGHT", 5, -5)
  145.     lib.gen_backdrop(h)
  146.     --bg
  147.     local b = s:CreateTexture(nil, "BACKGROUND")
  148.     b:SetTexture(cfg.statusbar_texture)
  149.     b:SetAllPoints(s)
  150.     b:SetVertexColor(1, 0.1, 0.1,0.8)
  151.    
  152.     f.Health = s
  153.     f.Health.bg2 = b
  154.   end
  155.  
  156.   --gen hp strings func
  157.   lib.gen_hpstrings = function(f, unit)
  158.     --creating helper frame here so our font strings don't inherit healthbar parameters
  159.     local h = CreateFrame("Frame", nil, f)
  160.     h:SetAllPoints(f.Health)
  161.     h:SetFrameLevel(15)
  162.     local fontsize
  163.         if f.mystyle == "player" then fontsize = 36
  164.         elseif f.mystyle == "target" then fontsize =14
  165.         elseif f.mystyle == "raid" or f.mystyle == "party" then fontsize = 15
  166.         else fontsize = 14
  167.     end
  168.  
  169.     local name = lib.gen_fontstring(f.Health, cfg.font, retVal(f,15,15,15), "THINOUTLINE")
  170.         if f.mystyle == "player" then
  171.         name:SetPoint("RIGHT", f.Health, "RIGHT", 0, 0)
  172.         name:SetJustifyH("RIGHT")
  173.         elseif f.mystyle == "raid" or f.mystyle == "party" then
  174.         name:SetPoint("LEFT", f.Health, "LEFT", 0, 4)
  175.         name:SetJustifyH("LEFT")
  176.         elseif f.mystyle == "pet" then
  177.         name:SetPoint("LEFT", f.Health, "TOPLEFT", 2, -4)
  178.         name:SetJustifyH("LEFT")
  179.         else
  180.         name:SetPoint("LEFT", f.Health, "TOPLEFT", 6, 0)
  181.         name:SetJustifyH("LEFT")
  182.     end
  183.    
  184.     local hpval = lib.gen_fontstring(f.Health, cfg.font, fontsize, "THINOUTLINE")
  185.         if f.mystyle == "player" then
  186.         hpval:SetPoint("LEFT", f.Health, "LEFT", 2, -1)
  187.         hpval:SetJustifyH("LEFT")
  188.         elseif f.mystyle == "raid" or f.mystyle == "party" then
  189.         hpval:SetPoint("RIGHT", f.Health, "RIGHT", 6, -8)
  190.         hpval:SetJustifyH("LEFT")
  191.         elseif f.mystyle == "focus" or f.mystyle == "focustarget" then
  192.         hpval:SetPoint("RIGHT", f.Health, "RIGHT", 2, -6)
  193.         hpval:SetJustifyH("LEFT")
  194.         --elseif f.mystyle == "target" or f.mystyle == "pet" then
  195.         --hpval:Hide()
  196.         else
  197.         hpval:SetPoint("RIGHT", f.Health, "TOPRIGHT", retVal(f,2,2,-3), retVal(f,-18,-14,-17))
  198.     end
  199.  
  200.    
  201.     if f.mystyle == "player" then
  202.         name:SetPoint("RIGHT", f, "RIGHT", 10, 6)
  203.     --elseif f.mystyle == "raid" or f.mystyle == "party" then
  204.     --  name:SetPoint("CENTER", f, "CENTER", 0, 6)
  205.     elseif f.mystyle == "target" or f.mystyle == "pet" then
  206.         name:SetPoint("RIGHT", f, "RIGHT", 0, -12) 
  207.     else
  208.         name:SetPoint("RIGHT", f, "RIGHT", 0, 0)
  209.     end
  210.  
  211.     if f.mystyle == "player" then
  212.         f:Tag(name, "[fail:afkdnd]")
  213.     elseif f.mystyle == "target" then
  214.         f:Tag(name, "[fail:level] [fail:color][name][fail:afkdnd]")
  215.     elseif f.mystyle == "raid" or f.mystyle == "party" then
  216.         f:Tag(name, "[fail:color][name][fail:afkdnd]")
  217.     else
  218.         f:Tag(name, "[fail:color][name]")
  219.     end
  220.     if f.mystyle == "player" then
  221.     f:Tag(hpval, "[fail:color][curhp]")
  222.     else
  223.     f:Tag(hpval, retVal(f,"[fail:color][fail:hp]","[fail:color][fail:hp]","[fail:color][fail:raidhp]"))
  224.     end
  225.  
  226.     local level
  227.         if f.mystyle == "player" then level = lib.gen_fontstring(f.Health, cfg.font, fontsize/2, "THINOUTLINE")
  228.         elseif f.mystyle == "target" then level = lib.gen_fontstring(f.Health, cfg.font, 18, "THINOUTLINE")
  229.         end
  230.     if f.mystyle == "player" and cfg.ShowPlayerName then
  231.         level:SetPoint("TOPRIGHT", f.Health, "TOPRIGHT", 0, 10)
  232.         level:SetJustifyH("RIGHT")
  233.     elseif f.mystyle =="target" then
  234.         level:SetPoint("RIGHT", f, "RIGHT", 8, 16)
  235.         level:SetJustifyH("RIGHT")
  236.     end
  237.     if f.mystyle == "player" and cfg.ShowPlayerName then
  238.         f:Tag(level, "[fail:level] [fail:color][name]")
  239.     elseif f.mystyle =="target" then
  240.         f:Tag(level, "[fail:pp]")
  241.     end
  242. end
  243.  
  244.   --gen powerbar func
  245.   lib.gen_ppbar = function(f)
  246.     --statusbar
  247.     local s = CreateFrame("StatusBar", nil, f)
  248.     s:SetStatusBarTexture(cfg.powerbar_texture)
  249.     fixStatusbar(s)
  250.     if f.mystyle == "player" or f.mystyle == "pet" then
  251.         s:SetHeight(16)
  252.         s:SetWidth(f:GetWidth())
  253.         s:SetPoint("TOP",f,"TOP",8,0)
  254.     else
  255.         s:SetHeight(retVal(f,16,14,10))
  256.         s:SetWidth(f:GetWidth())
  257.         s:SetPoint("TOP",f,"TOP",6,0)
  258.     end
  259.     s:SetFrameLevel(1)
  260.    
  261.     --helper
  262.     local h = CreateFrame("Frame", nil, s)
  263.     h:SetFrameLevel(0)
  264.     h:SetPoint("TOPLEFT",-5,5)
  265.     h:SetPoint("BOTTOMRIGHT",5,-5)
  266.     lib.gen_backdrop(h)
  267.     --bg
  268.     local b = s:CreateTexture(nil, "BACKGROUND")
  269.     b:SetTexture(cfg.powerbar_texture)
  270.     b:SetAllPoints(s)
  271.     --arrow
  272.     if f.mystyle == "player" then
  273.         s.arrow = s:CreateTexture(nil, "OVERLAY")
  274.         s.arrow:SetTexture([[Interface\Addons\oUF_Fail\media\textureArrow]])
  275.         s.arrow:SetSize(16,16)
  276.         s.arrow:SetPoint("BOTTOM", s:GetStatusBarTexture(), "RIGHT", 1, 8)
  277.         fixTex(s.arrow)
  278.        
  279.         local powa = lib.gen_fontstring(f.Health, cfg.font, 16, "OUTLINE")
  280.         powa:SetPoint("RIGHT", s.arrow, "LEFT", 6, -8)
  281.         powa:SetJustifyH("RIGHT")
  282.         f:Tag(powa, "[fail:pp]")
  283.        
  284.     end
  285.  
  286.     f.Power = s
  287.     f.Power.bg = b
  288. end
  289.  
  290.     --gen combat and LFD icons
  291.   lib.gen_InfoIcons = function(f)
  292.     local h = CreateFrame("Frame",nil,f)
  293.     h:SetAllPoints(f)
  294.     h:SetFrameLevel(10)
  295.     --combat icon
  296.     if f.mystyle == 'player' then
  297.         f.Combat = h:CreateTexture(nil, 'OVERLAY')
  298.         f.Combat:SetSize(16,16)
  299.         f.Combat:SetPoint('LEFT', -4, -16)
  300.         f.Combat:SetTexture([[Interface\Addons\oUF_Fail\media\combat]])
  301.     end
  302.     -- rest icon
  303.     if f.mystyle == 'player' and UnitLevel("Player") < 85 then
  304.         f.Resting = h:CreateTexture(nil, 'OVERLAY')
  305.         f.Resting:SetSize(18,18)
  306.         f.Resting:SetPoint('TOPLEFT', 0, -2)
  307.         f.Resting:SetTexture([[Interface\Addons\oUF_Fail\media\resting]])
  308.         f.Resting:SetAlpha(0.75)
  309.     end
  310.     --Leader icon
  311.     li = h:CreateTexture(nil, "OVERLAY")
  312.     li:SetPoint("TOPLEFT", f, -4, 0)
  313.     li:SetSize(16,16)
  314.     f.Leader = li
  315.     --Assist icon
  316.     ai = h:CreateTexture(nil, "OVERLAY")
  317.     ai:SetPoint("TOPLEFT", f, 0, 8)
  318.     ai:SetSize(12,12)
  319.     f.Assistant = ai
  320.     --ML icon
  321.     local ml = h:CreateTexture(nil, 'OVERLAY')
  322.     ml:SetSize(16,16)
  323.     ml:SetPoint('LEFT', f.Leader, 'RIGHT')
  324.     f.MasterLooter = ml
  325.   end
  326.  
  327.     -- LFG Role Indicator
  328.     lib.gen_LFDRole = function(f)
  329.         local lfdi = lib.gen_fontstring(f.Health, cfg.smallfont, 10, "THINOUTLINE")
  330.         lfdi:SetPoint('BOTTOM', f.Health, 'TOP', 0, 4)
  331.         f:Tag(lfdi, "[fail:lfdrole]")
  332.     end
  333.  
  334.     -- phase icon
  335.     lib.addPhaseIcon = function(self)
  336.         local picon = self.Health:CreateTexture(nil, 'OVERLAY')
  337.         picon:SetPoint('TOPRIGHT', self, 'TOPRIGHT', 40, 8)
  338.         picon:SetSize(16, 16)
  339.  
  340.         self.PhaseIcon = picon
  341.     end
  342.  
  343.     -- quest icon
  344.     lib.addQuestIcon = function(self)
  345.         local qicon = self.Health:CreateTexture(nil, 'OVERLAY')
  346.         qicon:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 8)
  347.         qicon:SetSize(16, 16)
  348.  
  349.         self.QuestIcon = qicon
  350.     end
  351.  
  352.     --gen raid mark icons
  353.   lib.gen_RaidMark = function(f)
  354.     local h = CreateFrame("Frame", nil, f)
  355.     h:SetAllPoints(f)
  356.     h:SetFrameLevel(10)
  357.     h:SetAlpha(0.8)
  358.     local ri = h:CreateTexture(nil,'OVERLAY',h)
  359.     ri:SetPoint("CENTER", f.Health, "BOTTOM", -135, 18)
  360.     ri:SetTexture([[Interface\Addons\oUF_Fail\media\raidicons.blp]])
  361.     local size = retVal(f, 36, 24, 18)
  362.     ri:SetSize(size, size)
  363.     f.RaidIcon = ri
  364.   end
  365.  
  366.     --gen hilight texture
  367.   lib.gen_highlight = function(f)
  368.     local OnEnter = function(f)
  369.         UnitFrame_OnEnter(f)
  370.         f.Highlight:Show()
  371.     end
  372.     local OnLeave = function(f)
  373.       UnitFrame_OnLeave(f)
  374.       f.Highlight:Hide()
  375.     end
  376.     f:SetScript("OnEnter", OnEnter)
  377.     f:SetScript("OnLeave", OnLeave)
  378.     local hl = f.Health:CreateTexture(nil, "OVERLAY")
  379.     hl:SetAllPoints(f.Health)
  380.     hl:SetTexture(cfg.statusbar_texture)
  381.     hl:SetVertexColor(.5,.5,.5,.1)
  382.     hl:SetBlendMode("ADD")
  383.     hl:Hide()
  384.     f.Highlight = hl
  385.   end
  386.  
  387.   -- Create Target Border
  388.     function lib.CreateTargetBorder(self)
  389.         self.TargetBorder = self.Health:CreateTexture("BACKGROUND", nil, self)
  390.         self.TargetBorder:SetPoint("TOPLEFT", self.Health, "TOPLEFT", -24, 24)
  391.         self.TargetBorder:SetPoint("BOTTOMRIGHT", self.Health, "BOTTOMRIGHT", 24, -24)
  392.         self.TargetBorder:SetTexture([[Interface\Addons\oUF_Fail\media\target]])
  393.         self.TargetBorder:SetVertexColor(1.0, 1.0, 0.1,0.6)
  394.         self.TargetBorder:SetBlendMode("ADD")
  395.         self.TargetBorder:Hide()
  396.     end
  397.  
  398.     -- Raid Frames Target Highlight Border
  399.     function lib.ChangedTarget(self, event, unit)
  400.    
  401.         if UnitIsUnit('target', self.unit) then
  402.             self.TargetBorder:Show()
  403.         else
  404.             self.TargetBorder:Hide()
  405.         end
  406.     end
  407.    
  408.     -- Create Raid Threat Status Border
  409.     function lib.CreateThreatBorder(self)
  410.        
  411.         local glowBorder = {edgeFile = cfg.backdrop_edge_texture, edgeSize = 5}
  412.         self.Thtborder = CreateFrame("Frame", nil, self)
  413.         self.Thtborder:SetPoint("TOPLEFT", self, "TOPLEFT", -8, 9)
  414.         self.Thtborder:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 9, -8)
  415.         self.Thtborder:SetBackdrop(glowBorder)
  416.         self.Thtborder:SetFrameLevel(1)
  417.         self.Thtborder:Hide()  
  418.     end
  419.  
  420.     -- Raid Frames Threat Highlight
  421.     function lib.UpdateThreat(self, event, unit)
  422.    
  423.         if (self.unit ~= unit) then return end
  424.        
  425.         local status = UnitThreatSituation(unit)
  426.         unit = unit or self.unit
  427.        
  428.         if status and status > 1 then
  429.             local r, g, b = GetThreatStatusColor(status)
  430.             self.Thtborder:Show()
  431.             self.Thtborder:SetBackdropBorderColor(r, g, b, 1)
  432.         else
  433.             self.Thtborder:SetBackdropBorderColor(r, g, b, 0)
  434.             self.Thtborder:Hide()
  435.         end
  436.     end
  437.    
  438.  
  439.   --gen castbar
  440. local PostCastStart = function(castbar, unit)
  441.     if unit ~= 'player' then
  442.         if castbar.interrupt then
  443.             castbar.Backdrop:SetBackdropBorderColor(1, .9, .4)
  444.             castbar.Backdrop:SetBackdropColor(1, .9, .4)
  445.         else
  446.             castbar.Backdrop:SetBackdropBorderColor(0, 0, 0)
  447.             castbar.Backdrop:SetBackdropColor(0, 0, 0)
  448.         end
  449.     end
  450. end
  451.  
  452. local CustomTimeText = function(castbar, duration)
  453.     if castbar.casting then
  454.         castbar.Time:SetFormattedText("%.1f / %.1f", duration, castbar.max)
  455.     elseif castbar.channeling then
  456.         castbar.Time:SetFormattedText("%.1f / %.1f", castbar.max - duration, castbar.max)
  457.     end
  458. end
  459.  
  460.   --gen castbar
  461.   lib.gen_castbar = function(f)
  462.     if not cfg.Castbars then return end
  463.     local cbColor = {95/255, 182/255, 255/255}
  464.     local s = CreateFrame("StatusBar", "oUF_failCastbar"..f.mystyle, f)
  465.     s:SetHeight(16)
  466.     if f.mystyle == "focus" then
  467.         s:SetWidth(f:GetWidth()*2 - 30)
  468.     elseif f.mystyle == "player" then
  469.         s:SetWidth(f:GetWidth()-21)
  470.     elseif f.mystyle == "pet" then
  471.         s:SetWidth(f:GetWidth()-23)
  472.     else
  473.         s:SetWidth(f:GetWidth()+50)
  474.     end
  475.     if f.mystyle == "player" then
  476.         s:SetPoint("BOTTOM", f, "TOP", 20, 13)  
  477.     elseif f.mystyle == "target" then
  478.         s:SetPoint("CENTER",f,"TOP",0,180)  
  479.     elseif f.mystyle == "targettarget" then
  480.         s:SetPoint("BOTTOM",f,"TOP",0,0)  
  481.     else
  482.         s:SetPoint("TOPLEFT",f,"BOTTOMLEFT",30,-15)
  483.     end
  484.     s:SetStatusBarTexture(cfg.statusbar_texture)
  485.     s:SetStatusBarColor(95/255, 182/255, 255/255,1)
  486.     s:SetFrameLevel(9)
  487.     --color
  488.     s.CastingColor = cbColor
  489.     s.CompleteColor = {20/255, 208/255, 0/255}
  490.     s.FailColor = {255/255, 12/255, 0/255}
  491.     s.ChannelingColor = cbColor
  492.     --helper
  493.     local h = CreateFrame("Frame", nil, s)
  494.     h:SetFrameLevel(0)
  495.     h:SetPoint("TOPLEFT",-5,5)
  496.     h:SetPoint("BOTTOMRIGHT",5,-5)
  497.     lib.gen_castbackdrop(h)
  498.     --spark
  499.     sp = s:CreateTexture(nil, "OVERLAY")
  500.     sp:SetTexture(spark)
  501.     sp:SetBlendMode("ADD")
  502.     sp:SetVertexColor(1, 1, 1, 1)
  503.     sp:SetHeight(s:GetHeight()*2.5)
  504.     sp:SetWidth(s:GetWidth()/18)
  505.    
  506.     --spell text
  507.     local txt = lib.gen_fontstring(s, cfg.font, 10, "THINOUTLINE")
  508.     if f.mystyle == "pet" then
  509.         txt:Hide()
  510.     else
  511.         txt:SetPoint("LEFT", 2, 10)
  512.         txt:SetJustifyH("LEFT")
  513.     end
  514.    
  515.     --time
  516.     local t = lib.gen_fontstring(s, cfg.font, 10, 'THINOUTLINE')
  517.     if f.mystyle == "pet" then
  518.         t:Hide()
  519.         txt:Hide()
  520.     else
  521.         t:SetPoint("RIGHT", -2, 0)
  522.         txt:SetPoint("RIGHT", f, "RIGHT", 0, 0)
  523.     end
  524.    
  525.     --icon
  526.     local i = s:CreateTexture(nil, "ARTWORK")
  527.     i:SetSize(24,24)
  528.     i:SetPoint("BOTTOMRIGHT", s, "BOTTOMLEFT", -6, 0)
  529.     i:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  530.     --helper2 for icon
  531.     local h2 = CreateFrame("Frame", nil, s)
  532.     h2:SetFrameLevel(0)
  533.     h2:SetPoint("TOPLEFT",i,"TOPLEFT",-5,5)
  534.     h2:SetPoint("BOTTOMRIGHT",i,"BOTTOMRIGHT",5,-5)
  535.     lib.gen_backdrop(h2)
  536.     --if f.mystyle == "player" then
  537.       --latency (only for player unit)
  538.       --local z = s:CreateTexture(nil,"OVERLAY")
  539.       --z:SetTexture(cfg.statusbar_texture)
  540.       --z:SetVertexColor(1,0.1,0,.6)
  541.       --z:SetPoint("TOPRIGHT")
  542.       --z:SetPoint("BOTTOMRIGHT")
  543.       --s:SetFrameLevel(1)
  544.       --s.SafeZone = z
  545.       -- custom latency display
  546.       --local l = lib.gen_fontstring(s, cfg.font, 10, "THINOUTLINE")
  547.       --l:SetPoint("CENTER", -2, 17)
  548.       --l:SetJustifyH("RIGHT")
  549.       --l:Hide()
  550.       --s.Lag = l
  551.       --f:RegisterEvent("UNIT_SPELLCAST_SENT", cast.OnCastSent)
  552.     --end
  553.     s.OnUpdate = cast.OnCastbarUpdate
  554.     s.PostCastStart = cast.PostCastStart
  555.     s.PostChannelStart = cast.PostCastStart
  556.     s.PostCastStop = cast.PostCastStop
  557.     s.PostChannelStop = cast.PostChannelStop
  558.     s.PostCastFailed = cast.PostCastFailed
  559.     s.PostCastInterrupted = cast.PostCastFailed
  560.    
  561.     f.Castbar = s
  562.     f.Castbar.Text = txt
  563.     f.Castbar.Time = t
  564.     f.Castbar.Icon = i
  565.     f.Castbar.Spark = sp
  566.   end
  567.  
  568.     -- mirror castbar!
  569.   lib.gen_mirrorcb = function(f)
  570.     for _, bar in pairs({'MirrorTimer1','MirrorTimer2','MirrorTimer3',}) do  
  571.       for i, region in pairs({_G[bar]:GetRegions()}) do
  572.         if (region.GetTexture and region:GetTexture() == 'SolidTexture') then
  573.           region:Hide()
  574.         end
  575.       end
  576.       _G[bar..'Border']:Hide()
  577.       _G[bar]:SetParent(UIParent)
  578.       _G[bar]:SetScale(1)
  579.       _G[bar]:SetHeight(16)
  580.       _G[bar]:SetWidth(280)
  581.       _G[bar]:SetBackdropColor(.1,.1,.1)
  582.       _G[bar..'Background'] = _G[bar]:CreateTexture(bar..'Background', 'BACKGROUND', _G[bar])
  583.       _G[bar..'Background']:SetTexture(cfg.statusbar_texture)
  584.       _G[bar..'Background']:SetAllPoints(bar)
  585.       _G[bar..'Background']:SetVertexColor(.15,.15,.15,.75)
  586.       _G[bar..'Text']:SetFont(cfg.font, 14, "THINOUTLINE")
  587.       _G[bar..'Text']:ClearAllPoints()
  588.       _G[bar..'Text']:SetPoint('CENTER', MirrorTimer1StatusBar, 0, 1)
  589.       _G[bar..'StatusBar']:SetAllPoints(_G[bar])
  590.       --glowing borders
  591.       local h = CreateFrame("Frame", nil, _G[bar])
  592.       h:SetFrameLevel(0)
  593.       h:SetPoint("TOPLEFT",-5,5)
  594.       h:SetPoint("BOTTOMRIGHT",5,-5)
  595.       lib.gen_backdrop(h)
  596.     end
  597.   end
  598.  
  599.  
  600.     -- Post Create Icon Function
  601.     local myPostCreateIcon = function(self, button)
  602.    
  603.         self.showDebuffType = true
  604.         self.disableCooldown = true
  605.         button.cd.noOCC = true
  606.         button.cd.noCooldownCount = true
  607.  
  608. --      button.icon:SetTexCoord(0,1,0,1)
  609.         button.icon:SetTexCoord(.07, .93, .07, .93)
  610.         button.icon:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0)
  611.         button.icon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 0, 0)
  612.         button.overlay:SetTexture(cfg.debuffBorder)
  613.         button.overlay:SetTexCoord(0,1,0,1)
  614.         button.overlay.Hide = function(self) self:SetVertexColor(0.3, 0.3, 0.3) end
  615.        
  616.        
  617.         button.time = lib.gen_fontstring(button, cfg.smallfont, 12, "OUTLINE")
  618.         button.time:SetPoint("BOTTOM", button, 2, -6)
  619.         button.time:SetJustifyH('CENTER')
  620.         button.time:SetVertexColor(1,1,1)
  621.        
  622.         button.count = lib.gen_fontstring(button, cfg.smallfont, 15, "OUTLINE")
  623.         button.count:ClearAllPoints()
  624.         button.count:SetPoint("TOPRIGHT", button, 5, 3)
  625.         button.count:SetJustifyH('RIGHT')
  626.         button.count:SetVertexColor(1,1,1) 
  627.        
  628.     -- helper
  629.         local h = CreateFrame("Frame", nil, button)
  630.         h:SetFrameLevel(0)
  631.         h:SetPoint("TOPLEFT",-5,5)
  632.         h:SetPoint("BOTTOMRIGHT",5,-5)
  633.         lib.gen_backdrop(h)
  634.     end
  635.  
  636. -- Post Update Icon Function
  637. local myPostUpdateIcon = function(self, unit, icon, index, offset, filter, isDebuff)
  638.  
  639.     local _, _, _, _, _, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, icon.filter)
  640.    
  641.     if duration and duration > 0 then
  642.         icon.time:Show()
  643.         icon.timeLeft = expirationTime 
  644.         icon:SetScript("OnUpdate", CreateBuffTimer)        
  645.     else
  646.         icon.time:Hide()
  647.         icon.timeLeft = math.huge
  648.         icon:SetScript("OnUpdate", nil)
  649.     end
  650.        
  651.     -- Desaturate non-Player Debuffs
  652.     if(icon.debuff) then
  653.         if(unit == "target") then  
  654.             if (unitCaster == 'player' or unitCaster == 'vehicle') then
  655.                 icon.icon:SetDesaturated(false)                
  656.             elseif(not UnitPlayerControlled(unit)) then -- If Unit is Player Controlled don't desaturate debuffs
  657.                 icon:SetBackdropColor(0, 0, 0)
  658.                 icon.overlay:SetVertexColor(0.3, 0.3, 0.3)      
  659.                 icon.icon:SetDesaturated(true)  
  660.             end
  661.         end
  662.     end
  663.    
  664.     -- Right Click Cancel Buff/Debuff
  665.     icon:SetScript('OnMouseUp', function(self, mouseButton)
  666.         if mouseButton == 'RightButton' then
  667.             CancelUnitBuff('player', index)
  668.     end end)
  669.    
  670.     icon.first = true
  671. end
  672.  
  673. local FormatTime = function(s)
  674.     local day, hour, minute = 86400, 3600, 60
  675.     if s >= day then
  676.         return format("%dd", floor(s/day + 0.5)), s % day
  677.     elseif s >= hour then
  678.         return format("%dh", floor(s/hour + 0.5)), s % hour
  679.     elseif s >= minute then
  680.         if s <= minute * 5 then
  681.             return format("%d:%02d", floor(s/60), s % minute), s - floor(s)
  682.         end
  683.         return format("%dm", floor(s/minute + 0.5)), s % minute
  684.     elseif s >= minute / 12 then
  685.         return floor(s + 0.5), (s * 100 - floor(s * 100))/100
  686.     end
  687.     return format("%.1f", s), (s * 100 - floor(s * 100))/100
  688. end
  689.  
  690. -- Create Buff/Debuff Timer Function
  691. function CreateBuffTimer(self, elapsed)
  692.     self.elapsed = (self.elapsed or 0) + elapsed
  693.     if self.elapsed >= 0.1 then
  694.         if not self.first then
  695.             self.timeLeft = self.timeLeft - self.elapsed
  696.         else
  697.             self.timeLeft = self.timeLeft - GetTime()
  698.             self.first = false
  699.         end
  700.            
  701.         if self.timeLeft > 0 and self.timeLeft <= 60*15 then -- Show time between 0 and 15 min
  702.             local time = FormatTime(self.timeLeft)
  703.             self.time:SetText(time)                            
  704.             if self.timeLeft >= 6 and self.timeLeft <= 60*5 then -- if Between 5 min and 6sec
  705.                 self.time:SetTextColor(0.95,0.95,0.95)
  706.             elseif self.timeLeft > 3 and self.timeLeft < 6 then -- if Between 6sec and 3sec
  707.                 self.time:SetTextColor(0.95,0.70,0)
  708.             elseif self.timeLeft <= 3 then -- Below 3sec
  709.                 self.time:SetTextColor(0.9, 0.05, 0.05)                
  710.             else
  711.                 self.time:SetTextColor(0.95,0.95,0.95) -- Fallback Color       
  712.             end
  713.         else
  714.             self.time:Hide()
  715.         end
  716.         self.elapsed = 0
  717.     end
  718. end
  719.  
  720. -- Generates the Buffs
  721.   lib.createBuffs = function(f)
  722.     b = CreateFrame("Frame", nil, f)
  723.     b.onlyShowPlayer = cfg.buffsOnlyShowPlayer
  724.     if f.mystyle == "target" then
  725.         b:SetPoint("TOPLEFT", f, "TOPRIGHT", 12, 0)
  726.         b.initialAnchor = "TOPLEFT"
  727.         b["growth-x"] = "RIGHT"
  728.         b["growth-y"] = "DOWN"
  729.         b.size = 24
  730.         b.num = 3
  731.         b.spacing = 6
  732.         b:SetHeight((b.size+b.spacing)*4)
  733.         --b:SetWidth(f:GetWidth()) Default Value
  734.         b:SetWidth(((b.size+b.spacing)*4)-b.spacing)
  735.     elseif f.mystyle == "player" then
  736.         b:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -5, -5)
  737.         b.initialAnchor = "TOPRIGHT"
  738.         b["growth-x"] = "LEFT"
  739.         b["growth-y"] = "DOWN"
  740.         b.size = 36
  741.         b.num = 40
  742.         b.spacing = 5
  743.         b:SetHeight((b.size+b.spacing)*4)
  744.         b:SetWidth(f:GetWidth()*2)
  745.     else
  746.         b.num = 0
  747.     end
  748.     b.PostCreateIcon = myPostCreateIcon
  749.     b.PostUpdateIcon = myPostUpdateIcon
  750.  
  751.     f.Buffs = b
  752.   end
  753.  
  754. -- Generates the Debuffs
  755.   lib.createDebuffs = function(f)
  756.     b = CreateFrame("Frame", nil, f)
  757.     b.size = 28
  758.     b.num = 20
  759.     b.onlyShowPlayer = cfg.debuffsOnlyShowPlayer
  760.     b.spacing = 6
  761.     b:SetHeight((b.size+b.spacing)*5)
  762.     b:SetWidth(f:GetWidth())
  763.     if(playerClass == "ROGUE" or playerClass == "DRUID") then
  764.         b:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 17)
  765.     else
  766.         b:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 6)
  767.     end
  768.     b.initialAnchor = "BOTTOMLEFT"
  769.     b["growth-x"] = "RIGHT"
  770.     b["growth-y"] = "UP"
  771.     b.PostCreateIcon = myPostCreateIcon
  772.     b.PostUpdateIcon = myPostUpdateIcon
  773.  
  774.     f.Debuffs = b
  775.   end
  776.  
  777. -- raid post update
  778. lib.PostUpdateRaidFrame = function(Health, unit, min, max)
  779.  
  780.     local disconnnected = not UnitIsConnected(unit)
  781.     local dead = UnitIsDead(unit)
  782.     local ghost = UnitIsGhost(unit)
  783.  
  784.     if disconnnected or dead or ghost then
  785.         Health:SetValue(max)
  786.        
  787.         if(disconnnected) then
  788.             Health:SetStatusBarColor(0,0,0,0.6)
  789.         elseif(ghost) then
  790.             Health:SetStatusBarColor(1,1,1,0.6)
  791.         elseif(dead) then
  792.             Health:SetStatusBarColor(1,0,0,0.7)
  793.         end
  794.     else
  795.         Health:SetValue(min)
  796.         if(unit == 'vehicle') then
  797.             Health:SetStatusBarColor(22/255, 106/255, 44/255)
  798.         end
  799.     end
  800.    
  801.     if not UnitInRange(unit) then
  802.         Health.bg2:SetVertexColor(.6, 0.3, 0.3,1)
  803.     else
  804.         Health.bg2:SetVertexColor(1, 0.1, 0.1,1)
  805.     end
  806. end
  807.  
  808. -- Eclipse Bar function
  809. local eclipseBarBuff = function(self, unit)
  810.     if self.hasSolarEclipse then
  811.         self.eBarBG:SetBackdropBorderColor(1,1,.5,.7)
  812.     elseif self.hasLunarEclipse then
  813.         self.eBarBG:SetBackdropBorderColor(.2,.2,1,.7)
  814.     else
  815.         self.eBarBG:SetBackdropBorderColor(0,0,0,1)
  816.     end
  817. end
  818.  
  819. lib.addEclipseBar = function(self)
  820.     if playerClass ~= "DRUID" then return end
  821.    
  822.     local eclipseBar = CreateFrame('Frame', nil, self)
  823.     eclipseBar:SetPoint('TOPLEFT', self.Health, 'BOTTOMLEFT', 0, -6)
  824.     eclipseBar:SetHeight(4)
  825.     eclipseBar:SetWidth(self.Health:GetWidth())
  826.     eclipseBar:SetFrameLevel(4)
  827.     local h = CreateFrame("Frame", nil, eclipseBar)
  828.     h:SetPoint("TOPLEFT",-5,5)
  829.     h:SetPoint("BOTTOMRIGHT",5,-5)
  830.     lib.gen_backdrop(h)
  831.     eclipseBar.eBarBG = h
  832.  
  833.     local lunarBar = CreateFrame('StatusBar', nil, eclipseBar)
  834.     lunarBar:SetPoint('LEFT', eclipseBar, 'LEFT', 0, 0)
  835.     lunarBar:SetSize(eclipseBar:GetWidth(), eclipseBar:GetHeight())
  836.     lunarBar:SetStatusBarTexture(cfg.statusbar_texture)
  837.     lunarBar:SetStatusBarColor(0, .1, .7)
  838.     lunarBar:SetFrameLevel(5)
  839.  
  840.     local solarBar = CreateFrame('StatusBar', nil, eclipseBar)
  841.     solarBar:SetPoint('LEFT', lunarBar:GetStatusBarTexture(), 'RIGHT', 0, 0)
  842.     solarBar:SetSize(eclipseBar:GetWidth(), eclipseBar:GetHeight())
  843.     solarBar:SetStatusBarTexture(cfg.statusbar_texture)
  844.     solarBar:SetStatusBarColor(1,1,.13)
  845.     solarBar:SetFrameLevel(5)
  846.  
  847.     local EBText = lib.gen_fontstring(solarBar, cfg.font, 10, "OUTLINE")
  848.     EBText:SetPoint('CENTER', eclipseBar, 'CENTER', 0, 0)
  849.     self:Tag(EBText, '[pereclipse]')
  850.    
  851.     eclipseBar.SolarBar = solarBar
  852.     eclipseBar.LunarBar = lunarBar
  853.     self.EclipseBar = eclipseBar
  854.     self.EclipseBar.PostUnitAura = eclipseBarBuff
  855. end
  856.  
  857. -- SoulShard bar
  858. lib.genShards = function(self)
  859.     if playerClass ~= "WARLOCK" then return end
  860.             local ssOverride = function(self, event, unit, powerType)
  861.                 if(self.unit ~= unit or (powerType and powerType ~= "SOUL_SHARDS")) then return end
  862.                 local ss = self.SoulShards
  863.                 local num = UnitPower(unit, SPELL_POWER_SOUL_SHARDS)
  864.                 for i = 1, SHARD_BAR_NUM_SHARDS do
  865.                     if(i <= num) then
  866.                         ss[i]:SetAlpha(1)
  867.                     else
  868.                         ss[i]:SetAlpha(0.2)
  869.                     end
  870.                 end
  871.             end
  872.            
  873.         local barFrame = CreateFrame("Frame", nil, self)
  874.         barFrame:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5)
  875.         barFrame:SetHeight(6)
  876.         barFrame:SetWidth(self:GetWidth())
  877.         barFrame:SetFrameLevel(4)
  878.  
  879.         for i= 1, 3 do
  880.             local shard = CreateFrame("StatusBar", nil, barFrame)
  881.             shard:SetSize((self.Health:GetWidth() / 3)-4, 6)
  882.             shard:SetStatusBarTexture(cfg.statusbar_texture)
  883.             shard:SetStatusBarColor(.86,.44, 1)
  884.             shard:SetFrameLevel(4)
  885.                
  886.             local h = CreateFrame("Frame", nil, shard)
  887.             h:SetFrameLevel(1)
  888.             h:SetPoint("TOPLEFT",-5,5)
  889.             h:SetPoint("BOTTOMRIGHT",5,-5)
  890.             lib.gen_totemback(h)
  891.  
  892.         if (i == 1) then
  893.             shard:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -5)
  894.         else
  895.             shard:SetPoint("TOPLEFT", barFrame[i-1], "TOPRIGHT", 6, 0)
  896.         end
  897.         barFrame[i] = shard
  898.     end
  899.     self.SoulShards = barFrame
  900.     self.SoulShards.Override = ssOverride
  901.            
  902. end        
  903.  
  904. -- HolyPowerbar
  905. lib.genHolyPower = function(self)
  906.     if playerClass ~= "PALADIN" then return end
  907.         local hpOverride = function(self, event, unit, powerType)
  908.                 if(self.unit ~= unit or (powerType and powerType ~= "HOLY_POWER")) then return end
  909.                
  910.                 local hp = self.HolyPower
  911.                 if(hp.PreUpdate) then hp:PreUpdate(unit) end
  912.                
  913.                 local num = UnitPower(unit, SPELL_POWER_HOLY_POWER)
  914.                 for i = 1, MAX_HOLY_POWER do
  915.                     if(i <= num) then
  916.                         hp[i]:SetAlpha(1)
  917.                     else
  918.                         hp[i]:SetAlpha(0.2)
  919.                     end
  920.                 end
  921.             end
  922.            
  923.         local barFrame = CreateFrame("Frame", nil, self)
  924.         barFrame:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5)
  925.         barFrame:SetHeight(6)
  926.         barFrame:SetWidth(self:GetWidth())
  927.         barFrame:SetFrameLevel(4)
  928.  
  929.         for i = 1, 3 do
  930.             local holyShard = CreateFrame("StatusBar", self:GetName().."_Holypower"..i, self)
  931.             holyShard:SetHeight(6)
  932.             holyShard:SetWidth((self.Health:GetWidth() / 3)-4, 6)
  933.             holyShard:SetStatusBarTexture(cfg.statusbar_texture)
  934.             holyShard:SetStatusBarColor(.9,.95,.33)
  935.             holyShard:SetFrameLevel(4)
  936.                
  937.             local h = CreateFrame("Frame", nil, holyShard)
  938.             h:SetFrameLevel(1)
  939.             h:SetPoint("TOPLEFT",-5,5)
  940.             h:SetPoint("BOTTOMRIGHT",5,-5)
  941.             lib.gen_totemback(h)
  942.  
  943.         if (i == 1) then
  944.             holyShard:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -5)
  945.         else
  946.             holyShard:SetPoint("TOPLEFT", barFrame[i-1], "TOPRIGHT", 6, 0)
  947.         end
  948.         barFrame[i] = holyShard
  949.     end
  950.     self.HolyPower = barFrame
  951.     self.HolyPower.Override = hpOverride
  952. end
  953.  
  954. -- runebar
  955. lib.genRunes = function(self)
  956.     if playerClass ~= "DEATHKNIGHT" then return end
  957.  
  958.     local runeFrame = CreateFrame("Frame", nil, self)
  959.     runeFrame:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5)
  960.     runeFrame:SetHeight(4)
  961.     runeFrame:SetWidth(self:GetWidth())
  962.     runeFrame:SetFrameLevel(4)
  963.    
  964.     for i= 1, 6 do
  965.         local rune = CreateFrame("StatusBar", nil, runeFrame)
  966.         rune:SetSize((self.Health:GetWidth() / 6)-5, 7)
  967.         rune:SetStatusBarTexture(cfg.statusbar_texture)
  968.         rune:SetFrameLevel(4)
  969.        
  970.             local h = CreateFrame("Frame", nil, rune)
  971.             h:SetFrameLevel(1)
  972.             h:SetPoint("TOPLEFT",-5,5)
  973.             h:SetPoint("BOTTOMRIGHT",5,-5)
  974.             lib.gen_totemback(h)
  975.    
  976.         if (i == 1) then
  977.             rune:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -6)
  978.         else
  979.             rune:SetPoint("TOPLEFT", runeFrame[i-1], "TOPRIGHT", 6, 0)
  980.         end
  981.  
  982.         runeFrame[i] = rune
  983.     end
  984.     self.Runes = runeFrame
  985. end
  986.  
  987. -- ReadyCheck
  988. lib.ReadyCheck = function(self)
  989.     if cfg.RCheckIcon then
  990.         rCheck = self.Health:CreateTexture(nil, "OVERLAY")
  991.         rCheck:SetSize(14, 14)
  992.         rCheck:SetPoint("BOTTOMLEFT", self.Health, "TOPRIGHT", -13, -12)
  993.         self.ReadyCheck = rCheck
  994.     end
  995. end
  996.  
  997. -- raid debuffs
  998. lib.raidDebuffs = function(f)
  999.     if cfg.showRaidDebuffs then
  1000.         local raid_debuffs = {
  1001.             debuffs = {
  1002.                 -- Any Zone
  1003.                 ["Viper Sting"] = 12,       -- Viper Sting
  1004.                 ["Wound Poison"] = 9,       -- Wound Poison
  1005.                 ["Mortal Strike"] = 8,      -- Mortal Strike
  1006.                 ["Furious Attacks"] = 8,    -- Furious Attacks
  1007.                 ["Aimed Shot"] = 8,         -- Aimed Shot
  1008.                 ["Counterspell"] = 10,      -- Counterspell
  1009.                 ["Blind"] = 10,             -- Blind
  1010.                 ["Cyclone"] = 10,           -- Cyclone
  1011.                 ["Hex"] = 7,                -- Hex
  1012.                 ["Polymorph"] = 7,          -- Polymorph
  1013.                 ["Entangling Roots"] = 7,   -- Entangling Roots
  1014.                 ["Frost Nova"] = 7,         -- Frost Nova
  1015.                 ["Freezing Trap"] = 7,      -- Freezing Trap
  1016.                 ["Crippling Poison"] = 6,   -- Crippling Poison
  1017.                 ["Bash"] = 5,               -- Bash
  1018.                 ["Cheap Shot"] = 5,         -- Cheap Shot
  1019.                 ["Kidney Shot"] = 5,        -- Kidney Shot
  1020.                 ["Throwdown"] = 5,          -- Throwdown
  1021.                 ["Sap"] = 5,                -- Sap
  1022.                 ["Hamstring"] = 5,          -- Hamstring
  1023.                 ["Wing Clip"] = 5,          -- Wing Clip
  1024.                 ["Fear"] = 3,               -- Fear
  1025.                 ["Psychic Scream"] = 3,     -- Psychic Scream
  1026.                 ["Howl of Terror"] = 3,     -- Howl of Terror
  1027.                 ["Intimidating Shout"] = 3, -- Intimidating Shout
  1028.  
  1029.             },
  1030.         }
  1031.  
  1032.         local instDebuffs = {}
  1033.         local instances = raid_debuffs.instances
  1034.         local getzone = function()
  1035.             local zone = GetInstanceInfo()
  1036.             if instances[zone] then
  1037.                 instDebuffs = instances[zone]
  1038.             else
  1039.                 instDebuffs = {}
  1040.             end
  1041.         end
  1042.  
  1043.         local debuffs = raid_debuffs.debuffs
  1044.         local CustomFilter = function(icons, ...)
  1045.             local _, icon, name, _, _, _, dtype = ...
  1046.             if instDebuffs[name] then
  1047.                 icon.priority = instDebuffs[name]
  1048.                 return true
  1049.             elseif debuffs[name] then
  1050.                 icon.priority = debuffs[name]
  1051.                 return true
  1052.             else
  1053.                 icon.priority = 0
  1054.             end
  1055.         end
  1056.  
  1057.         local dbsize = 18
  1058.         local debuffs = CreateFrame("Frame", nil, f)
  1059.         debuffs:SetWidth(dbsize) debuffs:SetHeight(dbsize)
  1060.         debuffs:SetPoint("TOPRIGHT", -10, 3)
  1061.         debuffs.size = dbsize
  1062.        
  1063.         debuffs.CustomFilter = CustomFilter
  1064.         f.raidDebuffs = debuffs
  1065.     end
  1066. end
  1067.  
  1068. -- oUF_HealPred
  1069. lib.HealPred = function(self)
  1070.     if not cfg.ShowIncHeals then return end
  1071.    
  1072.     local mhpb = CreateFrame('StatusBar', nil, self.Health)
  1073.     mhpb:SetPoint('TOPLEFT', self.Health:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
  1074.     mhpb:SetPoint('BOTTOMLEFT', self.Health:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
  1075.     mhpb:SetWidth(self:GetWidth())
  1076.     mhpb:SetStatusBarTexture(cfg.statusbar_texture)
  1077.     mhpb:SetStatusBarColor(1, 1, 1, 0.4)
  1078.     mhpb:SetFrameLevel(1)
  1079.  
  1080.     local ohpb = CreateFrame('StatusBar', nil, self.Health)
  1081.     ohpb:SetPoint('TOPLEFT', mhpb:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
  1082.     ohpb:SetPoint('BOTTOMLEFT', mhpb:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
  1083.     ohpb:SetWidth(self:GetWidth())
  1084.     ohpb:SetStatusBarTexture(cfg.statusbar_texture)
  1085.     ohpb:SetStatusBarColor(1, 1, 1, 0.4)
  1086.     mhpb:SetFrameLevel(1)
  1087.     self.HealPrediction = {
  1088.         myBar = mhpb,
  1089.         otherBar = ohpb,
  1090.         maxOverflow = 1,
  1091.     }
  1092. end
  1093.  
  1094. -- Combo points
  1095. lib.RogueComboPoints = function(self)
  1096.     if(playerClass == "ROGUE" or playerClass == "DRUID") then
  1097.        
  1098.         local barFrame = CreateFrame("Frame", nil, self)
  1099.         barFrame:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5)
  1100.         barFrame:SetHeight(4)
  1101.         barFrame:SetWidth(self:GetWidth())
  1102.         barFrame:SetFrameLevel(4)
  1103.        
  1104.         for i = 1, MAX_COMBO_POINTS do
  1105.             local point = CreateFrame("StatusBar", nil, barFrame)
  1106.             point:SetSize((self.Health:GetWidth() / 5)-5, 6)
  1107.             if i > 1 then point:SetPoint("LEFT", point[i - 1], "RIGHT") end
  1108.             point:SetStatusBarTexture(cfg.statusbar_texture)
  1109.             point:SetStatusBarColor(1.0, 0.9, 0)
  1110.  
  1111.             local h = CreateFrame("Frame", nil, point)
  1112.             h:SetFrameLevel(1)
  1113.             h:SetPoint("TOPLEFT",-5,5)
  1114.             h:SetPoint("BOTTOMRIGHT",5,-5)
  1115.             lib.gen_totemback(h)
  1116.  
  1117.         if (i == 1) then
  1118.             point:SetPoint('BOTTOMLEFT', self.Health, 'TOPLEFT', 0, 12)
  1119.         else
  1120.             point:SetPoint("TOPLEFT", barFrame[i-1], "TOPRIGHT", 6, 0)
  1121.         end
  1122.         barFrame[i] = point
  1123.         end
  1124.         self.CPoints = barFrame
  1125.         self.CPoints.unit = "player"
  1126.     end
  1127. end
  1128.  
  1129. -- Addons/Plugins -------------------------------------------
  1130.  
  1131. -- Totem timer support (requires oUF_boring_totembar)
  1132. lib.gen_TotemBar = function(self)
  1133.     if ( playerClass == "SHAMAN" and IsAddOnLoaded("oUF_boring_totembar") ) then
  1134.         local TotemBar = CreateFrame("Frame", nil, self)
  1135.         TotemBar:SetPoint("TOP", self, "BOTTOM", 0, -4)
  1136.         TotemBar:SetWidth(self:GetWidth())
  1137.         TotemBar:SetHeight(8)
  1138.  
  1139.         TotemBar.Destroy = true
  1140.         TotemBar.AbbreviateNames = true
  1141.         TotemBar.UpdateColors = true
  1142.        
  1143.         oUF.colors.totems = {
  1144.             { 233/255, 46/255, 16/255 }, -- fire
  1145.             { 173/255, 217/255, 25/255 }, -- earth
  1146.             { 35/255, 127/255, 255/255 }, -- water
  1147.             { 178/255, 53/255, 240/255 }  -- air
  1148.         }
  1149.  
  1150.         for i = 1, 4 do
  1151.         local t = CreateFrame("Frame", nil, TotemBar)
  1152.             t:SetHeight(8)
  1153.             t:SetWidth(self.Health:GetWidth()/4 - 5)
  1154.  
  1155.             local bar = CreateFrame("StatusBar", nil, t)
  1156.             bar:SetAllPoints(t)
  1157.             bar:SetStatusBarTexture(cfg.statusbar_texture)
  1158.             t.StatusBar = bar
  1159.  
  1160.             local h = CreateFrame("Frame", nil, t)
  1161.             h:SetFrameLevel(1)
  1162.             h:SetPoint("TOPLEFT",-5,5)
  1163.             h:SetPoint("BOTTOMRIGHT",5,-5)
  1164.             lib.gen_totemback(h)
  1165.            
  1166.             if (i == 1) then
  1167.                 t:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -5)
  1168.             else
  1169.                 t:SetPoint('TOPLEFT', TotemBar[i-1], "TOPRIGHT", 6, 0)
  1170.             end
  1171.  
  1172.             t.bg = t:CreateTexture(nil, "BORDER")
  1173.             t.bg:SetAllPoints(t)
  1174.             t.bg:SetTexture(cfg.backdrop_texture)
  1175.             t.bg.multiplier = 0.15
  1176.             t.bg:SetAlpha(0.6)
  1177.  
  1178.             local text = lib.gen_fontstring(t, cfg.smallfont, 10, "THINOUTLINE")
  1179.             text:SetPoint("CENTER",t,"BOTTOM",0,-8)
  1180.             text:SetFontObject"GameFontNormal"
  1181.             t.Text = text
  1182.  
  1183.             TotemBar[i] = t
  1184.         end
  1185.     self.TotemBar = TotemBar
  1186.     end
  1187. end
  1188.  
  1189. -- oUF_DebuffHighlight
  1190. lib.debuffHighlight = function(self)
  1191.     if cfg.enableDebuffHighlight then
  1192.         local dbh = self.Health:CreateTexture(nil, "OVERLAY")
  1193.         dbh:SetAllPoints(self.Health)
  1194.         dbh:SetTexture(cfg.debuffhighlight_texture)
  1195.         dbh:SetBlendMode("ADD")
  1196.         dbh:SetVertexColor(0,0,0,0) -- set alpha to 0 to hide the texture
  1197.         self.DebuffHighlight = dbh
  1198.         self.DebuffHighlightAlpha = 0.5
  1199.         self.DebuffHighlightFilter = true
  1200.     end
  1201. end
  1202.  
  1203. -- AuraWatch
  1204. local AWPostCreateIcon = function(AWatch, icon, spellID, name, self)
  1205.     icon.cd:SetReverse()
  1206.     local count = lib.gen_fontstring(icon, cfg.smallfont, 12, "OUTLINE")
  1207.     count:SetPoint("CENTER", icon, "BOTTOM", 3, 3)
  1208.     icon.count = count
  1209.     local h = CreateFrame("Frame", nil, icon)
  1210.     h:SetFrameLevel(4)
  1211.     h:SetPoint("TOPLEFT",-3,3)
  1212.     h:SetPoint("BOTTOMRIGHT",3,-3)
  1213.     lib.gen_backdrop(h)
  1214. end
  1215. lib.createAuraWatch = function(self, unit)
  1216.     if cfg.showAuraWatch then
  1217.         local auras = {}
  1218.         local spellIDs = {
  1219.             DEATHKNIGHT = {
  1220.             },
  1221.             DRUID = {
  1222.                 33763, -- Lifebloom
  1223.                 8936, -- Regrowth
  1224.                 774, -- Rejuvenation
  1225.                 48438, -- Wild Growth
  1226.             },
  1227.             HUNTER = {
  1228.                 34477, -- Misdirection
  1229.             },
  1230.             MAGE = {
  1231.                 54646, -- Focus Magic
  1232.             },
  1233.             PALADIN = {
  1234.                 53563, -- Beacon of Light
  1235.                 25771, -- Forbearance
  1236.             },
  1237.             PRIEST = {
  1238.                 17, -- Power Word: Shield
  1239.                 139, -- Renew
  1240.                 33076, -- Prayer of Mending
  1241.                 6788, -- Weakened Soul
  1242.             },
  1243.             ROGUE = {
  1244.                 57934, -- Tricks of the Trade
  1245.             },
  1246.             SHAMAN = {
  1247.                 974, -- Earth Shield
  1248.                 61295, -- Riptide
  1249.             },
  1250.             WARLOCK = {
  1251.                 20707, -- Soulstone Resurrection
  1252.             },
  1253.             WARRIOR = {
  1254.                 50720, -- Vigilance
  1255.             },
  1256.         }
  1257.        
  1258.         auras.onlyShowPresent = true
  1259.         auras.anyUnit = true
  1260.         auras.PostCreateIcon = AWPostCreateIcon
  1261.         -- Set any other AuraWatch settings
  1262.         auras.icons = {}
  1263.  
  1264.         for i, sid in pairs(spellIDs[playerClass]) do
  1265.             local icon = CreateFrame("Frame", nil, self)
  1266.             icon.spellID = sid
  1267.             -- set the dimensions and positions
  1268.             icon:SetWidth(14)
  1269.             icon:SetHeight(14)
  1270.             icon:SetFrameLevel(5)
  1271.             icon:SetPoint("BOTTOMRIGHT", self, "BOTTOMLEFT", 12 * i, 5)
  1272.            
  1273.             auras.icons[sid] = icon
  1274.         end
  1275.         self.AuraWatch = auras
  1276.     end
  1277. end
  1278.  
  1279.   -- oUF_CombatFeedback
  1280.   lib.gen_combat_feedback = function(f)
  1281.     if IsAddOnLoaded("oUF_CombatFeedback") then
  1282.       local h = CreateFrame("Frame", nil, f.Health)
  1283.       h:SetAllPoints(f.Health)
  1284.       h:SetFrameLevel(30)
  1285.       local cfbt = lib.gen_fontstring(h, cfg.font, 18, "THINOUTLINE")
  1286.       cfbt:SetPoint("CENTER", f.Health, "BOTTOM", 0, -1)
  1287.       cfbt.maxAlpha = 0.75
  1288.       cfbt.ignoreEnergize = true
  1289.       f.CombatFeedbackText = cfbt
  1290.     end
  1291.   end
  1292.  
  1293. -- oUF_WeaponEnchant (temporary weapon enchant icon)
  1294. lib.gen_WeaponEnchant = function(self)
  1295.     if IsAddOnLoaded("oUF_WeaponEnchant") then
  1296.         self.Enchant = CreateFrame("Frame", nil, self)
  1297.         self.Enchant:SetSize(24, 52)
  1298.         self.Enchant:SetPoint("TOPLEFT", oUF_failPlayer.Health, "TOPRIGHT", 10, 14)
  1299.         self.Enchant.size = 20
  1300.         self.Enchant.spacing = 6
  1301.         self.Enchant.initialAnchor = "LEFT"
  1302.         self.Enchant["growth-y"] = "DOWN"
  1303.         self.Enchant:SetFrameLevel(10)
  1304.  
  1305.         self.PostCreateEnchantIcon = myPostCreateIcon
  1306.         self.PostUpdateEnchantIcon = myPostUpdateIcon
  1307.     end
  1308. end
  1309.  
  1310. -- oUF_Vengeance Support
  1311. lib.gen_Vengeance = function(self)
  1312.     if IsAddOnLoaded("oUF_Vengeance") then
  1313.         --statusbar
  1314.         local v = CreateFrame("StatusBar", nil, self)
  1315.         v:SetWidth(self.Health:GetWidth()+6)
  1316.         v:SetHeight(6)
  1317.         v:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -6)
  1318.         v:SetStatusBarTexture(cfg.statusbar_texture)
  1319.         v:SetStatusBarColor(1, 0.1, 0.1,1)
  1320.         -- helper
  1321.         local h = CreateFrame("Frame", nil, v)
  1322.         h:SetFrameLevel(1)
  1323.         h:SetPoint("TOPLEFT",-5,5)
  1324.         h:SetPoint("BOTTOMRIGHT",5,-5)
  1325.         lib.gen_backdrop(h)
  1326.         --bg
  1327.         local b = v:CreateTexture(nil, "BACKGROUND")
  1328.         b:SetTexture(cfg.statusbar_texture)
  1329.         b:SetAllPoints(v)
  1330.         b:SetVertexColor(0.44,0.44,0.44,0.8)
  1331.         -- text label
  1332.         v.Text = lib.gen_fontstring(v, cfg.smallfont, 10, "THINOUTLINE")
  1333.         v.Text:SetPoint("CENTER",v,"CENTER",0,0)
  1334.         v.Text:SetJustifyH("LEFT")
  1335.        
  1336.         self.Vengeance = v
  1337.         self.Vengeance.bg = b
  1338.     end
  1339. end
  1340. --hand the lib to the namespace for further usage
  1341. ns.lib = lib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement