Advertisement
Guest User

ShadowedUF_Indicators.lua

a guest
Oct 26th, 2010
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 47.08 KB | None | 0 0
  1. --[[
  2.     Shadow Unit Frames (Aura Indicators), Mayen of Mal'Ganis (US) PvP, modified by Inemos of Madmortem (EU)
  3. ]]
  4.  
  5. local L = SUFIndicatorsLocals
  6. local SL = ShadowUF.L or ShadowUFLocals
  7. local Indicators = select(2, ...)
  8. local AceDialog, AceRegistry
  9. local playerClass = select(2, UnitClass("player"))
  10.  
  11. ShadowUF:RegisterModule(Indicators, "auraIndicators", L["Aura indicators"])
  12.  
  13. -- Aura cache loader, converts them into tables
  14. Indicators.auraConfig = setmetatable({}, {
  15.     __index = function(tbl, index)
  16.         local aura = ShadowUF.db.profile.auraIndicators.auras[index]
  17.         if( not aura ) then
  18.             tbl[index] = false
  19.         else
  20.             local func, msg = loadstring("return " .. aura)
  21.             if( func ) then
  22.                 func = func()
  23.             elseif( msg ) then
  24.                 error(msg, 3)
  25.             end
  26.            
  27.             tbl[index] = func
  28.             tbl[index].group = tbl[index].group or L["Miscellaneous"]
  29.         end
  30.        
  31.         return tbl[index]
  32. end})
  33.  
  34. function Indicators:OnInitialize()
  35.     if( ShadowUF.db.profile.auraIndicators and ShadowUF.db.profile.auraIndicators.updated ) then return end
  36.  
  37.     if( not ShadowUF.db.profile.units.auraIndicators ) then
  38.         ShadowUF.db.profile.units.raid.auraIndicators = {enabled = true}
  39.     end
  40.  
  41.     for _, unit in pairs(ShadowUF.unitList) do
  42.         if( not string.match(unit, "(%w+)target") ) then
  43.             ShadowUF.db.profile.units[unit].auraIndicators = ShadowUF.db.profile.units[unit].auraIndicators or {enabled = false}
  44.         end
  45.     end
  46.  
  47.     local defaults = {
  48.         updated = true,
  49.         disabled = {},
  50.         missing = {},
  51.         indicators = {
  52.             ["tl"] = {name = SL["Top Left"], anchorPoint = "TLI", anchorTo = "$parent", height = 8, width = 8, alpha = 1.0, x = 4, y = -3, friendly = true, hostile = true},
  53.             ["tr"] = {name = SL["Top Right"], anchorPoint = "TRI", anchorTo = "$parent", height = 8, width = 8, alpha = 1.0, x = -3, y = 3, friendly = true, hostile = true},
  54.             ["bl"] = {name = SL["Bottom Left"], anchorPoint = "BLI", anchorTo = "$parent", height = 8, width = 8, alpha = 1.0, x = 4, y = 4, friendly = true, hostile = true},
  55.             ["br"] = {name = SL["Bottom Right"], anchorPoint = "CRI", anchorTo = "$parent", height = 8, width = 8, alpha = 1.0, x = -4, y = -4, friendly = true, hostile = true},
  56.             ["c"] = {name = SL["Center"], anchorPoint = "C", anchorTo = "$parent", height = 20, width = 20, alpha = 1.0, x = 0, y = 0, friendly = true, hostile = true},
  57.         },
  58.         linked = {
  59.             [GetSpellInfo(61316)] = GetSpellInfo(1459), -- Dalaran Brilliance -> Arcane Brilliance
  60.         },
  61.         auras = {
  62.             [GetSpellInfo(774)] = [[{indicator = '', group = "Druid", priority = 10, r = 0.66, g = 0.66, b = 1.0}]], -- Rejuvenation
  63.             [GetSpellInfo(8936)] = [[{indicator = '', group = "Druid", priority = 10, r = 0.50, g = 1.0, b = 0.63}]], -- Regrowth
  64.             [GetSpellInfo(33763)] = [[{indicator = '', group = "Druid", priority = 10, r = 0.07, g = 1.0, b = 0.01}]], -- Lifebloom
  65.             [GetSpellInfo(48438)] = [[{indicator = '', group = "Druid", priority = 10, r = 0.51, g = 0.72, b = 0.77}]], -- Wild Growth
  66.             [GetSpellInfo(1126)] = [[{indicator = '', group = "Druid", priority = 10, r = 1.0, g = 0.33, b = 0.90}]], -- Gift of the Wild
  67.             [GetSpellInfo(14253)] = [[{indicator = '', group = "Druid", priority = 10, r = 0.40, g = 1.0, b = 0.45}]], -- Abolish Poison
  68.             [GetSpellInfo(139)] = [[{indicator = '', group = "Priest", priority = 10, r = 1, g = 0.62, b = 0.88}]], -- Renew
  69.             [GetSpellInfo(17)] = [[{indicator = '', group = "Priest", priority = 10, r = 0.55, g = 0.69, b = 1.0}]], -- Power Word: Shield
  70.             [GetSpellInfo(21562)] = [[{indicator = '', group = "Priest", priority = 10, r = 0.58, g = 1.0, b = 0.50}]], -- Prayer of Fortitude
  71.             [GetSpellInfo(528)] = [[{indicator = '', group = "Priest", priority = 10, r = 1.0, g = 0.79, b = 0.67}]], -- Abolish Disease
  72.             [GetSpellInfo(27683)] = [[{indicator = '', group = "Priest", priority = 10, r = 0.60, g = 0.18, b = 1.0}]], -- Prayer of Shadow Protection
  73.             [GetSpellInfo(9800)] = [[{indicator = '', group = "Paladin", priority = 10, r = 0.90, g = 1.0, b = 0.37}]], -- Sacred Shield = Holy Shield???
  74.             [GetSpellInfo(974)] = [[{indicator = '', group = "Shaman", priority = 10, r = 0.26, g = 1.0, b = 0.26}]], -- Earth Shield
  75.             [GetSpellInfo(61295)] = [[{indicator = '', group = "Shaman", priority = 10, r = 0.30, g = 0.24, b = 1.0}]], -- Riptide
  76.             [GetSpellInfo(54648)] = [[{indicator = '', group = "Mage", priority = 10, r = 0.67, g = 0.76, b = 1.0}]], -- Focus Magic
  77.             [GetSpellInfo(1459)] = [[{indicator = '', group = "Mage", priority = 10, r = 0.10, g = 0.68, b = 0.88}]], -- Arcane Brilliance
  78.             [GetSpellInfo(20707)] = [[{indicator = '', group = "Warlock", priority = 10, r = 0.42, g = 0.21, b = 0.65}]], -- Soulstone Ressurection
  79.             [GetSpellInfo(63337)] = [[{indicator = 'c', icon = true, group = "General Vezax", priority = 50, r = 0, g = 0, b = 0}]], -- Saronite Vapors
  80.             [GetSpellInfo(62659)] = [[{indicator = 'c', icon = true, group = "General Vezax", priority = 5, r = 0, g = 0, b = 0}]], -- Shadow Crash
  81.             [GetSpellInfo(62282)] = [[{indicator = 'c', icon = true, group = "Freya", priority = 0, r = 0, g = 0, b = 0}]], -- Iron Roots
  82.             [GetSpellInfo(63571)] = [[{indicator = 'c', icon = true, group = "Freya", priority = 100, r = 0, g = 0, b = 0}]], -- Nature's Fury
  83.             [GetSpellInfo(62717)] = [[{indicator = 'c', icon = true, group = "Ignis the Furnace Master", priority = 0, r = 0, g = 0, b = 0}]], -- Slag Pot
  84.             [GetSpellInfo(64389)] = [[{indicator = 'c', icon = true, group = "Auriaya", priority = 20, r = 0, g = 0, b = 0}]], -- Sentinel Blast
  85.             [GetSpellInfo(64667)] = [[{indicator = 'c', icon = true, group = "Auriaya", priority = 0, r = 0, g = 0, b = 0}]], -- Rip Flesh
  86.             [GetSpellInfo(64374)] = [[{indicator = 'c', icon = true, group = "Auriaya", priority = 10, r = 0, g = 0, b = 0}]], -- Savage Pounce
  87.             [GetSpellInfo(64478)] = [[{indicator = 'c', icon = true, group = "Auriaya", priority = 5, r = 0, g = 0, b = 0}]], -- Feral Pounce
  88.             [GetSpellInfo(64733)] = [[{indicator = 'c', icon = true, group = "Razorscale", priority = 10, r = 0, g = 0, b = 0}]], -- Devouring Flame
  89.             [GetSpellInfo(62055)] = [[{indicator = 'c', icon = true, group = "Kologarn", priority = 0, r = 0, g = 0, b = 0}]], -- Brittle Skin
  90.             [GetSpellInfo(63981)] = [[{indicator = 'c', icon = true, group = "Kologarn", priority = 10, r = 0, g = 0, b = 0}]], -- Stone Grip
  91.             [GetSpellInfo(61969)] = [[{indicator = 'c', icon = true, group = "Hodir", priority = 0, r = 0, g = 0, b = 0}]], -- Flash Freeze
  92.             [GetSpellInfo(62376)] = [[{indicator = '', icon = true, group = "Flame Leviathan", priority = 0, r = 0, g = 0, b = 0}]], -- Battering Ram
  93.             [GetSpellInfo(64637)] = [[{indicator = 'c', icon = true, group = "Assembly of Iron", priority = 0, r = 0, g = 0, b = 0}]], -- Overwhelming Power
  94.             [GetSpellInfo(63493)] = [[{indicator = 'c', icon = true, group = "Assembly of Iron", priority = 0, r = 0, g = 0, b = 0}]], -- Fusion Punch
  95.             [GetSpellInfo(63018)] = [[{indicator = 'c', icon = true, group = "XT-002 Deconstructor", priority = 0, r = 0, g = 0, b = 0}]], -- Searing Light
  96.             [GetSpellInfo(64234)] = [[{indicator = 'c', icon = true, group = "XT-002 Deconstructor", priority = 0, r = 0, g = 0, b = 0}]], -- Gravity Bomb
  97.             [GetSpellInfo(63830)] = [[{indicator = '', icon = true, group = "Yogg-Saron", priority = 50, r = 0, g = 0, b = 0}]], -- Malady of the Mind
  98.             [GetSpellInfo(64152)] = [[{indicator = 'c', icon = true, group = "Yogg-Saron", priority = 5, r = 0, g = 0, b = 0}]], -- Draining Poison
  99.             [GetSpellInfo(63038)] = [[{indicator = 'c', icon = true, group = "Yogg-Saron", priority = 0, r = 0, g = 0, b = 0}]], -- Dark Volley
  100.             [GetSpellInfo(63134)] = [[{indicator = 'c', icon = true, group = "Yogg-Saron", priority = 25, r = 0, g = 0, b = 0}]], -- Sara's Blessing
  101.             [GetSpellInfo(63713)] = [[{indicator = 'c', icon = true, group = "Yogg-Saron", priority = 100, r = 0, g = 0, b = 0}]], -- Dominate Mind
  102.             [GetSpellInfo(36655)] = [[{indicator = '', icon = true, group = "Yogg-Saron", priority = 1, r = 0, g = 0, b = 0}]], -- Drain Life
  103.             [GetSpellInfo(63147)] = [[{indicator = '', icon = true, group = "Yogg-Saron", priority = 50, r = 0, g = 0, b = 0}]], -- Sara's Anger
  104.             [GetSpellInfo(64157)] = [[{indicator = '', icon = true, group = "Yogg-Saron", priority = 100, r = 0, g = 0, b = 0}]], -- Curse of Doom
  105.             [GetSpellInfo(63120)] = [[{indicator = 'c', icon = true, group = "Yogg-Saron", priority = 100, r = 0, g = 0, b = 0}]], -- Insane
  106.             [GetSpellInfo(64125)] = [[{indicator = 'c', icon = true, group = "Yogg-Saron", priority = 75, r = 0, g = 0, b = 0}]], -- Squeeze
  107.             [GetSpellInfo(66331)] = [[{indicator = 'c', icon = true, group = "Gormok the Impaler", priority = 50, r = 0, g = 0, b = 0}]], -- Impale
  108.             [GetSpellInfo(66406)] = [[{indicator = 'c', icon = true, group = "Gormok the Impaler", priority = 25, r = 0, g = 0, b = 0}]], -- Snobolled
  109.             [GetSpellInfo(66823)] = [[{indicator = 'c', icon = true, group = "Acidmaw & Dreadscale", priority = 5, r = 0, g = 0, b = 0}]], -- Paralytic Toxin
  110.             [GetSpellInfo(66870)] = [[{indicator = 'c', icon = true, group = "Acidmaw & Dreadscale", priority = 5, r = 0, g = 0, b = 0}]], -- Burning Bile
  111.             [GetSpellInfo(66237)] = [[{indicator = 'c', icon = true, group = "Lord Jaraxxus", priority = 100, r = 0, g = 0, b = 0}]], -- Incinerate Flesh
  112.             [GetSpellInfo(66197)] = [[{indicator = 'c', icon = true, group = "Lord Jaraxxus", priority = 75, r = 0, g = 0, b = 0}]], -- Legion Flames
  113.             [GetSpellInfo(66001)] = [[{indicator = 'c', icon = true, group = "Twin Valkyrs", priority = 75, r = 0, g = 0, b = 0}]], -- Touch of Darkness
  114.             [GetSpellInfo(65950)] = [[{indicator = 'c', icon = true, group = "Twin Valkyrs", priority = 75, r = 0, g = 0, b = 0}]], -- Touch of Light
  115.             [GetSpellInfo(65775)] = [[{indicator = 'c', icon = true, group = "Anub'arak", priority = 75, r = 0, g = 0, b = 0}]], -- Acid-Drenched Mandibles
  116.             [GetSpellInfo(66013)] = [[{indicator = 'c', icon = true, group = "Anub'arak", priority = 75, r = 0, g = 0, b = 0}]], -- Penetrating Cold
  117.         }
  118.     }
  119.    
  120.     for classToken in pairs(RAID_CLASS_COLORS) do
  121.         defaults.disabled[classToken] = {}
  122.     end
  123.    
  124.     -- Recursion, you are my only friend
  125.     local function recursiveCheck(database, default)
  126.         for key, value in pairs(default) do
  127.             if( database[key] == nil ) then
  128.                 database[key] = default[key]
  129.             elseif( type(database[key]) == "table" ) then
  130.                 recursiveCheck(database[key], default[key])
  131.             end
  132.         end
  133.     end
  134.    
  135.     if( not ShadowUF.db.profile.auraIndicators ) then
  136.         ShadowUF.db.profile.auraIndicators = defaults
  137.     else
  138.         ShadowUF.db.profile.auraIndicators.updated = true
  139.         for key, value in pairs(ShadowUF.db.profile.auraIndicators) do
  140.             if( key ~= "updated" and type(value) == "boolean" ) then
  141.                 ShadowUF.db.profile.auraIndicators[key] = nil
  142.             end
  143.         end
  144.         recursiveCheck(ShadowUF.db.profile.auraIndicators, defaults)
  145.     end
  146. end
  147.  
  148. Indicators.OnProfileChange = Indicators.OnInitialize
  149.  
  150. function Indicators:OnEnable(frame)
  151.     -- Upgrade if needed
  152.     for _, indicator in pairs(ShadowUF.db.profile.auraIndicators.indicators) do
  153.         if( string.match(indicator.anchorPoint, "^I") ) then
  154.             indicator.anchorPoint = string.gsub(indicator.anchorPoint, "^I([A-Z][A-Z])", "%1I")
  155.         end
  156.     end
  157.  
  158.     -- Not going to create the indicators we want here, will do that when we do the layout stuff
  159.     frame.auraIndicators = frame.auraIndicators or CreateFrame("Frame", nil, frame)
  160.     frame.auraIndicators:SetFrameLevel(4)
  161.     frame.auraIndicators:Show()
  162.            
  163.     -- Of course, watch for auras
  164.     frame:RegisterUnitEvent("UNIT_AURA", self, "UpdateAuras")
  165.     frame:RegisterUpdateFunc(self, "UpdateAuras")
  166. end
  167.  
  168. function Indicators:OnDisable(frame)
  169.     frame:UnregisterAll(self)
  170.     frame.auraIndicators:Hide()
  171. end
  172.  
  173. local backdropTbl = {
  174.     bgFile = "Interface\\Addons\\ShadowedUF_Indicators\\backdrop",
  175.     edgeFile = "Interface\\Addons\\ShadowedUF_Indicators\\backdrop",
  176.     tile = true,
  177.     tileSize = 1,
  178.     edgeSize = 1,
  179. }
  180.  
  181. function Indicators:OnLayoutApplied(frame)
  182.     if( not frame.auraIndicators ) then return end
  183.        
  184.     -- Create indicators
  185.     local id = 1
  186.     for key, indicatorConfig in pairs(ShadowUF.db.profile.auraIndicators.indicators) do
  187.         -- Create indicator as needed
  188.         local indicator = frame.auraIndicators["indicator-" .. id]
  189.         if( not indicator ) then
  190.             indicator = CreateFrame("Frame", nil, frame.auraIndicators)
  191.             indicator:SetFrameLevel(frame.topFrameLevel + 1)
  192.             indicator.texture = indicator:CreateTexture(nil, "OVERLAY")
  193.             indicator.texture:SetPoint("CENTER", indicator)
  194.             indicator:SetAlpha(indicatorConfig.alpha)
  195.             indicator:SetBackdrop(backdropTbl)
  196.             indicator:SetBackdropColor(0, 0, 0, 1)
  197.            
  198.             indicator.cooldown = CreateFrame("Cooldown", nil, indicator, "CooldownFrameTemplate")
  199.             indicator.cooldown:SetReverse(true)
  200.             indicator.cooldown:SetPoint("CENTER", 0, -1)
  201.  
  202.             indicator.stack = indicator:CreateFontString(nil, "OVERLAY")
  203.             indicator.stack:SetFont("Interface\\AddOns\\ShadowedUnitFrames\\media\\fonts\\Myriad Condensed Web.ttf", 12, "OUTLINE")
  204.             indicator.stack:SetShadowColor(0, 0, 0, 1.0)
  205.             indicator.stack:SetShadowOffset(0.8, -0.8)
  206.             indicator.stack:SetPoint("BOTTOMRIGHT", indicator, "BOTTOMRIGHT", 1, 0)
  207.             indicator.stack:SetWidth(18)
  208.             indicator.stack:SetHeight(10)
  209.             indicator.stack:SetJustifyH("RIGHT")
  210.            
  211.             frame.auraIndicators["indicator-" .. id] = indicator
  212.         end
  213.        
  214.         -- Set up the sizing options
  215.         indicator:SetHeight(indicatorConfig.height)
  216.         indicator.texture:SetWidth(indicatorConfig.width - 1)
  217.         indicator:SetWidth(indicatorConfig.width)
  218.         indicator.texture:SetHeight(indicatorConfig.height - 1)
  219.        
  220.         ShadowUF.Layout:AnchorFrame(frame, indicator, indicatorConfig)
  221.        
  222.         -- Let the auras module quickly access indicators without having to use index
  223.         frame.auraIndicators[key] = indicator
  224.        
  225.         id = id + 1
  226.     end
  227. end
  228.  
  229. local auraList = {}
  230. local function scanAura(frame, filter)
  231.     local index = 1
  232.     while( true ) do
  233.         local name, rank, texture, count, debuffType, duration, endTime, caster, isStealable = UnitAura(frame.unit, index, filter)
  234.         if( not name ) then break end
  235.            
  236.         -- Setup the auras in the indicators based on priority
  237.         name = ShadowUF.db.profile.auraIndicators.linked[name] or name
  238.         local auraConfig = Indicators.auraConfig[name]
  239.         local indicator = auraConfig and frame.auraIndicators[auraConfig.indicator]
  240.        
  241.         if( indicator and indicator.enabled and
  242.             not ShadowUF.db.profile.auraIndicators.disabled[playerClass][name] and not ShadowUF.db.profile.units[frame.unitType].auraIndicators[auraConfig.group] and
  243.             not auraConfig.missing and ( not auraConfig.player or caster == ShadowUF.playerUnit ) ) then
  244.            
  245.             -- If the indicator is not restricted to the player only, then will give the player a slightly higher priority
  246.             local priority = auraConfig.priority
  247.             local color = auraConfig
  248.             if( not auraConfig.player and caster == ShadowUF.playerUnit ) then
  249.                 priority = priority + 0.1
  250.                 color = auraConfig.selfColor or auraConfig
  251.             end
  252.  
  253.             if( priority > indicator.priority ) then
  254.                 indicator.showStack = ShadowUF.db.profile.auraIndicators.indicators[auraConfig.indicator].showStack
  255.                 indicator.priority = priority
  256.                 indicator.showIcon = auraConfig.icon
  257.                 indicator.showDuration = auraConfig.duration
  258.                 indicator.spellDuration = duration
  259.                 indicator.spellEnd = endTime
  260.                 indicator.spellIcon = texture
  261.                 indicator.spellName = name
  262.                 indicator.spellStack = count
  263.                 indicator.colorR = color.r
  264.                 indicator.colorG = color.g
  265.                 indicator.colorB = color.b
  266.             end
  267.         end
  268.  
  269.         -- Save a small list that we can duplicate check, and figure out whats missing
  270.         auraList[name] = true
  271.  
  272.         index = index + 1
  273.     end
  274. end
  275.  
  276. function Indicators:UpdateIndicators(frame)
  277.     for key, indicatorConfig in pairs(ShadowUF.db.profile.auraIndicators.indicators) do
  278.         local indicator = frame.auraIndicators[key]
  279.         if( indicator and indicator.enabled and indicator.priority > -1 ) then
  280.             -- Show a cooldown ring
  281.             if( indicator.showDuration and indicator.spellDuration > 0 and indicator.spellEnd > 0 ) then
  282.                 indicator.cooldown:SetCooldown(indicator.spellEnd - indicator.spellDuration, indicator.spellDuration)
  283.             else
  284.                 indicator.cooldown:Hide()
  285.             end
  286.            
  287.             -- Show either the icon, or a solid color
  288.             if( indicator.showIcon and indicator.spellIcon ) then
  289.                 indicator.texture:SetTexture(indicator.spellIcon)
  290.                 indicator:SetBackdropColor(0, 0, 0, 0)
  291.             else
  292.                 indicator.texture:SetTexture(indicator.colorR, indicator.colorG, indicator.colorB)
  293.                 indicator:SetBackdropColor(0, 0, 0, 1)
  294.             end
  295.            
  296.             -- Show aura stack
  297.             if( indicator.showStack and indicator.spellStack > 1 ) then
  298.                 indicator.stack:SetText(indicator.spellStack)
  299.                 indicator.stack:Show()
  300.             else
  301.                 indicator.stack:Hide()
  302.             end
  303.            
  304.             indicator:Show()
  305.         else
  306.             indicator:Hide()
  307.         end
  308.     end
  309. end
  310.  
  311. function Indicators:UpdateAuras(frame)
  312.     for k in pairs(auraList) do auraList[k] = nil end
  313.     for key, config in pairs(ShadowUF.db.profile.auraIndicators.indicators) do
  314.         local indicator = frame.auraIndicators[key]
  315.         if( indicator ) then
  316.             indicator.priority = -1
  317.            
  318.             if( UnitIsFriend("player", frame.unit) ) then
  319.                 indicator.enabled = config.friendly
  320.             else
  321.                 indicator.enabled = config.hostile
  322.             end
  323.         end
  324.     end
  325.    
  326.     -- If they are dead, don't bother showing any indicators yet
  327.     if( UnitIsDeadOrGhost(frame.unit) or not UnitIsConnected(frame.unit) ) then
  328.         self:UpdateIndicators(frame)
  329.         return
  330.     end
  331.    
  332.     -- Scan auras
  333.     scanAura(frame, "HELPFUL")
  334.     scanAura(frame, "HARMFUL")
  335.    
  336.     -- Check for any indicators that are triggered due to something missing
  337.     for name in pairs(ShadowUF.db.profile.auraIndicators.missing) do
  338.         if( not auraList[name] ) then
  339.             local aura = self.auraConfig[name]
  340.             local indicator = frame.auraIndicators[aura.indicator]
  341.             if( indicator and indicator.enabled and aura.priority > indicator.priority and not ShadowUF.db.profile.auraIndicators.disabled[playerClass][name] ) then
  342.                 indicator.priority = aura.priority
  343.                 indicator.showIcon = aura.icon
  344.                 indicator.showDuration = aura.duration
  345.                 indicator.spellDuration = 0
  346.                 indicator.spellEnd = 0
  347.                 indicator.spellIcon = aura.iconTexture or select(3, GetSpellInfo(name))
  348.                 indicator.colorR = aura.r
  349.                 indicator.colorG = aura.g
  350.                 indicator.colorB = aura.b
  351.             end
  352.         end
  353.     end
  354.    
  355.     -- Now force the indicators to update
  356.     self:UpdateIndicators(frame)
  357. end
  358.  
  359.  
  360. function Indicators:OnConfigurationLoad()
  361.     -- Kill old settings
  362.     ShadowUF.db.profile.units.raid.grid = nil
  363.    
  364.     local groupList = {}
  365.     local function getAuraGroup(info)
  366.         for k in pairs(groupList) do groupList[k] = nil end
  367.         for name in pairs(ShadowUF.db.profile.auraIndicators.auras) do
  368.             local aura = Indicators.auraConfig[name]
  369.             groupList[aura.group] = aura.group
  370.         end
  371.    
  372.         return groupList
  373.     end
  374.  
  375.     local auraList = {}
  376.     local function getAuraList(info)
  377.         for k in pairs(auraList) do auraList[k] = nil end
  378.         for name in pairs(ShadowUF.db.profile.auraIndicators.auras) do
  379.             auraList[name] = name
  380.         end
  381.    
  382.         return auraList
  383.     end
  384.  
  385.     local indicatorList = {}
  386.     local function getIndicatorList(info)
  387.         for k in pairs(indicatorList) do indicatorList[k] = nil end
  388.         indicatorList[""] = L["None (Disabled)"]
  389.         for key, indicator in pairs(ShadowUF.db.profile.auraIndicators.indicators) do
  390.             indicatorList[key] = indicator.name
  391.         end
  392.        
  393.         return indicatorList
  394.     end
  395.        
  396.     local function writeTable(tbl)
  397.         local data = ""
  398.  
  399.         for key, value in pairs(tbl) do
  400.             local valueType = type(value)
  401.            
  402.             -- Wrap the key in brackets if it's a number
  403.             if( type(key) == "number" ) then
  404.                 key = string.format("[%s]", key)
  405.             -- Wrap the string with quotes if it has a space in it
  406.             elseif( string.match(key, " ") ) then
  407.                 key = string.format("[\"%s\"]", key)
  408.             end
  409.            
  410.             -- foo = {bar = 5}
  411.             if( valueType == "table" ) then
  412.                 data = string.format("%s%s=%s;", data, key, writeTable(value))
  413.             -- foo = true / foo = 5
  414.             elseif( valueType == "number" or valueType == "boolean" ) then
  415.                 data = string.format("%s%s=%s;", data, key, tostring(value))
  416.             -- foo = "bar"
  417.             else
  418.                 data = string.format("%s%s=\"%s\";", data, key, tostring(value))
  419.             end
  420.         end
  421.        
  422.         return "{" .. data .. "}"
  423.     end
  424.  
  425.     local function writeAuraTable(name)
  426.         ShadowUF.db.profile.auraIndicators.auras[name] = writeTable(Indicators.auraConfig[name])
  427.     end
  428.    
  429.     local groupMap, auraMap, linkMap = {}, {}, {}
  430.     local groupID, auraID, linkID = 0, 0, 0
  431.    
  432.     -- Actual aura configuration
  433.     local auraGroupTable = {
  434.         order = 1,
  435.         type = "group",
  436.         name = function(info) return groupMap[info[#(info)]] end,
  437.         desc = function(info)
  438.             local group = groupMap[info[#(info)]]
  439.             local totalInGroup = 0
  440.             for _, aura in pairs(Indicators.auraConfig) do
  441.                 if( type(aura) == "table" and aura.group == group ) then
  442.                     totalInGroup = totalInGroup + 1
  443.                 end
  444.             end
  445.            
  446.             return string.format(L["%d auras in group"], totalInGroup)
  447.         end,
  448.         args = {},
  449.     }
  450.    
  451.     local auraConfigTable = {
  452.         order = 0,
  453.         type = "group",
  454.         inline = true,
  455.         name = function(info) return auraMap[info[#(info)]] end,
  456.         hidden = function(info)
  457.             local group = groupMap[info[#(info) - 1]]
  458.             local aura = Indicators.auraConfig[auraMap[info[#(info)]]]
  459.             return aura.group ~= group
  460.         end,
  461.         set = function(info, value, g, b, a)
  462.             local aura = auraMap[info[#(info) - 1]]
  463.             local key = info[#(info)]
  464.  
  465.             -- So I don't have to load every aura to see if it only triggers if it's missing
  466.             if( key == "missing" ) then
  467.                 ShadowUF.db.profile.auraIndicators.missing[aura] = value and true or nil
  468.             -- Changing the color
  469.             elseif( key == "color" ) then
  470.                 Indicators.auraConfig[aura].r = value
  471.                 Indicators.auraConfig[aura].g = g
  472.                 Indicators.auraConfig[aura].b = b
  473.                 Indicators.auraConfig[aura].alpha = a
  474.  
  475.                 writeAuraTable(aura)
  476.                 ShadowUF.Layout:Reload()
  477.                 return
  478.             elseif( key == "selfColor" ) then
  479.                 Indicators.auraConfig[aura].selfColor = Indicators.auraConfig[aura].selfColor or {}
  480.                 Indicators.auraConfig[aura].selfColor.r = value
  481.                 Indicators.auraConfig[aura].selfColor.g = g
  482.                 Indicators.auraConfig[aura].selfColor.b = b
  483.                 Indicators.auraConfig[aura].selfColor.alpha = a
  484.  
  485.                 writeAuraTable(aura)
  486.                 ShadowUF.Layout:Reload()
  487.                 return
  488.             end
  489.  
  490.             Indicators.auraConfig[aura][key] = value
  491.             writeAuraTable(aura)
  492.             ShadowUF.Layout:Reload()
  493.         end,
  494.         get = function(info)
  495.             local aura = auraMap[info[#(info) - 1]]
  496.             local key = info[#(info)]
  497.             local config = Indicators.auraConfig[aura]         
  498.             if( key == "color" ) then
  499.                 return config.r, config.g, config.b, config.alpha
  500.             elseif( key == "selfColor" ) then
  501.                 if( not config.selfColor ) then return 0, 0, 0, 1 end
  502.                 return config.selfColor.r, config.selfColor.g, config.selfColor.b, config.selfColor.alpha
  503.             end
  504.            
  505.             return config[key]
  506.         end,
  507.         args = {   
  508.             indicator = {
  509.                 order = 1,
  510.                 type = "select",
  511.                 name = L["Show inside"],
  512.                 desc = L["Indicator this aura should be displayed in."],
  513.                 values = getIndicatorList,
  514.                 hidden = false,
  515.             },
  516.             priority = {
  517.                 order = 2,
  518.                 type = "range",
  519.                 name = L["Priority"],
  520.                 desc = L["If multiple auras are shown in the same indicator, the higher priority one is shown first."],
  521.                 min = 0, max = 100, step = 1,
  522.                 hidden = false,
  523.             },
  524.             sep1 = {
  525.                 order = 3,
  526.                 type = "description",
  527.                 name = "",
  528.                 width = "full",
  529.                 hidden = false,
  530.             },
  531.             color = {
  532.                 order = 4,
  533.                 type = "color",
  534.                 name = L["Indicator color"],
  535.                 desc = L["Solid color to use in the indicator, only used if you do not have use aura icon enabled."],
  536.                 disabled = function(info) return Indicators.auraConfig[auraMap[info[#(info) - 1]]].icon end,
  537.                 hidden = false,
  538.                 hasAlpha = true,
  539.             },
  540.             selfColor = {
  541.                 order = 4.5,
  542.                 type = "color",
  543.                 name = L["Your aura color"],
  544.                 desc = L["This color will be used if the indicator shown is your own, only applies if icons are not used.\nHandy if you want to know if a target has a Rejuvenation on them, but you also want to know if you were the one who casted the Rejuvenation."],
  545.                 hidden = false,
  546.                 disabled = function(info)
  547.                     if( Indicators.auraConfig[auraMap[info[#(info) - 1]]].icon ) then return true end
  548.                     return Indicators.auraConfig[auraMap[info[#(info) - 1]]].player
  549.                 end,
  550.                 hasAlpha = true,
  551.             },
  552.             sep2 = {
  553.                 order = 5,
  554.                 type = "description",
  555.                 name = "",
  556.                 width = "full",
  557.                 hidden = false,
  558.             },
  559.             icon = {
  560.                 order = 6,
  561.                 type = "toggle",
  562.                 name = L["Show aura icon"],
  563.                 desc = L["Instead of showing a solid color inside the indicator, the icon of the aura will be shown."],
  564.                 hidden = false,
  565.             },
  566.             duration = {
  567.                 order = 7,
  568.                 type = "toggle",
  569.                 name = L["Show aura duration"],
  570.                 desc = L["Shows a cooldown wheel on the indicator with how much time is left on the aura."],
  571.                 hidden = false,
  572.             },
  573.             player = {
  574.                 order = 8,
  575.                 type = "toggle",
  576.                 name = L["Only show self cast auras"],
  577.                 desc = L["Only auras you specifically cast will be shown."],
  578.                 hidden = false,
  579.             },
  580.             missing = {
  581.                 order = 9,
  582.                 type = "toggle",
  583.                 name = L["Only show if missing"],
  584.                 desc = L["Only active this aura inside an indicator if the group member does not have the aura."],
  585.                 hidden = false,
  586.             },
  587.             delete = {
  588.                 order = 10,
  589.                 type = "execute",
  590.                 name = SL["Delete"],
  591.                 hidden = false,
  592.                 confirm = true,
  593.                 confirmText = L["Are you sure you want to delete this aura?"],
  594.                 func = function(info)
  595.                     local key = info[#(info) - 1]
  596.                     local aura = auraMap[key]
  597.  
  598.                     auraGroupTable.args[key] = nil
  599.                     ShadowUF.db.profile.auraIndicators.auras[aura] = nil
  600.                     ShadowUF.db.profile.auraIndicators.missing[aura] = nil
  601.                     Indicators.auraConfig[aura] = nil
  602.                    
  603.                     -- Check if the group should disappear
  604.                     local groupList = getAuraGroup(info)
  605.                     for groupID, name in pairs(groupMap) do
  606.                         if( not groupList[name] ) then
  607.                             unitTable.args[tostring(groupID)] = nil
  608.                             ShadowUF.Config.options.args.auraIndicators.args.auras.args[tostring(groupID)] = nil
  609.                             groupMap[groupID] = nil
  610.                         end
  611.                     end
  612.                    
  613.                     ShadowUF.Layout:Reload()
  614.                 end,
  615.             },
  616.         },
  617.     }  
  618.    
  619.     local indicatorTable = {
  620.         order = 1,
  621.         type = "group",
  622.         name = function(info) return ShadowUF.db.profile.auraIndicators.indicators[info[#(info)]].name end,
  623.         args = {
  624.             config = {
  625.                 order = 0,
  626.                 type = "group",
  627.                 inline = true,
  628.                 name = function(info) return ShadowUF.db.profile.auraIndicators.indicators[info[#(info) - 1]].name end,
  629.                 set = function(info, value)
  630.                     local indicator = info[#(info) - 2]
  631.                     local key = info[#(info)]
  632.  
  633.                     ShadowUF.db.profile.auraIndicators.indicators[indicator][key] = value
  634.                     ShadowUF.Layout:Reload()
  635.                 end,
  636.                 get = function(info)
  637.                     local indicator = info[#(info) - 2]
  638.                     local key = info[#(info)]
  639.                     return ShadowUF.db.profile.auraIndicators.indicators[indicator][key]
  640.                 end,
  641.                 args = {
  642.                     showStack = {
  643.                         order = 1,
  644.                         type = "toggle",
  645.                         name = L["Show auras stack"],
  646.                         desc = L["Any auras shown in this indicator will have their total stack displayed."],
  647.                         width = "full",
  648.                     },
  649.                     friendly = {
  650.                         order = 2,
  651.                         type = "toggle",
  652.                         name = L["Enable for friendlies"],
  653.                         desc = L["Unchecking this will disable the indicator for all friendly units."],
  654.                     },
  655.                     hostile = {
  656.                         order = 3,
  657.                         type = "toggle",
  658.                         name = L["Enable for hostiles"],
  659.                         desc = L["Unchecking this will disable the indicator for all hostile units."],
  660.                     },
  661.                     anchorPoint = {
  662.                         order = 4,
  663.                         type = "select",
  664.                         name = SL["Anchor point"],
  665.                         values = {["BRI"] = L["Inside Bottom Right"], ["BLI"] = L["Inside Bottom Left"], ["TRI"] = SL["Inside Top Right"], ["TLI"] = SL["Inside Top Left"], ["CLI"] = SL["Inside Center Left"], ["C"] = SL["Center"], ["CRI"] = SL["Inside Center Right"]},
  666.                     },
  667.                     size = {
  668.                         order = 5,
  669.                         name = SL["Size"],
  670.                         type = "range",
  671.                         min = 0, max = 50, step = 1,
  672.                         set = function(info, value)
  673.                             local indicator = info[#(info) - 2]
  674.                             ShadowUF.db.profile.auraIndicators.indicators[indicator].height = value
  675.                             ShadowUF.db.profile.auraIndicators.indicators[indicator].width = value
  676.                             ShadowUF.Layout:Reload()
  677.                         end,
  678.                         get = function(info)
  679.                             local indicator = info[#(info) - 2]
  680.                             -- Upgrade code, force them to be the same size
  681.                             if( ShadowUF.db.profile.auraIndicators.indicators[indicator].height ~= ShadowUF.db.profile.auraIndicators.indicators[indicator].width ) then
  682.                                 local size = max(ShadowUF.db.profile.auraIndicators.indicators[indicator].height, ShadowUF.db.profile.auraIndicators.indicators[indicator].width)
  683.                                
  684.                                 ShadowUF.db.profile.auraIndicators.indicators[indicator].height = size
  685.                                 ShadowUF.db.profile.auraIndicators.indicators[indicator].width = size
  686.                             end
  687.                            
  688.                             return ShadowUF.db.profile.auraIndicators.indicators[indicator].height
  689.                         end,
  690.                     },
  691.                     x = {
  692.                         order = 6,
  693.                         type = "range",
  694.                         name = SL["X Offset"],
  695.                         min = -50, max = 50, step = 1,
  696.                     },
  697.                     y = {
  698.                         order = 7,
  699.                         type = "range",
  700.                         name = SL["Y Offset"],
  701.                         min = -50, max = 50, step = 1,
  702.                     },
  703.                     delete = {
  704.                         order = 8,
  705.                         type = "execute",
  706.                         name = SL["Delete"],
  707.                         confirm = true,
  708.                         confirmText = L["Are you sure you want to delete this indicator?"],
  709.                         func = function(info)
  710.                             local indicator = info[#(info) - 2]
  711.                            
  712.                             ShadowUF.Config.options.args.auraIndicators.args.indicators.args[indicator] = nil
  713.                             ShadowUF.db.profile.auraIndicators.indicators[indicator] = nil
  714.                            
  715.                             -- Any aura taht was set to us should be swapped back to none
  716.                             for name in pairs(ShadowUF.db.profile.auraIndicators.auras) do
  717.                                 local aura = Indicators.auraConfig[name]
  718.                                 if( aura.indicator == indicator ) then
  719.                                     aura.indicator = ""
  720.                                     writeAuraTable(name)
  721.                                 end
  722.                             end
  723.                            
  724.                             ShadowUF.Layout:Reload()
  725.                         end,
  726.                     },
  727.                 },
  728.             },
  729.         },
  730.     }
  731.    
  732.     local parentLinkTable = {
  733.         order = 3,
  734.         type = "group",
  735.         name = function(info) return linkMap[info[#(info)]] end,
  736.         args = {},
  737.     }
  738.    
  739.     local childLinkTable = {
  740.         order = 1,
  741.         name = function(info) return linkMap[info[#(info)]] end,
  742.         hidden = function(info)
  743.             local aura = linkMap[info[#(info)]]
  744.             local parent = linkMap[info[#(info) - 1]]
  745.            
  746.             return ShadowUF.db.profile.auraIndicators.linked[aura] ~= parent
  747.         end,
  748.         type = "group",
  749.         inline = true,
  750.         args = {
  751.             delete = {
  752.                 type = "execute",
  753.                 name = L["Delete link"],
  754.                 hidden = false,
  755.                 func = function(info)
  756.                     local auraID = info[#(info) - 1]
  757.                     local aura = linkMap[auraID]
  758.                     local parent = ShadowUF.db.profile.auraIndicators.linked[aura]
  759.                     ShadowUF.db.profile.auraIndicators.linked[aura] = nil
  760.                     parentLinkTable.args[auraID] = nil
  761.                    
  762.                     local found
  763.                     for _, to in pairs(ShadowUF.db.profile.auraIndicators.linked) do
  764.                         if( to == parent ) then
  765.                             found = true
  766.                             break
  767.                         end
  768.                     end
  769.                    
  770.                     if( not found ) then
  771.                         for id, name in pairs(linkMap) do
  772.                             if( name == parent ) then
  773.                                 ShadowUF.Config.options.args.auraIndicators.args.linked.args[tostring(id)] = nil
  774.                                 linkMap[id] = nil
  775.                             end
  776.                         end
  777.                     end
  778.                    
  779.                     ShadowUF.Layout:Reload()
  780.                 end,
  781.             },
  782.         },
  783.     }
  784.  
  785.     local addAura, addLink, setGlobalUnits, globalConfig = {}, {}, {}, {}
  786.  
  787.     -- Per unit enabled status
  788.     local unitTable = {
  789.         order = ShadowUF.Config.getUnitOrder or 1,
  790.         type = "group",
  791.         name = function(info) return SL.units[info[3]] end,
  792.         desc = function(info)
  793.             local totalDisabled = 0
  794.             for key, enabled in pairs(ShadowUF.db.profile.units[info[3]].auraIndicators) do
  795.                 if( key ~= "enabled" and enabled ) then
  796.                     totalDisabled = totalDisabled + 1
  797.                 end
  798.             end
  799.            
  800.             return totalDisabled > 0 and string.format(L["%s aura groups disabled"], totalDisabled) or L["All aura groups enabled for unit."]
  801.         end,
  802.         args = {
  803.             enabled = {
  804.                 order = 1,
  805.                 inline = true,
  806.                 type = "group",
  807.                 name = function(info) return string.format(L["Indicator status for %s"], SL.units[info[3]]) end,
  808.                 args = {
  809.                     enabled = {
  810.                         order = 1,
  811.                         type = "toggle",
  812.                         name = L["Enable indicators"],
  813.                         desc = function(info) return string.format(L["Unchecking this will completely disable the aura indicators mod for %s."], SL.units[info[3]]) end,
  814.                         set = function(info, value) ShadowUF.db.profile.units[info[3]].auraIndicators.enabled = value; ShadowUF.Layout:Reload() end,
  815.                         get = function(info) return ShadowUF.db.profile.units[info[3]].auraIndicators.enabled end,
  816.                     },
  817.                 },
  818.             },
  819.             groups = {
  820.                 order = 2,
  821.                 inline = true,
  822.                 type = "group",
  823.                 name = L["Enabled aura groups"],
  824.                 disabled = function(info) return not ShadowUF.db.profile.units[info[3]].auraIndicators.enabled end,
  825.                 args = {},
  826.             },
  827.         }
  828.     }
  829.    
  830.     local unitGroupTable = {
  831.         order = 1,
  832.         type = "toggle",
  833.         name = function(info) return groupMap[info[#(info)]] end,
  834.         desc = function(info)
  835.             local auraIndicators = ShadowUF.db.profile.units[info[3]].auraIndicators
  836.             local group = groupMap[info[#(info)]]
  837.            
  838.             return auraIndicators[group] and string.format(L["Disabled for %s."], SL.units[info[3]]) or string.format(L["Enabled for %s."], SL.units[info[3]])
  839.         end,
  840.         set = function(info, value) ShadowUF.db.profile.units[info[3]].auraIndicators[groupMap[info[#(info)]]] = not value and true or nil end,
  841.         get = function(info, value) return not ShadowUF.db.profile.units[info[3]].auraIndicators[groupMap[info[#(info)]]] end,
  842.     }
  843.  
  844.     local globalUnitGroupTable = {
  845.         order = 1,
  846.         type = "toggle",
  847.         name = function(info) return groupMap[info[#(info)]] end,
  848.         disabled = function(info) for unit in pairs(setGlobalUnits) do return false end return true end,
  849.         set = function(info, value)
  850.             local auraGroup = groupMap[info[#(info)]]
  851.             globalConfig[auraGroup] = not value and true or nil
  852.            
  853.             for unit in pairs(setGlobalUnits) do
  854.                 ShadowUF.db.profile.units[unit].auraIndicators[auraGroup] = globalConfig[auraGroup]
  855.             end
  856.         end,
  857.         get = function(info, value) return not globalConfig[groupMap[info[#(info)]]] end,
  858.     }
  859.    
  860.     local enabledUnits = {}
  861.     local function getEnabledUnits()
  862.         table.wipe(enabledUnits)
  863.         for unit, config in pairs(ShadowUF.db.profile.units) do
  864.             if( config.auraIndicators and config.auraIndicators.enabled ) then
  865.                 enabledUnits[unit] = SL.units[unit]
  866.             end
  867.         end
  868.        
  869.         return enabledUnits
  870.     end
  871.            
  872.     -- Actual tab view thing
  873.     ShadowUF.Config.options.args.auraIndicators = {
  874.         order = 4.5,
  875.         type = "group",
  876.         name = L["Aura indicators"],
  877.         desc = L["For configuring the aura indicators module."],
  878.         childGroups = "tab",
  879.         hidden = false,
  880.         args = {
  881.             indicators = {
  882.                 order = 1,
  883.                 type = "group",
  884.                 name = L["Indicators"],
  885.                 childGroups = "tree",
  886.                 args = {
  887.                     add = {
  888.                         order = 0,
  889.                         type = "group",
  890.                         name = L["Add indicator"],
  891.                         args = {
  892.                             add = {
  893.                                 order = 0,
  894.                                 type = "group",
  895.                                 inline = true,
  896.                                 name = L["Add new indicator"],
  897.                                 args = {
  898.                                     name = {
  899.                                         order = 0,
  900.                                         type = "input",
  901.                                         name = L["Indicator name"],
  902.                                         width = "full",
  903.                                         set = function(info, value)
  904.                                             local id = string.format("%d", GetTime() + math.random(100))
  905.                                             ShadowUF.db.profile.auraIndicators.indicators[id] = {enabled = true, friendly = true, hostile = true, name = value, anchorPoint = "C", anchorTo = "$parent", height = 10, width = 10, alpha = 1.0, x = 0, y = 0}
  906.                                             ShadowUF.Config.options.args.auraIndicators.args.indicators.args[id] = indicatorTable
  907.  
  908.                                             AceDialog = AceDialog or LibStub("AceConfigDialog-3.0")
  909.                                             AceRegistry = AceRegistry or LibStub("AceConfigRegistry-3.0")
  910.                                             AceDialog.Status.ShadowedUF.children.auraIndicators.children.indicators.status.groups.selected = id
  911.                                             AceRegistry:NotifyChange("ShadowedUF")
  912.                                         end,
  913.                                         get = function() return "" end,
  914.                                     },
  915.                                 },
  916.                             },
  917.                         },
  918.                     },
  919.                 },
  920.             },
  921.             auras = {
  922.                 order = 2,
  923.                 type = "group",
  924.                 name = L["Auras"],
  925.                 args = {
  926.                     add = {
  927.                         order = 0,
  928.                         type = "group",
  929.                         name = L["Add aura"],
  930.                         set = function(info, value) addAura[info[#(info)]] = value end,
  931.                         get = function(info) return addAura[info[#(info)]] end,
  932.                         args = {
  933.                             add = {
  934.                                 order = 0,
  935.                                 inline = true,
  936.                                 type = "group",
  937.                                 name = L["Add new aura"],
  938.                                 args = {
  939.                                     name = {
  940.                                         order = 0,
  941.                                         type = "input",
  942.                                         name = L["Aura name"],
  943.                                         desc = L["The exact buff or debuff name, this is case sensitive."],
  944.                                         width = "full",
  945.                                     },
  946.                                     group = {
  947.                                         order = 1,
  948.                                         type = "select",
  949.                                         name = L["Aura group"],
  950.                                         desc = L["What group this aura belongs to, this is where you will find it when configuring."],
  951.                                         values = getAuraGroup,
  952.                                     },
  953.                                     custom = {
  954.                                         order = 2,
  955.                                         type = "input",
  956.                                         name = L["New aura group"],
  957.                                         desc = L["Allows you to enter a new aura group."],
  958.                                     },
  959.                                     create = {
  960.                                         order = 3,
  961.                                         type = "execute",
  962.                                         name = L["Add aura"],
  963.                                         disabled = function(info) return not addAura.name or (not addAura.group and not addAura.custom) end,
  964.                                         func = function(info)
  965.                                             addAura.custom = string.trim(addAura.custom or "")
  966.                                             addAura.custom = addAura.custom ~= "" and addAura.custom or nil
  967.                                             if( addAura.group and string.trim(addAura.group) == "" ) then
  968.                                                 addAura.group = L["Miscellaneous"]
  969.                                             end
  970.                                            
  971.                                             local group = addAura.custom or addAura.group
  972.                                            
  973.                                             -- Don't overwrite an existing group, but don't tell them either, mostly because I don't want to add error reporting code
  974.                                             if( not ShadowUF.db.profile.auraIndicators.auras[addAura.name] ) then
  975.                                                 -- Odds are, if they are saying to show it only if a buff is missing it's cause they want to know when their own class buff is not there
  976.                                                 -- so will cheat it, and jump start it by storing the texture if we find it from GetSpellInfo directly
  977.                                                 Indicators.auraConfig[addAura.name] = {indicator = "", group = group, iconTexture = select(3, GetSpellInfo(addAura.name)), priority = 0, r = 0, g = 0, b = 0}
  978.                                                 ShadowUF.db.profile.auraIndicators.auras[addAura.name] = "{}"
  979.                                                
  980.                                                 auraID = auraID + 1
  981.                                                 auraMap[tostring(auraID)] = addAura.name
  982.                                                 auraGroupTable.args[tostring(auraID)] = auraConfigTable
  983.                                             end
  984.                                            
  985.                                             addAura.name = nil
  986.                                             addAura.custom = nil
  987.                                             addAura.group = nil
  988.                                            
  989.                                             -- Check if the group exists
  990.                                             local gID
  991.                                             for id, name in pairs(groupMap) do
  992.                                                 if( name == group ) then
  993.                                                     gID = id
  994.                                                     break
  995.                                                 end
  996.                                             end
  997.                                            
  998.                                             if( not gID ) then
  999.                                                 groupID = groupID + 1
  1000.                                                 groupMap[tostring(groupID)] = group
  1001.  
  1002.                                                 unitTable.args.groups.args[tostring(groupID)] = unitGroupTable
  1003.                                                 ShadowUF.Config.options.args.auraIndicators.args.units.args.global.args.groups.args[tostring(groupID)] = globalUnitGroupTable
  1004.                                                 ShadowUF.Config.options.args.auraIndicators.args.auras.args[tostring(groupID)] = auraGroupTable
  1005.                                             end
  1006.                                            
  1007.                                             -- Shunt the user to the this groups page
  1008.                                             AceDialog = AceDialog or LibStub("AceConfigDialog-3.0")
  1009.                                             AceRegistry = AceRegistry or LibStub("AceConfigRegistry-3.0")
  1010.                                             AceDialog.Status.ShadowedUF.children.auraIndicators.children.auras.status.groups.selected = tostring(gID or groupID)
  1011.                                             AceRegistry:NotifyChange("ShadowedUF")
  1012.                                            
  1013.                                             ShadowUF.Layout:Reload()
  1014.                                         end,
  1015.                                     },
  1016.                                 },
  1017.                             },
  1018.                         },
  1019.                     },
  1020.                 },
  1021.             },
  1022.             linked = {
  1023.                 order = 3,
  1024.                 type = "group",
  1025.                 name = L["Linked spells"],
  1026.                 childGroups = "tree",
  1027.                 args = {
  1028.                     help = {
  1029.                         order = 0,
  1030.                         type = "group",
  1031.                         name = SL["Help"],
  1032.                         inline = true,
  1033.                         args = {
  1034.                             help = {
  1035.                                 order = 0,
  1036.                                 type = "description",
  1037.                                 name = L["You can link auras together using this, for example you can link Mark of the Wild to Gift of the Wild so if the player has Mark of the Wild but not Gift of the Wild, it will still show Mark of the Wild as if they had Gift of the Wild."],
  1038.                                 width = "full",
  1039.                             },
  1040.                         },
  1041.                     },
  1042.                     add = {
  1043.                         order = 1,
  1044.                         type = "group",
  1045.                         name = L["Add link"],
  1046.                         inline = true,
  1047.                         set = function(info, value)
  1048.                             addLink[info[#(info)]] = value
  1049.                         end,
  1050.                         get = function(info) return addLink[info[#(info)]] end,
  1051.                         args = {
  1052.                             from = {
  1053.                                 order = 0,
  1054.                                 type = "input",
  1055.                                 name = L["Link from"],
  1056.                                 desc = L["Spell you want to link to a primary aura, the casing must be exact."],
  1057.                             },
  1058.                             to = {
  1059.                                 order = 1,
  1060.                                 type = "select",
  1061.                                 name = L["Link to"],
  1062.                                 values = getAuraList,
  1063.                             },
  1064.                             link = {
  1065.                                 order = 3,
  1066.                                 type = "execute",
  1067.                                 name = L["Link"],
  1068.                                 disabled = function() return not addLink.from or not addLink.to or addLink.from == "" end,
  1069.                                 func = function(info)
  1070.                                     local lID, pID
  1071.                                     for id, name in pairs(linkMap) do
  1072.                                         if( name == addLink.from ) then
  1073.                                             lID = id
  1074.                                         elseif( name == addLink.to ) then
  1075.                                             pID = id
  1076.                                         end
  1077.                                     end
  1078.                                    
  1079.                                     if( not pID ) then
  1080.                                         linkID = linkID + 1
  1081.                                         pID = linkID
  1082.                                         linkMap[tostring(linkID)] = addLink.to
  1083.                                     end
  1084.  
  1085.                                     if( not lID ) then
  1086.                                         linkID = linkID + 1
  1087.                                         lID = linkID
  1088.                                         linkMap[tostring(linkID)] = addLink.from
  1089.                                     end
  1090.                                                                        
  1091.                                     ShadowUF.db.profile.auraIndicators.linked[addLink.from] = addLink.to
  1092.                                     ShadowUF.Config.options.args.auraIndicators.args.linked.args[tostring(pID)] = parentLinkTable
  1093.                                     parentLinkTable.args[tostring(lID)] = childLinkTable
  1094.  
  1095.                                     addLink.from = nil
  1096.                                     addLink.to = nil
  1097.                                    
  1098.                                     ShadowUF.Layout:Reload()
  1099.                                 end,
  1100.                             },
  1101.                         },
  1102.                     },
  1103.                 },
  1104.             },
  1105.             units = {
  1106.                 order = 4,
  1107.                 type = "group",
  1108.                 name = L["Enable by unit"],
  1109.                 args = {
  1110.                     help = {
  1111.                         order = 0,
  1112.                         type = "group",
  1113.                         name = SL["Help"],
  1114.                         inline = true,
  1115.                         args = {
  1116.                             help = {
  1117.                                 order = 0,
  1118.                                 type = "description",
  1119.                                 name = L["You can disable aura groups for units here. For example, you could set an aura group that shows DPS debuffs to only show on the target."],
  1120.                                 width = "full",
  1121.                             },
  1122.                         },
  1123.                     },
  1124.                     global = {
  1125.                         order = 0,
  1126.                         type = "group",
  1127.                         name = SL["Global"],
  1128.                         desc = L["Global configurating will let you mass enable or disable aura groups for multiple units at once."],
  1129.                         args = {
  1130.                             units = {
  1131.                                 order = 0,
  1132.                                 type = "multiselect",
  1133.                                 name = L["Units to change"],
  1134.                                 desc = L["Units that should have the aura groups settings changed below."],
  1135.                                 values = getEnabledUnits,
  1136.                                 set = function(info, unit, enabled) setGlobalUnits[unit] = enabled or nil end,
  1137.                                 get = function(info, unit) return setGlobalUnits[unit] end,
  1138.                             },
  1139.                             groups = {
  1140.                                 order = 1,
  1141.                                 type = "group",
  1142.                                 inline = true,
  1143.                                 name = L["Aura groups"],
  1144.                                 args = {},
  1145.                             },
  1146.                         },
  1147.                     },
  1148.                 },
  1149.             },
  1150.             classes = {
  1151.                 order = 5,
  1152.                 type = "group",
  1153.                 name = L["Enable by class"],
  1154.                 childGroups = "tree",
  1155.                 args = {
  1156.                     help = {
  1157.                         order = 0,
  1158.                         type = "group",
  1159.                         name = SL["Help"],
  1160.                         inline = true,
  1161.                         args = {
  1162.                             help = {
  1163.                                 order = 0,
  1164.                                 type = "description",
  1165.                                 name = L["You can override what aura is enabled on a per-class basis, note that if the aura is disabled through the main listing, then your class settings here will not matter."],
  1166.                                 width = "full",
  1167.                             },
  1168.                         },
  1169.                     }
  1170.                 },
  1171.             },
  1172.         },
  1173.     }
  1174.    
  1175.     local classTable = {
  1176.         order = 1,
  1177.         type = "group",
  1178.         name = function(info) return LOCALIZED_CLASS_NAMES_MALE[info[#(info)]] end,
  1179.         args = {},
  1180.     }
  1181.    
  1182.     local classAuraTable = {
  1183.         order = 1,
  1184.         type = "toggle",
  1185.         name = function(info) return auraMap[info[#(info)]] end,
  1186.         set = function(info, value)
  1187.             local aura = auraMap[info[#(info)]]
  1188.             local class = info[#(info) - 1]
  1189.             value = not value
  1190.  
  1191.             if( value == false ) then value = nil end
  1192.             ShadowUF.db.profile.auraIndicators.disabled[class][aura] = value
  1193.             ShadowUF.Layout:Reload()
  1194.         end,
  1195.         get = function(info)
  1196.             local aura = auraMap[info[#(info)]]
  1197.             local class = info[#(info) - 1]
  1198.            
  1199.             return not ShadowUF.db.profile.auraIndicators.disabled[class][aura]
  1200.         end,
  1201.     }
  1202.        
  1203.     -- Build links 
  1204.     local addedFrom = {}
  1205.     for from, to in pairs(ShadowUF.db.profile.auraIndicators.linked) do
  1206.         local pID = addedFrom[to]
  1207.         if( not pID ) then
  1208.             linkID = linkID + 1
  1209.             pID = linkID
  1210.  
  1211.             addedFrom[to] = pID
  1212.         end
  1213.  
  1214.         linkID = linkID + 1
  1215.        
  1216.         ShadowUF.db.profile.auraIndicators.linked[from] = to
  1217.         ShadowUF.Config.options.args.auraIndicators.args.linked.args[tostring(pID)] = parentLinkTable
  1218.         parentLinkTable.args[tostring(linkID)] = childLinkTable
  1219.        
  1220.         linkMap[tostring(linkID)] = from
  1221.         linkMap[tostring(pID)] = to
  1222.     end
  1223.        
  1224.     -- Build the aura configuration
  1225.     local parents = {}
  1226.     for name in pairs(ShadowUF.db.profile.auraIndicators.auras) do
  1227.         local aura = Indicators.auraConfig[name]
  1228.         if( aura.group ) then
  1229.             auraMap[tostring(auraID)] = name
  1230.             auraGroupTable.args[tostring(auraID)] = auraConfigTable
  1231.             classTable.args[tostring(auraID)] = classAuraTable
  1232.             auraID = auraID + 1
  1233.            
  1234.             parents[aura.group] = true
  1235.         end
  1236.     end
  1237.    
  1238.     -- Now create all of the parent stuff
  1239.     for group in pairs(parents) do
  1240.         groupMap[tostring(groupID)] = group
  1241.         unitTable.args.groups.args[tostring(groupID)] = unitGroupTable
  1242.         ShadowUF.Config.options.args.auraIndicators.args.units.args.global.args.groups.args[tostring(groupID)] = globalUnitGroupTable
  1243.         ShadowUF.Config.options.args.auraIndicators.args.auras.args[tostring(groupID)] = auraGroupTable
  1244.        
  1245.         groupID = groupID + 1
  1246.     end
  1247.  
  1248.     -- Aura status by unit
  1249.     for unit, config in pairs(ShadowUF.db.profile.units) do
  1250.         if( config.auraIndicators ) then
  1251.             ShadowUF.Config.options.args.auraIndicators.args.units.args[unit] = unitTable
  1252.         end
  1253.     end
  1254.    
  1255.     -- Build class status thing
  1256.     for classToken in pairs(RAID_CLASS_COLORS) do
  1257.         ShadowUF.Config.options.args.auraIndicators.args.classes.args[classToken] = classTable
  1258.     end
  1259.    
  1260.     -- Quickly build the indicator one
  1261.     for key in pairs(ShadowUF.db.profile.auraIndicators.indicators) do
  1262.         ShadowUF.Config.options.args.auraIndicators.args.indicators.args[key] = indicatorTable
  1263.     end
  1264.    
  1265.     -- Automatically unlock the advanced text configuration for raid frames, regardless of advanced being enabled
  1266.     local advanceTextTable = ShadowUF.Config.advanceTextTable
  1267.     local originalHidden = advanceTextTable.args.sep.hidden
  1268.     local function unlockRaidText(info)
  1269.         if( info[2] == "raid" ) then return false end
  1270.         return originalHidden(info)
  1271.     end
  1272.    
  1273.     advanceTextTable.args.anchorPoint.hidden = unlockRaidText
  1274.     advanceTextTable.args.sep.hidden = unlockRaidText
  1275.     advanceTextTable.args.x.hidden = unlockRaidText
  1276.     advanceTextTable.args.y.hidden = unlockRaidText
  1277. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement