Advertisement
Guest User

group.lua indicator added

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