mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
remove temp folder structure
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user