Advertisement
Guest User

Untitled

a guest
May 14th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.95 KB | None | 0 0
  1. local _, cfg = ... --import config
  2. local _, ns = ... --get addon namespace
  3. local _, playerClass = UnitClass("player")
  4. local isBeautiful = IsAddOnLoaded("!Beautycase") --!Beautycase check
  5.  
  6. if not cfg.group.enable then return end
  7. -----------------------------
  8. -- Backdrop function
  9. local function CreateBackdrop(frame)
  10.     frame:SetBackdrop({bgFile = "Interface\\Buttons\\WHITE8x8",
  11.         insets = {top = 1, left = 1, bottom = 1, right = 1}})
  12.     frame:SetBackdropColor(unpack(cfg.bColor))
  13.     if isBeautiful then
  14.         frame:CreateBeautyBorder(12)
  15.         frame:SetBeautyBorderPadding(1)
  16.     end
  17. end
  18. --Spawn Indicators
  19. local indicatorPositions = { "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT" }
  20. local indicatorBackdrop = { bgFile = "Interface\\Buttons\\WHITE8X8" }
  21. local function UpdateIndicators(self, event, unit)
  22.     for i = 1, #indicatorPositions do
  23.         local position = indicatorPositions[i]
  24.         local indicator = indicators[position]
  25.         indicator:SetShown(UnitBuff(unit, indicator.aura))
  26.     end
  27. end
  28. ------------------------------------------------------------------------
  29. -- Shared settings
  30. ------------------------------------------------------------------------
  31. local function Shared(self, unit, isSingle)
  32.     unit = gsub(unit, "%d", "")
  33.  
  34.     self:SetScript('OnEnter', UnitFrame_OnEnter)
  35.     self:SetScript('OnLeave', UnitFrame_OnLeave)
  36.  
  37.     self:RegisterForClicks'AnyUp'
  38.    
  39.     self:SetWidth(cfg.group.width)
  40.     self:SetHeight(cfg.group.height)
  41.    
  42.     -----------------------------
  43.     -- Health
  44.     local Health = CreateFrame("StatusBar", nil, self)
  45.     Health:SetStatusBarTexture(cfg.statusbar_texture)
  46.     Health:SetPoint('TOP')
  47.     Health:SetPoint('LEFT')
  48.     Health:SetPoint('RIGHT')
  49.     Health:SetHeight(cfg.group.height)
  50.     CreateBackdrop(Health)
  51.     -- Options
  52.     Health.frequentUpdates = true
  53.     Health.colorTapping = true
  54.     Health.colorDisconnected = true
  55.     Health.colorClass = true
  56.     Health.colorReaction = true
  57.     Health.colorHealth = true
  58.     -- Register it with oUF
  59.     self.Health = Health
  60.    
  61.     -----------------------------
  62.     --Heal Prediction
  63.     -- Position and size
  64.     local myBar = CreateFrame('StatusBar', nil, self.Health)
  65.     myBar:SetFrameStrata("BACKGROUND")
  66.     myBar:SetPoint('TOP')
  67.     myBar:SetPoint('BOTTOM')
  68.     myBar:SetPoint('LEFT', self.Health:GetStatusBarTexture(), 'RIGHT')
  69.     myBar:SetWidth(cfg.group.width)
  70.     myBar:SetStatusBarTexture(cfg.statusbar_texture)
  71.     myBar:SetStatusBarColor(0,1,0)
  72.    
  73.     local otherBar = CreateFrame('StatusBar', nil, self.Health)
  74.     otherBar:SetFrameStrata("BACKGROUND")
  75.     otherBar:SetPoint('TOP')
  76.     otherBar:SetPoint('BOTTOM')
  77.     otherBar:SetPoint('LEFT', self.Health:GetStatusBarTexture(), 'RIGHT')
  78.     otherBar:SetWidth(cfg.group.width)
  79.     otherBar:SetStatusBarTexture(cfg.statusbar_texture)
  80.     otherBar:SetStatusBarColor(0,1,0)
  81.  
  82.     local healAbsorbBar = CreateFrame('StatusBar', nil, self.Health)
  83.     healAbsorbBar:SetFrameStrata("BACKGROUND")
  84.     healAbsorbBar:SetPoint('TOP')
  85.     healAbsorbBar:SetPoint('BOTTOM')
  86.     healAbsorbBar:SetPoint('LEFT', self.Health:GetStatusBarTexture(), 'RIGHT')
  87.     healAbsorbBar:SetWidth(cfg.group.width)
  88.     healAbsorbBar:SetStatusBarTexture(cfg.statusbar_texture)
  89.     healAbsorbBar:SetStatusBarColor(0,1,0)
  90.    
  91.    -- Register with oUF
  92.    self.HealPrediction = {
  93.       myBar = myBar,
  94.       otherBar = otherBar,
  95.       absorbBar = absorbBar,
  96.       healAbsorbBar = healAbsorbBar,
  97.       maxOverflow = 1.05,
  98.       frequentUpdates = true,
  99.    }
  100.    
  101.     -----------------------------
  102.     --Text
  103.     --Name
  104.     local NameText = Health:CreateFontString(nil, "OVERLAY", "TextStatusBarText") -- parent to last child to make sure it's on top
  105.     NameText:SetPoint("BOTTOM", Health, "TOP", 0,-12) -- but anchor to the base element so it doesn't wiggle
  106.     NameText:SetFont(cfg.font, 8, cfg.style)
  107.     NameText:SetJustifyH("CENTER")
  108.     self:Tag(NameText, "[name]") -- oUF will automagically update it!
  109.     Health.text = NameText
  110.     --Health Percent
  111.     local HealthText = Health:CreateFontString(nil, "OVERLAY", "TextStatusBarText") -- parent to last child to make sure it's on top
  112.     HealthText:SetPoint("TOP", Health, "BOTTOM", 0,12) -- but anchor to the base element so it doesn't wiggle
  113.     HealthText:SetFont(cfg.font, 8, cfg.style)
  114.     HealthText:SetJustifyH("CENTER")
  115.     self:Tag(HealthText, "[perhp]") -- oUF will automagically update it!
  116.     Health.text = HealthText
  117.  
  118.     -----------------------------
  119.     -- Rez Icon
  120.     -- Position and sizew
  121.     local ResurrectIcon = self.Health:CreateTexture(nil, 'OVERLAY')
  122.     ResurrectIcon:SetSize(16, 16)
  123.     ResurrectIcon:SetPoint('CENTER', self.Health)
  124.    
  125.     -- Register it with oUF
  126.     self.ResurrectIcon = ResurrectIcon
  127.    
  128.     -----------------------------
  129.     -- Raid icons
  130.     -- Position and size
  131.     local RaidIcon = self.Health:CreateTexture(nil, 'OVERLAY')
  132.     RaidIcon:SetSize(16, 16)
  133.     RaidIcon:SetPoint('CENTER', self.Health)
  134.    
  135.     -- Register it with oUF
  136.     self.RaidIcon = RaidIcon
  137.    
  138.     -----------------------------
  139.     -- Raid Roles
  140.     -- Position and size
  141.     local RaidRole = self.Health:CreateTexture(nil, 'OVERLAY')
  142.     RaidRole:SetSize(16, 16)
  143.     RaidRole:SetPoint('TOPLEFT')
  144.    
  145.     -- Register it with oUF
  146.     self.RaidRole = RaidRole
  147.    
  148.     -----------------------------
  149.     -- LFD Role
  150.     -- Position and size
  151.     local LFDRole = self.Health:CreateTexture(nil, "OVERLAY")
  152.     LFDRole:SetSize(16, 16)
  153.     LFDRole:SetPoint("TOPLEFT", self.Health)
  154.    
  155.     -- Register it with oUF
  156.     self.LFDRole = LFDRole
  157.    
  158.     ------------------------
  159.     -- Plugin: oUF_Smooth --
  160.     ------------------------
  161.     if IsAddOnLoaded("oUF_Smooth") and not strmatch(unit, ".target$") then
  162.         self.Health.Smooth = true
  163.         if self.Power then
  164.             self.Power.Smooth = true
  165.         end
  166.     end
  167.    
  168.     ----------------------------
  169.     -- Plugin: oUF_SpellRange --
  170.     ----------------------------
  171.     if IsAddOnLoaded("oUF_SpellRange") then
  172.         self.SpellRange = {
  173.             insideAlpha = 1,
  174.             outsideAlpha = 0.5,
  175.         }
  176.     --Range
  177.     elseif unit == "pet" or unit == "party" or unit == "partypet" then
  178.         self.Range = {
  179.             insideAlpha = 1,
  180.             outsideAlpha = 0.5,
  181.         }
  182.     end
  183.  
  184.     ----------------------------
  185.     -------- Indicaters --------
  186.     ----------------------------
  187.     if cfg.indicators.enable then
  188.         local indicators = CreateFrame("Frame", nil ,self)
  189.         indicators:SetAllPoints(true)
  190.         indicators:EnableMouse(false)
  191.         self.indicators = indicators
  192.  
  193.         -- Build the indicators
  194.         for i = 1, #indicatorPositions do
  195.             local position = indicatorPositions[i]
  196.             local indicator = CreateFrame("Frame", nil, indicators)
  197.             indicator:SetPoint(position)
  198.             indicator:SetSize(5, 5)
  199.             indicator:SetBackdrop(indicatorBackdrop)
  200.  
  201.             indicator.aura = cfg.indicators["aura"..i]
  202.             indicators[position] = indicator
  203.         end
  204.  
  205.         -- Register the event on the frame itself
  206.         self:RegisterEvent("UNIT_AURA", UpdateIndicators)
  207.     end
  208. end
  209.  
  210. --Spawn Frames
  211. oUF:RegisterStyle('BobGroup', Shared)
  212. oUF:Factory(function(self)
  213.     self:SetActiveStyle'BobGroup'
  214.     local party = self:SpawnHeader(nil, nil, 'raid,party',
  215.         'showParty', true,
  216.         'showPlayer', true,
  217.         'showRaid', true,
  218.         'showSolo', cfg.group.showSolo,
  219.         'yOffset', cfg.group.offsety,
  220.         'groupingOrder', "1,2,3,4,5,6,7,8",
  221.         'maxColumns', cfg.group.columns,
  222.         'unitsPerColumn', cfg.group.unitpercolumn,
  223.         'columnAnchorPoint', cfg.group.growth,
  224.         'sortMethod', cfg.group.sortmethod,
  225.         'groupBy', cfg.group.groupby,
  226.         'columnSpacing', cfg.group.offsetx
  227.     )
  228.     --Positions (categorized by spec and class)
  229.     if (playerClass == "PRIEST" and GetSpecialization() == 1) then
  230.         party:SetPoint(unpack(cfg.group.healposition))
  231.     elseif (playerClass == "PRIEST" and GetSpecialization() == 2) then
  232.         party:SetPoint(unpack(cfg.group.healposition))
  233.     elseif (playerClass == "PALADIN" and GetSpecialization() == 3) then
  234.         party:SetPoint(unpack(cfg.group.healposition))
  235.     elseif (playerClass == "DRUID" and GetSpecialization() == 4) then
  236.         party:SetPoint(unpack(cfg.group.healposition))
  237.     elseif (playerClass == "MONK" and GetSpecialization() == 2) then
  238.         party:SetPoint(unpack(cfg.group.healposition))
  239.     elseif (playerClass == "SHAMAN" and GetSpecialization() == 3) then
  240.         party:SetPoint(unpack(cfg.group.healposition))
  241.     else
  242.         party:SetPoint(unpack(cfg.group.position))
  243.     end
  244. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement