Implement group and nameplate search
This commit is contained in:
		
							
								
								
									
										11
									
								
								NewAge/CataAuraBar/CustomText.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								NewAge/CataAuraBar/CustomText.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
function()
 | 
			
		||||
    if aura_env.state.pname then
 | 
			
		||||
        output = ""
 | 
			
		||||
        if aura_env.state.pclass then
 | 
			
		||||
            output = aura_env.GetClassColor(aura_env.state.pclass) .. aura_env.state.pname .. "\124r"
 | 
			
		||||
        else
 | 
			
		||||
            output = aura_env.state.pname
 | 
			
		||||
        end
 | 
			
		||||
        return output
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
@@ -12,12 +12,133 @@ local function PrintTable(table)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
aura_env.GetClassColor = function(class)
 | 
			
		||||
    if class == "Death Knight" then
 | 
			
		||||
        return "\124cFFC41E3A"
 | 
			
		||||
    elseif class == "Druid" then
 | 
			
		||||
        return "\124cFFFF7C0A"
 | 
			
		||||
    elseif class == "Hunter" then
 | 
			
		||||
        return "\124cFFAAD372"
 | 
			
		||||
    elseif class == "Mage" then
 | 
			
		||||
        return "\124cFF3FC7EB"
 | 
			
		||||
    elseif class == "Paladin" then
 | 
			
		||||
        return "\124cFFF48CBA"
 | 
			
		||||
    elseif class == "Priest" then
 | 
			
		||||
        return "\124cFFFFFFFF"
 | 
			
		||||
    elseif class == "Rogue" then
 | 
			
		||||
        return "\124cFFFFF468"
 | 
			
		||||
    elseif class == "Shaman" then
 | 
			
		||||
        return "\124cFF0070DD"
 | 
			
		||||
    elseif class == "Warlock" then
 | 
			
		||||
        return "\124cFF8788EE"
 | 
			
		||||
    elseif class == "Warrior" then
 | 
			
		||||
        return "\124cFFC69B6D"
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local Unit = {
 | 
			
		||||
    New = function(self, unit)
 | 
			
		||||
        o = {
 | 
			
		||||
            ["unit"] = unit,
 | 
			
		||||
        }
 | 
			
		||||
        setmetatable(o, self)
 | 
			
		||||
        self.__index = self
 | 
			
		||||
        return o
 | 
			
		||||
    end,
 | 
			
		||||
 | 
			
		||||
    GetAuras = function(self, auraFunc, name, type)
 | 
			
		||||
        return nil
 | 
			
		||||
    end,
 | 
			
		||||
}
 | 
			
		||||
local BasicUnit = Unit:New("player")
 | 
			
		||||
function BasicUnit:GetAuras(auraFunc, name)
 | 
			
		||||
    local aura, _, _, _, _, duration, expirationTime, _, _, _, spellID = auraFunc(self.unit, name)
 | 
			
		||||
    return {
 | 
			
		||||
        [UnitName(self.unit)] = {
 | 
			
		||||
            ["duration"] = duration,
 | 
			
		||||
            ["expirationTime"] = expirationTime,
 | 
			
		||||
            ["spellID"] = spellID,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
end
 | 
			
		||||
-- Maybe implement some sort of throttle to group unit?
 | 
			
		||||
local GroupUnit = Unit:New("group")
 | 
			
		||||
function GroupUnit:GetAuras(auraFunc, name)
 | 
			
		||||
    local raidMem = GetNumRaidMembers()
 | 
			
		||||
    local num = GetNumPartyMembers()
 | 
			
		||||
    local unitPrefix = "party"
 | 
			
		||||
    if raidMem > num then
 | 
			
		||||
        unitPrefix = "raid"
 | 
			
		||||
        num = raidMem
 | 
			
		||||
    end
 | 
			
		||||
    auras = {}
 | 
			
		||||
    for i = 1, num do
 | 
			
		||||
        local aura, _, _, _, _, duration, expirationTime, _, _, _, spellID = auraFunc(unitPrefix .. i, name)
 | 
			
		||||
        if aura ~= nil then
 | 
			
		||||
            auras[UnitName(unitPrefix .. i)] = {
 | 
			
		||||
                ["duration"] = duration,
 | 
			
		||||
                ["expirationTime"] = expirationTime,
 | 
			
		||||
                ["spellID"] = spellID,
 | 
			
		||||
                ["class"] = UnitClass(unitPrefix .. i) or "Paladin",
 | 
			
		||||
            }
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    if unitPrefix == "party" then
 | 
			
		||||
        local aura, _, _, _, _, duration, expirationTime, _, _, _, spellID = auraFunc("player", name)
 | 
			
		||||
        if aura ~= nil then
 | 
			
		||||
            auras[UnitName("player")] = {
 | 
			
		||||
                ["duration"] = duration,
 | 
			
		||||
                ["expirationTime"] = expirationTime,
 | 
			
		||||
                ["spellID"] = spellID,
 | 
			
		||||
                ["class"] = UnitClass(unitPrefix .. i) or "Paladin",
 | 
			
		||||
            }
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    return auras
 | 
			
		||||
end
 | 
			
		||||
local NameplateUnit = Unit:New("nameplate")
 | 
			
		||||
function NameplateUnit:GetAuras(auraFunc, name)
 | 
			
		||||
    local unitPrefix = "nameplate"
 | 
			
		||||
    auras = {}
 | 
			
		||||
    for i = 1, 40 do
 | 
			
		||||
        local aura, _, _, _, _, duration, expirationTime, _, _, _, spellID = auraFunc(auraPrefix .. i, name)
 | 
			
		||||
        if aura ~= nil then
 | 
			
		||||
            auras[UnitName(unitPrefix .. i)] = {
 | 
			
		||||
                ["duration"] = duration,
 | 
			
		||||
                ["expirationTime"] = expirationTime,
 | 
			
		||||
                ["spellID"] = spellID,
 | 
			
		||||
            }
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    return auras
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local UnitFactory = {
 | 
			
		||||
    New = function(self)
 | 
			
		||||
        o = {}
 | 
			
		||||
        setmetatable(o, self)
 | 
			
		||||
        self.__index = self
 | 
			
		||||
        return o
 | 
			
		||||
    end,
 | 
			
		||||
 | 
			
		||||
    CreateUnit = function(self, target)
 | 
			
		||||
        target = string.lower(target)
 | 
			
		||||
        if target == "player" or target == "target" or target == "focus" then
 | 
			
		||||
            return BasicUnit:New(target)
 | 
			
		||||
        elseif target == "group" then
 | 
			
		||||
            return GroupUnit:New(target)
 | 
			
		||||
        elseif target == "nameplate" then
 | 
			
		||||
            return NameplateUnit:New(target)
 | 
			
		||||
        end
 | 
			
		||||
    end,
 | 
			
		||||
}
 | 
			
		||||
local unitFactory = UnitFactory:New()
 | 
			
		||||
 | 
			
		||||
local Aura = {
 | 
			
		||||
    New = function(self, entry, index)
 | 
			
		||||
        o = {
 | 
			
		||||
            ["name"] = entry.auraName,
 | 
			
		||||
            ["type"] = entry.auraType,
 | 
			
		||||
            ["target"] = entry.target,
 | 
			
		||||
            ["unit"] = entry.target,
 | 
			
		||||
            ["hasCooldown"] = entry.hasCooldown,
 | 
			
		||||
            ["index"] = index,
 | 
			
		||||
            ["GetAura"] = entry.GetAura,
 | 
			
		||||
@@ -28,7 +149,10 @@ local Aura = {
 | 
			
		||||
    end,
 | 
			
		||||
 | 
			
		||||
    IsActive = function(self)
 | 
			
		||||
        return self.GetAura(self.target, self.name, self.type) ~= nil
 | 
			
		||||
        for k,v in pairs(self.unit:GetAuras(self.GetAura, self.name)) do
 | 
			
		||||
            return true
 | 
			
		||||
        end
 | 
			
		||||
        return false
 | 
			
		||||
    end,
 | 
			
		||||
    IsOnCooldown = function(self)
 | 
			
		||||
        if not self.hasCooldown then
 | 
			
		||||
@@ -38,10 +162,13 @@ local Aura = {
 | 
			
		||||
    end,
 | 
			
		||||
 | 
			
		||||
    AddAsAura = function(self, allstates)
 | 
			
		||||
        duration = select(6, self.GetAura(self.target, self.name, self.type))
 | 
			
		||||
        expirationTime = select(7, self.GetAura(self.target, self.name, self.type))
 | 
			
		||||
        icon = self:GetAuraIcon()
 | 
			
		||||
        allstates[self.name] = {
 | 
			
		||||
        local auras = self.unit:GetAuras(self.GetAura, self.name)
 | 
			
		||||
        for k,v in pairs(auras) do
 | 
			
		||||
            print(k, v)
 | 
			
		||||
            duration = v.duration
 | 
			
		||||
            expirationTime = v.expirationTime
 | 
			
		||||
            icon = self:GetAuraIcon(v.spellID)
 | 
			
		||||
            allstates[self.name .. k] = {
 | 
			
		||||
                changed = true,
 | 
			
		||||
                show = true,
 | 
			
		||||
                resort = true,
 | 
			
		||||
@@ -50,10 +177,13 @@ local Aura = {
 | 
			
		||||
                expirationTime = expirationTime,
 | 
			
		||||
                index = self.index,
 | 
			
		||||
                icon = icon,
 | 
			
		||||
                pname = k,
 | 
			
		||||
                pclass = v.class,
 | 
			
		||||
                IsOnCooldown = true,
 | 
			
		||||
                IsActive = true,
 | 
			
		||||
                IsBad = self.GetAura == UnitDebuff,
 | 
			
		||||
            }
 | 
			
		||||
        end
 | 
			
		||||
    end,
 | 
			
		||||
    AddAsCooldown = function(self, allstates)
 | 
			
		||||
        if not self.hasCooldown then
 | 
			
		||||
@@ -98,8 +228,7 @@ local Aura = {
 | 
			
		||||
    GetSpellIcon = function(self)
 | 
			
		||||
        return select(3, GetSpellInfo(self.name))
 | 
			
		||||
    end,
 | 
			
		||||
    GetAuraIcon = function(self)
 | 
			
		||||
        spellID = select(11, self.GetAura(self.target, self.name, self.type))
 | 
			
		||||
    GetAuraIcon = function(self, spellID)
 | 
			
		||||
        return select(3, GetSpellInfo(spellID))
 | 
			
		||||
    end,
 | 
			
		||||
}
 | 
			
		||||
@@ -111,7 +240,7 @@ local Entry = {
 | 
			
		||||
        local entryData = StrSplit(entry, ",")
 | 
			
		||||
        local name = self:ReadEntryData(entryData, 1)
 | 
			
		||||
        local type = self:ReadEntryData(entryData, 2) or "Buff"
 | 
			
		||||
        local target = self:ReadEntryData(entryData, 3) or "Player"
 | 
			
		||||
        local target = unitFactory:CreateUnit(self:ReadEntryData(entryData, 3) or "Player")
 | 
			
		||||
        local cooldown = (self:ReadEntryData(entryData, 4) == "0") or false
 | 
			
		||||
        cooldown = not cooldown
 | 
			
		||||
        local GetAura = UnitBuff
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user