mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
nameplates and font
This commit is contained in:
@@ -63,13 +63,13 @@ function select(n, ...)
|
||||
end
|
||||
end
|
||||
|
||||
local temp = {}
|
||||
local args = {}
|
||||
|
||||
for i = n, getn(arg) do
|
||||
tinsert(temp, arg[i])
|
||||
args[(i-n)+1] = arg[i]
|
||||
end
|
||||
|
||||
return unpack(temp)
|
||||
return unpack(args)
|
||||
end
|
||||
|
||||
function math.modf(i)
|
||||
|
||||
@@ -53,40 +53,38 @@ function E:UpdateBlizzardFonts()
|
||||
end
|
||||
|
||||
if(self.private.general.replaceBlizzFonts) then
|
||||
SetFont(GameTooltipHeader, NORMAL, self.db.general.fontSize)
|
||||
SetFont(NumberFont_OutlineThick_Mono_Small, NUMBER, self.db.general.fontSize, "OUTLINE")
|
||||
SetFont(NumberFont_Outline_Huge, NUMBER, 28, MONOCHROME.."THICKOUTLINE", 28)
|
||||
SetFont(NumberFont_Outline_Large, NUMBER, 15, MONOCHROME.."OUTLINE")
|
||||
SetFont(NumberFont_Outline_Med, NUMBER, self.db.general.fontSize, "OUTLINE")
|
||||
SetFont(NumberFont_Shadow_Med, NORMAL, self.db.general.fontSize)
|
||||
SetFont(NumberFont_Shadow_Small, NORMAL, self.db.general.fontSize)
|
||||
SetFont(QuestFont, NORMAL, self.db.general.fontSize)
|
||||
SetFont(QuestFont_Large, NORMAL, 14)
|
||||
SetFont(SystemFont_Large, NORMAL, 15)
|
||||
SetFont(GameFontNormalMed3, NORMAL, 15)
|
||||
SetFont(SystemFont_Shadow_Huge1, NORMAL, 20, MONOCHROME .. "OUTLINE")
|
||||
SetFont(SystemFont_Med1, NORMAL, self.db.general.fontSize)
|
||||
SetFont(SystemFont_Med3, NORMAL, self.db.general.fontSize)
|
||||
SetFont(SystemFont_OutlineThick_Huge2, NORMAL, 20, MONOCHROME .. "THICKOUTLINE")
|
||||
SetFont(SystemFont_Outline_Small, NUMBER, self.db.general.fontSize, "OUTLINE")
|
||||
SetFont(SystemFont_Shadow_Large, NORMAL, 15)
|
||||
SetFont(SystemFont_Shadow_Med1, NORMAL, self.db.general.fontSize)
|
||||
SetFont(SystemFont_Shadow_Med3, NORMAL, self.db.general.fontSize)
|
||||
SetFont(SystemFont_Shadow_Outline_Huge2, NORMAL, 20, MONOCHROME .. "OUTLINE")
|
||||
SetFont(SystemFont_Shadow_Small, NORMAL, self.db.general.fontSize)
|
||||
SetFont(SystemFont_Small, NORMAL, self.db.general.fontSize)
|
||||
SetFont(SystemFont_Tiny, NORMAL, self.db.general.fontSize)
|
||||
SetFont(Tooltip_Med, NORMAL, self.db.general.fontSize)
|
||||
SetFont(Tooltip_Small, NORMAL, self.db.general.fontSize)
|
||||
SetFont(FriendsFont_Normal, NORMAL, self.db.general.fontSize)
|
||||
SetFont(FriendsFont_Small, NORMAL, self.db.general.fontSize)
|
||||
SetFont(FriendsFont_Large, NORMAL, self.db.general.fontSize)
|
||||
SetFont(FriendsFont_UserText, NORMAL, self.db.general.fontSize)
|
||||
SetFont(SpellFont_Small, NORMAL, self.db.general.fontSize*0.9)
|
||||
SetFont(ZoneTextString, NORMAL, 32, MONOCHROME .. "OUTLINE")
|
||||
SetFont(SubZoneTextString, NORMAL, 25, MONOCHROME .. "OUTLINE")
|
||||
SetFont(PVPInfoTextString, NORMAL, 22, MONOCHROME .. "OUTLINE")
|
||||
SetFont(PVPArenaTextString, NORMAL, 22, MONOCHROME .. "OUTLINE")
|
||||
SetFont(CombatTextFont, COMBAT, 25, MONOCHROME .. "OUTLINE")
|
||||
SetFont(SystemFont, NORMAL, self.db.general.fontSize);
|
||||
SetFont(GameFontNormal, NORMAL, self.db.general.fontSize);
|
||||
SetFont(GameFontNormalSmall, NORMAL, self.db.general.fontSize);
|
||||
SetFont(GameFontNormalLarge, NORMAL, self.db.general.fontSize);
|
||||
SetFont(GameFontNormalHuge, NORMAL, 25, MONOCHROME .. "OUTLINE");
|
||||
SetFont(BossEmoteNormalHuge, NORMAL, 25, MONOCHROME .. "OUTLINE");
|
||||
SetFont(GameFontBlack, NORMAL, self.db.general.fontSize);
|
||||
SetFont(NumberFontNormal, NUMBER, self.db.general.fontSize, MONOCHROME .. "OUTLINE");
|
||||
SetFont(NumberFontNormalSmall, NUMBER, self.db.general.fontSize);
|
||||
SetFont(NumberFontNormalLarge, NUMBER, self.db.general.fontSize);
|
||||
SetFont(NumberFontNormalHuge, NUMBER, self.db.general.fontSize);
|
||||
SetFont(ChatFontNormal, NORMAL, self.db.general.fontSize);
|
||||
SetFont(ChatFontSmall, NORMAL, self.db.general.fontSize);
|
||||
SetFont(QuestTitleFont, NORMAL, self.db.general.fontSize + 8);
|
||||
SetFont(QuestFont, NORMAL, self.db.general.fontSize);
|
||||
SetFont(QuestFontHighlight, NORMAL, self.db.general.fontSize);
|
||||
SetFont(ItemTextFontNormal, NORMAL, self.db.general.fontSize);
|
||||
SetFont(ItemTextFontNormal, NORMAL, self.db.general.fontSize);
|
||||
SetFont(MailTextFontNormal, NORMAL, self.db.general.fontSize);
|
||||
SetFont(SubSpellFont, NORMAL, self.db.general.fontSize);
|
||||
SetFont(DialogButtonNormalText, NORMAL, self.db.general.fontSize);
|
||||
SetFont(ZoneTextFont, NORMAL, 32, MONOCHROME .. "OUTLINE");
|
||||
SetFont(SubZoneTextFont, NORMAL, 25, MONOCHROME .. "OUTLINE");
|
||||
SetFont(PVPInfoTextFont, NORMAL, 22, MONOCHROME .. "OUTLINE");
|
||||
SetFont(TextStatusBarText, NORMAL, self.db.general.fontSize);
|
||||
SetFont(TextStatusBarTextSmall, NORMAL, self.db.general.fontSize);
|
||||
-- SetFont(GameTooltipText, NORMAL, self.db.general.fontSize);
|
||||
-- SetFont(GameTooltipTextSmall, NORMAL, self.db.general.fontSize);
|
||||
-- SetFont(GameTooltipHeaderText, NORMAL, self.db.general.fontSize);
|
||||
-- SetFont(WorldMapTextFont, NORMAL, self.db.general.fontSize);
|
||||
SetFont(InvoiceTextFontNormal, NORMAL, self.db.general.fontSize);
|
||||
SetFont(InvoiceTextFontSmall, NORMAL, self.db.general.fontSize);
|
||||
SetFont(CombatTextFont, COMBAT, 25, MONOCHROME .. "OUTLINE");
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,5 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Include file="NamePlates\Load_NamePlates.xml"/>
|
||||
<Include file="Auras\Load_Auras.xml"/>
|
||||
<Include file="Tooltip\Load_Tooltip.xml"/>
|
||||
<Include file="DataTexts\Load_DataTexts.xml"/>
|
||||
|
||||
@@ -0,0 +1,544 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
local LSM = LibStub("LibSharedMedia-3.0")
|
||||
|
||||
local select, unpack, pairs = select, unpack, pairs
|
||||
local tonumber = tonumber
|
||||
local band = bit.band
|
||||
local gsub = string.gsub
|
||||
local tinsert, tremove, wipe = table.insert, table.remove, table.wipe
|
||||
|
||||
local CreateFrame = CreateFrame
|
||||
local UnitAura = UnitAura
|
||||
local UnitGUID = UnitGUID
|
||||
local GetSpellTexture = GetSpellTexture
|
||||
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
|
||||
local AURA_TYPE_BUFF = AURA_TYPE_BUFF
|
||||
local AURA_TYPE_DEBUFF = AURA_TYPE_DEBUFF
|
||||
|
||||
local RaidIconBit = {
|
||||
["STAR"] = "0x00100000",
|
||||
["CIRCLE"] = "0x00200000",
|
||||
["DIAMOND"] = "0x00400000",
|
||||
["TRIANGLE"] = "0x00800000",
|
||||
["MOON"] = "0x01000000",
|
||||
["SQUARE"] = "0x02000000",
|
||||
["CROSS"] = "0x04000000",
|
||||
["SKULL"] = "0x08000000"
|
||||
}
|
||||
|
||||
local RaidIconIndex = {
|
||||
"STAR",
|
||||
"CIRCLE",
|
||||
"DIAMOND",
|
||||
"TRIANGLE",
|
||||
"MOON",
|
||||
"SQUARE",
|
||||
"CROSS",
|
||||
"SKULL"
|
||||
}
|
||||
|
||||
local ByRaidIcon = {}
|
||||
local ByName = {}
|
||||
|
||||
local auraCache = {}
|
||||
local buffCache = {}
|
||||
local debuffCache = {}
|
||||
|
||||
local auraList = {}
|
||||
local auraSpellID = {}
|
||||
local auraName = {}
|
||||
local auraExpiration = {}
|
||||
local auraStacks = {}
|
||||
local auraCaster = {}
|
||||
local auraDuration = {}
|
||||
local auraTexture = {}
|
||||
local auraType = {}
|
||||
local cachedAuraDurations = {}
|
||||
|
||||
local TimeColors = {
|
||||
[0] = "|cffeeeeee",
|
||||
[1] = "|cffeeeeee",
|
||||
[2] = "|cffeeeeee",
|
||||
[3] = "|cffFFEE00",
|
||||
[4] = "|cfffe0000"
|
||||
}
|
||||
|
||||
local AURA_UPDATE_INTERVAL = 0.1
|
||||
|
||||
local PolledHideIn
|
||||
do
|
||||
local Framelist = {}
|
||||
local Watcherframe = CreateFrame("Frame")
|
||||
local WatcherframeActive = false
|
||||
local timeToUpdate = 0
|
||||
|
||||
local function CheckFramelist()
|
||||
local curTime = GetTime()
|
||||
if curTime < timeToUpdate then return end
|
||||
local framecount = 0
|
||||
timeToUpdate = curTime + AURA_UPDATE_INTERVAL
|
||||
|
||||
for frame, expiration in pairs(Framelist) do
|
||||
if expiration < curTime then
|
||||
frame:Hide()
|
||||
Framelist[frame] = nil
|
||||
else
|
||||
if frame.Poll then frame:Poll(expiration) end
|
||||
framecount = framecount + 1
|
||||
end
|
||||
end
|
||||
if framecount == 0 then Watcherframe:SetScript("OnUpdate", nil); WatcherframeActive = false end
|
||||
end
|
||||
|
||||
function PolledHideIn(frame, expiration)
|
||||
if expiration == 0 then
|
||||
frame:Hide()
|
||||
Framelist[frame] = nil
|
||||
else
|
||||
Framelist[frame] = expiration
|
||||
frame:Show()
|
||||
|
||||
if not WatcherframeActive then
|
||||
Watcherframe:SetScript("OnUpdate", CheckFramelist)
|
||||
WatcherframeActive = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function GetSpellDuration(spellID)
|
||||
if spellID then return cachedAuraDurations[spellID] end
|
||||
end
|
||||
|
||||
local function SetSpellDuration(spellID, duration)
|
||||
if spellID then cachedAuraDurations[spellID] = duration end
|
||||
end
|
||||
|
||||
local function UpdateAuraTime(frame, expiration)
|
||||
local timeleft = expiration - GetTime()
|
||||
local timervalue, formatid = E:GetTimeInfo(timeleft, 4)
|
||||
local timeFormat = E.TimeFormats[3][2]
|
||||
if timervalue < 4 then
|
||||
timeFormat = E.TimeFormats[4][2]
|
||||
end
|
||||
frame.timeLeft:SetFormattedText(("%s%s|r"):format(TimeColors[formatid], timeFormat), timervalue)
|
||||
end
|
||||
|
||||
local function RemoveAuraInstance(guid, spellID, caster)
|
||||
if guid and spellID and auraList[guid] then
|
||||
local instanceID = tostring(guid)..tostring(spellID)..(tostring(caster or "UNKNOWN_CASTER"))
|
||||
local auraID = spellID..(tostring(caster or "UNKNOWN_CASTER"))
|
||||
if auraList[guid][auraID] then
|
||||
auraSpellID[instanceID] = nil
|
||||
auraName[instanceID] = nil
|
||||
auraExpiration[instanceID] = nil
|
||||
auraStacks[instanceID] = nil
|
||||
auraCaster[instanceID] = nil
|
||||
auraDuration[instanceID] = nil
|
||||
auraTexture[instanceID] = nil
|
||||
auraType[instanceID] = nil
|
||||
auraList[guid][auraID] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function GetAuraList(guid)
|
||||
if guid and auraList[guid] then return auraList[guid] end
|
||||
end
|
||||
|
||||
local function GetAuraInstance(guid, auraID)
|
||||
if guid and auraID then
|
||||
local instanceID = guid..auraID
|
||||
local spellID, name, expiration, stacks, caster, duration, texture, type
|
||||
spellID = auraSpellID[instanceID]
|
||||
name = auraName[instanceID]
|
||||
expiration = auraExpiration[instanceID]
|
||||
stacks = auraStacks[instanceID]
|
||||
caster = auraCaster[instanceID]
|
||||
duration = auraDuration[instanceID]
|
||||
texture = auraTexture[instanceID]
|
||||
type = auraType[instanceID]
|
||||
return spellID, name, expiration, stacks, caster, duration, texture, type
|
||||
end
|
||||
end
|
||||
|
||||
local function SetAuraInstance(guid, name, spellID, expiration, stacks, caster, duration, texture, type)
|
||||
if guid and spellID and caster and texture then
|
||||
local auraID = spellID..(tostring(caster or "UNKNOWN_CASTER"))
|
||||
local instanceID = guid..auraID
|
||||
auraList[guid] = auraList[guid] or {}
|
||||
auraList[guid][auraID] = instanceID
|
||||
auraSpellID[instanceID] = spellID
|
||||
auraName[instanceID] = name
|
||||
auraExpiration[instanceID] = expiration
|
||||
auraStacks[instanceID] = stacks
|
||||
auraCaster[instanceID] = caster
|
||||
auraDuration[instanceID] = duration
|
||||
auraTexture[instanceID] = texture
|
||||
auraType[instanceID] = type
|
||||
end
|
||||
end
|
||||
|
||||
local function WipeAuraList(guid)
|
||||
if guid and auraList[guid] then
|
||||
local unitAuraList = auraList[guid]
|
||||
for auraID, instanceID in pairs(unitAuraList) do
|
||||
auraSpellID[instanceID] = nil
|
||||
auraName[instanceID] = nil
|
||||
auraExpiration[instanceID] = nil
|
||||
auraStacks[instanceID] = nil
|
||||
auraCaster[instanceID] = nil
|
||||
auraDuration[instanceID] = nil
|
||||
auraTexture[instanceID] = nil
|
||||
auraType[instanceID] = nil
|
||||
unitAuraList[auraID] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:CleanAuraLists()
|
||||
local currentTime = GetTime()
|
||||
for guid, instanceList in pairs(auraList) do
|
||||
local auraCount = 0
|
||||
for auraID, instanceID in pairs(instanceList) do
|
||||
local expiration = auraExpiration[instanceID]
|
||||
if expiration and expiration < currentTime then
|
||||
auraList[guid][auraID] = nil
|
||||
auraSpellID[instanceID] = nil
|
||||
auraName[instanceID] = nil
|
||||
auraExpiration[instanceID] = nil
|
||||
auraStacks[instanceID] = nil
|
||||
auraCaster[instanceID] = nil
|
||||
auraDuration[instanceID] = nil
|
||||
auraTexture[instanceID] = nil
|
||||
auraType[instanceID] = nil
|
||||
else
|
||||
auraCount = auraCount + 1
|
||||
end
|
||||
end
|
||||
if auraCount == 0 then
|
||||
auraList[guid] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:SetAura(aura, icon, count, expirationTime)
|
||||
aura.icon:SetTexture(icon)
|
||||
if count > 1 then
|
||||
aura.count:SetText(count)
|
||||
else
|
||||
aura.count:SetText("")
|
||||
end
|
||||
aura:Show()
|
||||
PolledHideIn(aura, expirationTime)
|
||||
end
|
||||
|
||||
function mod:HideAuraIcons(auras)
|
||||
for i = 1, getn(auras.icons) do
|
||||
PolledHideIn(auras.icons[i], 0)
|
||||
end
|
||||
end
|
||||
|
||||
local currentAura = {}
|
||||
function mod:UpdateElement_Auras(frame)
|
||||
if not frame.HealthBar:IsShown() then return end
|
||||
|
||||
local guid = frame.guid
|
||||
|
||||
if not guid then
|
||||
if RAID_CLASS_COLORS[frame.UnitClass] then
|
||||
local name = gsub(frame.oldName:GetText(), "%s%(%*%)","")
|
||||
guid = ByName[name]
|
||||
elseif frame.RaidIcon:IsShown() then
|
||||
guid = ByRaidIcon[frame.RaidIconType]
|
||||
end
|
||||
|
||||
if guid then
|
||||
frame.guid = guid
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local hasDebuffs = false
|
||||
local hasBuffs = false
|
||||
|
||||
local numDebuff = 0
|
||||
local numBuff = 0
|
||||
|
||||
local aurasOnUnit = GetAuraList(guid)
|
||||
|
||||
debuffCache = wipe(debuffCache)
|
||||
buffCache = wipe(buffCache)
|
||||
|
||||
if aurasOnUnit then
|
||||
local numAuras = 0
|
||||
local aura
|
||||
|
||||
for instanceid in pairs(aurasOnUnit) do
|
||||
numAuras = (numDebuff + numBuff) + 1
|
||||
aura = wipe(currentAura[numAuras] or {})
|
||||
|
||||
aura.spellID, aura.name, aura.expirationTime, aura.count, aura.caster, aura.duration, aura.icon, aura.type = GetAuraInstance(guid, instanceid)
|
||||
|
||||
local filter = false
|
||||
local db = self.db.units[frame.UnitType].buffs.filters
|
||||
if aura.type == AURA_TYPE_DEBUFF then
|
||||
db = self.db.units[frame.UnitType].debuffs.filters
|
||||
end
|
||||
|
||||
if db.personal and aura.caster == UnitGUID("player") then
|
||||
filter = true
|
||||
end
|
||||
|
||||
local trackFilter = E.global["unitframe"]["aurafilters"][db.filter]
|
||||
if db.filter and trackFilter then
|
||||
local spell = trackFilter.spells[tonumber(aura.spellID)] or trackFilter.spells[aura.name]
|
||||
if trackFilter.type == "Whitelist" then
|
||||
if spell and spell.enable then
|
||||
filter = true
|
||||
end
|
||||
elseif trackFilter.type == "Blacklist" and spell and spell.enable then
|
||||
filter = false
|
||||
end
|
||||
end
|
||||
|
||||
if filter ~= true then
|
||||
numAuras = numAuras - 1
|
||||
RemoveAuraInstance(guid, aura.spellID, aura.caster)
|
||||
wipe(aura)
|
||||
end
|
||||
|
||||
if tonumber(aura.spellID) then
|
||||
aura.unit = frame.unit
|
||||
if aura.expirationTime > GetTime() then
|
||||
if aura.type == "BUFF" then
|
||||
numBuff = numBuff + 1
|
||||
buffCache[numBuff] = aura
|
||||
else
|
||||
numDebuff = numDebuff + 1
|
||||
debuffCache[numDebuff] = aura
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
wipe(currentAura)
|
||||
end
|
||||
|
||||
local frameNum = 1
|
||||
local maxAuras = getn(frame.Debuffs.icons)
|
||||
local maxDuration = self.db.units[frame.UnitType].debuffs.filters.maxDuration
|
||||
|
||||
self:HideAuraIcons(frame.Debuffs)
|
||||
if numDebuff > 0 and self.db.units[frame.UnitType].debuffs.enable then
|
||||
for index = 1, getn(debuffCache) do
|
||||
if frameNum > maxAuras then break end
|
||||
local debuff = debuffCache[index]
|
||||
if debuff.spellID and debuff.expirationTime and debuff.duration <= maxDuration then
|
||||
self:SetAura(frame.Debuffs.icons[frameNum], debuff.icon, debuff.count, debuff.expirationTime)
|
||||
frameNum = frameNum + 1
|
||||
hasDebuffs = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
frameNum = 1
|
||||
maxAuras = getn(frame.Buffs.icons)
|
||||
maxDuration = self.db.units[frame.UnitType].buffs.filters.maxDuration
|
||||
|
||||
self:HideAuraIcons(frame.Buffs)
|
||||
if numBuff > 0 and self.db.units[frame.UnitType].buffs.enable then
|
||||
for index = 1, getn(buffCache) do
|
||||
if frameNum > maxAuras then break end
|
||||
local buff = buffCache[index]
|
||||
if buff.spellID and buff.expirationTime and buff.duration <= maxDuration then
|
||||
self:SetAura(frame.Buffs.icons[frameNum], buff.icon, buff.count, buff.expirationTime)
|
||||
frameNum = frameNum + 1
|
||||
hasBuffs = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
debuffCache = wipe(debuffCache)
|
||||
buffCache = wipe(buffCache)
|
||||
|
||||
local TopLevel = frame.HealthBar
|
||||
local TopOffset = ((self.db.units[frame.UnitType].showName and select(2, frame.Name:GetFont()) + 5) or 0)
|
||||
if hasDebuffs then
|
||||
TopOffset = TopOffset + 3
|
||||
frame.Debuffs:SetPoint("BOTTOMLEFT", TopLevel, "TOPLEFT", 0, TopOffset)
|
||||
frame.Debuffs:SetPoint("BOTTOMRIGHT", TopLevel, "TOPRIGHT", 0, TopOffset)
|
||||
TopLevel = frame.Debuffs
|
||||
TopOffset = 3
|
||||
end
|
||||
|
||||
if hasBuffs then
|
||||
if not hasDebuffs then
|
||||
TopOffset = TopOffset + 3
|
||||
end
|
||||
frame.Buffs:SetPoint("BOTTOMLEFT", TopLevel, "TOPLEFT", 0, TopOffset)
|
||||
frame.Buffs:SetPoint("BOTTOMRIGHT", TopLevel, "TOPRIGHT", 0, TopOffset)
|
||||
TopLevel = frame.Buffs
|
||||
TopOffset = 3
|
||||
end
|
||||
|
||||
if frame.TopLevelFrame ~= TopLevel then
|
||||
frame.TopLevelFrame = TopLevel
|
||||
frame.TopOffset = TopOffset
|
||||
end
|
||||
end
|
||||
|
||||
function mod:UpdateElement_AurasByUnitID(unit)
|
||||
--[[local guid = UnitGUID(unit)
|
||||
WipeAuraList(guid)
|
||||
|
||||
local index = 1
|
||||
local name, _, texture, count, _, duration, expirationTime, unitCaster, _, _, spellID = UnitAura(unit, index, "HARMFUL")
|
||||
while name do
|
||||
SetSpellDuration(spellID, duration)
|
||||
SetAuraInstance(guid, name, spellID, expirationTime, count, UnitGUID(unitCaster or ""), duration, texture, AURA_TYPE_DEBUFF)
|
||||
index = index + 1
|
||||
name , _, texture, count, _, duration, expirationTime, unitCaster, _, _, spellID = UnitAura(unit, index, "HARMFUL")
|
||||
end
|
||||
|
||||
index = 1
|
||||
local name, _, texture, count, _, duration, expirationTime, unitCaster, _, _, spellID = UnitAura(unit, index, "HELPFUL")
|
||||
while name do
|
||||
SetSpellDuration(spellID, duration)
|
||||
SetAuraInstance(guid, name, spellID, expirationTime, count, UnitGUID(unitCaster or ""), duration, texture, AURA_TYPE_BUFF)
|
||||
index = index + 1
|
||||
name, _, texture, count, _, duration, expirationTime, unitCaster, _, _, spellID = UnitAura(unit, index, "HELPFUL")
|
||||
end
|
||||
|
||||
local raidIcon, name
|
||||
if UnitPlayerControlled(unit) then name = UnitName(unit) end
|
||||
raidIcon = RaidIconIndex[GetRaidTargetIndex(unit) or ""]
|
||||
if raidIcon then ByRaidIcon[raidIcon] = guid end
|
||||
|
||||
local frame = self:SearchForFrame(guid, raidIcon, name)
|
||||
if frame then
|
||||
self:UpdateElement_Auras(frame)
|
||||
end]]
|
||||
end
|
||||
|
||||
function mod:COMBAT_LOG_EVENT_UNFILTERED(_, _, event, sourceGUID, _, _, destGUID, destName, destFlags, ...)
|
||||
if destGUID == UnitGUID("target") then return end
|
||||
--if band(destFlags, COMBATLOG_OBJECT_REACTION_FRIENDLY) ~= 0 then then return
|
||||
if not (event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REFRESH" or event == "SPELL_AURA_APPLIED_DOSE" or event == "SPELL_AURA_REMOVED_DOSE" or event == "SPELL_AURA_BROKEN" or event == "SPELL_AURA_BROKEN_SPELL" or event == "SPELL_AURA_REMOVED") then return end
|
||||
|
||||
--local spellID, spellName, _, auraType, stackCount = ...
|
||||
|
||||
if event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REFRESH" then
|
||||
local duration = GetSpellDuration(spellID)
|
||||
local texture = GetSpellTexture(spellID)
|
||||
SetAuraInstance(destGUID, spellName, spellID, GetTime() + (duration or 0), 1, sourceGUID, duration, texture, auraType)
|
||||
elseif event == "SPELL_AURA_APPLIED_DOSE" or event == "SPELL_AURA_REMOVED_DOSE" then
|
||||
local duration = GetSpellDuration(spellID)
|
||||
local texture = GetSpellTexture(spellID)
|
||||
SetAuraInstance(destGUID, spellName, spellID, GetTime() + (duration or 0), stackCount, sourceGUID, duration, texture, auraType)
|
||||
elseif event == "SPELL_AURA_BROKEN" or event == "SPELL_AURA_BROKEN_SPELL" or event == "SPELL_AURA_REMOVED" then
|
||||
RemoveAuraInstance(destGUID, spellID, sourceGUID)
|
||||
end
|
||||
|
||||
local name, raidIcon
|
||||
if band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) > 0 then
|
||||
local rawName = strsplit("-", destName)
|
||||
ByName[rawName] = destGUID
|
||||
name = rawName
|
||||
end
|
||||
|
||||
for iconName, bitmask in pairs(RaidIconBit) do
|
||||
if band(destFlags, bitmask) > 0 then
|
||||
ByRaidIcon[iconName] = destGUID
|
||||
raidIcon = iconName
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local frame = self:SearchForFrame(destGUID, raidIcon, name)
|
||||
if frame then
|
||||
self:UpdateElement_Auras(frame)
|
||||
end
|
||||
end
|
||||
|
||||
function mod:CreateAuraIcon(parent)
|
||||
local aura = CreateFrame("Frame", nil, parent)
|
||||
self:StyleFrame(aura, true)
|
||||
|
||||
aura.icon = aura:CreateTexture(nil, "OVERLAY")
|
||||
aura.icon:SetAllPoints()
|
||||
aura.icon:SetTexCoord(unpack(E.TexCoords))
|
||||
|
||||
aura.timeLeft = aura:CreateFontString(nil, "OVERLAY")
|
||||
aura.timeLeft:SetPoint("TOPLEFT", 2, 2)
|
||||
aura.timeLeft:SetFont(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
|
||||
aura.count = aura:CreateFontString(nil, "OVERLAY")
|
||||
aura.count:SetPoint("BOTTOMRIGHT", 0, 0)
|
||||
aura.count:SetFont(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
aura.Poll = parent.PollFunction
|
||||
|
||||
return aura
|
||||
end
|
||||
|
||||
function mod:Auras_SizeChanged(width)
|
||||
local numAuras = getn(self.icons)
|
||||
for i = 1, numAuras do
|
||||
self.icons[i]:SetWidth(((width - numAuras) / numAuras) - (E.private.general.pixelPerfect and 0 or 3))
|
||||
self.icons[i]:SetHeight((self.db.baseHeight or 18) * (self:GetParent().HealthBar.currentScale or 1))
|
||||
end
|
||||
self:SetHeight((self.db.baseHeight or 18) * (self:GetParent().HealthBar.currentScale or 1))
|
||||
end
|
||||
|
||||
function mod:UpdateAuraIcons(auras)
|
||||
local maxAuras = auras.db.numAuras
|
||||
local numCurrentAuras = getn(auras.icons)
|
||||
if(numCurrentAuras > maxAuras) then
|
||||
for i = maxAuras, numCurrentAuras do
|
||||
tinsert(auraCache, auras.icons[i])
|
||||
auras.icons[i]:Hide()
|
||||
auras.icons[i] = nil
|
||||
end
|
||||
end
|
||||
|
||||
if(numCurrentAuras ~= maxAuras) then
|
||||
self.Auras_SizeChanged(auras, auras:GetWidth(), auras:GetHeight())
|
||||
end
|
||||
|
||||
for i = 1, maxAuras do
|
||||
auras.icons[i] = auras.icons[i] or tremove(auraCache) or mod:CreateAuraIcon(auras)
|
||||
auras.icons[i]:SetParent(auras)
|
||||
auras.icons[i]:ClearAllPoints()
|
||||
auras.icons[i]:Hide()
|
||||
auras.icons[i]:SetHeight(auras.db.baseHeight or 18)
|
||||
|
||||
if(auras.side == "LEFT") then
|
||||
if(i == 1) then
|
||||
auras.icons[i]:SetPoint("BOTTOMLEFT", auras, "BOTTOMLEFT")
|
||||
else
|
||||
auras.icons[i]:SetPoint("LEFT", auras.icons[i-1], "RIGHT", E.Border + E.Spacing*3, 0)
|
||||
end
|
||||
else
|
||||
if(i == 1) then
|
||||
auras.icons[i]:SetPoint("BOTTOMRIGHT", auras, "BOTTOMRIGHT")
|
||||
else
|
||||
auras.icons[i]:SetPoint("RIGHT", auras.icons[i-1], "LEFT", -(E.Border + E.Spacing*3), 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConstructElement_Auras(frame, side)
|
||||
local auras = CreateFrame("Frame", nil, frame)
|
||||
|
||||
auras:SetScript("OnSizeChanged", mod.Auras_SizeChanged)
|
||||
auras:SetHeight(18)
|
||||
auras.side = side
|
||||
auras.PollFunction = UpdateAuraTime
|
||||
auras.icons = {}
|
||||
|
||||
return auras
|
||||
end
|
||||
@@ -0,0 +1,247 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
local LSM = LibStub("LibSharedMedia-3.0")
|
||||
|
||||
local select, unpack = select, unpack
|
||||
|
||||
local CreateFrame = CreateFrame
|
||||
local GetTime = GetTime
|
||||
local UnitCastingInfo = UnitCastingInfo
|
||||
local UnitChannelInfo = UnitChannelInfo
|
||||
local FAILED = FAILED
|
||||
local INTERRUPTED = INTERRUPTED
|
||||
|
||||
function mod:UpdateElement_CastBarOnUpdate(elapsed)
|
||||
if self.casting then
|
||||
self.value = self.value + elapsed
|
||||
if self.value >= self.maxValue then
|
||||
self:SetValue(self.maxValue)
|
||||
self:Hide()
|
||||
return
|
||||
end
|
||||
self:SetValue(self.value)
|
||||
|
||||
if self.castTimeFormat == "CURRENT" then
|
||||
self.Time:SetFormattedText("%.1f", self.value)
|
||||
elseif self.castTimeFormat == "CURRENT_MAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.1f", self.value, self.maxValue)
|
||||
else --REMAINING
|
||||
self.Time:SetFormattedText("%.1f", (self.maxValue - self.value))
|
||||
end
|
||||
|
||||
if self.Spark then
|
||||
local sparkPosition = (self.value / self.maxValue) * self:GetWidth()
|
||||
self.Spark:SetPoint("CENTER", self, "LEFT", sparkPosition, 0)
|
||||
end
|
||||
elseif self.channeling then
|
||||
self.value = self.value - elapsed
|
||||
if self.value <= 0 then
|
||||
self:Hide()
|
||||
return
|
||||
end
|
||||
self:SetValue(self.value)
|
||||
|
||||
if self.channelTimeFormat == "CURRENT" then
|
||||
self.Time:SetFormattedText("%.1f", (self.maxValue - self.value))
|
||||
elseif self.channelTimeFormat == "CURRENT_MAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.1f", (self.maxValue - self.value), self.maxValue)
|
||||
else --REMAINING
|
||||
self.Time:SetFormattedText("%.1f", self.value)
|
||||
end
|
||||
elseif self.holdTime > 0 then
|
||||
self.holdTime = self.holdTime - elapsed
|
||||
else
|
||||
self:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function mod:UpdateElement_Cast(frame, event, unit, ...)
|
||||
if self.db.units[frame.UnitType].castbar.enable ~= true then return end
|
||||
if frame.unit ~= unit then return end
|
||||
|
||||
if event == "UNIT_SPELLCAST_START" then
|
||||
local name, _, _, texture, startTime, endTime = UnitCastingInfo(unit)
|
||||
if not name then
|
||||
frame.CastBar:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
if frame.CastBar.Spark then
|
||||
frame.CastBar.Spark:Show()
|
||||
end
|
||||
frame.CastBar.Name:SetText(name)
|
||||
frame.CastBar.value = (GetTime() - (startTime / 1000))
|
||||
frame.CastBar.maxValue = (endTime - startTime) / 1000
|
||||
frame.CastBar:SetMinMaxValues(0, frame.CastBar.maxValue)
|
||||
frame.CastBar:SetValue(frame.CastBar.value)
|
||||
|
||||
if frame.CastBar.Icon then
|
||||
frame.CastBar.Icon.texture:SetTexture(texture)
|
||||
end
|
||||
|
||||
frame.CastBar.casting = true
|
||||
frame.CastBar.channeling = nil
|
||||
frame.CastBar.holdTime = 0
|
||||
|
||||
frame.CastBar:Show()
|
||||
elseif event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_CHANNEL_STOP" then
|
||||
if not frame.CastBar:IsVisible() then
|
||||
frame.CastBar:Hide()
|
||||
end
|
||||
if (frame.CastBar.casting and event == "UNIT_SPELLCAST_STOP") or
|
||||
(frame.CastBar.channeling and event == "UNIT_SPELLCAST_CHANNEL_STOP") then
|
||||
if frame.CastBar.Spark then
|
||||
frame.CastBar.Spark:Hide()
|
||||
end
|
||||
|
||||
frame.CastBar:SetValue(frame.CastBar.maxValue)
|
||||
if event == "UNIT_SPELLCAST_STOP" then
|
||||
frame.CastBar.casting = nil
|
||||
else
|
||||
frame.CastBar.channeling = nil
|
||||
end
|
||||
|
||||
frame.CastBar:Hide()
|
||||
end
|
||||
elseif event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_INTERRUPTED" then
|
||||
if frame.CastBar:IsShown() then
|
||||
frame.CastBar:SetValue(frame.CastBar.maxValue)
|
||||
if frame.CastBar.Spark then
|
||||
frame.CastBar.Spark:Hide()
|
||||
end
|
||||
|
||||
if event == "UNIT_SPELLCAST_FAILED" then
|
||||
frame.CastBar.Name:SetText(FAILED)
|
||||
else
|
||||
frame.CastBar.Name:SetText(INTERRUPTED)
|
||||
end
|
||||
frame.CastBar.casting = nil
|
||||
frame.CastBar.channeling = nil
|
||||
frame.CastBar.holdTime = self.db.units[frame.UnitType].castbar.timeToHold --How long the castbar should stay visible after being interrupted, in seconds
|
||||
end
|
||||
elseif event == "UNIT_SPELLCAST_DELAYED" then
|
||||
if frame:IsShown() then
|
||||
local name, _, _, _, startTime, endTime = UnitCastingInfo(unit)
|
||||
if not name then
|
||||
-- if there is no name, there is no bar
|
||||
frame.CastBar:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
frame.CastBar.Name:SetText(name)
|
||||
frame.CastBar.value = (GetTime() - (startTime / 1000))
|
||||
frame.CastBar.maxValue = (endTime - startTime) / 1000
|
||||
frame.CastBar:SetMinMaxValues(0, frame.CastBar.maxValue)
|
||||
|
||||
if not frame.CastBar.casting then
|
||||
if frame.CastBar.Spark then
|
||||
frame.CastBar.Spark:Show()
|
||||
end
|
||||
|
||||
frame.CastBar.casting = true
|
||||
frame.CastBar.channeling = nil
|
||||
end
|
||||
end
|
||||
elseif event == "UNIT_SPELLCAST_CHANNEL_START" then
|
||||
local name, _, _, texture, startTime, endTime = UnitChannelInfo(unit)
|
||||
if not name then
|
||||
frame.CastBar:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
frame.CastBar.Name:SetText(name)
|
||||
frame.CastBar.value = (endTime / 1000) - GetTime()
|
||||
frame.CastBar.maxValue = (endTime - startTime) / 1000
|
||||
frame.CastBar:SetMinMaxValues(0, frame.CastBar.maxValue)
|
||||
frame.CastBar:SetValue(frame.CastBar.value)
|
||||
frame.CastBar.holdTime = 0
|
||||
|
||||
if frame.CastBar.Icon then
|
||||
frame.CastBar.Icon.texture:SetTexture(texture)
|
||||
end
|
||||
if frame.CastBar.Spark then
|
||||
frame.CastBar.Spark:Hide()
|
||||
end
|
||||
|
||||
frame.CastBar.casting = nil
|
||||
frame.CastBar.channeling = true
|
||||
|
||||
frame.CastBar:Show()
|
||||
elseif event == "UNIT_SPELLCAST_CHANNEL_UPDATE" then
|
||||
if frame.CastBar:IsShown() then
|
||||
local name, _, _, _, startTime, endTime = UnitChannelInfo(unit)
|
||||
if not name then
|
||||
frame.CastBar:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
frame.CastBar.Name:SetText(name)
|
||||
frame.CastBar.value = ((endTime / 1000) - GetTime())
|
||||
frame.CastBar.maxValue = (endTime - startTime) / 1000
|
||||
frame.CastBar:SetMinMaxValues(0, frame.CastBar.maxValue)
|
||||
frame.CastBar:SetValue(frame.CastBar.value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConfigureElement_CastBar(frame)
|
||||
local castBar = frame.CastBar
|
||||
|
||||
castBar:ClearAllPoints()
|
||||
castBar:SetPoint("TOPLEFT", frame.HealthBar, "BOTTOMLEFT", 0, -self.db.units[frame.UnitType].castbar.offset)
|
||||
castBar:SetPoint("TOPRIGHT", frame.HealthBar, "BOTTOMRIGHT", 0, -self.db.units[frame.UnitType].castbar.offset)
|
||||
castBar:SetHeight(self.db.units[frame.UnitType].castbar.height)
|
||||
|
||||
castBar.Icon:SetPoint("TOPLEFT", frame.HealthBar, "TOPRIGHT", self.db.units[frame.UnitType].castbar.offset, 0);
|
||||
castBar.Icon:SetPoint("BOTTOMLEFT", castBar, "BOTTOMRIGHT", self.db.units[frame.UnitType].castbar.offset, 0);
|
||||
castBar.Icon:SetWidth(self.db.units[frame.UnitType].castbar.height + self.db.units[frame.UnitType].healthbar.height + self.db.units[frame.UnitType].castbar.offset)
|
||||
|
||||
castBar.Time:SetPoint("TOPRIGHT", castBar, "BOTTOMRIGHT", 0, -E.Border*3)
|
||||
castBar.Name:SetPoint("TOPLEFT", castBar, "BOTTOMLEFT", 0, -E.Border*3)
|
||||
castBar.Name:SetPoint("TOPRIGHT", castBar.Time, "TOPLEFT")
|
||||
|
||||
castBar.Name:SetJustifyH("LEFT")
|
||||
castBar.Name:SetJustifyV("TOP")
|
||||
castBar.Name:SetFont(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
castBar.Time:SetJustifyH("RIGHT")
|
||||
castBar.Time:SetJustifyV("TOP")
|
||||
castBar.Time:SetFont(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
|
||||
if self.db.units[frame.UnitType].castbar.hideSpellName then
|
||||
castBar.Name:Hide()
|
||||
else
|
||||
castBar.Name:Show()
|
||||
end
|
||||
if self.db.units[frame.UnitType].castbar.hideTime then
|
||||
castBar.Time:Hide()
|
||||
else
|
||||
castBar.Time:Show()
|
||||
end
|
||||
|
||||
castBar:SetStatusBarTexture(LSM:Fetch("statusbar", self.db.statusbar))
|
||||
castBar:SetStatusBarColor(self.db.castColor.r, self.db.castColor.g, self.db.castColor.b)
|
||||
|
||||
castBar.castTimeFormat = self.db.units[frame.UnitType].castbar.castTimeFormat
|
||||
castBar.channelTimeFormat = self.db.units[frame.UnitType].castbar.channelTimeFormat
|
||||
end
|
||||
|
||||
function mod:ConstructElement_CastBar(parent)
|
||||
local frame = CreateFrame("StatusBar", "$parentCastBar", parent)
|
||||
self:StyleFrame(frame)
|
||||
--frame:SetScript("OnUpdate", mod.UpdateElement_CastBarOnUpdate)
|
||||
|
||||
frame.Icon = CreateFrame("Frame", nil, frame)
|
||||
frame.Icon.texture = frame.Icon:CreateTexture(nil, "BORDER")
|
||||
frame.Icon.texture:SetAllPoints()
|
||||
frame.Icon.texture:SetTexCoord(unpack(E.TexCoords))
|
||||
self:StyleFrame(frame.Icon)
|
||||
|
||||
frame.Name = frame:CreateFontString(nil, "OVERLAY")
|
||||
frame.Time = frame:CreateFontString(nil, "OVERLAY")
|
||||
frame.Spark = frame:CreateTexture(nil, "OVERLAY")
|
||||
frame.Spark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]])
|
||||
frame.Spark:SetBlendMode("ADD")
|
||||
--frame.Spark:SetSize(15, 15)
|
||||
frame:Hide()
|
||||
return frame
|
||||
end
|
||||
@@ -0,0 +1,67 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
|
||||
local ComboColors = {
|
||||
[1] = {0.69, 0.31, 0.31},
|
||||
[2] = {0.69, 0.31, 0.31},
|
||||
[3] = {0.65, 0.63, 0.35},
|
||||
[4] = {0.65, 0.63, 0.35},
|
||||
[5] = {0.33, 0.59, 0.33}
|
||||
}
|
||||
|
||||
local GetComboPoints = GetComboPoints
|
||||
local MAX_COMBO_POINTS = MAX_COMBO_POINTS
|
||||
|
||||
function mod:UpdateElement_CPoints(frame)
|
||||
if not self.db.comboPoints then return end
|
||||
if frame.UnitType == "FRIENDLY_PLAYER" or frame.UnitType == "FRIENDLY_NPC" then return end
|
||||
|
||||
local numPoints
|
||||
if UnitExists("target") and frame.isTarget then
|
||||
numPoints = GetComboPoints("player", "target")
|
||||
end
|
||||
|
||||
if numPoints and numPoints > 0 then
|
||||
frame.CPoints:Show()
|
||||
for i = 1, MAX_COMBO_POINTS do
|
||||
if i <= numPoints then
|
||||
frame.CPoints[i]:Show()
|
||||
else
|
||||
frame.CPoints[i]:Hide()
|
||||
end
|
||||
end
|
||||
else
|
||||
frame.CPoints:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConfigureElement_CPoints(frame)
|
||||
if self.db.comboPoints and not frame.CPoints:IsShown() then
|
||||
frame.CPoints:Show()
|
||||
elseif frame.CPoints:IsShown() then
|
||||
frame.CPoints:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConstructElement_CPoints(parent)
|
||||
local frame = CreateFrame("Frame", nil, parent.HealthBar)
|
||||
frame:SetPoint("CENTER", parent.HealthBar, "BOTTOM")
|
||||
frame:SetWidth(68)
|
||||
frame:SetHeight(1)
|
||||
frame:Hide()
|
||||
|
||||
for i = 1, MAX_COMBO_POINTS do
|
||||
frame[i] = frame:CreateTexture(nil, "OVERLAY")
|
||||
frame[i]:SetTexture([[Interface\AddOns\ElvUI\media\textures\bubbleTex.tga]])
|
||||
frame[i]:SetWidth(12)
|
||||
frame[i]:SetHeight(12)
|
||||
frame[i]:SetVertexColor(unpack(ComboColors[i]))
|
||||
|
||||
if i == 1 then
|
||||
frame[i]:SetPoint("LEFT", frame, "TOPLEFT")
|
||||
else
|
||||
frame[i]:SetPoint("LEFT", frame[i-1], "RIGHT", 2, 0)
|
||||
end
|
||||
end
|
||||
return frame
|
||||
end
|
||||
@@ -0,0 +1,56 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
local LSM = LibStub("LibSharedMedia-3.0")
|
||||
|
||||
local CreateFrame = CreateFrame
|
||||
|
||||
function mod:UpdateElement_Glow(frame)
|
||||
if not frame.HealthBar:IsShown() then return end
|
||||
|
||||
local r, g, b, shouldShow
|
||||
if frame.isTarget and self.db.useTargetGlow then
|
||||
r, g, b = 1, 1, 1
|
||||
shouldShow = true
|
||||
else
|
||||
local health = frame.oldHealthBar:GetValue()
|
||||
local _, maxHealth = frame.oldHealthBar:GetMinMaxValues()
|
||||
local perc = health / maxHealth
|
||||
if perc <= self.db.lowHealthThreshold then
|
||||
if perc <= self.db.lowHealthThreshold / 2 then
|
||||
r, g, b = 1, 0, 0
|
||||
else
|
||||
r, g, b = 1, 1, 0
|
||||
end
|
||||
|
||||
shouldShow = true
|
||||
end
|
||||
end
|
||||
|
||||
if shouldShow then
|
||||
frame.Glow:Show()
|
||||
if r ~= frame.Glow.r or g ~= frame.Glow.g or b ~= frame.Glow.b then
|
||||
frame.Glow:SetBackdropBorderColor(r, g, b)
|
||||
frame.Glow.r, frame.Glow.g, frame.Glow.b = r, g, b
|
||||
end
|
||||
elseif frame.Glow:IsShown() then
|
||||
frame.Glow:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConfigureElement_Glow(frame)
|
||||
|
||||
end
|
||||
|
||||
function mod:ConstructElement_Glow(frame)
|
||||
local f = CreateFrame("Frame", nil, frame)
|
||||
f:SetFrameLevel(frame.HealthBar:GetFrameLevel() - 1)
|
||||
E:SetOutside(f, frame.HealthBar, 3, 3)
|
||||
f:SetBackdrop({
|
||||
edgeFile = LSM:Fetch("border", "ElvUI GlowBorder"), edgeSize = E:Scale(3),
|
||||
insets = {left = E:Scale(5), right = E:Scale(5), top = E:Scale(5), bottom = E:Scale(5)}
|
||||
})
|
||||
|
||||
f:SetScale(E.PixelMode and 1.5 or 2)
|
||||
f:Hide()
|
||||
return f
|
||||
end
|
||||
@@ -0,0 +1,28 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
|
||||
function mod:UpdateElement_HealerIcon(frame)
|
||||
local icon = frame.HealerIcon
|
||||
icon:ClearAllPoints()
|
||||
if frame.HealthBar:IsShown() then
|
||||
icon:SetPoint("RIGHT", frame.HealthBar, "LEFT", -6, 0)
|
||||
else
|
||||
icon:SetPoint("BOTTOM", frame.Name, "TOP", 0, 3)
|
||||
end
|
||||
if self.Healers[frame.UnitName] and frame.UnitType == "ENEMY_PLAYER" then
|
||||
icon:Show()
|
||||
else
|
||||
icon:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConstructElement_HealerIcon(frame)
|
||||
local texture = frame:CreateTexture(nil, "OVERLAY")
|
||||
texture:SetPoint("RIGHT", frame.HealthBar, "LEFT", -6, 0)
|
||||
texture:SetWidth(40)
|
||||
texture:SetHeight(40)
|
||||
texture:SetTexture([[Interface\AddOns\ElvUI\media\textures\healer.tga]])
|
||||
texture:Hide()
|
||||
|
||||
return texture
|
||||
end
|
||||
@@ -0,0 +1,180 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
local LSM = LibStub("LibSharedMedia-3.0")
|
||||
--local LMH = LibStub("LibMobHealth-4.0")
|
||||
|
||||
local tonumber = tonumber
|
||||
|
||||
local GetInstanceDifficulty = GetInstanceDifficulty
|
||||
local UnitLevel = UnitLevel
|
||||
|
||||
function mod:UpdateElement_HealthOnValueChanged()
|
||||
local frame = this:GetParent().UnitFrame
|
||||
if not frame.UnitType then return end -- Bugs
|
||||
|
||||
mod:UpdateElement_Health(frame)
|
||||
mod:UpdateElement_HealthColor(frame)
|
||||
mod:UpdateElement_Glow(frame)
|
||||
end
|
||||
|
||||
function mod:UpdateElement_HealthColor(frame)
|
||||
if(not frame.HealthBar:IsShown()) then return end
|
||||
|
||||
local r, g, b
|
||||
local scale = 1
|
||||
|
||||
local class = frame.UnitClass
|
||||
local classColor = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]
|
||||
local useClassColor = mod.db.units[frame.UnitType].healthbar.useClassColor
|
||||
|
||||
if classColor and ((frame.UnitType == "FRIENDLY_PLAYER" and useClassColor and E.private.general.classCache) or (frame.UnitType == "ENEMY_PLAYER" and useClassColor and E.private.general.classCache)) then
|
||||
r, g, b = classColor.r, classColor.g, classColor.b
|
||||
elseif frame.UnitReaction == 1 then
|
||||
r, g, b = mod.db.reactions.tapped.r, mod.db.reactions.tapped.g, mod.db.reactions.tapped.b
|
||||
else
|
||||
local status = mod:UnitDetailedThreatSituation(frame)
|
||||
if status then
|
||||
if status == 3 then
|
||||
if E.Role == "Tank" then
|
||||
r, g, b = mod.db.threat.goodColor.r, mod.db.threat.goodColor.g, mod.db.threat.goodColor.b
|
||||
scale = mod.db.threat.goodScale
|
||||
else
|
||||
r, g, b = mod.db.threat.badColor.r, mod.db.threat.badColor.g, mod.db.threat.badColor.b
|
||||
scale = mod.db.threat.badScale
|
||||
end
|
||||
elseif status == 2 then
|
||||
if E.Role == "Tank" then
|
||||
r, g, b = mod.db.threat.badTransition.r, mod.db.threat.badTransition.g, mod.db.threat.badTransition.b
|
||||
else
|
||||
r, g, b = mod.db.threat.goodTransition.r, mod.db.threat.goodTransition.g, mod.db.threat.goodTransition.b
|
||||
end
|
||||
scale = 1
|
||||
elseif status == 1 then
|
||||
if E.Role == "Tank" then
|
||||
r, g, b = mod.db.threat.goodTransition.r, mod.db.threat.goodTransition.g, mod.db.threat.goodTransition.b
|
||||
else
|
||||
r, g, b = mod.db.threat.badTransition.r, mod.db.threat.badTransition.g, mod.db.threat.badTransition.b
|
||||
end
|
||||
scale = 1
|
||||
else
|
||||
if E.Role == "Tank" then
|
||||
r, g, b = mod.db.threat.badColor.r, mod.db.threat.badColor.g, mod.db.threat.badColor.b
|
||||
scale = mod.db.threat.badScale
|
||||
else
|
||||
r, g, b = mod.db.threat.goodColor.r, mod.db.threat.goodColor.g, mod.db.threat.goodColor.b
|
||||
scale = mod.db.threat.goodScale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (not status) or (status and not mod.db.threat.useThreatColor) then
|
||||
local reactionType = frame.UnitReaction
|
||||
if reactionType == 4 then
|
||||
r, g, b = mod.db.reactions.neutral.r, mod.db.reactions.neutral.g, mod.db.reactions.neutral.b
|
||||
elseif reactionType > 4 then
|
||||
if frame.UnitType == "FRIENDLY_PLAYER" then
|
||||
r, g, b = mod.db.reactions.friendlyPlayer.r, mod.db.reactions.friendlyPlayer.g, mod.db.reactions.friendlyPlayer.b
|
||||
else
|
||||
r, g, b = mod.db.reactions.good.r, mod.db.reactions.good.g, mod.db.reactions.good.b
|
||||
end
|
||||
else
|
||||
r, g, b = mod.db.reactions.bad.r, mod.db.reactions.bad.g, mod.db.reactions.bad.b
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if r ~= frame.HealthBar.r or g ~= frame.HealthBar.g or b ~= frame.HealthBar.b then
|
||||
if not frame.CustomColor then
|
||||
frame.HealthBar:SetStatusBarColor(r, g, b)
|
||||
frame.HealthBar.r, frame.HealthBar.g, frame.HealthBar.b = r, g, b
|
||||
else
|
||||
local CustomColor = frame.CustomColor
|
||||
frame.HealthBar:SetStatusBarColor(CustomColor.r, CustomColor.g, CustomColor.b)
|
||||
frame.HealthBar.r, frame.HealthBar.g, frame.HealthBar.b = CustomColor.r, CustomColor.g, CustomColor.b
|
||||
end
|
||||
end
|
||||
|
||||
if (not frame.isTarget or not mod.db.useTargetScale) and not frame.CustomScale then
|
||||
frame.ThreatScale = scale
|
||||
mod:SetFrameScale(frame, scale)
|
||||
end
|
||||
end
|
||||
|
||||
function mod:UpdateElement_Health(frame)
|
||||
local health = frame.oldHealthBar:GetValue()
|
||||
local _, maxHealth = frame.oldHealthBar:GetMinMaxValues()
|
||||
|
||||
frame.HealthBar:SetMinMaxValues(0, maxHealth)
|
||||
frame.HealthBar:SetValue(health)
|
||||
|
||||
if self.db.units[frame.UnitType].healthbar.text.enable then
|
||||
if maxHealth ~= 100 then
|
||||
frame.HealthBar.text:SetText(E:GetFormattedText(self.db.units[frame.UnitType].healthbar.text.format, health, maxHealth))
|
||||
else
|
||||
local newMaxHealth
|
||||
|
||||
if frame.unit == "target" then
|
||||
--health, maxHealth = LMH:GetUnitHealth("target")
|
||||
else
|
||||
local level = self:UnitLevel(frame)
|
||||
if level == "??" then
|
||||
level = UnitLevel("player") + 3
|
||||
end
|
||||
|
||||
if frame.UnitType == "FRIENDLY_PLAYER" or frame.UnitType == "ENEMY_PLAYER" then
|
||||
-- newMaxHealth = LMH:GetMaxHP(frame.UnitName, tonumber(level), "pc")
|
||||
elseif frame.UnitType == "FRIENDLY_NPC" or frame.UnitType == "ENEMY_NPC" then
|
||||
-- newMaxHealth = LMH:GetMaxHP(frame.UnitName, tonumber(level), "npc", GetInstanceDifficulty())
|
||||
else
|
||||
-- newMaxHealth = LMH:GetMaxHP(frame.UnitName, tonumber(level))
|
||||
end
|
||||
|
||||
if newMaxHealth then
|
||||
health = newMaxHealth / 100 * health
|
||||
maxHealth = newMaxHealth
|
||||
end
|
||||
end
|
||||
|
||||
frame.HealthBar.text:SetText(E:GetFormattedText(self.db.units[frame.UnitType].healthbar.text.format, health, maxHealth))
|
||||
end
|
||||
else
|
||||
frame.HealthBar.text:SetText("")
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConfigureElement_HealthBar(frame, configuring)
|
||||
local healthBar = frame.HealthBar
|
||||
|
||||
healthBar:SetPoint("TOP", frame, "CENTER", 0, self.db.units[frame.UnitType].castbar.height + 3)
|
||||
if frame.isTarget and self.db.useTargetScale then
|
||||
healthBar:SetHeight(self.db.units[frame.UnitType].healthbar.height * ((frame.CustomScale and frame.CustomScale * self.db.targetScale) or self.db.targetScale))
|
||||
healthBar:SetWidth(self.db.units[frame.UnitType].healthbar.width * ((frame.CustomScale and frame.CustomScale * self.db.targetScale) or self.db.targetScale))
|
||||
else
|
||||
healthBar:SetHeight((frame.CustomScale and frame.CustomScale * self.db.units[frame.UnitType].healthbar.height) or self.db.units[frame.UnitType].healthbar.height)
|
||||
healthBar:SetWidth((frame.CustomScale and frame.CustomScale * self.db.units[frame.UnitType].healthbar.width) or self.db.units[frame.UnitType].healthbar.width)
|
||||
end
|
||||
|
||||
healthBar:SetStatusBarTexture(LSM:Fetch("statusbar", self.db.statusbar), "BORDER")
|
||||
if(not configuring) and (self.db.units[frame.UnitType].healthbar.enable or frame.isTarget) then
|
||||
healthBar:Show()
|
||||
end
|
||||
|
||||
healthBar.text:SetAllPoints(healthBar)
|
||||
healthBar.text:SetFont(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
end
|
||||
|
||||
function mod:ConstructElement_HealthBar(parent)
|
||||
local frame = CreateFrame("StatusBar", nil, parent)
|
||||
self:StyleFrame(frame)
|
||||
frame:SetFrameLevel(parent:GetFrameLevel())
|
||||
|
||||
frame.text = frame:CreateFontString(nil, "OVERLAY")
|
||||
frame.scale = CreateAnimationGroup(frame)
|
||||
|
||||
frame.scale.width = frame.scale:CreateAnimation("Width")
|
||||
frame.scale.width:SetDuration(0.2)
|
||||
frame.scale.height = frame.scale:CreateAnimation("Height")
|
||||
frame.scale.height:SetDuration(0.2)
|
||||
frame:Hide()
|
||||
return frame
|
||||
end
|
||||
@@ -0,0 +1,37 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
local LSM = LibStub("LibSharedMedia-3.0")
|
||||
|
||||
local format = format
|
||||
|
||||
function mod:UpdateElement_Level(frame)
|
||||
if not self.db.units[frame.UnitType].showLevel then return end
|
||||
|
||||
local level, r, g, b = self:UnitLevel(frame)
|
||||
|
||||
if self.db.units[frame.UnitType].healthbar.enable or frame.isTarget then
|
||||
frame.Level:SetText(level)
|
||||
else
|
||||
frame.Level:SetText(format(" [%s]", level))
|
||||
end
|
||||
frame.Level:SetTextColor(r, g, b)
|
||||
end
|
||||
|
||||
function mod:ConfigureElement_Level(frame)
|
||||
local level = frame.Level
|
||||
|
||||
level:ClearAllPoints()
|
||||
|
||||
if self.db.units[frame.UnitType].healthbar.enable or frame.isTarget then
|
||||
level:SetJustifyH("RIGHT")
|
||||
level:SetPoint("BOTTOMRIGHT", frame.HealthBar, "TOPRIGHT", 0, E.Border*2)
|
||||
else
|
||||
level:SetPoint("LEFT", frame.Name, "RIGHT")
|
||||
level:SetJustifyH("LEFT")
|
||||
end
|
||||
level:SetFont(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
end
|
||||
|
||||
function mod:ConstructElement_Level(frame)
|
||||
return frame:CreateFontString(nil, "OVERLAY")
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="Auras.lua"/>
|
||||
<Script file="CastBar.lua"/>
|
||||
<Script file="ComboPoints.lua"/>
|
||||
<Script file="Glow.lua"/>
|
||||
<Script file="HealthBar.lua"/>
|
||||
<Script file="Level.lua"/>
|
||||
<Script file="Name.lua"/>
|
||||
<Script file="RaidIcon.lua"/>
|
||||
<Script file="HealerIcon.lua"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,63 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
local LSM = LibStub("LibSharedMedia-3.0")
|
||||
|
||||
function mod:UpdateElement_Name(frame)
|
||||
if not self.db.units[frame.UnitType].showName then return end
|
||||
|
||||
frame.Name:SetText(frame.UnitName)
|
||||
|
||||
local useClassColor = self.db.units[frame.UnitType].name and self.db.units[frame.UnitType].name.useClassColor
|
||||
if useClassColor and (frame.UnitType == "FRIENDLY_PLAYER" or frame.UnitType == "ENEMY_PLAYER") then
|
||||
local class = frame.UnitClass
|
||||
local color = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]
|
||||
if class and color then
|
||||
frame.Name:SetTextColor(color.r, color.g, color.b)
|
||||
else
|
||||
frame.Name:SetTextColor(self.db.reactions.friendlyPlayer.r, self.db.reactions.friendlyPlayer.g, self.db.reactions.friendlyPlayer.b)
|
||||
end
|
||||
elseif not self.db.units[frame.UnitType].healthbar.enable and not frame.isTarget then
|
||||
local reactionType = frame.UnitReaction
|
||||
|
||||
local r, g, b
|
||||
if reactionType == 4 then
|
||||
r, g, b = self.db.reactions.neutral.r, self.db.reactions.neutral.g, self.db.reactions.neutral.b
|
||||
elseif reactionType > 4 then
|
||||
if frame.UnitType == "FRIENDLY_PLAYER" then
|
||||
r, g, b = mod.db.reactions.friendlyPlayer.r, mod.db.reactions.friendlyPlayer.g, mod.db.reactions.friendlyPlayer.b
|
||||
else
|
||||
r, g, b = mod.db.reactions.good.r, mod.db.reactions.good.g, mod.db.reactions.good.b
|
||||
end
|
||||
else
|
||||
r, g, b = self.db.reactions.bad.r, self.db.reactions.bad.g, self.db.reactions.bad.b
|
||||
end
|
||||
|
||||
frame.Name:SetTextColor(r, g, b)
|
||||
else
|
||||
frame.Name:SetTextColor(1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ConfigureElement_Name(frame)
|
||||
local name = frame.Name
|
||||
|
||||
name:SetJustifyH("LEFT")
|
||||
name:SetJustifyV("BOTTOM")
|
||||
name:ClearAllPoints()
|
||||
if self.db.units[frame.UnitType].healthbar.enable or frame.isTarget then
|
||||
name:SetJustifyH("LEFT")
|
||||
name:SetPoint("BOTTOMLEFT", frame.HealthBar, "TOPLEFT", 0, E.Border*2)
|
||||
name:SetPoint("BOTTOMRIGHT", frame.Level, "BOTTOMLEFT")
|
||||
else
|
||||
name:SetJustifyH("CENTER")
|
||||
name:SetPoint("BOTTOM", frame, "CENTER", 0, 0)
|
||||
end
|
||||
|
||||
name:SetFont(LSM:Fetch("font", self.db.font), self.db.fontSize, self.db.fontOutline)
|
||||
end
|
||||
|
||||
function mod:ConstructElement_Name(frame)
|
||||
local name = frame:CreateFontString(nil, "OVERLAY")
|
||||
|
||||
return name
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:GetModule("NamePlates")
|
||||
|
||||
function mod:UpdateElement_RaidIcon(frame)
|
||||
local icon = frame.RaidIcon
|
||||
icon:ClearAllPoints()
|
||||
if frame.HealthBar:IsShown() then
|
||||
icon:SetPoint("RIGHT", frame.HealthBar, "LEFT", -6, 0)
|
||||
else
|
||||
icon:SetPoint("BOTTOM", frame.Name, "TOP", 0, 3)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="NamePlates.lua"/>
|
||||
<Include file="Elements\Load_Elements.xml"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,756 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local mod = E:NewModule("NamePlates", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0")
|
||||
--local CC = E:GetModule("ClassCache")
|
||||
|
||||
local _G = _G
|
||||
local pairs, tonumber = pairs, tonumber
|
||||
local select = select
|
||||
local gsub, split = string.gsub, string.split
|
||||
local twipe = table.wipe
|
||||
|
||||
local CreateFrame = CreateFrame
|
||||
local GetBattlefieldScore = GetBattlefieldScore
|
||||
local GetNumBattlefieldScores = GetNumBattlefieldScores
|
||||
local UnitClass = UnitClass
|
||||
local UnitExists = UnitExists
|
||||
local UnitGUID = UnitGUID
|
||||
local SetCVar = SetCVar
|
||||
local WorldFrame = WorldFrame
|
||||
local WorldGetNumChildren, WorldGetChildren = WorldFrame.GetNumChildren, WorldFrame.GetChildren
|
||||
|
||||
local numChildren = 0
|
||||
local isTarget = false
|
||||
local BORDER = "Interface\\Tooltips\\Nameplate-Border"
|
||||
local FSPAT = "%s*"
|
||||
local queryList = {}
|
||||
|
||||
local RaidIconCoordinate = {
|
||||
[0] = {[0] = "STAR", [0.25] = "MOON"},
|
||||
[0.25] = {[0] = "CIRCLE", [0.25] = "SQUARE"},
|
||||
[0.5] = {[0] = "DIAMOND", [0.25] = "CROSS"},
|
||||
[0.75] = {[0] = "TRIANGLE", [0.25] = "SKULL"}
|
||||
}
|
||||
|
||||
local healClasses = {
|
||||
["DRUID"] = true,
|
||||
["HUNTER"] = false,
|
||||
["MAGE"] = false,
|
||||
["PALADIN"] = true,
|
||||
["PRIEST"] = true,
|
||||
["ROGUE"] = false,
|
||||
["SHAMAN"] = true,
|
||||
["WARLOCK"] = false,
|
||||
["WARRIOR"] = false
|
||||
}
|
||||
|
||||
mod.CreatedPlates = {}
|
||||
mod.VisiblePlates = {}
|
||||
mod.Healers = {}
|
||||
|
||||
function mod:CheckFilter(frame)
|
||||
--[[local db = E.global.nameplates["filter"][frame.UnitName]
|
||||
if db and db.enable then
|
||||
if db.hide then
|
||||
frame:Hide()
|
||||
return
|
||||
else
|
||||
if not frame:IsShown() then
|
||||
frame:Show()
|
||||
end
|
||||
|
||||
if db.customColor then
|
||||
frame.CustomColor = db.color
|
||||
frame.HealthBar:SetStatusBarColor(db.color.r, db.color.g, db.color.b)
|
||||
else
|
||||
frame.CustomColor = nil
|
||||
end
|
||||
|
||||
if db.customScale and db.customScale ~= 1 then
|
||||
frame.CustomScale = db.customScale
|
||||
else
|
||||
frame.CustomScale = nil
|
||||
end
|
||||
end
|
||||
elseif not frame:IsShown() then
|
||||
frame:Show()
|
||||
end]]
|
||||
return true
|
||||
end
|
||||
|
||||
function mod:CheckBGHealers()
|
||||
local name, class, damageDone, healingDone, _
|
||||
for i = 1, GetNumBattlefieldScores() do
|
||||
name, _, _, _, _, _, _, _, _, class, damageDone, healingDone = GetBattlefieldScore(i)
|
||||
if name and class and healClasses[class] then
|
||||
name = name:match("(.+)%-.+") or name
|
||||
if name and healingDone > (damageDone * 2) then
|
||||
self.Healers[name] = true
|
||||
elseif name and self.Healers[name] then
|
||||
self.Healers[name] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:SetFrameScale(frame, scale)
|
||||
if frame.HealthBar.currentScale ~= scale then
|
||||
if frame.HealthBar.scale:IsPlaying() then
|
||||
frame.HealthBar.scale:Stop()
|
||||
end
|
||||
frame.HealthBar.scale.width:SetChange(self.db.units[frame.UnitType].healthbar.width * scale)
|
||||
frame.HealthBar.scale.height:SetChange(self.db.units[frame.UnitType].healthbar.height * scale)
|
||||
frame.HealthBar.scale:Play()
|
||||
frame.HealthBar.currentScale = scale
|
||||
end
|
||||
end
|
||||
|
||||
function mod:SetTargetFrame(frame)
|
||||
if isTarget then return end
|
||||
|
||||
local targetExists = UnitExists("target") == 1
|
||||
if targetExists and frame:GetParent():IsShown() and frame:GetParent():GetAlpha() == 1 then
|
||||
if self.db.useTargetScale then
|
||||
self:SetFrameScale(frame, (frame.CustomScale and frame.CustomScale * self.db.targetScale) or self.db.targetScale)
|
||||
end
|
||||
frame.isTarget = true
|
||||
frame.unit = "target"
|
||||
-- frame.guid = UnitGUID("target")
|
||||
|
||||
if self.db.units[frame.UnitType].healthbar.enable ~= true then
|
||||
frame.Name:ClearAllPoints()
|
||||
frame.Level:ClearAllPoints()
|
||||
frame.HealthBar.r, frame.HealthBar.g, frame.HealthBar.b = nil, nil, nil
|
||||
self:ConfigureElement_HealthBar(frame)
|
||||
self:ConfigureElement_CastBar(frame)
|
||||
self:ConfigureElement_Glow(frame)
|
||||
self:ConfigureElement_Level(frame)
|
||||
self:ConfigureElement_Name(frame)
|
||||
|
||||
self:UpdateElement_All(frame, true)
|
||||
end
|
||||
|
||||
--[[if UnitCastingInfo("target") then
|
||||
frame:GetScript("OnEvent")(frame, "UNIT_SPELLCAST_START", "target")
|
||||
elseif UnitChannelInfo("target") then
|
||||
frame:GetScript("OnEvent")(frame, "UNIT_SPELLCAST_CHANNEL_START", "target")
|
||||
end]]
|
||||
|
||||
frame:SetAlpha(1)
|
||||
|
||||
mod:UpdateElement_AurasByUnitID("target")
|
||||
elseif frame.isTarget then
|
||||
if self.db.useTargetScale then
|
||||
self:SetFrameScale(frame, frame.CustomScale or frame.ThreatScale or 1)
|
||||
end
|
||||
frame.isTarget = nil
|
||||
frame.unit = nil
|
||||
-- frame.guid = nil
|
||||
if self.db.units[frame.UnitType].healthbar.enable ~= true then
|
||||
self:UpdateAllFrame(frame)
|
||||
end
|
||||
|
||||
if targetExists then
|
||||
frame:SetAlpha(self.db.nonTargetTransparency)
|
||||
else
|
||||
frame:SetAlpha(1)
|
||||
end
|
||||
else
|
||||
if targetExists then
|
||||
frame:SetAlpha(self.db.nonTargetTransparency)
|
||||
else
|
||||
frame:SetAlpha(1)
|
||||
end
|
||||
end
|
||||
|
||||
mod:UpdateElement_HealthColor(frame)
|
||||
mod:UpdateElement_Glow(frame)
|
||||
mod:UpdateElement_CPoints(frame)
|
||||
|
||||
return frame.isTarget
|
||||
end
|
||||
|
||||
function mod:GetNumVisiblePlates()
|
||||
local i = 0
|
||||
for _ in pairs(mod.VisiblePlates) do
|
||||
i = i + 1
|
||||
end
|
||||
return i
|
||||
end
|
||||
|
||||
function mod:StyleFrame(parent, noBackdrop, point)
|
||||
point = point or parent
|
||||
local noscalemult = E.mult * UIParent:GetScale()
|
||||
|
||||
if point.bordertop then return end
|
||||
|
||||
if not noBackdrop then
|
||||
point.backdrop = parent:CreateTexture(nil, "BACKGROUND")
|
||||
point.backdrop:SetAllPoints(point)
|
||||
point.backdrop:SetTexture(unpack(E["media"].backdropfadecolor))
|
||||
end
|
||||
|
||||
if E.PixelMode then
|
||||
point.bordertop = parent:CreateTexture()
|
||||
point.bordertop:SetPoint("TOPLEFT", point, "TOPLEFT", -noscalemult, noscalemult)
|
||||
point.bordertop:SetPoint("TOPRIGHT", point, "TOPRIGHT", noscalemult, noscalemult)
|
||||
point.bordertop:SetHeight(noscalemult)
|
||||
point.bordertop:SetTexture(unpack(E["media"].bordercolor))
|
||||
|
||||
point.borderbottom = parent:CreateTexture()
|
||||
point.borderbottom:SetPoint("BOTTOMLEFT", point, "BOTTOMLEFT", -noscalemult, -noscalemult)
|
||||
point.borderbottom:SetPoint("BOTTOMRIGHT", point, "BOTTOMRIGHT", noscalemult, -noscalemult)
|
||||
point.borderbottom:SetHeight(noscalemult)
|
||||
point.borderbottom:SetTexture(unpack(E["media"].bordercolor))
|
||||
|
||||
point.borderleft = parent:CreateTexture()
|
||||
point.borderleft:SetPoint("TOPLEFT", point, "TOPLEFT", -noscalemult, noscalemult)
|
||||
point.borderleft:SetPoint("BOTTOMLEFT", point, "BOTTOMLEFT", noscalemult, -noscalemult)
|
||||
point.borderleft:SetWidth(noscalemult)
|
||||
point.borderleft:SetTexture(unpack(E["media"].bordercolor))
|
||||
|
||||
point.borderright = parent:CreateTexture()
|
||||
point.borderright:SetPoint("TOPRIGHT", point, "TOPRIGHT", noscalemult, noscalemult)
|
||||
point.borderright:SetPoint("BOTTOMRIGHT", point, "BOTTOMRIGHT", -noscalemult, -noscalemult)
|
||||
point.borderright:SetWidth(noscalemult)
|
||||
point.borderright:SetTexture(unpack(E["media"].bordercolor))
|
||||
else
|
||||
point.bordertop = parent:CreateTexture(nil, "OVERLAY")
|
||||
point.bordertop:SetPoint("TOPLEFT", point, "TOPLEFT", -noscalemult, noscalemult*2)
|
||||
point.bordertop:SetPoint("TOPRIGHT", point, "TOPRIGHT", noscalemult, noscalemult*2)
|
||||
point.bordertop:SetHeight(noscalemult)
|
||||
point.bordertop:SetTexture(unpack(E.media.bordercolor))
|
||||
|
||||
point.bordertop.backdrop = parent:CreateTexture()
|
||||
point.bordertop.backdrop:SetPoint("TOPLEFT", point.bordertop, "TOPLEFT", noscalemult, noscalemult)
|
||||
point.bordertop.backdrop:SetPoint("TOPRIGHT", point.bordertop, "TOPRIGHT", -noscalemult, noscalemult)
|
||||
point.bordertop.backdrop:SetHeight(noscalemult * 3)
|
||||
point.bordertop.backdrop:SetTexture(0, 0, 0)
|
||||
|
||||
point.borderbottom = parent:CreateTexture(nil, "OVERLAY")
|
||||
point.borderbottom:SetPoint("BOTTOMLEFT", point, "BOTTOMLEFT", -noscalemult, -noscalemult*2)
|
||||
point.borderbottom:SetPoint("BOTTOMRIGHT", point, "BOTTOMRIGHT", noscalemult, -noscalemult*2)
|
||||
point.borderbottom:SetHeight(noscalemult)
|
||||
point.borderbottom:SetTexture(unpack(E.media.bordercolor))
|
||||
|
||||
point.borderbottom.backdrop = parent:CreateTexture()
|
||||
point.borderbottom.backdrop:SetPoint("BOTTOMLEFT", point.borderbottom, "BOTTOMLEFT", noscalemult, -noscalemult)
|
||||
point.borderbottom.backdrop:SetPoint("BOTTOMRIGHT", point.borderbottom, "BOTTOMRIGHT", -noscalemult, -noscalemult)
|
||||
point.borderbottom.backdrop:SetHeight(noscalemult * 3)
|
||||
point.borderbottom.backdrop:SetTexture(0, 0, 0)
|
||||
|
||||
point.borderleft = parent:CreateTexture(nil, "OVERLAY")
|
||||
point.borderleft:SetPoint("TOPLEFT", point, "TOPLEFT", -noscalemult*2, noscalemult*2)
|
||||
point.borderleft:SetPoint("BOTTOMLEFT", point, "BOTTOMLEFT", noscalemult*2, -noscalemult*2)
|
||||
point.borderleft:SetWidth(noscalemult)
|
||||
point.borderleft:SetTexture(unpack(E.media.bordercolor))
|
||||
|
||||
point.borderleft.backdrop = parent:CreateTexture()
|
||||
point.borderleft.backdrop:SetPoint("TOPLEFT", point.borderleft, "TOPLEFT", -noscalemult, noscalemult)
|
||||
point.borderleft.backdrop:SetPoint("BOTTOMLEFT", point.borderleft, "BOTTOMLEFT", -noscalemult, -noscalemult)
|
||||
point.borderleft.backdrop:SetWidth(noscalemult * 3)
|
||||
point.borderleft.backdrop:SetTexture(0, 0, 0)
|
||||
|
||||
point.borderright = parent:CreateTexture(nil, "OVERLAY")
|
||||
point.borderright:SetPoint("TOPRIGHT", point, "TOPRIGHT", noscalemult*2, noscalemult*2)
|
||||
point.borderright:SetPoint("BOTTOMRIGHT", point, "BOTTOMRIGHT", -noscalemult*2, -noscalemult*2)
|
||||
point.borderright:SetWidth(noscalemult)
|
||||
point.borderright:SetTexture(unpack(E.media.bordercolor))
|
||||
|
||||
point.borderright.backdrop = parent:CreateTexture()
|
||||
point.borderright.backdrop:SetPoint("TOPRIGHT", point.borderright, "TOPRIGHT", noscalemult, noscalemult)
|
||||
point.borderright.backdrop:SetPoint("BOTTOMRIGHT", point.borderright, "BOTTOMRIGHT", noscalemult, -noscalemult)
|
||||
point.borderright.backdrop:SetWidth(noscalemult * 3)
|
||||
point.borderright.backdrop:SetTexture(0, 0, 0)
|
||||
end
|
||||
end
|
||||
|
||||
function mod:RoundColors(r, g, b)
|
||||
return floor(r*100+.5) / 100, floor(g*100+.5) / 100, floor(b*100+.5) / 100
|
||||
end
|
||||
|
||||
function mod:UnitClass(name, type)
|
||||
if E.private.general.classCache then
|
||||
if type == "FRIENDLY_PLAYER" then
|
||||
local _, class = UnitClass(name)
|
||||
if class then
|
||||
return class
|
||||
else
|
||||
local name, realm = split("-", name)
|
||||
--return CC:GetClassByName(name, realm)
|
||||
end
|
||||
end
|
||||
else
|
||||
if type == "FRIENDLY_PLAYER" then
|
||||
--return select(2, UnitClass(name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:UnitDetailedThreatSituation(frame)
|
||||
return false
|
||||
end
|
||||
|
||||
function mod:UnitLevel(frame)
|
||||
local level, boss = frame.oldLevel:GetObjectType() == "FontString" and tonumber(frame.oldLevel:GetText()) or false, frame.BossIcon:IsShown()
|
||||
if boss or not level then
|
||||
return "??", 0.9, 0, 0
|
||||
else
|
||||
return level, frame.oldLevel:GetTextColor()
|
||||
end
|
||||
end
|
||||
|
||||
function mod:GetUnitInfo(frame)
|
||||
--[[if UnitExists("target") == 1 and frame:GetParent():IsShown() and frame:GetParent():GetAlpha() == 1 then
|
||||
if UnitIsPlayer("target") then
|
||||
if UnitIsEnemy("target", "player") then
|
||||
return 2, "ENEMY_PLAYER"
|
||||
else
|
||||
return 5, "FRIENDLY_PLAYER"
|
||||
end
|
||||
else
|
||||
if UnitIsEnemy("target", "player") then
|
||||
return 2, "ENEMY_NPC"
|
||||
elseif UnitReaction("target", "player") == 4 then
|
||||
return 4, "ENEMY_NPC"
|
||||
else
|
||||
return 5, "FRIENDLY_NPC"
|
||||
end
|
||||
end
|
||||
end]]
|
||||
|
||||
local r, g, b = mod:RoundColors(frame.oldHealthBar:GetStatusBarColor())
|
||||
if r == 1 and g == 0 and b == 0 then
|
||||
return 2, "ENEMY_NPC"
|
||||
elseif r == 0 and g == 0 and b == 1 then
|
||||
return 5, "FRIENDLY_PLAYER"
|
||||
elseif r == 0 and g == 1 and b == 0 then
|
||||
return 5, "FRIENDLY_NPC"
|
||||
elseif r == 1 and g == 1 and b == 0 then
|
||||
return 4, "ENEMY_NPC"
|
||||
end
|
||||
end
|
||||
|
||||
function mod:OnShow(self)
|
||||
isTarget = false
|
||||
|
||||
self:SetWidth(0.01)
|
||||
self:SetHeight(0.01)
|
||||
|
||||
mod.VisiblePlates[self.UnitFrame] = true
|
||||
|
||||
self.UnitFrame.UnitName = gsub(self.UnitFrame.oldName:GetText(), FSPAT, "")
|
||||
local unitReaction, unitType = mod:GetUnitInfo(self.UnitFrame)
|
||||
self.UnitFrame.UnitType = unitType
|
||||
self.UnitFrame.UnitClass = mod:UnitClass(self.UnitFrame.oldName:GetText(), unitType)
|
||||
self.UnitFrame.UnitReaction = unitReaction
|
||||
|
||||
if not self.UnitFrame.UnitClass then
|
||||
queryList[self.UnitFrame.UnitName] = self.UnitFrame
|
||||
end
|
||||
|
||||
if unitType == "ENEMY_NPC" and self.UnitFrame.UnitClass then
|
||||
unitType = "ENEMY_PLAYER"
|
||||
self.UnitFrame.UnitType = unitType
|
||||
end
|
||||
|
||||
if not mod:CheckFilter(self.UnitFrame) then return end
|
||||
|
||||
if unitType == "ENEMY_PLAYER" then
|
||||
mod:UpdateElement_HealerIcon(self.UnitFrame)
|
||||
end
|
||||
|
||||
self.UnitFrame.Level:ClearAllPoints()
|
||||
self.UnitFrame.Name:ClearAllPoints()
|
||||
|
||||
mod:ConfigureElement_HealthBar(self.UnitFrame)
|
||||
if mod.db.units[unitType].healthbar.enable then
|
||||
mod:ConfigureElement_CastBar(self.UnitFrame)
|
||||
mod:ConfigureElement_Glow(self.UnitFrame)
|
||||
|
||||
if mod.db.units[unitType].buffs.enable then
|
||||
self.UnitFrame.Buffs.db = mod.db.units[unitType].buffs
|
||||
mod:UpdateAuraIcons(self.UnitFrame.Buffs)
|
||||
end
|
||||
|
||||
if mod.db.units[unitType].debuffs.enable then
|
||||
self.UnitFrame.Debuffs.db = mod.db.units[unitType].debuffs
|
||||
mod:UpdateAuraIcons(self.UnitFrame.Debuffs)
|
||||
end
|
||||
end
|
||||
|
||||
if mod.db.units[unitType].healthbar.enable then
|
||||
mod:ConfigureElement_Name(self.UnitFrame)
|
||||
mod:ConfigureElement_Level(self.UnitFrame)
|
||||
else
|
||||
mod:ConfigureElement_Level(self.UnitFrame)
|
||||
mod:ConfigureElement_Name(self.UnitFrame)
|
||||
end
|
||||
|
||||
--[[if(mod.db.units[unitType].castbar.enable) then
|
||||
self.UnitFrame:RegisterEvent("UNIT_SPELLCAST_START")
|
||||
self.UnitFrame:RegisterEvent("UNIT_SPELLCAST_STOP")
|
||||
self.UnitFrame:RegisterEvent("UNIT_SPELLCAST_FAILED")
|
||||
self.UnitFrame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
|
||||
self.UnitFrame:RegisterEvent("UNIT_SPELLCAST_DELAYED")
|
||||
self.UnitFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
|
||||
self.UnitFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
|
||||
self.UnitFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
|
||||
end]]
|
||||
|
||||
mod:UpdateElement_All(self.UnitFrame)
|
||||
|
||||
self.UnitFrame:Show()
|
||||
end
|
||||
|
||||
function mod:OnHide(self)
|
||||
--local self = this
|
||||
mod.VisiblePlates[self.UnitFrame] = nil
|
||||
|
||||
self.UnitFrame.unit = nil
|
||||
|
||||
mod:HideAuraIcons(self.UnitFrame.Buffs)
|
||||
mod:HideAuraIcons(self.UnitFrame.Debuffs)
|
||||
self.UnitFrame.Glow.r, self.UnitFrame.Glow.g, self.UnitFrame.Glow.b = nil, nil, nil
|
||||
self.UnitFrame.Glow:Hide()
|
||||
self.UnitFrame.HealthBar.r, self.UnitFrame.HealthBar.g, self.UnitFrame.HealthBar.b = nil, nil, nil
|
||||
self.UnitFrame.HealthBar:Hide()
|
||||
--self.UnitFrame.CastBar:Hide()
|
||||
self.UnitFrame.Level:ClearAllPoints()
|
||||
self.UnitFrame.Level:SetText("")
|
||||
self.UnitFrame.Name:ClearAllPoints()
|
||||
self.UnitFrame.Name:SetText("")
|
||||
self.UnitFrame.CPoints:Hide()
|
||||
self.UnitFrame:Hide()
|
||||
self.UnitFrame.isTarget = nil
|
||||
self.UnitFrame.displayedUnit = nil
|
||||
self.ThreatData = nil
|
||||
self.UnitFrame.UnitName = nil
|
||||
self.UnitFrame.UnitType = nil
|
||||
self.UnitFrame.ThreatScale = nil
|
||||
|
||||
self.UnitFrame.ThreatReaction = nil
|
||||
self.UnitFrame.guid = nil
|
||||
self.UnitFrame.RaidIconType = nil
|
||||
self.UnitFrame.CustomColor = nil
|
||||
self.UnitFrame.CustomScale = nil
|
||||
end
|
||||
|
||||
function mod:UpdateAllFrame(frame)
|
||||
mod:OnHide(frame:GetParent())
|
||||
mod:OnShow(frame:GetParent())
|
||||
end
|
||||
|
||||
function mod:ConfigureAll()
|
||||
if E.private.nameplates.enable ~= true then return end
|
||||
|
||||
self:ForEachPlate("UpdateAllFrame")
|
||||
self:UpdateCVars()
|
||||
end
|
||||
|
||||
function mod:ForEachPlate(functionToRun, ...)
|
||||
for frame in pairs(self.CreatedPlates) do
|
||||
if frame and frame.UnitFrame then
|
||||
self[functionToRun](self, frame.UnitFrame, unpack(arg))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:UpdateElement_All(frame, noTargetFrame)
|
||||
if self.db.units[frame.UnitType].healthbar.enable or frame.isTarget then
|
||||
self:UpdateElement_Health(frame)
|
||||
self:UpdateElement_HealthColor(frame)
|
||||
self:UpdateElement_Auras(frame)
|
||||
end
|
||||
self:UpdateElement_RaidIcon(frame)
|
||||
self:UpdateElement_HealerIcon(frame)
|
||||
self:UpdateElement_Name(frame)
|
||||
self:UpdateElement_Level(frame)
|
||||
|
||||
if not noTargetFrame then
|
||||
mod:ScheduleTimer("ForEachPlate", 0.25, 1, "SetTargetFrame")
|
||||
end
|
||||
end
|
||||
|
||||
function mod:OnCreated(frame)
|
||||
isTarget = false
|
||||
local HealthBar, CastBar = frame:GetChildren()
|
||||
local Border, Highlight, Name, Level, BossIcon, RaidIcon = frame:GetRegions()
|
||||
|
||||
frame.UnitFrame = CreateFrame("Button", nil, frame)
|
||||
frame.UnitFrame:SetWidth(100)
|
||||
frame.UnitFrame:SetHeight(20)
|
||||
frame.UnitFrame:SetPoint("CENTER", 0, 0)
|
||||
frame.UnitFrame:SetScript("OnEvent", self.OnEvent)
|
||||
frame.UnitFrame:SetScript("OnClick", function()
|
||||
frame:Click()
|
||||
end)
|
||||
|
||||
frame.UnitFrame.HealthBar = self:ConstructElement_HealthBar(frame.UnitFrame)
|
||||
frame.UnitFrame.CastBar = self:ConstructElement_CastBar(frame.UnitFrame)
|
||||
frame.UnitFrame.Level = self:ConstructElement_Level(frame.UnitFrame)
|
||||
frame.UnitFrame.Name = self:ConstructElement_Name(frame.UnitFrame)
|
||||
frame.UnitFrame.Glow = self:ConstructElement_Glow(frame.UnitFrame)
|
||||
frame.UnitFrame.Buffs = self:ConstructElement_Auras(frame.UnitFrame, "LEFT")
|
||||
frame.UnitFrame.Debuffs = self:ConstructElement_Auras(frame.UnitFrame, "RIGHT")
|
||||
frame.UnitFrame.HealerIcon = self:ConstructElement_HealerIcon(frame.UnitFrame)
|
||||
frame.UnitFrame.CPoints = self:ConstructElement_CPoints(frame.UnitFrame)
|
||||
|
||||
--self:QueueObject(CastBarBorder)
|
||||
--self:QueueObject(CastBarIcon)
|
||||
self:QueueObject(HealthBar)
|
||||
--self:QueueObject(CastBar)
|
||||
self:QueueObject(Level)
|
||||
self:QueueObject(Name)
|
||||
self:QueueObject(Border)
|
||||
self:QueueObject(Highlight)
|
||||
--CastBar:Kill()
|
||||
--CastBarIcon:SetParent(E.HiddenFrame)
|
||||
BossIcon:SetAlpha(0)
|
||||
|
||||
frame.UnitFrame.oldHealthBar = HealthBar
|
||||
frame.UnitFrame.oldCastBar = CastBar
|
||||
--frame.UnitFrame.oldCastBar.Icon = CastBarIcon
|
||||
frame.UnitFrame.oldName = Name
|
||||
frame.UnitFrame.oldHighlight = Highlight
|
||||
frame.UnitFrame.oldLevel = Level
|
||||
|
||||
RaidIcon:SetParent(frame.UnitFrame)
|
||||
frame.UnitFrame.RaidIcon = RaidIcon
|
||||
|
||||
frame.UnitFrame.BossIcon = BossIcon
|
||||
|
||||
self:OnShow(frame)
|
||||
|
||||
HookScript(frame, "OnShow", function() self:OnShow(this) end)
|
||||
HookScript(frame, "OnHide", function() self:OnHide(this) end)
|
||||
|
||||
HookScript(HealthBar, "OnValueChanged", self.UpdateElement_HealthOnValueChanged)
|
||||
|
||||
self.CreatedPlates[frame] = true
|
||||
self.VisiblePlates[frame.UnitFrame] = true
|
||||
end
|
||||
|
||||
function mod:OnEvent(event, unit, ...)
|
||||
if not self.unit then return end
|
||||
|
||||
mod:UpdateElement_Cast(self, event, unit, unpack(arg))
|
||||
end
|
||||
|
||||
function mod:QueueObject(object)
|
||||
local objectType = object:GetObjectType()
|
||||
if objectType == "Texture" then
|
||||
object:SetTexture("")
|
||||
object:SetTexCoord(0, 0, 0, 0)
|
||||
elseif objectType == "FontString" then
|
||||
object:SetWidth(0.001)
|
||||
elseif objectType == "StatusBar" then
|
||||
object:SetStatusBarTexture("")
|
||||
end
|
||||
object:Hide()
|
||||
end
|
||||
|
||||
function mod:OnUpdate(elapsed)
|
||||
local count = WorldGetNumChildren(WorldFrame)
|
||||
if count ~= numChildren then
|
||||
for i = numChildren + 1, count do
|
||||
local frame = select(i, WorldGetChildren(WorldFrame))
|
||||
local region = frame:GetRegions()
|
||||
|
||||
if(not mod.CreatedPlates[frame] and region and region:GetObjectType() == "Texture" and region:GetTexture() == BORDER) then
|
||||
mod:OnCreated(frame)
|
||||
end
|
||||
end
|
||||
numChildren = count
|
||||
end
|
||||
|
||||
local i = 0
|
||||
for frame in pairs(mod.VisiblePlates) do
|
||||
i = i + 1
|
||||
|
||||
local getTarget = mod:SetTargetFrame(frame)
|
||||
if not getTarget then
|
||||
frame:GetParent():SetAlpha(1)
|
||||
end
|
||||
|
||||
if i == mod:GetNumVisiblePlates() then
|
||||
isTarget = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:CheckRaidIcon(frame)
|
||||
if frame.RaidIcon:IsShown() then
|
||||
local ux, uy = frame.RaidIcon:GetTexCoord()
|
||||
frame.RaidIconType = RaidIconCoordinate[ux][uy]
|
||||
else
|
||||
frame.RaidIconType = nil
|
||||
end
|
||||
end
|
||||
|
||||
function mod:SearchNameplateByGUID(guid)
|
||||
for frame in pairs(self.VisiblePlates) do
|
||||
if frame and frame:IsShown() and frame.guid == guid then
|
||||
return frame
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:SearchNameplateByName(sourceName)
|
||||
if not sourceName then return end
|
||||
local SearchFor = strsplit("-", sourceName)
|
||||
for frame in pairs(self.VisiblePlates) do
|
||||
if frame and frame:IsShown() and frame.UnitName == SearchFor and RAID_CLASS_COLORS[frame.UnitClass] then
|
||||
return frame
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:SearchNameplateByIconName(raidIcon)
|
||||
for frame in pairs(self.VisiblePlates) do
|
||||
self:CheckRaidIcon(frame)
|
||||
if frame and frame:IsShown() and frame.RaidIcon:IsShown() and (frame.RaidIconType == raidIcon) then
|
||||
return frame
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:SearchForFrame(guid, raidIcon, name)
|
||||
local frame
|
||||
if guid then frame = self:SearchNameplateByGUID(guid) end
|
||||
if (not frame) and name then frame = self:SearchNameplateByName(name) end
|
||||
if (not frame) and raidIcon then frame = self:SearchNameplateByIconName(raidIcon) end
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
function mod:UpdateCVars()
|
||||
-- SetCVar("showVKeyCastbar", "1")
|
||||
-- SetCVar("nameplateAllowOverlap", self.db.motionType == "STACKED" and "0" or "1")
|
||||
end
|
||||
|
||||
local function CopySettings(from, to)
|
||||
for setting, value in pairs(from) do
|
||||
if type(value) == "table" then
|
||||
CopySettings(from[setting], to[setting])
|
||||
else
|
||||
if to[setting] ~= nil then
|
||||
to[setting] = from[setting]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:ResetSettings(unit)
|
||||
CopySettings(P.nameplates.units[unit], self.db.units[unit])
|
||||
end
|
||||
|
||||
function mod:CopySettings(from, to)
|
||||
if from == to then return end
|
||||
|
||||
CopySettings(self.db.units[from], self.db.units[to])
|
||||
end
|
||||
|
||||
function mod:PLAYER_ENTERING_WORLD()
|
||||
self:CleanAuraLists()
|
||||
twipe(self.Healers)
|
||||
local inInstance, instanceType = IsInInstance()
|
||||
if inInstance and instanceType == "pvp" and self.db.units.ENEMY_PLAYER.markHealers then
|
||||
self.CheckHealerTimer = self:ScheduleRepeatingTimer("CheckBGHealers", 3)
|
||||
self:CheckBGHealers()
|
||||
else
|
||||
if self.CheckHealerTimer then
|
||||
self:CancelTimer(self.CheckHealerTimer)
|
||||
self.CheckHealerTimer = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mod:PLAYER_TARGET_CHANGED()
|
||||
isTarget = false
|
||||
end
|
||||
|
||||
function mod:UNIT_AURA(_, unit)
|
||||
if unit == "target" then
|
||||
self:UpdateElement_AurasByUnitID("target")
|
||||
end
|
||||
end
|
||||
|
||||
function mod:PLAYER_COMBO_POINTS()
|
||||
self:ForEachPlate("UpdateElement_CPoints")
|
||||
end
|
||||
|
||||
function mod:PLAYER_REGEN_DISABLED()
|
||||
if self.db.showFriendlyCombat == "TOGGLE_ON" then
|
||||
ShowFriendNameplates();
|
||||
elseif self.db.showFriendlyCombat == "TOGGLE_OFF" then
|
||||
HideFriendNameplates();
|
||||
end
|
||||
|
||||
if self.db.showEnemyCombat == "TOGGLE_ON" then
|
||||
ShowNameplates();
|
||||
elseif self.db.showEnemyCombat == "TOGGLE_OFF" then
|
||||
HideNameplates();
|
||||
end
|
||||
end
|
||||
|
||||
function mod:PLAYER_REGEN_ENABLED()
|
||||
self:CleanAuraLists()
|
||||
if self.db.showFriendlyCombat == "TOGGLE_ON" then
|
||||
HideFriendNameplates();
|
||||
elseif self.db.showFriendlyCombat == "TOGGLE_OFF" then
|
||||
ShowFriendNameplates();
|
||||
end
|
||||
|
||||
if self.db.showEnemyCombat == "TOGGLE_ON" then
|
||||
HideNameplates();
|
||||
elseif self.db.showEnemyCombat == "TOGGLE_OFF" then
|
||||
ShowNameplates();
|
||||
end
|
||||
end
|
||||
|
||||
--[[function mod:ClassCacheQueryResult(_, name, class)
|
||||
if queryList[name] then
|
||||
local frame = queryList[name]
|
||||
|
||||
if frame.UnitType then
|
||||
if frame.UnitType == "ENEMY_NPC" then
|
||||
frame.UnitType = "ENEMY_PLAYER"
|
||||
end
|
||||
frame.UnitClass = class
|
||||
|
||||
if self.db.units[frame.UnitType].healthbar.enable then
|
||||
self:UpdateElement_HealthColor(frame)
|
||||
end
|
||||
self:UpdateElement_Name(frame)
|
||||
end
|
||||
|
||||
queryList[name] = nil
|
||||
end
|
||||
end]]
|
||||
|
||||
function mod:Initialize()
|
||||
self.db = E.db["nameplates"]
|
||||
if E.private["nameplates"].enable ~= true then return end
|
||||
|
||||
self:UpdateCVars()
|
||||
|
||||
self.Frame = CreateFrame("Frame"):SetScript("OnUpdate", self.OnUpdate)
|
||||
|
||||
self:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
self:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
self:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
self:RegisterEvent("PLAYER_TARGET_CHANGED")
|
||||
--self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||
--self:RegisterEvent("UNIT_AURA")
|
||||
--self:RegisterEvent("PLAYER_COMBO_POINTS")
|
||||
|
||||
--self:RegisterMessage("ClassCacheQueryResult")
|
||||
|
||||
E.NamePlates = self
|
||||
end
|
||||
|
||||
local function InitializeCallback()
|
||||
mod:Initialize()
|
||||
end
|
||||
|
||||
E:RegisterModule(mod:GetName(), InitializeCallback)
|
||||
@@ -23,6 +23,10 @@ V["bags"] = {
|
||||
["bagBar"] = false,
|
||||
}
|
||||
|
||||
V["nameplates"] = {
|
||||
["enable"] = true,
|
||||
}
|
||||
|
||||
V["auras"] = {
|
||||
["enable"] = true,
|
||||
["disableBlizzard"] = true,
|
||||
|
||||
@@ -105,6 +105,249 @@ P["databars"] = {
|
||||
},
|
||||
}
|
||||
|
||||
P["nameplates"] = {
|
||||
["statusbar"] = "ElvUI Norm",
|
||||
["font"] = "Homespun",
|
||||
["fontSize"] = 8,
|
||||
["fontOutline"] = "MONOCHROMEOUTLINE",
|
||||
["useTargetScale"] = true,
|
||||
["targetScale"] = 1.15,
|
||||
["nonTargetTransparency"] = 0.35,
|
||||
["motionType"] = "OVERLAP",
|
||||
["lowHealthThreshold"] = 0.4,
|
||||
|
||||
["showFriendlyCombat"] = "DISABLED",
|
||||
["showEnemyCombat"] = "DISABLED",
|
||||
|
||||
["clampToScreen"] = false,
|
||||
["useTargetGlow"] = true,
|
||||
|
||||
["castColor"] = {r = 1, g = 208/255, b = 0},
|
||||
["comboPoints"] = true,
|
||||
["reactions"] = {
|
||||
["friendlyPlayer"] = {r = 0.31, g = 0.45, b = 0.63},
|
||||
["tapped"] = {r = 0.6, g = 0.6, b = 0.6},
|
||||
["good"] = {r = 75/255, g = 175/255, b = 76/255},
|
||||
["neutral"] = {r = 218/255, g = 197/255, b = 92/255},
|
||||
["bad"] = {r = 0.78, g = 0.25, b = 0.25},
|
||||
},
|
||||
["threat"] = {
|
||||
["goodColor"] = {r = 75/255, g = 175/255, b = 76/255},
|
||||
["badColor"] = {r = 0.78, g = 0.25, b = 0.25},
|
||||
["goodTransition"] = {r = 218/255, g = 197/255, b = 92/255},
|
||||
["badTransition"] = {r = 235/255, g = 163/255, b = 40/255},
|
||||
["beingTankedByTankColor"] = {r = .8, g = 0.1,b = 1},
|
||||
["beingTankedByTank"] = true,
|
||||
["goodScale"] = 0.8,
|
||||
["badScale"] = 1.2,
|
||||
["useThreatColor"] = true,
|
||||
},
|
||||
|
||||
["units"] = {
|
||||
["FRIENDLY_PLAYER"] = {
|
||||
["healthbar"] = {
|
||||
["enable"] = false,
|
||||
["height"] = 10,
|
||||
["width"] = 150,
|
||||
["glowStyle"] = "TARGET_THREAT",
|
||||
["text"] = {
|
||||
["enable"] = false,
|
||||
["format"] = "CURRENT",
|
||||
},
|
||||
["useClassColor"] = true,
|
||||
},
|
||||
["showName"] = true,
|
||||
["showLevel"] = false,
|
||||
["castbar"] = {
|
||||
["enable"] = true,
|
||||
["height"] = 8,
|
||||
["offset"] = 1,
|
||||
["hideSpellName"] = false,
|
||||
["hideTime"] = false,
|
||||
["castTimeFormat"] = "CURRENT",
|
||||
["channelTimeFormat"] = "CURRENT",
|
||||
["timeToHold"] = 0
|
||||
},
|
||||
["buffs"] = {
|
||||
["enable"] = true,
|
||||
["numAuras"] = 4,
|
||||
["filters"] = {
|
||||
["personal"] = true,
|
||||
["maxDuration"] = 120,
|
||||
["filter"] = "TurtleBuffs"
|
||||
},
|
||||
},
|
||||
["debuffs"] = {
|
||||
["enable"] = true,
|
||||
["numAuras"] = 4,
|
||||
["baseHeight"] = 18,
|
||||
["filters"] = {
|
||||
["personal"] = true,
|
||||
["maxDuration"] = 120,
|
||||
["filter"] = "CCDebuffs"
|
||||
},
|
||||
},
|
||||
["name"] = {
|
||||
["useClassColor"] = true,
|
||||
},
|
||||
},
|
||||
["ENEMY_PLAYER"] = {
|
||||
["markHealers"] = true,
|
||||
["healthbar"] = {
|
||||
["enable"] = true,
|
||||
["height"] = 10,
|
||||
["width"] = 150,
|
||||
["glowStyle"] = "TARGET_THREAT",
|
||||
["text"] = {
|
||||
["enable"] = false,
|
||||
["format"] = "CURRENT",
|
||||
},
|
||||
["useClassColor"] = true,
|
||||
},
|
||||
["showName"] = true,
|
||||
["showLevel"] = true,
|
||||
["castbar"] = {
|
||||
["enable"] = true,
|
||||
["height"] = 8,
|
||||
["offset"] = 1,
|
||||
["hideSpellName"] = false,
|
||||
["hideTime"] = false,
|
||||
["castTimeFormat"] = "CURRENT",
|
||||
["channelTimeFormat"] = "CURRENT",
|
||||
["timeToHold"] = 0
|
||||
},
|
||||
["buffs"] = {
|
||||
["enable"] = true,
|
||||
["numAuras"] = 4,
|
||||
["baseHeight"] = 18,
|
||||
["filters"] = {
|
||||
["personal"] = true,
|
||||
["maxDuration"] = 120,
|
||||
["filter"] = "TurtleBuffs"
|
||||
},
|
||||
},
|
||||
["debuffs"] = {
|
||||
["enable"] = true,
|
||||
["numAuras"] = 4,
|
||||
["baseHeight"] = 18,
|
||||
["filters"] = {
|
||||
["personal"] = true,
|
||||
["maxDuration"] = 120,
|
||||
["filter"] = "CCDebuffs"
|
||||
},
|
||||
},
|
||||
["name"] = {
|
||||
["useClassColor"] = true,
|
||||
},
|
||||
},
|
||||
["FRIENDLY_NPC"] = {
|
||||
["healthbar"] = {
|
||||
["enable"] = false,
|
||||
["height"] = 10,
|
||||
["width"] = 150,
|
||||
["glowStyle"] = "TARGET_THREAT",
|
||||
["text"] = {
|
||||
["enable"] = false,
|
||||
["format"] = "CURRENT",
|
||||
},
|
||||
},
|
||||
["showName"] = true,
|
||||
["showLevel"] = true,
|
||||
["castbar"] = {
|
||||
["enable"] = true,
|
||||
["height"] = 8,
|
||||
["offset"] = 1,
|
||||
["hideSpellName"] = false,
|
||||
["hideTime"] = false,
|
||||
["castTimeFormat"] = "CURRENT",
|
||||
["channelTimeFormat"] = "CURRENT",
|
||||
["timeToHold"] = 0
|
||||
},
|
||||
["buffs"] = {
|
||||
["enable"] = true,
|
||||
["numAuras"] = 4,
|
||||
["baseHeight"] = 18,
|
||||
["filters"] = {
|
||||
["personal"] = true,
|
||||
["maxDuration"] = 120,
|
||||
["filter"] = "TurtleBuffs"
|
||||
},
|
||||
},
|
||||
["debuffs"] = {
|
||||
["enable"] = true,
|
||||
["numAuras"] = 4,
|
||||
["baseHeight"] = 18,
|
||||
["filters"] = {
|
||||
["personal"] = true,
|
||||
["maxDuration"] = 120,
|
||||
["filter"] = "CCDebuffs"
|
||||
},
|
||||
},
|
||||
["eliteIcon"] = {
|
||||
["enable"] = false,
|
||||
["size"] = 20,
|
||||
["position"] = "RIGHT",
|
||||
["xOffset"] = 15,
|
||||
["yOffset"] = 0,
|
||||
},
|
||||
},
|
||||
["ENEMY_NPC"] = {
|
||||
["healthbar"] = {
|
||||
["enable"] = true,
|
||||
["height"] = 10,
|
||||
["width"] = 150,
|
||||
["glowStyle"] = "TARGET_THREAT",
|
||||
["text"] = {
|
||||
["enable"] = false,
|
||||
["format"] = "CURRENT",
|
||||
},
|
||||
},
|
||||
["showName"] = true,
|
||||
["showLevel"] = true,
|
||||
["castbar"] = {
|
||||
["enable"] = true,
|
||||
["height"] = 8,
|
||||
["offset"] = 1,
|
||||
["hideSpellName"] = false,
|
||||
["hideTime"] = false,
|
||||
["castTimeFormat"] = "CURRENT",
|
||||
["channelTimeFormat"] = "CURRENT",
|
||||
["timeToHold"] = 0
|
||||
},
|
||||
["buffs"] = {
|
||||
["enable"] = true,
|
||||
["numAuras"] = 4,
|
||||
["baseHeight"] = 18,
|
||||
["filters"] = {
|
||||
["personal"] = true,
|
||||
["maxDuration"] = 120,
|
||||
["filter"] = "TurtleBuffs"
|
||||
},
|
||||
},
|
||||
["debuffs"] = {
|
||||
["enable"] = true,
|
||||
["numAuras"] = 4,
|
||||
["baseHeight"] = 18,
|
||||
["filters"] = {
|
||||
["personal"] = true,
|
||||
["maxDuration"] = 120,
|
||||
["filter"] = "CCDebuffs"
|
||||
},
|
||||
},
|
||||
["eliteIcon"] = {
|
||||
["enable"] = false,
|
||||
["size"] = 20,
|
||||
["position"] = "RIGHT",
|
||||
["xOffset"] = 15,
|
||||
["yOffset"] = 0,
|
||||
},
|
||||
["detection"] = {
|
||||
["enable"] = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
--Auras
|
||||
P["auras"] = {
|
||||
["font"] = "Homespun",
|
||||
|
||||
Reference in New Issue
Block a user