Advertisement
CelestialFury

player.lua

May 8th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.41 KB | None | 0 0
  1. local E, L, V, P, G = unpack(select(2, ...)); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
  2. local UF = E:GetModule('UnitFrames');
  3.  
  4.  
  5.  
  6. local _, ns = ...
  7. local ElvUF = ns.oUF
  8. assert(ElvUF, "ElvUI was unable to locate oUF.")
  9.  
  10. local CAN_HAVE_CLASSBAR = (E.myclass == "PALADIN" or E.myclass == "SHAMAN" or E.myclass == "DRUID" or E.myclass == "DEATHKNIGHT" or E.myclass == "WARLOCK")
  11.  
  12. function UF:Construct_PlayerFrame(frame)
  13.     frame.Threat = self:Construct_ThreatGlow(frame, true)
  14.    
  15.     frame.Health = self:Construct_HealthBar(frame, true, true, 'RIGHT')
  16.     frame.Health.frequentUpdates = true;
  17.    
  18.     frame.Power = self:Construct_PowerBar(frame, true, true, 'LEFT', true)
  19.     frame.Power.frequentUpdates = true;
  20.    
  21.     frame.Name = self:Construct_NameText(frame)
  22.    
  23.     frame.Portrait = self:Construct_Portrait(frame)
  24.    
  25.     frame.Buffs = self:Construct_Buffs(frame)
  26.    
  27.     frame.Debuffs = self:Construct_Debuffs(frame)
  28.    
  29.     frame.Castbar = self:Construct_Castbar(frame, 'LEFT')
  30.    
  31.     if E.myclass == "PALADIN" then
  32.         frame.HolyPower = self:Construct_PaladinWarlockResourceBar(frame, E.myclass)
  33.     elseif E.myclass == "WARLOCK" then
  34.         frame.SoulShards = self:Construct_PaladinWarlockResourceBar(frame, E.myclass)
  35.     elseif E.myclass == "DEATHKNIGHT" then
  36.         frame.Runes = self:Construct_DeathKnightResourceBar(frame)
  37.     elseif E.myclass == "SHAMAN" then
  38.         frame.TotemBar = self:Construct_ShamanTotemBar(frame)
  39.     elseif E.myclass == "DRUID" then
  40.         frame.EclipseBar = self:Construct_DruidResourceBar(frame)
  41.         frame.DruidAltMana = self:Construct_DruidAltManaBar(frame)
  42.     end
  43.     frame.RaidIcon = UF:Construct_RaidIcon(frame)
  44.     frame.Resting = self:Construct_RestingIndicator(frame)
  45.     frame.Combat = self:Construct_CombatIndicator(frame)
  46.     frame.PvPText = self:Construct_PvPIndicator(frame)
  47.     frame.AltPowerBar = self:Construct_AltPowerBar(frame)
  48.     frame.DebuffHighlight = self:Construct_DebuffHighlight(frame)
  49.     frame.HealPrediction = self:Construct_HealComm(frame)
  50.  
  51.     frame.CombatFade = true
  52. end
  53.  
  54. function UF:Update_PlayerFrame(frame, db)
  55.     frame.db = db
  56.     local BORDER = E:Scale(2)
  57.     local SPACING = E:Scale(1)
  58.     local UNIT_WIDTH = db.width
  59.     local UNIT_HEIGHT = db.height
  60.    
  61.     local USE_POWERBAR = db.power.enable
  62.     local USE_MINI_POWERBAR = db.power.width ~= 'fill' and USE_POWERBAR
  63.     local USE_POWERBAR_OFFSET = db.power.offset ~= 0 and USE_POWERBAR
  64.     local POWERBAR_OFFSET = db.power.offset
  65.     local POWERBAR_HEIGHT = db.power.height
  66.     local POWERBAR_WIDTH = db.width - (BORDER*2)
  67.    
  68.     local USE_CLASSBAR = db.classbar.enable and CAN_HAVE_CLASSBAR
  69.     local USE_MINI_CLASSBAR = db.classbar.fill == "spaced" and USE_CLASSBAR
  70.     local CLASSBAR_HEIGHT = db.classbar.height
  71.     local CLASSBAR_WIDTH = db.width - (BORDER*2)
  72.     local CLASSBAR_OFFSET = db.classbar.offset
  73.    
  74.     local USE_PORTRAIT = db.portrait.enable
  75.     local USE_PORTRAIT_OVERLAY = db.portrait.overlay and USE_PORTRAIT
  76.     local PORTRAIT_WIDTH = db.portrait.width
  77.    
  78.     local unit = self.unit
  79.    
  80.     frame.colors = ElvUF.colors
  81.     frame:Size(UNIT_WIDTH, UNIT_HEIGHT)
  82.    
  83.     --Adjust some variables
  84.     do
  85.         if not USE_POWERBAR then
  86.             POWERBAR_HEIGHT = 0
  87.         end
  88.        
  89.         if USE_PORTRAIT_OVERLAY or not USE_PORTRAIT then
  90.             PORTRAIT_WIDTH = 0
  91.             if USE_POWERBAR_OFFSET then
  92.                 CLASSBAR_WIDTH = CLASSBAR_WIDTH - POWERBAR_OFFSET
  93.             end        
  94.         end
  95.        
  96.         if USE_PORTRAIT then
  97.             CLASSBAR_WIDTH = math.ceil((UNIT_WIDTH - (BORDER*2)) - PORTRAIT_WIDTH)
  98.            
  99.             if USE_POWERBAR_OFFSET then
  100.                 CLASSBAR_WIDTH = CLASSBAR_WIDTH - POWERBAR_OFFSET
  101.             end
  102.         end
  103.        
  104.         if USE_POWERBAR_OFFSET then
  105.             CLASSBAR_WIDTH = CLASSBAR_WIDTH - POWERBAR_OFFSET
  106.         end
  107.  
  108.         if USE_MINI_CLASSBAR then
  109.             CLASSBAR_WIDTH = CLASSBAR_WIDTH*2/3
  110.         end
  111.        
  112.         if USE_MINI_POWERBAR then
  113.             POWERBAR_WIDTH = POWERBAR_WIDTH / 2
  114.         end
  115.     end
  116.    
  117.     --Threat
  118.     do
  119.         local threat = frame.Threat
  120.        
  121.         local mini_classbarY = 0
  122.         if USE_MINI_CLASSBAR then
  123.             mini_classbarY = -(SPACING+(CLASSBAR_HEIGHT/2))
  124.         end
  125.        
  126.         threat:ClearAllPoints()
  127.         threat:SetBackdropBorderColor(0, 0, 0, 0)
  128.         threat:Point("TOPLEFT", -4, 4+mini_classbarY)
  129.         threat:Point("TOPRIGHT", 4, 4+mini_classbarY)
  130.        
  131.         if USE_MINI_POWERBAR then
  132.             threat:Point("BOTTOMLEFT", -4, -4 + (POWERBAR_HEIGHT/2))
  133.             threat:Point("BOTTOMRIGHT", 4, -4 + (POWERBAR_HEIGHT/2))       
  134.         else
  135.             threat:Point("BOTTOMLEFT", -4, -4)
  136.             threat:Point("BOTTOMRIGHT", 4, -4)
  137.         end
  138.  
  139.         if USE_POWERBAR_OFFSET then
  140.             threat:Point("TOPRIGHT", 4-POWERBAR_OFFSET, 4+mini_classbarY)
  141.             threat:Point("BOTTOMRIGHT", 4-POWERBAR_OFFSET, -4) 
  142.         end    
  143.  
  144.         if USE_POWERBAR_OFFSET == true then
  145.             if USE_PORTRAIT == true and not USE_PORTRAIT_OVERLAY then
  146.                 threat:Point("BOTTOMLEFT", frame.Portrait.backdrop, "BOTTOMLEFT", -4, -4)
  147.             else
  148.                 threat:Point("BOTTOMLEFT", frame.Health, "BOTTOMLEFT", -5, -5)
  149.             end
  150.             threat:Point("BOTTOMRIGHT", frame.Health, "BOTTOMRIGHT", 5, -5)
  151.         end            
  152.     end
  153.    
  154.     --Rest Icon
  155.     do
  156.         local rIcon = frame.Resting
  157.         if db.restIcon then
  158.             if not frame:IsElementEnabled('Resting') then
  159.                 frame:EnableElement('Resting')
  160.             end            
  161.         elseif frame:IsElementEnabled('Resting') then
  162.             frame:DisableElement('Resting')
  163.             rIcon:Hide()
  164.         end
  165.     end
  166.    
  167.     --Health
  168.     do
  169.         local health = frame.Health
  170.         health.Smooth = self.db.smoothbars
  171.  
  172.         --Text
  173.         if db.health.text then
  174.             health.value:Show()
  175.            
  176.             local x, y = self:GetPositionOffset(db.health.position)
  177.             health.value:ClearAllPoints()
  178.             health.value:Point(db.health.position, health, db.health.position, x, y)
  179.         else
  180.             health.value:Hide()
  181.         end
  182.        
  183.         --Colors
  184.         health.colorSmooth = nil
  185.         health.colorHealth = nil
  186.         health.colorClass = nil
  187.         health.colorReaction = nil
  188.         if self.db['colors'].healthclass ~= true then
  189.             if self.db['colors'].colorhealthbyvalue == true then
  190.                 health.colorSmooth = true
  191.             else
  192.                 health.colorHealth = true
  193.             end    
  194.         else
  195.             health.colorClass = true
  196.             health.colorReaction = true
  197.         end
  198.        
  199.         --Position
  200.         health:ClearAllPoints()
  201.         health:Point("TOPRIGHT", frame, "TOPRIGHT", -BORDER, -BORDER)
  202.         if USE_POWERBAR_OFFSET then
  203.             health:Point("TOPRIGHT", frame, "TOPRIGHT", -(BORDER+POWERBAR_OFFSET), -BORDER)
  204.             health:Point("BOTTOMLEFT", frame, "BOTTOMLEFT", BORDER, BORDER+POWERBAR_OFFSET)
  205.         elseif USE_MINI_POWERBAR then
  206.             health:Point("BOTTOMLEFT", frame, "BOTTOMLEFT", BORDER, BORDER + (POWERBAR_HEIGHT/2))
  207.         else
  208.             health:Point("BOTTOMLEFT", frame, "BOTTOMLEFT", BORDER, BORDER + POWERBAR_HEIGHT)
  209.         end
  210.        
  211.         health.bg:ClearAllPoints()
  212.         if not USE_PORTRAIT_OVERLAY then
  213.             health:Point("TOPLEFT", PORTRAIT_WIDTH+BORDER, -BORDER)    
  214.             health.bg:SetParent(health)
  215.             health.bg:SetAllPoints()
  216.         else
  217.             health.bg:Point('BOTTOMLEFT', health:GetStatusBarTexture(), 'BOTTOMRIGHT')
  218.             health.bg:Point('TOPRIGHT', health)    
  219.             health.bg:SetParent(frame.Portrait.overlay)        
  220.         end
  221.        
  222.         if USE_CLASSBAR then
  223.             local DEPTH
  224.             if USE_MINI_CLASSBAR then
  225.                 DEPTH = -(BORDER+(CLASSBAR_HEIGHT/2))
  226.             else
  227.                 DEPTH = -(BORDER+CLASSBAR_HEIGHT+SPACING)
  228.             end
  229.            
  230.             if USE_POWERBAR_OFFSET then
  231.                 health:Point("TOPRIGHT", frame, "TOPRIGHT", -(BORDER+POWERBAR_OFFSET), DEPTH)
  232.             else
  233.                 health:Point("TOPRIGHT", frame, "TOPRIGHT", -BORDER, DEPTH)
  234.             end
  235.            
  236.             health:Point("TOPLEFT", frame, "TOPLEFT", PORTRAIT_WIDTH+BORDER, DEPTH)
  237.         end
  238.     end
  239.    
  240.     --Name
  241.     do
  242.         local name = frame.Name
  243.         if db.name.enable then
  244.             name:Show()
  245.            
  246.             if not db.power.hideonnpc then
  247.                 local x, y = self:GetPositionOffset(db.name.position)
  248.                 name:ClearAllPoints()
  249.                 name:Point(db.name.position, frame.Health, db.name.position, x, y)             
  250.             end
  251.         else
  252.             name:Hide()
  253.         end
  254.     end
  255.    
  256.     --Power
  257.     do
  258.         local power = frame.Power
  259.         if USE_POWERBAR then
  260.             if not frame:IsElementEnabled('Power') then
  261.                 frame:EnableElement('Power')
  262.                 power:Show()
  263.             end    
  264.        
  265.             power.Smooth = self.db.smoothbars
  266.            
  267.             --Text
  268.             if db.power.text then
  269.                 power.value:Show()
  270.                
  271.                 local x, y = self:GetPositionOffset(db.power.position)
  272.                 power.value:ClearAllPoints()
  273.                 power.value:Point(db.power.position, frame.Health, db.power.position, x, y)        
  274.             else
  275.                 power.value:Hide()
  276.             end
  277.            
  278.             --Colors
  279.             power.colorClass = nil
  280.             power.colorReaction = nil  
  281.             power.colorPower = nil
  282.             if self.db['colors'].powerclass then
  283.                 power.colorClass = true
  284.                 power.colorReaction = true
  285.             else
  286.                 power.colorPower = true
  287.             end    
  288.            
  289.             --Position
  290.             power:ClearAllPoints()
  291.             if USE_POWERBAR_OFFSET then
  292.                 power:Point("TOPRIGHT", frame.Health, "TOPRIGHT", POWERBAR_OFFSET, -POWERBAR_OFFSET)
  293.                 power:Point("BOTTOMLEFT", frame.Health, "BOTTOMLEFT", POWERBAR_OFFSET, -POWERBAR_OFFSET)
  294.                 power:SetFrameStrata("LOW")
  295.                 power:SetFrameLevel(2)
  296.             elseif USE_MINI_POWERBAR then
  297.                 power:Width(POWERBAR_WIDTH - BORDER*2)
  298.                 power:Height(POWERBAR_HEIGHT - BORDER*2)
  299.                 power:Point("RIGHT", frame, "BOTTOMRIGHT", -(BORDER*2 + 4), BORDER + (POWERBAR_HEIGHT/2))
  300.                 power:SetFrameStrata("MEDIUM")
  301.                 power:SetFrameLevel(frame:GetFrameLevel() + 3)
  302.             else
  303.                 power:Point("TOPLEFT", frame.Health.backdrop, "BOTTOMLEFT", BORDER, -(BORDER + SPACING))
  304.                 power:Point("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -BORDER, BORDER)
  305.             end
  306.         elseif frame:IsElementEnabled('Power') then
  307.             frame:DisableElement('Power')
  308.             power:Hide()
  309.             power.value:Hide()
  310.         end
  311.     end
  312.    
  313.     --Portrait
  314.     do
  315.         local portrait = frame.Portrait
  316.        
  317.         --Set Points
  318.         if USE_PORTRAIT then
  319.             if not frame:IsElementEnabled('Portrait') then
  320.                 frame:EnableElement('Portrait')
  321.             end
  322.            
  323.             portrait:ClearAllPoints()
  324.            
  325.             if USE_PORTRAIT_OVERLAY then
  326.                 portrait:SetFrameLevel(frame.Health:GetFrameLevel() + 1)
  327.                 portrait:SetAllPoints(frame.Health)
  328.                 portrait:SetAlpha(0.3)
  329.                 portrait:Show()    
  330.             else
  331.                 portrait:SetAlpha(1)
  332.                 portrait:Show()
  333.                
  334.                 if USE_MINI_CLASSBAR and USE_CLASSBAR then
  335.                     portrait.backdrop:Point("TOPLEFT", frame, "TOPLEFT", 0, -((CLASSBAR_HEIGHT/2)))
  336.                 else
  337.                     portrait.backdrop:SetPoint("TOPLEFT", frame, "TOPLEFT")
  338.                 end    
  339.                
  340.                 if USE_MINI_POWERBAR or USE_POWERBAR_OFFSET or not USE_POWERBAR then
  341.                     portrait.backdrop:Point("BOTTOMRIGHT", frame.Health.backdrop, "BOTTOMLEFT", -SPACING, 0)
  342.                 else
  343.                     portrait.backdrop:Point("BOTTOMRIGHT", frame.Power.backdrop, "BOTTOMLEFT", -SPACING, 0)
  344.                 end
  345.  
  346.                 portrait:Point('BOTTOMLEFT', portrait.backdrop, 'BOTTOMLEFT', BORDER, BORDER)      
  347.                 portrait:Point('TOPRIGHT', portrait.backdrop, 'TOPRIGHT', -BORDER, -BORDER)            
  348.             end
  349.         else
  350.             if frame:IsElementEnabled('Portrait') then
  351.                 frame:DisableElement('Portrait')
  352.                 portrait:Hide()
  353.             end    
  354.         end
  355.     end
  356.  
  357.     --Auras Disable/Enable
  358.     --Only do if both debuffs and buffs aren't being used.
  359.     do
  360.         if db.debuffs.enable or db.buffs.enable then
  361.             if not frame:IsElementEnabled('Aura') then
  362.                 frame:EnableElement('Aura')
  363.             end
  364.         else
  365.             if frame:IsElementEnabled('Aura') then
  366.                 frame:DisableElement('Aura')
  367.             end        
  368.         end
  369.        
  370.         frame.Buffs:ClearAllPoints()
  371.         frame.Debuffs:ClearAllPoints()
  372.     end
  373.    
  374.     --Buffs
  375.     do
  376.         local buffs = frame.Buffs
  377.         local rows = db.buffs.numrows
  378.        
  379.         if USE_POWERBAR_OFFSET then
  380.             buffs:SetWidth(UNIT_WIDTH - POWERBAR_OFFSET)
  381.         else
  382.             buffs:SetWidth(UNIT_WIDTH)
  383.         end
  384.        
  385.         if db.buffs.initialAnchor == "RIGHT" or db.buffs.initialAnchor == "LEFT" then
  386.             rows = 1;
  387.             buffs:SetWidth(UNIT_WIDTH / 2)
  388.         end
  389.        
  390.         buffs.num = db.buffs.perrow * rows
  391.         buffs.size = ((((buffs:GetWidth() - (buffs.spacing*(buffs.num/rows - 1))) / buffs.num)) * rows)
  392.  
  393.         local x, y = self:GetAuraOffset(db.buffs.initialAnchor, db.buffs.anchorPoint)
  394.         local attachTo = self:GetAuraAnchorFrame(frame, db.buffs.attachTo)
  395.  
  396.         buffs:Point(db.buffs.initialAnchor, attachTo, db.buffs.anchorPoint, x, y)
  397.         buffs:Height(buffs.size * rows)
  398.         buffs.initialAnchor = db.buffs.initialAnchor
  399.         buffs["growth-y"] = db.buffs['growth-y']
  400.         buffs["growth-x"] = db.buffs['growth-x']
  401.  
  402.         if db.buffs.enable then        
  403.             buffs:Show()
  404.         else
  405.             buffs:Hide()
  406.         end
  407.     end
  408.    
  409.     --Debuffs
  410.     do
  411.         local debuffs = frame.Debuffs
  412.         local rows = db.debuffs.numrows
  413.        
  414.         if USE_POWERBAR_OFFSET then
  415.             debuffs:SetWidth(UNIT_WIDTH - POWERBAR_OFFSET)
  416.         else
  417.             debuffs:SetWidth(UNIT_WIDTH)
  418.         end
  419.        
  420.         if db.debuffs.initialAnchor == "RIGHT" or db.debuffs.initialAnchor == "LEFT" then
  421.             rows = 1;
  422.             debuffs:SetWidth(UNIT_WIDTH / 2)
  423.         end
  424.        
  425.         debuffs.num = db.debuffs.perrow * rows
  426.         debuffs.size = ((((debuffs:GetWidth() - (debuffs.spacing*(debuffs.num/rows - 1))) / debuffs.num)) * rows)
  427.  
  428.         local x, y = self:GetAuraOffset(db.debuffs.initialAnchor, db.debuffs.anchorPoint)
  429.         local attachTo = self:GetAuraAnchorFrame(frame, db.debuffs.attachTo, db.buffs.attachTo == 'DEBUFFS' and db.debuffs.attachTo == 'BUFFS')
  430.  
  431.         debuffs:Point(db.debuffs.initialAnchor, attachTo, db.debuffs.anchorPoint, x, y)
  432.         debuffs:Height(debuffs.size * rows)
  433.         debuffs.initialAnchor = db.debuffs.initialAnchor
  434.         debuffs["growth-y"] = db.debuffs['growth-y']
  435.         debuffs["growth-x"] = db.debuffs['growth-x']
  436.  
  437.         if db.debuffs.enable then          
  438.             debuffs:Show()
  439.         else
  440.             debuffs:Hide()
  441.         end
  442.     end
  443.    
  444.     --Castbar
  445.     do
  446.         local castbar = frame.Castbar
  447.         castbar:Width(db.castbar.width - 4)
  448.         castbar:Height(db.castbar.height)
  449.        
  450.         --Latency
  451.         if db.castbar.latency then
  452.             castbar.SafeZone = castbar.LatencyTexture
  453.             castbar.LatencyTexture:Show()
  454.         else
  455.             castbar.SafeZone = nil
  456.             castbar.LatencyTexture:Hide()
  457.         end
  458.        
  459.         --Icon
  460.         if db.castbar.icon then
  461.             castbar.Icon = castbar.ButtonIcon
  462.             castbar.Icon.bg:Width(db.castbar.height + 4)
  463.             castbar.Icon.bg:Height(db.castbar.height + 4)
  464.            
  465.             castbar:Width(db.castbar.width - castbar.Icon.bg:GetWidth() - 5)
  466.             castbar.Icon.bg:Show()
  467.         else
  468.             castbar.ButtonIcon.bg:Hide()
  469.             castbar.Icon = nil
  470.         end
  471.  
  472.         if db.castbar.spark then
  473.             castbar.Spark:Show()
  474.         else
  475.             castbar.Spark:Hide()
  476.         end
  477.        
  478.         castbar:ClearAllPoints()
  479.         castbar:Point("TOPRIGHT", frame, "BOTTOMRIGHT", (-BORDER + db.castbar.xOffset), (-(BORDER*2+BORDER) + db.castbar.yOffset))
  480.        
  481.         if db.castbar.enable and not frame:IsElementEnabled('Castbar') then
  482.             frame:EnableElement('Castbar')
  483.         elseif not db.castbar.enable and frame:IsElementEnabled('Castbar') then
  484.             frame:DisableElement('Castbar')
  485.         end        
  486.     end
  487.    
  488.     --Resource Bars
  489.     do
  490.         if E.myclass == "PALADIN" then
  491.             local bars = frame.HolyPower
  492.             bars:ClearAllPoints()
  493.             if USE_MINI_CLASSBAR then
  494.             --  bars:Point("CENTER", frame.Health.backdrop, "TOP", -(BORDER*3 + 6), -SPACING)
  495.                 bars:SetFrameStrata("MEDIUM")
  496.             else
  497.                 --bars:Point("BOTTOMLEFT", frame.Health.backdrop, "TOPLEFT", BORDER, BORDER+SPACING)
  498.                 bars:SetFrameStrata("LOW")
  499.             end
  500.             bars:Width(CLASSBAR_WIDTH)
  501.             bars:Height(CLASSBAR_HEIGHT - (BORDER*2))
  502.             bars:Point("BOTTOMRIGHT", frame.Health.backdrop, "TOPRIGHT", db.classbar.xOffset, db.classbar.yOffset)
  503.             for i = 1, MAX_HOLY_POWER do
  504.                 bars[i]:SetHeight(bars:GetHeight())
  505.                 bars[i]:SetWidth(E:Scale(bars:GetWidth() - 2)/MAX_HOLY_POWER)  
  506.                 bars[i]:GetStatusBarTexture():SetHorizTile(false)
  507.                 bars[i]:ClearAllPoints()
  508.                 if i == 1 then
  509.                     bars[i]:SetPoint("LEFT", bars)
  510.                 else
  511.                     if USE_MINI_CLASSBAR then
  512.                         bars[i]:Point("LEFT", bars[i-1], "RIGHT", SPACING+(BORDER*2)+8, 0)
  513.                     else
  514.                         bars[i]:Point("LEFT", bars[i-1], "RIGHT", SPACING, 0)
  515.                     end
  516.                 end
  517.                
  518.                 if not USE_MINI_CLASSBAR then
  519.                     bars[i].backdrop:Hide()
  520.                 else
  521.                     bars[i].backdrop:Show()
  522.                 end
  523.             end
  524.            
  525.             if not USE_MINI_CLASSBAR then
  526.                 bars.backdrop:Show()
  527.             else
  528.                 bars.backdrop:Hide()           
  529.             end    
  530.            
  531.             if USE_CLASSBAR and not frame:IsElementEnabled('HolyPower') then
  532.                 frame:EnableElement('HolyPower')
  533.                 bars:Show()
  534.             elseif not USE_CLASSBAR and frame:IsElementEnabled('HolyPower') then
  535.                 frame:DisableElement('HolyPower')  
  536.                 bars:Hide()
  537.             end    
  538.            
  539.         elseif E.myclass == "WARLOCK" then
  540.             local bars = frame.SoulShards
  541.             bars:ClearAllPoints()
  542.             if USE_MINI_CLASSBAR then
  543.                 --bars:Point("CENTER", frame.Health.backdrop, "TOP", -(BORDER*3 + 6), -SPACING)
  544.                 bars:SetFrameStrata("MEDIUM")
  545.             else
  546.                 --bars:Point("BOTTOMLEFT", frame.Health.backdrop, "TOPLEFT", BORDER, BORDER+SPACING)
  547.                 bars:SetFrameStrata("LOW")
  548.             end
  549.             bars:Width(CLASSBAR_WIDTH)
  550.             bars:Height(CLASSBAR_HEIGHT - (BORDER*2))
  551.             bars:Point("BOTTOMRIGHT", frame.Health.backdrop, "TOPRIGHT", db.classbar.xOffset, db.classbar.yOffset)
  552.             for i = 1, SHARD_BAR_NUM_SHARDS do
  553.                 bars[i]:SetHeight(bars:GetHeight())
  554.                 bars[i]:SetWidth(E:Scale(bars:GetWidth() - 2)/SHARD_BAR_NUM_SHARDS)
  555.                 bars[i]:ClearAllPoints()
  556.                 if i == 1 then
  557.                     bars[i]:SetPoint("LEFT", bars)
  558.                 else
  559.                     if USE_MINI_CLASSBAR then
  560.                         bars[i]:Point("LEFT", bars[i-1], "RIGHT", SPACING+(BORDER*2)+8, 0)
  561.                     else
  562.                         bars[i]:Point("LEFT", bars[i-1], "RIGHT", SPACING, 0)
  563.                     end
  564.                 end
  565.                
  566.                 if not USE_MINI_CLASSBAR then
  567.                     bars[i].backdrop:Hide()
  568.                 else
  569.                     bars[i].backdrop:Show()
  570.                 end            
  571.             end
  572.            
  573.             if not USE_MINI_CLASSBAR then
  574.                 bars.backdrop:Show()
  575.             else
  576.                 bars.backdrop:Hide()           
  577.             end
  578.            
  579.             if USE_CLASSBAR and not frame:IsElementEnabled('SoulShards') then
  580.                 frame:EnableElement('SoulShards')
  581.                 bars:Show()
  582.             elseif not USE_CLASSBAR and frame:IsElementEnabled('SoulShards') then
  583.                 frame:DisableElement('SoulShards')
  584.                 bars:Hide()
  585.             end                
  586.         elseif E.myclass == "DEATHKNIGHT" then
  587.             local runes = frame.Runes
  588.             runes:ClearAllPoints()
  589.             if USE_MINI_CLASSBAR then
  590.                 CLASSBAR_WIDTH = CLASSBAR_WIDTH * 3/2 --Multiply by reciprocal to reset previous setting              
  591.                 CLASSBAR_WIDTH = CLASSBAR_WIDTH * 4/5
  592.                 --runes:Point("CENTER", frame.Health.backdrop, "TOP", -(BORDER*3 + 8), -SPACING)
  593.                 runes:SetFrameStrata("MEDIUM")
  594.             else
  595.                 --runes:Point("BOTTOMLEFT", frame.Health.backdrop, "TOPLEFT", BORDER, BORDER+SPACING)
  596.                 runes:SetFrameStrata("LOW")
  597.             end
  598.             runes:Width(CLASSBAR_WIDTH)
  599.             runes:Height(CLASSBAR_HEIGHT - (BORDER*2))         
  600.             runes:Point("BOTTOMRIGHT", frame.Health.backdrop, "TOPRIGHT", db.classbar.xOffset, db.classbar.yOffset)
  601.             for i = 1, 6 do
  602.                 runes[i]:SetHeight(runes:GetHeight())
  603.                 runes[i]:SetWidth(E:Scale(runes:GetWidth() - 5) / 6)   
  604.                 if USE_MINI_CLASSBAR then
  605.                     runes[i].backdrop:Show()
  606.                 else
  607.                     runes[i].backdrop:Hide()   
  608.                 end
  609.                
  610.                 runes[i]:ClearAllPoints()
  611.                 if i == 1 then
  612.                     runes[i]:SetPoint("LEFT", runes)
  613.                 else
  614.                     if USE_MINI_CLASSBAR then
  615.                         runes[i]:Point("LEFT", runes[i-1], "RIGHT", SPACING+(BORDER*2)+2, 0)
  616.                     else
  617.                         runes[i]:Point("LEFT", runes[i-1], "RIGHT", SPACING, 0)
  618.                     end
  619.                 end
  620.                
  621.                 if not USE_MINI_CLASSBAR then
  622.                     runes[i].backdrop:Hide()
  623.                 else
  624.                     runes[i].backdrop:Show()
  625.                 end                
  626.             end
  627.            
  628.             if not USE_MINI_CLASSBAR then
  629.                 runes.backdrop:Show()
  630.             else
  631.                 runes.backdrop:Hide()
  632.             end    
  633.  
  634.             if USE_CLASSBAR and not frame:IsElementEnabled('Runes') then
  635.                 frame:EnableElement('Runes')
  636.                 runes:Show()
  637.             elseif not USE_CLASSBAR and frame:IsElementEnabled('Runes') then
  638.                 frame:DisableElement('Runes')  
  639.                 runes:Hide()
  640.                 RuneFrame.Show = RuneFrame.Hide
  641.                 RuneFrame:Hide()               
  642.             end                
  643.         elseif E.myclass == "SHAMAN" then
  644.             local totems = frame.TotemBar
  645.            
  646.             totems:ClearAllPoints()
  647.             if not USE_MINI_CLASSBAR then
  648.                 --totems:Point("BOTTOMLEFT", frame.Health.backdrop, "TOPLEFT", BORDER, BORDER+SPACING)
  649.                 totems:SetFrameStrata("LOW")
  650.             else
  651.                 CLASSBAR_WIDTH = CLASSBAR_WIDTH * 3/2 --Multiply by reciprocal to reset previous setting
  652.                 CLASSBAR_WIDTH = CLASSBAR_WIDTH * 4/5
  653.                 --totems:Point("CENTER", frame.Health.backdrop, "TOP", -(BORDER*3 + 6), -SPACING)
  654.                 totems:SetFrameStrata("MEDIUM")        
  655.             end
  656.            
  657.             totems:Width(CLASSBAR_WIDTH)
  658.             totems:Height(CLASSBAR_HEIGHT - (BORDER*2))
  659.             totems:Point("BOTTOMRIGHT", frame.Health.backdrop, "TOPRIGHT", db.classbar.xOffset, db.classbar.yOffset)
  660.             for i=1, 4 do
  661.                 totems[i]:SetHeight(totems:GetHeight())
  662.                 totems[i]:SetWidth(E:Scale(totems:GetWidth() - 3) / 4) 
  663.  
  664.                 if USE_MINI_CLASSBAR then
  665.                     totems[i].backdrop:Show()
  666.                 else
  667.                     totems[i].backdrop:Hide()
  668.                 end
  669.                
  670.                 totems[i]:ClearAllPoints()
  671.                 if i == 1 then
  672.                     totems[i]:SetPoint("LEFT", totems)
  673.                 else
  674.                     if USE_MINI_CLASSBAR then
  675.                         totems[i]:Point("LEFT", totems[i-1], "RIGHT", SPACING+(BORDER*2)+4, 0)
  676.                     else
  677.                         totems[i]:Point("LEFT", totems[i-1], "RIGHT", SPACING, 0)
  678.                     end
  679.                 end    
  680.  
  681.                 if not USE_MINI_CLASSBAR then
  682.                     totems[i].backdrop:Hide()
  683.                 else
  684.                     totems[i].backdrop:Show()
  685.                 end                    
  686.             end
  687.            
  688.             if not USE_MINI_CLASSBAR then
  689.                 totems.backdrop:Show()
  690.             else
  691.                 totems.backdrop:Hide()
  692.             end    
  693.  
  694.             if USE_CLASSBAR and not frame:IsElementEnabled('TotemBar') then
  695.                 frame:EnableElement('TotemBar')
  696.                 totems:Show()
  697.             elseif not USE_CLASSBAR and frame:IsElementEnabled('TotemBar') then
  698.                 frame:DisableElement('TotemBar')   
  699.                 totems:Hide()
  700.             end                
  701.         elseif E.myclass == "DRUID" then
  702.             local eclipseBar = frame.EclipseBar
  703.  
  704.             eclipseBar:ClearAllPoints()
  705.             if not USE_MINI_CLASSBAR then
  706.                 --eclipseBar:Point("BOTTOMLEFT", frame.Health.backdrop, "TOPLEFT", BORDER, BORDER+SPACING)
  707.                 eclipseBar:SetFrameStrata("LOW")
  708.             else       
  709.                 CLASSBAR_WIDTH = CLASSBAR_WIDTH * 3/2 --Multiply by reciprocal to reset previous setting
  710.                 CLASSBAR_WIDTH = CLASSBAR_WIDTH * 2/3          
  711.                 --eclipseBar:Point("LEFT", frame.Health.backdrop, "TOPLEFT", (BORDER*2 + 4), 0)
  712.                 eclipseBar:SetFrameStrata("MEDIUM")                    
  713.             end
  714.  
  715.             eclipseBar:Width(CLASSBAR_WIDTH)
  716.             eclipseBar:Height(CLASSBAR_HEIGHT - (BORDER*2))
  717.             eclipseBar:Point("BOTTOMRIGHT", frame.Health.backdrop, "TOPRIGHT", db.classbar.xOffset, db.classbar.yOffset)
  718.             --?? Apparent bug fix for the width after in-game settings change
  719.             eclipseBar.LunarBar:SetMinMaxValues(0, 0)
  720.             eclipseBar.SolarBar:SetMinMaxValues(0, 0)
  721.             eclipseBar.LunarBar:Size(CLASSBAR_WIDTH, CLASSBAR_HEIGHT - (BORDER*2))         
  722.             eclipseBar.SolarBar:Size(CLASSBAR_WIDTH, CLASSBAR_HEIGHT - (BORDER*2)) 
  723.            
  724.             if USE_CLASSBAR and not frame:IsElementEnabled('EclipseBar') then
  725.                 frame:EnableElement('EclipseBar')
  726.                 eclipseBar:Show()
  727.             elseif not USE_CLASSBAR and frame:IsElementEnabled('EclipseBar') then
  728.                 frame:DisableElement('EclipseBar') 
  729.                 eclipseBar:Hide()
  730.             end                
  731.         end
  732.     end
  733.    
  734.     --Combat Fade
  735.     do
  736.         if db.combatfade and not frame:IsElementEnabled('CombatFade') then
  737.             frame:EnableElement('CombatFade')
  738.         elseif not db.combatfade and frame:IsElementEnabled('CombatFade') then
  739.             frame:DisableElement('CombatFade')
  740.         end    
  741.     end
  742.    
  743.     --AltPower
  744.     do
  745.         local altpower = frame.AltPowerBar
  746.         altpower:Point("TOP", E.UIParent, "TOP", 0, -70)
  747.         altpower:Width(db.altpower.width)
  748.         altpower:Height(db.altpower.height)
  749.         altpower.Smooth = self.db.smoothbars
  750.        
  751.         if db.altpower.enable and not frame:IsElementEnabled('AltPowerBar') then
  752.             frame:EnableElement('AltPowerBar')
  753.         elseif not db.altpower.enable and frame:IsElementEnabled('AltPowerBar') then
  754.             frame:DisableElement('AltPowerBar')
  755.         end        
  756.     end
  757.    
  758.     --Debuff Highlight
  759.     do
  760.         local dbh = frame.DebuffHighlight
  761.         if E.db.unitframe.debuffHighlighting then
  762.             frame:EnableElement('DebuffHighlight')
  763.         else
  764.             frame:DisableElement('DebuffHighlight')
  765.         end
  766.     end
  767.    
  768.     --OverHealing
  769.     do
  770.         local healPrediction = frame.HealPrediction
  771.        
  772.         if db.healPrediction then
  773.             if not frame:IsElementEnabled('HealPrediction') then
  774.                 frame:EnableElement('HealPrediction')
  775.             end
  776.  
  777.             healPrediction.myBar:ClearAllPoints()
  778.             healPrediction.myBar:Width(db.width - (BORDER*2))
  779.             healPrediction.myBar:SetPoint('BOTTOMLEFT', frame.Health:GetStatusBarTexture(), 'BOTTOMRIGHT')
  780.             healPrediction.myBar:SetPoint('TOPLEFT', frame.Health:GetStatusBarTexture(), 'TOPRIGHT')   
  781.  
  782.             healPrediction.otherBar:ClearAllPoints()
  783.             healPrediction.otherBar:SetPoint('TOPLEFT', healPrediction.myBar:GetStatusBarTexture(), 'TOPRIGHT')
  784.             healPrediction.otherBar:SetPoint('BOTTOMLEFT', healPrediction.myBar:GetStatusBarTexture(), 'BOTTOMRIGHT')  
  785.             healPrediction.otherBar:Width(db.width - (BORDER*2))
  786.            
  787.             if not USE_PORTRAIT_OVERLAY then
  788.                 healPrediction.myBar:SetParent(frame)
  789.                 healPrediction.otherBar:SetParent(frame)
  790.             else   
  791.                 healPrediction.myBar:SetParent(frame.Portrait.overlay)     
  792.                 healPrediction.otherBar:SetParent(frame.Portrait.overlay)                  
  793.             end
  794.         else
  795.             if frame:IsElementEnabled('HealPrediction') then
  796.                 frame:DisableElement('HealPrediction')
  797.             end    
  798.         end
  799.     end
  800.    
  801.     frame.snapOffset = -(12 + db.castbar.height)
  802.    
  803.     if not frame.mover then
  804.         frame:ClearAllPoints()
  805.         frame:Point('BOTTOMLEFT', E.UIParent, 'BOTTOM', -417, 75) --Set to default position
  806.     end
  807.  
  808.     frame:UpdateAllElements()
  809. end
  810.  
  811. tinsert(UF['unitstoload'], 'player')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement