init
This commit is contained in:
@@ -0,0 +1,463 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
local LSM = E.Libs.LSM
|
||||
local LAI = E.Libs.LAI
|
||||
|
||||
--Lua functions
|
||||
local select, unpack, pairs = select, unpack, pairs
|
||||
local band = bit.band
|
||||
local tinsert = table.insert
|
||||
local floor = math.floor
|
||||
local split = string.split
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
local GetSpellInfo = GetSpellInfo
|
||||
local GetTime = GetTime
|
||||
|
||||
local CREATED, VISIBLE, HIDDEN = 2, 1, 0
|
||||
|
||||
local positionValues = {
|
||||
BOTTOMLEFT = "TOP",
|
||||
BOTTOMRIGHT = "TOP",
|
||||
LEFT = "RIGHT",
|
||||
RIGHT = "LEFT",
|
||||
TOPLEFT = "BOTTOM",
|
||||
TOPRIGHT = "BOTTOM"
|
||||
}
|
||||
|
||||
local positionValues2 = {
|
||||
BOTTOMLEFT = "BOTTOM",
|
||||
BOTTOMRIGHT = "BOTTOM",
|
||||
LEFT = "LEFT",
|
||||
RIGHT = "RIGHT",
|
||||
TOPLEFT = "TOP",
|
||||
TOPRIGHT = "TOP"
|
||||
}
|
||||
|
||||
|
||||
local RaidIconBit = {
|
||||
["STAR"] = 0x00100000,
|
||||
["CIRCLE"] = 0x00200000,
|
||||
["DIAMOND"] = 0x00400000,
|
||||
["TRIANGLE"] = 0x00800000,
|
||||
["MOON"] = 0x01000000,
|
||||
["SQUARE"] = 0x02000000,
|
||||
["CROSS"] = 0x04000000,
|
||||
["SKULL"] = 0x08000000
|
||||
}
|
||||
|
||||
local ByRaidIcon = {}
|
||||
|
||||
function NP:LibAuraInfo_AURA_APPLIED(event, destGUID)
|
||||
self:UpdateElement_AurasByGUID(destGUID, event)
|
||||
end
|
||||
|
||||
function NP:LibAuraInfo_AURA_REMOVED(event, destGUID)
|
||||
self:UpdateElement_AurasByGUID(destGUID, event)
|
||||
end
|
||||
|
||||
function NP:LibAuraInfo_AURA_REFRESH(event, destGUID)
|
||||
self:LibAuraInfo_AURA_APPLIED(event, destGUID)
|
||||
end
|
||||
|
||||
function NP:LibAuraInfo_AURA_APPLIED_DOSE(event, destGUID)
|
||||
self:LibAuraInfo_AURA_APPLIED(event, destGUID)
|
||||
end
|
||||
|
||||
function NP:LibAuraInfo_AURA_CLEAR(event, destGUID)
|
||||
self:UpdateElement_AurasByGUID(destGUID, event)
|
||||
end
|
||||
|
||||
function NP:LibAuraInfo_UNIT_AURA(event, destGUID)
|
||||
self:UpdateElement_AurasByGUID(destGUID, event)
|
||||
end
|
||||
|
||||
function NP:UpdateTime(elapsed)
|
||||
self.timeLeft = self.timeLeft - elapsed
|
||||
self:SetValue(self.timeLeft)
|
||||
|
||||
if self.nextUpdate > 0 then
|
||||
self.nextUpdate = self.nextUpdate - elapsed
|
||||
return
|
||||
end
|
||||
|
||||
if self.timeLeft < 0 then
|
||||
self:SetScript("OnUpdate", nil)
|
||||
self:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
local value, id, nextUpdate, remainder = E:GetTimeInfo(self.timeLeft, self.threshold, self.hhmmThreshold, self.mmssThreshold)
|
||||
self.nextUpdate = nextUpdate
|
||||
|
||||
local style = E.TimeFormats[id]
|
||||
if style then
|
||||
local which = (self.textColors and 2 or 1) + (self.showSeconds and 0 or 2)
|
||||
if self.textColors then
|
||||
self.text:SetFormattedText(style[which], value, self.textColors[id], remainder)
|
||||
else
|
||||
self.text:SetFormattedText(style[which], value, remainder)
|
||||
end
|
||||
end
|
||||
|
||||
local color = self.timeColors[id]
|
||||
if color then
|
||||
self.text:SetTextColor(color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
|
||||
local unstableAffliction = GetSpellInfo(30108)
|
||||
local vampiricTouch = GetSpellInfo(34914)
|
||||
function NP:SetAura(frame, guid, index, filter, isDebuff, visible)
|
||||
local isAura, name, texture, count, debuffType, duration, expiration, caster, spellID, _ = LAI:GUIDAura(guid, index, filter)
|
||||
|
||||
if frame.forceShow or frame.forceCreate then
|
||||
spellID = 47540
|
||||
name, _, texture = GetSpellInfo(spellID)
|
||||
if frame.forceShow then
|
||||
isAura, count, debuffType, duration, expiration = true, 5, "Magic", 0, 0
|
||||
end
|
||||
end
|
||||
|
||||
if isAura then
|
||||
local position = visible + 1
|
||||
local button = frame[position] or NP:Construct_AuraIcon(frame, position)
|
||||
|
||||
button.caster = caster
|
||||
button.filter = filter
|
||||
button.isDebuff = isDebuff
|
||||
|
||||
local filterCheck = not frame.forceCreate
|
||||
if not (frame.forceShow or frame.forceCreate) then
|
||||
filterCheck = NP:AuraFilter(guid, button, name, texture, count, debuffType, duration, expiration, caster, spellID)
|
||||
end
|
||||
|
||||
if filterCheck then
|
||||
if button.icon then button.icon:SetTexture(texture) end
|
||||
if button.count then button.count:SetText(count > 1 and count) end
|
||||
|
||||
if duration > 0 and expiration ~= 0 then
|
||||
local timeLeft = expiration - GetTime()
|
||||
if timeLeft > 0 then
|
||||
button.timeLeft = timeLeft
|
||||
button.nextUpdate = 0
|
||||
|
||||
button:SetMinMaxValues(0, duration)
|
||||
button:SetValue(timeLeft)
|
||||
|
||||
button:SetScript("OnUpdate", NP.UpdateTime)
|
||||
-- else
|
||||
-- return HIDDEN
|
||||
end
|
||||
else
|
||||
button.timeLeft = nil
|
||||
button.text:SetText("")
|
||||
button:SetScript("OnUpdate", nil)
|
||||
button:SetMinMaxValues(0, 1)
|
||||
button:SetValue(0)
|
||||
end
|
||||
|
||||
button:SetID(index)
|
||||
button:Show()
|
||||
|
||||
if isDebuff then
|
||||
local color = (debuffType and DebuffTypeColor[debuffType]) or DebuffTypeColor.none
|
||||
if button.name and (button.name == unstableAffliction or button.name == vampiricTouch) then
|
||||
self:StyleFrameColor(button, 0.05, 0.85, 0.94)
|
||||
else
|
||||
self:StyleFrameColor(button, color.r * 0.6, color.g * 0.6, color.b * 0.6)
|
||||
end
|
||||
end
|
||||
|
||||
return VISIBLE
|
||||
elseif frame.forceCreate then
|
||||
button:Hide()
|
||||
|
||||
return CREATED
|
||||
else
|
||||
return HIDDEN
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Update_AurasPosition(frame, db)
|
||||
local size = db.size + db.spacing
|
||||
local anchor = E.InversePoints[db.anchorPoint]
|
||||
local growthx = (db.growthX == "LEFT" and -1) or 1
|
||||
local growthy = (db.growthY == "DOWN" and -1) or 1
|
||||
local cols = db.perrow
|
||||
|
||||
for i = frame.anchoredIcons + 1, #frame do
|
||||
local button = frame[i]
|
||||
if not button then break end
|
||||
|
||||
local col = (i - 1) % cols
|
||||
local row = floor((i - 1) / cols)
|
||||
|
||||
button:SetSize(db.size, db.size)
|
||||
button:ClearAllPoints()
|
||||
button:SetPoint(anchor, frame, anchor, col * size * growthx, row * size * growthy)
|
||||
|
||||
button.count:FontTemplate(LSM:Fetch("font", db.countFont), db.countFontSize, db.countFontOutline)
|
||||
button.count:ClearAllPoints()
|
||||
button.count:SetPoint(db.countPosition, db.countXOffset, db.countYOffset)
|
||||
|
||||
button.text:FontTemplate(LSM:Fetch("font", db.durationFont), db.durationFontSize, db.durationFontOutline)
|
||||
button.text:ClearAllPoints()
|
||||
button.text:SetPoint(db.durationPosition, db.durationXOffset, db.durationYOffset)
|
||||
|
||||
button:SetOrientation(db.cooldownOrientation)
|
||||
|
||||
button.bg:ClearAllPoints()
|
||||
if db.cooldownOrientation == "VERTICAL" then
|
||||
button.bg:SetPoint("TOPLEFT", button)
|
||||
button.bg:SetPoint("BOTTOMRIGHT", button:GetStatusBarTexture(), "TOPRIGHT")
|
||||
else
|
||||
button.bg:SetPoint("TOPRIGHT", button)
|
||||
button.bg:SetPoint("BOTTOMLEFT", button:GetStatusBarTexture(), "BOTTOMRIGHT")
|
||||
end
|
||||
|
||||
if db.reverseCooldown then
|
||||
button:SetStatusBarColor(0, 0, 0, 0.5)
|
||||
button.bg:SetTexture(0, 0, 0, 0)
|
||||
else
|
||||
button:SetStatusBarColor(0, 0, 0, 0)
|
||||
button.bg:SetTexture(0, 0, 0, 0.5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function NP:UpdateElement_AuraIcons(frame, guid, filter, limit, isDebuff)
|
||||
local index, visible, hidden, created = 1, 0, 0, 0
|
||||
|
||||
while visible < limit do
|
||||
local result = NP:SetAura(frame, guid, index, filter, isDebuff, visible)
|
||||
if not result then
|
||||
break
|
||||
elseif result == HIDDEN then
|
||||
hidden = hidden + 1
|
||||
elseif result == VISIBLE then
|
||||
visible = visible + 1
|
||||
elseif result == CREATED then
|
||||
visible = visible + 1
|
||||
created = created + 1
|
||||
end
|
||||
index = index + 1
|
||||
end
|
||||
|
||||
visible = visible - created
|
||||
|
||||
for i = visible + 1, #frame do
|
||||
frame[i].timeLeft = nil
|
||||
frame[i]:SetScript("OnUpdate", nil)
|
||||
frame[i]:Hide()
|
||||
end
|
||||
return visible
|
||||
end
|
||||
|
||||
function NP:UpdateElement_Auras(frame)
|
||||
if not frame.Health:IsShown() then return end
|
||||
|
||||
local guid = frame.guid
|
||||
|
||||
if not guid then
|
||||
if frame.UnitClass == "HERO" then
|
||||
local name = frame.UnitName
|
||||
guid = self.GUIDByName[name]
|
||||
elseif frame.RaidIcon:IsShown() then
|
||||
guid = ByRaidIcon[frame.RaidIconType]
|
||||
end
|
||||
|
||||
if guid then
|
||||
frame.guid = guid
|
||||
elseif not frame.Buffs.forceShow and not frame.Debuffs.forceShow then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local db = NP.db.units[frame.UnitType].buffs
|
||||
if db.enable then
|
||||
local buffs = frame.Buffs
|
||||
buffs.visibleBuffs = NP:UpdateElement_AuraIcons(buffs, guid, buffs.filter or "HELPFUL", db.perrow * db.numrows)
|
||||
|
||||
if #buffs > buffs.anchoredIcons then
|
||||
self:Update_AurasPosition(buffs, db)
|
||||
|
||||
buffs.anchoredIcons = #buffs
|
||||
end
|
||||
end
|
||||
|
||||
db = NP.db.units[frame.UnitType].debuffs
|
||||
if db.enable then
|
||||
local debuffs = frame.Debuffs
|
||||
debuffs.visibleDebuffs = NP:UpdateElement_AuraIcons(debuffs, guid, debuffs.filter or "HARMFUL", db.perrow * db.numrows, true)
|
||||
|
||||
if #debuffs > debuffs.anchoredIcons then
|
||||
self:Update_AurasPosition(debuffs, db)
|
||||
|
||||
debuffs.anchoredIcons = #debuffs
|
||||
end
|
||||
end
|
||||
|
||||
self:StyleFilterUpdate(frame, "UNIT_AURA")
|
||||
end
|
||||
|
||||
function NP:UpdateElement_AurasByGUID(guid, event)
|
||||
local destName, destFlags = LAI:GetGUIDInfo(guid)
|
||||
|
||||
if destName then
|
||||
destName = split("-", destName)
|
||||
end
|
||||
|
||||
local raidIcon
|
||||
if destFlags then
|
||||
for iconName, bitmask in pairs(RaidIconBit) do
|
||||
if band(destFlags, bitmask) > 0 then
|
||||
ByRaidIcon[iconName] = guid
|
||||
raidIcon = iconName
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local frame = self:SearchForFrame(guid, raidIcon, destName)
|
||||
if frame then
|
||||
frame.guid = guid
|
||||
self.GUIDByName[destName] = guid
|
||||
self:UpdateElement_Auras(frame)
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Construct_AuraIcon(parent, index)
|
||||
local db = NP.db.units[parent:GetParent().UnitType][parent.type]
|
||||
|
||||
local button = CreateFrame("StatusBar", "$parentButton"..index, parent)
|
||||
NP:StyleFrame(button, true)
|
||||
|
||||
button:SetStatusBarTexture(E.media.blankTex)
|
||||
button:SetStatusBarColor(0, 0, 0, 0)
|
||||
button:SetOrientation("VERTICAL")
|
||||
|
||||
button.bg = button:CreateTexture()
|
||||
button.bg:SetTexture(0, 0, 0, 0.5)
|
||||
|
||||
button.bg:SetPoint("TOPLEFT", button)
|
||||
button.bg:SetPoint("BOTTOMRIGHT", button:GetStatusBarTexture(), "TOPRIGHT")
|
||||
|
||||
button.icon = button:CreateTexture(nil, "BORDER")
|
||||
button.icon:SetTexCoord(unpack(E.TexCoords))
|
||||
button.icon:SetAllPoints()
|
||||
|
||||
button.count = button:CreateFontString(nil, "OVERLAY")
|
||||
button.count:SetJustifyH("RIGHT")
|
||||
button.count:FontTemplate(LSM:Fetch("font", db.countFont), db.countFontSize, db.countFontOutline)
|
||||
|
||||
button.text = button:CreateFontString(nil, "OVERLAY")
|
||||
|
||||
-- support cooldown override
|
||||
if not button.isRegisteredCooldown then
|
||||
button.CooldownOverride = "nameplates"
|
||||
button.isRegisteredCooldown = true
|
||||
button.forceEnabled = true
|
||||
|
||||
if not E.RegisteredCooldowns.nameplates then E.RegisteredCooldowns.nameplates = {} end
|
||||
tinsert(E.RegisteredCooldowns.nameplates, button)
|
||||
end
|
||||
|
||||
button.text:FontTemplate(LSM:Fetch("font", db.durationFont), db.durationFontSize, db.durationFontOutline)
|
||||
|
||||
NP:Update_CooldownOptions(button)
|
||||
|
||||
tinsert(parent, button)
|
||||
|
||||
return button
|
||||
end
|
||||
|
||||
function NP:Update_CooldownOptions(button)
|
||||
E:Cooldown_Options(button, self.db.cooldown, button)
|
||||
end
|
||||
|
||||
function NP:Configure_Auras(frame, auraType)
|
||||
local auras = frame[auraType]
|
||||
local db = self.db.units[frame.UnitType][auras.type]
|
||||
|
||||
auras:SetWidth(db.perrow * db.size + ((db.perrow - 1) * db.spacing))
|
||||
auras:SetHeight(db.numrows * db.size + ((db.numrows - 1) * db.spacing))
|
||||
auras:ClearAllPoints()
|
||||
auras:SetPoint(positionValues[db.anchorPoint], db.attachTo == "BUFFS" and frame.Buffs or frame.Health, positionValues2[db.anchorPoint], db.xOffset, db.yOffset)
|
||||
end
|
||||
|
||||
function NP:ConstructElement_Auras(frame, auraType)
|
||||
local auras = CreateFrame("Frame", "$parent"..auraType, frame)
|
||||
auras:Show()
|
||||
auras:SetSize(150, 27)
|
||||
auras:SetPoint("TOP", 0, 22)
|
||||
auras.anchoredIcons = 0
|
||||
auras.type = string.lower(auraType)
|
||||
|
||||
return auras
|
||||
end
|
||||
|
||||
function NP:CheckFilter(name, spellID, isPlayer, allowDuration, noDuration, ...)
|
||||
for i = 1, select("#", ...) do
|
||||
local filterName = select(i, ...)
|
||||
if not filterName then return true end
|
||||
if G.nameplates.specialFilters[filterName] or E.global.unitframe.aurafilters[filterName] then
|
||||
local filter = E.global.unitframe.aurafilters[filterName]
|
||||
if filter then
|
||||
local filterType = filter.type
|
||||
local spellList = filter.spells
|
||||
local spell = spellList and (spellList[spellID] or spellList[name])
|
||||
|
||||
if filterType and (filterType == "Whitelist") and (spell and spell.enable) and allowDuration then
|
||||
return true
|
||||
elseif filterType and (filterType == "Blacklist") and (spell and spell.enable) then
|
||||
return false
|
||||
end
|
||||
elseif filterName == "Personal" and isPlayer and allowDuration then
|
||||
return true
|
||||
elseif filterName == "nonPersonal" and (not isPlayer) and allowDuration then
|
||||
return true
|
||||
elseif filterName == "blockNoDuration" and noDuration then
|
||||
return false
|
||||
elseif filterName == "blockNonPersonal" and (not isPlayer) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function NP:AuraFilter(guid, button, name, texture, count, debuffType, duration, expiration, caster, spellID)
|
||||
local parent = button:GetParent()
|
||||
local parentType = parent.type
|
||||
local db = NP.db.units[parent:GetParent().UnitType][parentType]
|
||||
if not db then return true end
|
||||
|
||||
local isPlayer = caster == E.myguid
|
||||
|
||||
-- keep these same as in `UF:AuraFilter`
|
||||
button.isPlayer = isPlayer
|
||||
button.dtype = debuffType
|
||||
button.duration = duration
|
||||
button.expiration = expiration
|
||||
button.stackCount = count
|
||||
button.name = name
|
||||
button.spellID = spellID
|
||||
button.spell = name
|
||||
button.priority = 0
|
||||
|
||||
if not db.filters then return true end
|
||||
|
||||
local priority = db.filters.priority
|
||||
local noDuration = (not duration or duration == 0)
|
||||
local allowDuration = noDuration or (duration and (duration > 0) and db.filters.maxDuration == 0 or duration <= db.filters.maxDuration) and (db.filters.minDuration == 0 or duration >= db.filters.minDuration)
|
||||
local filterCheck
|
||||
|
||||
if priority ~= "" then
|
||||
filterCheck = NP:CheckFilter(name, spellID, isPlayer, allowDuration, noDuration, split(",", priority))
|
||||
else
|
||||
filterCheck = allowDuration and true -- Allow all auras to be shown when the filter list is empty, while obeying duration sliders
|
||||
end
|
||||
|
||||
return filterCheck
|
||||
end
|
||||
@@ -0,0 +1,358 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
local LSM = E.Libs.LSM
|
||||
|
||||
--Lua functions
|
||||
local unpack = unpack
|
||||
local abs = math.abs
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
local GetTime = GetTime
|
||||
local UnitCastingInfo = UnitCastingInfo
|
||||
local UnitChannelInfo = UnitChannelInfo
|
||||
local FAILED = FAILED
|
||||
local INTERRUPTED = INTERRUPTED
|
||||
|
||||
local function resetAttributes(self)
|
||||
self.casting = nil
|
||||
self.channeling = nil
|
||||
self.notInterruptible = nil
|
||||
self.spellName = nil
|
||||
end
|
||||
|
||||
function NP:Update_CastBarOnUpdate(elapsed)
|
||||
if self.casting or self.channeling then
|
||||
local isCasting = self.casting
|
||||
if isCasting then
|
||||
self.value = self.value + elapsed
|
||||
if self.value >= self.max then
|
||||
resetAttributes(self)
|
||||
self:Hide()
|
||||
NP:StyleFilterUpdate(self:GetParent(), "FAKE_Casting")
|
||||
return
|
||||
end
|
||||
else
|
||||
self.value = self.value - elapsed
|
||||
if self.value <= 0 then
|
||||
resetAttributes(self)
|
||||
self:Hide()
|
||||
NP:StyleFilterUpdate(self:GetParent(), "FAKE_Casting")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if self.delay ~= 0 then
|
||||
if self.channeling then
|
||||
if self.channelTimeFormat == "CURRENT" then
|
||||
self.Time:SetFormattedText("%.1f |cffaf5050%.2f|r", abs(self.value - self.max), self.delay)
|
||||
elseif self.channelTimeFormat == "CURRENTMAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.2f |cffaf5050%.2f|r", abs(self.value - self.max), self.max, self.delay)
|
||||
elseif self.channelTimeFormat == "REMAINING" then
|
||||
self.Time:SetFormattedText("%.1f |cffaf5050%.2f|r", self.value, self.delay)
|
||||
elseif self.channelTimeFormat == "REMAININGMAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.2f |cffaf5050%.2f|r", self.value, self.max, self.max, self.delay)
|
||||
end
|
||||
else
|
||||
if self.castTimeFormat == "CURRENT" then
|
||||
self.Time:SetFormattedText("%.1f |cffaf5050%s %.2f|r", self.value, "+", self.delay)
|
||||
elseif self.castTimeFormat == "CURRENTMAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.2f |cffaf5050%s %.2f|r", self.value, self.max, "+", self.delay)
|
||||
elseif self.castTimeFormat == "REMAINING" then
|
||||
self.Time:SetFormattedText("%.1f |cffaf5050%s %.2f|r", abs(self.value - self.max), "+", self.delay)
|
||||
elseif self.castTimeFormat == "REMAININGMAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.2f |cffaf5050%s %.2f|r", abs(self.value - self.max), self.max, "+", self.delay)
|
||||
end
|
||||
end
|
||||
else
|
||||
if self.channeling then
|
||||
if self.channelTimeFormat == "CURRENT" then
|
||||
self.Time:SetFormattedText("%.1f", abs(self.value - self.max))
|
||||
elseif self.channelTimeFormat == "CURRENTMAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.2f", abs(self.value - self.max), self.max)
|
||||
elseif self.channelTimeFormat == "REMAINING" then
|
||||
self.Time:SetFormattedText("%.1f", self.value)
|
||||
elseif self.channelTimeFormat == "REMAININGMAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.2f", self.value, self.max)
|
||||
end
|
||||
else
|
||||
if self.castTimeFormat == "CURRENT" then
|
||||
self.Time:SetFormattedText("%.1f", self.value)
|
||||
elseif self.castTimeFormat == "CURRENTMAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.2f", self.value, self.max)
|
||||
elseif self.castTimeFormat == "REMAINING" then
|
||||
self.Time:SetFormattedText("%.1f", abs(self.value - self.max))
|
||||
elseif self.castTimeFormat == "REMAININGMAX" then
|
||||
self.Time:SetFormattedText("%.1f / %.2f", abs(self.value - self.max), self.max)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self:SetValue(self.value)
|
||||
elseif self.holdTime > 0 then
|
||||
self.holdTime = self.holdTime - elapsed
|
||||
else
|
||||
resetAttributes(self)
|
||||
self:Hide()
|
||||
NP:StyleFilterUpdate(self:GetParent(), "FAKE_Casting")
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Update_CastBar(frame, event, unit)
|
||||
local castBar = frame.CastBar
|
||||
if unit then
|
||||
if not event then
|
||||
if UnitChannelInfo(unit) then
|
||||
event = "UNIT_SPELLCAST_CHANNEL_START"
|
||||
elseif UnitCastingInfo(unit) then
|
||||
event = "UNIT_SPELLCAST_START"
|
||||
end
|
||||
end
|
||||
elseif castBar:IsShown() then
|
||||
resetAttributes(castBar)
|
||||
castBar:Hide()
|
||||
end
|
||||
|
||||
if self.db.units[frame.UnitType].castbar.enable ~= true then return end
|
||||
if self.db.units[frame.UnitType].health.enable ~= true and not (frame.isTarget and self.db.alwaysShowTargetHealth) then return end --Bug
|
||||
|
||||
if event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_CHANNEL_START" then
|
||||
local name, _, _, texture, startTime, endTime, _, _, notInterruptible = UnitCastingInfo(unit)
|
||||
event = "UNIT_SPELLCAST_START"
|
||||
if not name then
|
||||
name, _, _, texture, startTime, endTime, _, notInterruptible = UnitChannelInfo(unit)
|
||||
event = "UNIT_SPELLCAST_CHANNEL_START"
|
||||
end
|
||||
|
||||
if not name then
|
||||
resetAttributes(castBar)
|
||||
castBar:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
endTime = endTime / 1000
|
||||
startTime = startTime / 1000
|
||||
|
||||
castBar.max = endTime - startTime
|
||||
castBar.startTime = startTime
|
||||
castBar.delay = 0
|
||||
castBar.casting = event == "UNIT_SPELLCAST_START"
|
||||
castBar.channeling = event == "UNIT_SPELLCAST_CHANNEL_START"
|
||||
castBar.notInterruptible = notInterruptible
|
||||
castBar.holdTime = 0
|
||||
castBar.interrupted = nil
|
||||
castBar.spellName = name
|
||||
|
||||
if castBar.casting then
|
||||
castBar.value = GetTime() - startTime
|
||||
else
|
||||
castBar.value = endTime - GetTime()
|
||||
end
|
||||
|
||||
castBar:SetMinMaxValues(0, castBar.max)
|
||||
castBar:SetValue(castBar.value)
|
||||
|
||||
castBar.Icon.texture:SetTexture(texture)
|
||||
castBar.Spark:Show()
|
||||
castBar.Name:SetText(name)
|
||||
castBar.Time:SetText()
|
||||
|
||||
castBar:Show()
|
||||
elseif event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_CHANNEL_STOP" then
|
||||
if castBar:IsShown() then
|
||||
resetAttributes(castBar)
|
||||
end
|
||||
elseif event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_INTERRUPTED" then
|
||||
if castBar:IsShown() then
|
||||
castBar.Spark:Hide()
|
||||
castBar.Name:SetText(event == "UNIT_SPELLCAST_FAILED" and FAILED or INTERRUPTED)
|
||||
|
||||
castBar.holdTime = self.db.units[frame.UnitType].castbar.timeToHold --How long the castbar should stay visible after being interrupted, in seconds
|
||||
castBar.interrupted = true
|
||||
|
||||
resetAttributes(castBar)
|
||||
castBar:SetValue(castBar.max)
|
||||
end
|
||||
elseif event == "UNIT_SPELLCAST_DELAYED" or event == "UNIT_SPELLCAST_CHANNEL_UPDATE" then
|
||||
if frame:IsShown() then
|
||||
local name, startTime, endTime, _
|
||||
if event == "UNIT_SPELLCAST_DELAYED" then
|
||||
name, _, _, _, startTime, endTime = UnitCastingInfo(unit)
|
||||
else
|
||||
name, _, _, _, startTime, endTime = UnitChannelInfo(unit)
|
||||
end
|
||||
|
||||
if not name then
|
||||
resetAttributes(castBar)
|
||||
castBar:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
endTime = endTime / 1000
|
||||
startTime = startTime / 1000
|
||||
|
||||
local delta
|
||||
if castBar.casting then
|
||||
delta = startTime - castBar.startTime
|
||||
castBar.value = GetTime() - startTime
|
||||
else
|
||||
delta = castBar.startTime - startTime
|
||||
castBar.value = endTime - GetTime()
|
||||
end
|
||||
|
||||
if delta < 0 then
|
||||
delta = 0
|
||||
end
|
||||
|
||||
castBar.Name:SetText(name)
|
||||
castBar.max = endTime - startTime
|
||||
castBar.startTime = startTime
|
||||
castBar.delay = castBar.delay + delta
|
||||
castBar:SetMinMaxValues(0, castBar.max)
|
||||
castBar:SetValue(castBar.value)
|
||||
end
|
||||
elseif event == "UNIT_SPELLCAST_INTERRUPTIBLE" or event == "UNIT_SPELLCAST_NOT_INTERRUPTIBLE" then
|
||||
castBar.notInterruptible = event == "UNIT_SPELLCAST_NOT_INTERRUPTIBLE"
|
||||
end
|
||||
|
||||
if not castBar.notInterruptible then
|
||||
if castBar.interrupted then
|
||||
castBar:SetStatusBarColor(self.db.colors.castInterruptedColor.r, self.db.colors.castInterruptedColor.g, self.db.colors.castInterruptedColor.b)
|
||||
else
|
||||
castBar:SetStatusBarColor(self.db.colors.castColor.r, self.db.colors.castColor.g, self.db.colors.castColor.b)
|
||||
end
|
||||
castBar.Icon.texture:SetDesaturated(false)
|
||||
else
|
||||
castBar:SetStatusBarColor(self.db.colors.castNoInterruptColor.r, self.db.colors.castNoInterruptColor.g, self.db.colors.castNoInterruptColor.b)
|
||||
|
||||
if self.db.colors.castbarDesaturate then
|
||||
castBar.Icon.texture:SetDesaturated(true)
|
||||
end
|
||||
end
|
||||
|
||||
self:StyleFilterUpdate(frame, "FAKE_Casting")
|
||||
end
|
||||
|
||||
function NP:Configure_CastBarScale(frame, scale, noPlayAnimation)
|
||||
if frame.currentScale == scale then return end
|
||||
local db = self.db.units[frame.UnitType].castbar
|
||||
if not db.enable then return end
|
||||
|
||||
local castBar = frame.CastBar
|
||||
|
||||
if noPlayAnimation then
|
||||
castBar:SetSize(db.width * scale, db.height * scale)
|
||||
castBar.Icon:SetSize(db.iconSize * scale, db.iconSize * scale)
|
||||
else
|
||||
if castBar.scale:IsPlaying() or castBar.Icon.scale:IsPlaying() then
|
||||
castBar.scale:Stop()
|
||||
castBar.Icon.scale:Stop()
|
||||
end
|
||||
|
||||
castBar.scale.width:SetChange(db.width * scale)
|
||||
castBar.scale.height:SetChange(db.height * scale)
|
||||
castBar.scale:Play()
|
||||
|
||||
castBar.Icon.scale.width:SetChange(db.iconSize * scale)
|
||||
castBar.Icon.scale.height:SetChange(db.iconSize * scale)
|
||||
castBar.Icon.scale:Play()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_CastBar(frame, configuring)
|
||||
local db = self.db.units[frame.UnitType].castbar
|
||||
local castBar = frame.CastBar
|
||||
|
||||
castBar:SetPoint("TOP", frame.Health, "BOTTOM", db.xOffset, db.yOffset)
|
||||
|
||||
if db.showIcon then
|
||||
castBar.Icon:ClearAllPoints()
|
||||
castBar.Icon:SetPoint(db.iconPosition == "RIGHT" and "BOTTOMLEFT" or "BOTTOMRIGHT", castBar, db.iconPosition == "RIGHT" and "BOTTOMRIGHT" or "BOTTOMLEFT", db.iconOffsetX, db.iconOffsetY)
|
||||
castBar.Icon:Show()
|
||||
else
|
||||
castBar.Icon:Hide()
|
||||
end
|
||||
|
||||
castBar.Time:ClearAllPoints()
|
||||
castBar.Name:ClearAllPoints()
|
||||
|
||||
castBar.Spark:SetPoint("CENTER", castBar:GetStatusBarTexture(), "RIGHT", 0, 0)
|
||||
castBar.Spark:SetHeight(db.height * 2)
|
||||
|
||||
if db.textPosition == "BELOW" then
|
||||
castBar.Time:SetPoint("TOPRIGHT", castBar, "BOTTOMRIGHT")
|
||||
castBar.Name:SetPoint("TOPLEFT", castBar, "BOTTOMLEFT")
|
||||
elseif db.textPosition == "ABOVE" then
|
||||
castBar.Time:SetPoint("BOTTOMRIGHT", castBar, "TOPRIGHT")
|
||||
castBar.Name:SetPoint("BOTTOMLEFT", castBar, "TOPLEFT")
|
||||
else
|
||||
castBar.Time:SetPoint("RIGHT", castBar, "RIGHT", -4, 0)
|
||||
castBar.Name:SetPoint("LEFT", castBar, "LEFT", 4, 0)
|
||||
end
|
||||
|
||||
if configuring then
|
||||
self:Configure_CastBarScale(frame, frame.currentScale or 1, configuring)
|
||||
end
|
||||
|
||||
castBar.Name:FontTemplate(LSM:Fetch("font", db.font), db.fontSize, db.fontOutline)
|
||||
castBar.Time:FontTemplate(LSM:Fetch("font", db.font), db.fontSize, db.fontOutline)
|
||||
|
||||
if db.hideSpellName then
|
||||
castBar.Name:Hide()
|
||||
else
|
||||
castBar.Name:Show()
|
||||
end
|
||||
if db.hideTime then
|
||||
castBar.Time:Hide()
|
||||
else
|
||||
castBar.Time:Show()
|
||||
end
|
||||
|
||||
castBar:SetStatusBarTexture(LSM:Fetch("statusbar", self.db.statusbar))
|
||||
|
||||
castBar.castTimeFormat = db.castTimeFormat
|
||||
castBar.channelTimeFormat = db.channelTimeFormat
|
||||
end
|
||||
|
||||
function NP:Construct_CastBar(parent)
|
||||
local frame = CreateFrame("StatusBar", "$parentCastBar", parent)
|
||||
NP:StyleFrame(frame)
|
||||
frame:SetScript("OnUpdate", NP.Update_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))
|
||||
NP:StyleFrame(frame.Icon)
|
||||
|
||||
frame.Time = frame:CreateFontString(nil, "OVERLAY")
|
||||
frame.Time:SetJustifyH("RIGHT")
|
||||
frame.Time:SetWordWrap(false)
|
||||
|
||||
frame.Name = frame:CreateFontString(nil, "OVERLAY")
|
||||
frame.Name:SetJustifyH("LEFT")
|
||||
frame.Name:SetWordWrap(false)
|
||||
|
||||
frame.Spark = frame:CreateTexture(nil, "OVERLAY")
|
||||
frame.Spark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]])
|
||||
frame.Spark:SetBlendMode("ADD")
|
||||
frame.Spark:SetSize(15, 15)
|
||||
|
||||
frame.holdTime = 0
|
||||
frame.interrupted = nil
|
||||
|
||||
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.Icon.scale = CreateAnimationGroup(frame.Icon)
|
||||
frame.Icon.scale.width = frame.Icon.scale:CreateAnimation("Width")
|
||||
frame.Icon.scale.width:SetDuration(0.2)
|
||||
frame.Icon.scale.height = frame.Icon.scale:CreateAnimation("Height")
|
||||
frame.Icon.scale.height:SetDuration(0.2)
|
||||
|
||||
frame:Hide()
|
||||
|
||||
return frame
|
||||
end
|
||||
@@ -0,0 +1,119 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...))
|
||||
local NP = E:GetModule("NamePlates")
|
||||
local LSM = E.Libs.LSM
|
||||
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
local GetComboPoints = GetComboPoints
|
||||
local MAX_COMBO_POINTS = MAX_COMBO_POINTS
|
||||
|
||||
function NP:Update_CPoints(frame)
|
||||
if frame.UnitType == "FRIENDLY_PLAYER" or frame.UnitType == "FRIENDLY_NPC" then return end
|
||||
if not self.db.units.TARGET.comboPoints.enable then return end
|
||||
|
||||
local numPoints
|
||||
if 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 NP:Configure_CPointsScale(frame, scale, noPlayAnimation)
|
||||
if frame.UnitType == "FRIENDLY_PLAYER" or frame.UnitType == "FRIENDLY_NPC" then return end
|
||||
local db = self.db.units.TARGET.comboPoints
|
||||
if not db.enable then return end
|
||||
|
||||
if noPlayAnimation then
|
||||
frame.CPoints:SetWidth(((db.width * 5) + (db.spacing * 4)) * scale)
|
||||
frame.CPoints:SetHeight(db.height * scale)
|
||||
else
|
||||
if frame.CPoints.scale:IsPlaying() then
|
||||
frame.CPoints.scale:Stop()
|
||||
end
|
||||
|
||||
frame.CPoints.scale.width:SetChange(((db.width * 5) + (db.spacing * 4)) * scale)
|
||||
frame.CPoints.scale.height:SetChange(db.height * scale)
|
||||
frame.CPoints.scale:Play()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_CPoints(frame, configuring)
|
||||
if frame.UnitType == "FRIENDLY_PLAYER" or frame.UnitType == "FRIENDLY_NPC" then return end
|
||||
local db = self.db.units.TARGET.comboPoints
|
||||
if not db.enable then return end
|
||||
|
||||
local comboBar = frame.CPoints
|
||||
local healthShown = self.db.units[frame.UnitType].health.enable or (frame.isTarget and self.db.alwaysShowTargetHealth)
|
||||
|
||||
comboBar:ClearAllPoints()
|
||||
if healthShown then
|
||||
comboBar:Point("CENTER", frame.Health, "BOTTOM", db.xOffset, db.yOffset)
|
||||
else
|
||||
comboBar:Point("CENTER", frame, "TOP", db.xOffset, db.yOffset)
|
||||
end
|
||||
|
||||
for i = 1, MAX_COMBO_POINTS do
|
||||
local comboPoint = comboBar[i]
|
||||
comboPoint.backdrop:SetTexture(LSM:Fetch("statusbar", self.db.statusbar))
|
||||
local color = self.db.colors.comboPoints[i]
|
||||
comboPoint.backdrop:SetVertexColor(color.r, color.g, color.b)
|
||||
|
||||
comboPoint:SetWidth(db.width)
|
||||
|
||||
comboPoint:ClearAllPoints()
|
||||
if i == 1 then
|
||||
comboPoint:SetPoint("TOPLEFT")
|
||||
comboPoint:SetPoint("BOTTOMLEFT")
|
||||
else
|
||||
comboPoint:SetPoint("TOPLEFT", comboBar[i - 1], "TOPRIGHT", db.spacing, 0)
|
||||
comboPoint:SetPoint("BOTTOMLEFT", comboBar[i - 1], "BOTTOMRIGHT")
|
||||
end
|
||||
end
|
||||
|
||||
comboBar.spacing = db.spacing * (MAX_COMBO_POINTS - 1)
|
||||
|
||||
if configuring then
|
||||
self:Configure_CPointsScale(frame, frame.currentScale or 1, configuring)
|
||||
end
|
||||
end
|
||||
|
||||
local function CPoints_OnSizeChanged(self, width)
|
||||
width = width - self.spacing
|
||||
for i = 1, MAX_COMBO_POINTS do
|
||||
self[i]:SetWidth(width * 0.2)
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Construct_CPoints(parent)
|
||||
local comboBar = CreateFrame("Frame", "$parentComboPoints", parent)
|
||||
comboBar:Hide()
|
||||
|
||||
comboBar.scale = CreateAnimationGroup(comboBar)
|
||||
comboBar.scale.width = comboBar.scale:CreateAnimation("Width")
|
||||
comboBar.scale.width:SetDuration(0.2)
|
||||
comboBar.scale.height = comboBar.scale:CreateAnimation("Height")
|
||||
comboBar.scale.height:SetDuration(0.2)
|
||||
|
||||
comboBar:SetScript("OnSizeChanged", CPoints_OnSizeChanged)
|
||||
|
||||
for i = 1, MAX_COMBO_POINTS do
|
||||
comboBar[i] = CreateFrame("Frame", "$parentComboPoint"..i, comboBar)
|
||||
self:StyleFrame(comboBar[i])
|
||||
end
|
||||
|
||||
return comboBar
|
||||
end
|
||||
@@ -0,0 +1,61 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
|
||||
function NP:UpdateElement_CutawayHealthFadeOut(frame)
|
||||
local cutawayHealth = frame.CutawayHealth
|
||||
cutawayHealth.fading = true
|
||||
E:UIFrameFadeOut(cutawayHealth, self.db.cutawayHealthFadeOutTime, cutawayHealth:GetAlpha(), 0)
|
||||
cutawayHealth.isPlaying = nil
|
||||
end
|
||||
|
||||
local function CutawayHealthClosure(frame)
|
||||
NP:UpdateElement_CutawayHealthFadeOut(frame)
|
||||
end
|
||||
|
||||
function NP:CutawayHealthValueChangeCallback(frame, health, maxHealth)
|
||||
if self.db.cutawayHealth then
|
||||
frame.CutawayHealth:SetMinMaxValues(0, maxHealth)
|
||||
local oldValue = frame.Health:GetValue()
|
||||
local change = oldValue - health
|
||||
if change > 0 and not frame.CutawayHealth.isPlaying then
|
||||
local cutawayHealth = frame.CutawayHealth
|
||||
if cutawayHealth.fading then
|
||||
E:UIFrameFadeRemoveFrame(cutawayHealth)
|
||||
end
|
||||
cutawayHealth.fading = false
|
||||
cutawayHealth:SetValue(oldValue)
|
||||
cutawayHealth:SetAlpha(1)
|
||||
|
||||
E:Delay(self.db.cutawayHealthLength, CutawayHealthClosure, frame)
|
||||
|
||||
cutawayHealth.isPlaying = true
|
||||
cutawayHealth:Show()
|
||||
end
|
||||
else
|
||||
if frame.CutawayHealth.isPlaying then
|
||||
frame.CutawayHealth.isPlaying = nil
|
||||
frame.CutawayHealth:SetScript("OnUpdate", nil)
|
||||
end
|
||||
frame.CutawayHealth:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:CutawayHealthColorChangeCallback(frame, r, g, b)
|
||||
frame.CutawayHealth:SetStatusBarColor(r * 1.5, g * 1.5, b * 1.5, 1)
|
||||
end
|
||||
|
||||
function NP:ConstructElement_CutawayHealth(parent)
|
||||
local healthBar = parent.Health
|
||||
|
||||
local cutawayHealth = CreateFrame("StatusBar", "$parentCutawayHealth", healthBar)
|
||||
cutawayHealth:SetAllPoints()
|
||||
cutawayHealth:SetStatusBarTexture(E.media.blankTex)
|
||||
cutawayHealth:SetFrameLevel(healthBar:GetFrameLevel() - 1)
|
||||
|
||||
NP:RegisterHealthBarCallbacks(parent, NP.CutawayHealthValueChangeCallback, NP.CutawayHealthColorChangeCallback)
|
||||
|
||||
return cutawayHealth
|
||||
end
|
||||
@@ -0,0 +1,53 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
|
||||
function NP:Update_Elite(frame)
|
||||
local db = self.db.units[frame.UnitType].eliteIcon
|
||||
if not db then return end
|
||||
|
||||
local icon = frame.Elite
|
||||
if db.enable then
|
||||
local elite, boss = frame.EliteIcon:IsShown(), frame.BossIcon:IsShown()
|
||||
|
||||
if boss then
|
||||
icon:SetTexCoord(0, 0.15, 0.62, 0.94)
|
||||
icon:Show()
|
||||
elseif elite then
|
||||
icon:SetTexCoord(0, 0.15, 0.35, 0.63)
|
||||
icon:Show()
|
||||
else
|
||||
icon:Hide()
|
||||
end
|
||||
else
|
||||
icon:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_Elite(frame)
|
||||
local db = self.db.units[frame.UnitType].eliteIcon
|
||||
if not db then return end
|
||||
|
||||
local icon = frame.Elite
|
||||
|
||||
icon:Size(db.size)
|
||||
icon:ClearAllPoints()
|
||||
|
||||
if frame.Health:IsShown() then
|
||||
icon:SetParent(frame.Health)
|
||||
icon:Point(db.position, frame.Health, db.position, db.xOffset, db.yOffset)
|
||||
else
|
||||
icon:SetParent(frame)
|
||||
icon:Point(db.position, frame, db.position, db.xOffset, db.yOffset)
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Construct_Elite(frame)
|
||||
local icon = frame.Health:CreateTexture(nil, "OVERLAY")
|
||||
icon:SetTexture(E.Media.Textures.Nameplates)
|
||||
icon:Hide()
|
||||
|
||||
return icon
|
||||
end
|
||||
@@ -0,0 +1,193 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
local LSM = E.Libs.LSM
|
||||
|
||||
--Lua functions
|
||||
local ipairs = ipairs
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
|
||||
--[[
|
||||
Target Glow Style Option Variables
|
||||
style1 - Border
|
||||
style2 - Background
|
||||
style3 - Top Arrow Only
|
||||
style4 - Side Arrows Only
|
||||
style5 - Border + Top Arrow
|
||||
style6 - Background + Top Arrow
|
||||
style7 - Border + Side Arrows
|
||||
style8 - Background + Side Arrows
|
||||
]]
|
||||
|
||||
function NP:Update_Glow(frame)
|
||||
local showIndicator
|
||||
|
||||
if frame.isTarget then
|
||||
showIndicator = 1
|
||||
elseif self.db.lowHealthThreshold > 0 then
|
||||
local health = frame.oldHealthBar:GetValue()
|
||||
local _, maxHealth = frame.oldHealthBar:GetMinMaxValues()
|
||||
local perc = health / maxHealth
|
||||
|
||||
if health > 1 and perc <= self.db.lowHealthThreshold then
|
||||
if perc <= self.db.lowHealthThreshold / 2 then
|
||||
showIndicator = 2
|
||||
else
|
||||
showIndicator = 3
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local glowStyle = self.db.units.TARGET.glowStyle
|
||||
local healthIsShown = frame.Health:IsShown()
|
||||
|
||||
if not healthIsShown then
|
||||
if glowStyle == "style1" then
|
||||
glowStyle = "none"
|
||||
elseif glowStyle == "style5" then
|
||||
glowStyle = "style3"
|
||||
elseif glowStyle == "style7" then
|
||||
glowStyle = "style4"
|
||||
end
|
||||
end
|
||||
|
||||
if showIndicator and glowStyle ~= "none" then
|
||||
local r, g, b
|
||||
|
||||
if showIndicator == 1 then
|
||||
local color = self.db.colors.glowColor
|
||||
r, g, b = color.r, color.g, color.b
|
||||
elseif showIndicator == 2 then
|
||||
r, g, b = 1, 0, 0
|
||||
else
|
||||
r, g, b = 1, 1, 0
|
||||
end
|
||||
|
||||
-- Indicators
|
||||
frame.TopIndicator:SetVertexColor(r, g, b)
|
||||
frame.LeftIndicator:SetVertexColor(r, g, b)
|
||||
frame.RightIndicator:SetVertexColor(r, g, b)
|
||||
|
||||
if glowStyle == "style3" or glowStyle == "style5" or glowStyle == "style6" then
|
||||
frame.LeftIndicator:Hide()
|
||||
frame.RightIndicator:Hide()
|
||||
|
||||
if healthIsShown then
|
||||
frame.TopIndicator:Show()
|
||||
end
|
||||
elseif glowStyle == "style4" or glowStyle == "style7" or glowStyle == "style8" then
|
||||
frame.TopIndicator:Hide()
|
||||
|
||||
if healthIsShown then
|
||||
frame.LeftIndicator:Show()
|
||||
frame.RightIndicator:Show()
|
||||
end
|
||||
end
|
||||
|
||||
-- Spark / Shadow
|
||||
frame.Shadow:SetBackdropBorderColor(r, g, b)
|
||||
frame.Spark:SetVertexColor(r, g, b)
|
||||
|
||||
if glowStyle == "style1" or glowStyle == "style5" or glowStyle == "style7" then
|
||||
frame.Spark:Hide()
|
||||
frame.Shadow:Show()
|
||||
elseif glowStyle == "style2" or glowStyle == "style6" or glowStyle == "style8" then
|
||||
frame.Shadow:Hide()
|
||||
frame.Spark:Show()
|
||||
end
|
||||
else
|
||||
frame.TopIndicator:Hide()
|
||||
frame.LeftIndicator:Hide()
|
||||
frame.RightIndicator:Hide()
|
||||
frame.Shadow:Hide()
|
||||
frame.Spark:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_Glow(frame)
|
||||
local glowStyle = self.db.units.TARGET.glowStyle
|
||||
local healthIsShown = frame.Health:IsShown()
|
||||
|
||||
if not healthIsShown then
|
||||
if glowStyle == "style1" then
|
||||
glowStyle = "none"
|
||||
elseif glowStyle == "style5" then
|
||||
glowStyle = "style3"
|
||||
elseif glowStyle == "style7" then
|
||||
glowStyle = "style4"
|
||||
end
|
||||
end
|
||||
|
||||
if glowStyle ~= "none" then
|
||||
local color = self.db.colors.glowColor
|
||||
local r, g, b, a = color.r, color.g, color.b, color.a
|
||||
|
||||
-- Indicators
|
||||
frame.LeftIndicator:SetVertexColor(r, g, b)
|
||||
frame.RightIndicator:SetVertexColor(r, g, b)
|
||||
frame.TopIndicator:SetVertexColor(r, g, b)
|
||||
|
||||
frame.TopIndicator:ClearAllPoints()
|
||||
frame.LeftIndicator:ClearAllPoints()
|
||||
frame.RightIndicator:ClearAllPoints()
|
||||
|
||||
if glowStyle == "style3" or glowStyle == "style5" or glowStyle == "style6" then
|
||||
if healthIsShown then
|
||||
frame.TopIndicator:SetPoint("BOTTOM", frame.Health, "TOP", 0, 6)
|
||||
else
|
||||
frame.TopIndicator:SetPoint("BOTTOM", frame.Name, "TOP", 0, 8)
|
||||
end
|
||||
elseif glowStyle == "style4" or glowStyle == "style7" or glowStyle == "style8" then
|
||||
if healthIsShown then
|
||||
frame.LeftIndicator:SetPoint("LEFT", frame.Health, "RIGHT", -3, 0)
|
||||
frame.RightIndicator:SetPoint("RIGHT", frame.Health, "LEFT", 3, 0)
|
||||
else
|
||||
frame.LeftIndicator:SetPoint("LEFT", frame.Name, "RIGHT", 20, 0)
|
||||
frame.RightIndicator:SetPoint("RIGHT", frame.Name, "LEFT", -20, 0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Spark / Shadow
|
||||
frame.Shadow:SetBackdropBorderColor(r, g, b)
|
||||
frame.Shadow:SetAlpha(a)
|
||||
|
||||
frame.Spark:SetVertexColor(r, g, b, a)
|
||||
frame.Spark:ClearAllPoints()
|
||||
|
||||
if glowStyle == "style1" or glowStyle == "style5" or glowStyle == "style7" then
|
||||
frame.Shadow:SetOutside(frame.Health, E:Scale(E.PixelMode and 6 or 8), E:Scale(E.PixelMode and 6 or 8))
|
||||
elseif glowStyle == "style2" or glowStyle == "style6" or glowStyle == "style8" then
|
||||
if healthIsShown then
|
||||
local size = E.Border + 14
|
||||
frame.Spark:SetPoint("TOPLEFT", frame.Health, -(size * 2), size)
|
||||
frame.Spark:SetPoint("BOTTOMRIGHT", frame.Health, (size * 2), -size)
|
||||
else
|
||||
local nameIsShown = frame.Name:IsShown()
|
||||
frame.Spark:SetPoint("TOPLEFT", nameIsShown and frame.Name or frame.IconFrame, -20, 8)
|
||||
frame.Spark:SetPoint("BOTTOMRIGHT", nameIsShown and frame.Name or frame.IconFrame, 20, -8)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local Textures = {"Spark", "TopIndicator", "LeftIndicator", "RightIndicator"}
|
||||
|
||||
function NP:Construct_Glow(frame)
|
||||
frame.Shadow = CreateFrame("Frame", "$parentGlow", frame)
|
||||
frame.Shadow:SetFrameLevel(frame.Health:GetFrameLevel() - 1)
|
||||
frame.Shadow:SetBackdrop({edgeFile = LSM:Fetch("border", "ElvUI GlowBorder"), edgeSize = E:Scale(6)})
|
||||
frame.Shadow:Hide()
|
||||
|
||||
for _, object in ipairs(Textures) do
|
||||
frame[object] = frame:CreateTexture(nil, "BACKGROUND")
|
||||
frame[object]:Hide()
|
||||
end
|
||||
|
||||
frame.Spark:SetTexture(E.Media.Textures.Spark)
|
||||
frame.TopIndicator:SetTexture(E.Media.Textures.ArrowUp)
|
||||
frame.TopIndicator:SetRotation(3.14)
|
||||
frame.LeftIndicator:SetTexture(E.Media.Textures.ArrowUp)
|
||||
frame.LeftIndicator:SetRotation(1.57)
|
||||
frame.RightIndicator:SetTexture(E.Media.Textures.ArrowUp)
|
||||
frame.RightIndicator:SetRotation(-1.57)
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
|
||||
function NP:Update_HealerIcon(frame)
|
||||
local icon = frame.HealerIcon
|
||||
if frame.UnitType == "ENEMY_PLAYER" and self.Healers[frame.UnitName] then
|
||||
icon:ClearAllPoints()
|
||||
if frame.Health:IsShown() then
|
||||
icon:SetPoint("RIGHT", frame.Health, "LEFT", -6, 0)
|
||||
else
|
||||
icon:SetPoint("BOTTOM", frame.Name, "TOP", 0, 3)
|
||||
end
|
||||
|
||||
icon:Show()
|
||||
else
|
||||
icon:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Construct_HealerIcon(frame)
|
||||
local texture = frame:CreateTexture(nil, "OVERLAY")
|
||||
texture:SetPoint("RIGHT", frame.Health, "LEFT", -6, 0)
|
||||
texture:SetSize(40, 40)
|
||||
texture:SetTexture(E.Media.Textures.Healer)
|
||||
texture:Hide()
|
||||
|
||||
return texture
|
||||
end
|
||||
@@ -0,0 +1,213 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
local LSM = E.Libs.LSM
|
||||
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
|
||||
function NP:Update_HealthOnValueChanged()
|
||||
local frame = self:GetParent().UnitFrame
|
||||
if not frame.UnitType then return end -- Bugs
|
||||
|
||||
NP:Update_Health(frame)
|
||||
NP:Update_HealthColor(frame)
|
||||
NP:Update_Glow(frame)
|
||||
NP:StyleFilterUpdate(frame, "UNIT_HEALTH")
|
||||
end
|
||||
|
||||
function NP:Update_HealthColor(frame)
|
||||
if not frame.Health:IsShown() then return end
|
||||
|
||||
local r, g, b
|
||||
local scale = 1
|
||||
|
||||
local classColor = E.media.herocolor
|
||||
local useClassColor = NP.db.units[frame.UnitType].health.useClassColor
|
||||
if classColor and ((frame.UnitType == "FRIENDLY_PLAYER" and useClassColor) or (frame.UnitType == "ENEMY_PLAYER" and useClassColor)) then
|
||||
r, g, b = classColor.r, classColor.g, classColor.b
|
||||
else
|
||||
local db = self.db.colors
|
||||
local status = frame.ThreatStatus
|
||||
if status then
|
||||
if status == 3 then
|
||||
if E.Role == "Tank" then
|
||||
r, g, b = db.threat.goodColor.r, db.threat.goodColor.g, db.threat.goodColor.b
|
||||
scale = NP.db.threat.goodScale
|
||||
else
|
||||
r, g, b = db.threat.badColor.r, db.threat.badColor.g, db.threat.badColor.b
|
||||
scale = NP.db.threat.badScale
|
||||
end
|
||||
elseif status == 2 then
|
||||
if E.Role == "Tank" then
|
||||
r, g, b = db.threat.badTransition.r, db.threat.badTransition.g, db.threat.badTransition.b
|
||||
else
|
||||
r, g, b = db.threat.goodTransition.r, db.threat.goodTransition.g, db.threat.goodTransition.b
|
||||
end
|
||||
scale = 1
|
||||
elseif status == 1 then
|
||||
if E.Role == "Tank" then
|
||||
r, g, b = db.threat.goodTransition.r, db.threat.goodTransition.g, db.threat.goodTransition.b
|
||||
else
|
||||
r, g, b = db.threat.badTransition.r, db.threat.badTransition.g, db.threat.badTransition.b
|
||||
end
|
||||
scale = 1
|
||||
else
|
||||
if E.Role == "Tank" then
|
||||
r, g, b = db.threat.badColor.r, db.threat.badColor.g, db.threat.badColor.b
|
||||
scale = self.db.threat.badScale
|
||||
else
|
||||
r, g, b = db.threat.goodColor.r, db.threat.goodColor.g, db.threat.goodColor.b
|
||||
scale = self.db.threat.goodScale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (not status) or (status and not NP.db.threat.useThreatColor) then
|
||||
local reactionType = frame.UnitReaction
|
||||
if reactionType == 4 then
|
||||
r, g, b = db.reactions.neutral.r, db.reactions.neutral.g, db.reactions.neutral.b
|
||||
elseif reactionType and reactionType > 4 then
|
||||
if frame.UnitType == "FRIENDLY_PLAYER" then
|
||||
r, g, b = db.reactions.friendlyPlayer.r, db.reactions.friendlyPlayer.g, db.reactions.friendlyPlayer.b
|
||||
else
|
||||
r, g, b = db.reactions.good.r, db.reactions.good.g, db.reactions.good.b
|
||||
end
|
||||
else
|
||||
r, g, b = db.reactions.bad.r, db.reactions.bad.g, db.reactions.bad.b
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if r ~= frame.Health.r or g ~= frame.Health.g or b ~= frame.Health.b then
|
||||
if not frame.HealthColorChanged then
|
||||
frame.Health:SetStatusBarColor(r, g, b)
|
||||
|
||||
if frame.HealthColorChangeCallbacks then
|
||||
for _, cb in ipairs(frame.HealthColorChangeCallbacks) do
|
||||
cb(self, frame, r, g, b)
|
||||
end
|
||||
end
|
||||
end
|
||||
frame.Health.r, frame.Health.g, frame.Health.b = r, g, b
|
||||
end
|
||||
|
||||
if frame.ThreatScale ~= scale then
|
||||
frame.ThreatScale = scale
|
||||
if frame.isTarget and self.db.useTargetScale then
|
||||
scale = scale * self.db.targetScale
|
||||
end
|
||||
self:SetFrameScale(frame, scale * (frame.ActionScale or 1))
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Update_Health(frame)
|
||||
local health = frame.oldHealthBar:GetValue()
|
||||
local _, maxHealth = frame.oldHealthBar:GetMinMaxValues()
|
||||
frame.Health:SetMinMaxValues(0, maxHealth)
|
||||
|
||||
if frame.HealthValueChangeCallbacks then
|
||||
for _, cb in ipairs(frame.HealthValueChangeCallbacks) do
|
||||
cb(self, frame, health, maxHealth)
|
||||
end
|
||||
end
|
||||
|
||||
frame.Health:SetValue(health)
|
||||
frame.FlashTexture:Point("TOPRIGHT", frame.Health:GetStatusBarTexture(), "TOPRIGHT") --idk why this fixes this
|
||||
|
||||
if self.db.units[frame.UnitType].health.text.enable then
|
||||
frame.Health.Text:SetText(E:GetFormattedText(self.db.units[frame.UnitType].health.text.format, health, maxHealth))
|
||||
end
|
||||
end
|
||||
|
||||
function NP:RegisterHealthBarCallbacks(frame, valueChangeCB, colorChangeCB)
|
||||
if valueChangeCB then
|
||||
frame.HealthValueChangeCallbacks = frame.HealthValueChangeCallbacks or {}
|
||||
tinsert(frame.HealthValueChangeCallbacks, valueChangeCB)
|
||||
end
|
||||
|
||||
if colorChangeCB then
|
||||
frame.HealthColorChangeCallbacks = frame.HealthColorChangeCallbacks or {}
|
||||
tinsert(frame.HealthColorChangeCallbacks, colorChangeCB)
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Update_HealthBar(frame)
|
||||
if self.db.units[frame.UnitType].health.enable or (frame.isTarget and self.db.alwaysShowTargetHealth) then
|
||||
frame.Health:Show()
|
||||
else
|
||||
frame.Health:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_HealthBarScale(frame, scale, noPlayAnimation)
|
||||
if noPlayAnimation then
|
||||
frame.Health:SetWidth(self.db.units[frame.UnitType].health.width * scale)
|
||||
frame.Health:SetHeight(self.db.units[frame.UnitType].health.height * scale)
|
||||
else
|
||||
if frame.Health.scale:IsPlaying() then
|
||||
frame.Health.scale:Stop()
|
||||
end
|
||||
|
||||
frame.Health.scale.width:SetChange(self.db.units[frame.UnitType].health.width * scale)
|
||||
frame.Health.scale.height:SetChange(self.db.units[frame.UnitType].health.height * scale)
|
||||
frame.Health.scale:Play()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_HealthBar(frame, configuring)
|
||||
local db = self.db.units[frame.UnitType].health
|
||||
local healthBar = frame.Health
|
||||
|
||||
healthBar:SetPoint("TOP", frame, "TOP", 0, 0)
|
||||
|
||||
if configuring then
|
||||
healthBar:SetStatusBarTexture(LSM:Fetch("statusbar", self.db.statusbar), "BORDER")
|
||||
|
||||
self:Configure_HealthBarScale(frame, frame.currentScale or 1, configuring)
|
||||
|
||||
E:SetSmoothing(healthBar, self.db.smoothbars)
|
||||
|
||||
if db.text.enable then
|
||||
healthBar.Text:ClearAllPoints()
|
||||
healthBar.Text:Point(E.InversePoints[db.text.position], db.text.parent == "Nameplate" and frame or frame[db.text.parent], db.text.position, db.text.xOffset, db.text.yOffset)
|
||||
healthBar.Text:FontTemplate(LSM:Fetch("font", db.text.font), db.text.fontSize, db.text.fontOutline)
|
||||
healthBar.Text:Show()
|
||||
else
|
||||
healthBar.Text:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function HealthBar_OnSizeChanged(self, width)
|
||||
local health = self:GetValue()
|
||||
local _, maxHealth = self:GetMinMaxValues()
|
||||
self:GetStatusBarTexture():SetPoint("TOPRIGHT", -(width * ((maxHealth - health) / maxHealth)), 0)
|
||||
end
|
||||
|
||||
function NP:Construct_HealthBar(parent)
|
||||
local frame = CreateFrame("StatusBar", "$parentHealthBar", parent)
|
||||
frame:SetStatusBarTexture(LSM:Fetch("statusbar", self.db.statusbar), "BORDER")
|
||||
self:StyleFrame(frame)
|
||||
|
||||
frame:SetScript("OnSizeChanged", HealthBar_OnSizeChanged)
|
||||
|
||||
parent.FlashTexture = frame:CreateTexture(nil, "OVERLAY")
|
||||
parent.FlashTexture:SetTexture(LSM:Fetch("background", "ElvUI Blank"))
|
||||
parent.FlashTexture:Point("BOTTOMLEFT", frame:GetStatusBarTexture(), "BOTTOMLEFT")
|
||||
parent.FlashTexture:Point("TOPRIGHT", frame:GetStatusBarTexture(), "TOPRIGHT")
|
||||
parent.FlashTexture:Hide()
|
||||
|
||||
frame.Text = frame:CreateFontString(nil, "OVERLAY")
|
||||
frame.Text:SetAllPoints(frame)
|
||||
frame.Text:SetWordWrap(false)
|
||||
|
||||
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,34 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
local LSM = E.Libs.LSM
|
||||
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
|
||||
function NP:Update_Highlight(frame)
|
||||
if not NP.db.highlight then return end
|
||||
|
||||
if frame.isMouseover and ((frame.IconOnlyChanged or frame.NameOnlyChanged) or (not self.db.units[frame.UnitType].health.enable and self.db.units[frame.UnitType].name.enable)) and not frame.isTarget then
|
||||
frame.Name.NameOnlyGlow:Show()
|
||||
frame.Health.Highlight:Show()
|
||||
elseif frame.isMouseover and (not frame.NameOnlyChanged or self.db.units[frame.UnitType].health.enable) and not frame.isTarget then
|
||||
frame.Health.Highlight:Show()
|
||||
else
|
||||
frame.Name.NameOnlyGlow:Hide()
|
||||
frame.Health.Highlight:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_Highlight(frame)
|
||||
frame.Health.Highlight:ClearAllPoints()
|
||||
frame.Health.Highlight:SetPoint("TOPLEFT", frame.Health, "TOPLEFT")
|
||||
frame.Health.Highlight:SetPoint("BOTTOMRIGHT", frame.Health:GetStatusBarTexture(), "BOTTOMRIGHT")
|
||||
frame.Health.Highlight:SetTexture(LSM:Fetch("statusbar", self.db.statusbar))
|
||||
end
|
||||
|
||||
function NP:Construct_Highlight(frame)
|
||||
local highlight = frame.Health:CreateTexture("$parentHighlight", "OVERLAY")
|
||||
highlight:SetVertexColor(1, 1, 1, 0.3)
|
||||
highlight:Hide()
|
||||
return highlight
|
||||
end
|
||||
@@ -0,0 +1,82 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
|
||||
function NP:Update_IconFrame(frame, triggered)
|
||||
local db = self.db.units[frame.UnitType].iconFrame
|
||||
if not db then return end
|
||||
|
||||
if (db and db.enable) or (frame.IconOnlyChanged or frame.IconChanged) then
|
||||
local totem, unit, icon = self.Totems[frame.UnitName], self.UniqueUnits[frame.UnitName]
|
||||
if totem then
|
||||
icon = NP.TriggerConditions.totems[totem][3]
|
||||
elseif unit then
|
||||
icon = NP.TriggerConditions.uniqueUnits[unit][3]
|
||||
end
|
||||
|
||||
if icon then
|
||||
frame.IconFrame.texture:SetTexture(icon)
|
||||
frame.IconFrame:Show()
|
||||
|
||||
self:StyleFrameColor(frame.IconFrame, frame.oldHealthBar:GetStatusBarColor())
|
||||
|
||||
if triggered then
|
||||
frame.IconFrame:ClearAllPoints()
|
||||
frame.IconFrame:SetPoint("TOP", frame)
|
||||
end
|
||||
else
|
||||
frame.IconFrame:Hide()
|
||||
end
|
||||
else
|
||||
frame.IconFrame:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_IconOnlyGlow(frame)
|
||||
local glowStyle = self.db.units.TARGET.glowStyle
|
||||
|
||||
frame.Shadow:Hide()
|
||||
frame.Spark:Hide()
|
||||
|
||||
frame.TopIndicator:ClearAllPoints()
|
||||
frame.LeftIndicator:ClearAllPoints()
|
||||
frame.RightIndicator:ClearAllPoints()
|
||||
|
||||
if glowStyle == "style3" or glowStyle == "style5" or glowStyle == "style6" then
|
||||
frame.TopIndicator:SetPoint("BOTTOM", frame.IconFrame, "TOP", -1, 6)
|
||||
elseif glowStyle == "style4" or glowStyle == "style7" or glowStyle == "style8" then
|
||||
frame.LeftIndicator:SetPoint("LEFT", frame.IconFrame, "RIGHT", -3, 0)
|
||||
frame.RightIndicator:SetPoint("RIGHT", frame.IconFrame, "LEFT", 3, 0)
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_IconFrame(frame)
|
||||
local db = self.db.units[frame.UnitType].iconFrame
|
||||
|
||||
if db then
|
||||
if db.enable or frame.IconChanged then
|
||||
frame.IconFrame:SetSize(db.size, db.size)
|
||||
frame.IconFrame:ClearAllPoints()
|
||||
frame.IconFrame:SetPoint(E.InversePoints[db.position], db.parent == "Nameplate" and frame or frame[db.parent], db.position, db.xOffset, db.yOffset)
|
||||
else
|
||||
frame.IconFrame:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Construct_IconFrame(frame)
|
||||
local iconFrame = CreateFrame("Frame", nil, frame)
|
||||
iconFrame:Hide()
|
||||
|
||||
iconFrame:SetSize(24, 24)
|
||||
iconFrame:SetPoint("CENTER")
|
||||
NP:StyleFrame(iconFrame, true)
|
||||
|
||||
iconFrame.texture = iconFrame:CreateTexture()
|
||||
iconFrame.texture:SetAllPoints()
|
||||
iconFrame.texture:SetTexCoord(unpack(E.TexCoords))
|
||||
|
||||
return iconFrame
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
local LSM = E.Libs.LSM
|
||||
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
|
||||
function NP:Update_Level(frame)
|
||||
if not self.db.units[frame.UnitType].level.enable then return end
|
||||
|
||||
local levelText, r, g, b = self:UnitLevel(frame)
|
||||
|
||||
local level = frame.Level
|
||||
level:ClearAllPoints()
|
||||
|
||||
if self.db.units[frame.UnitType].health.enable or (frame.isTarget and self.db.alwaysShowTargetHealth) then
|
||||
level:SetJustifyH("RIGHT")
|
||||
level:SetPoint("BOTTOMRIGHT", frame.Health, "TOPRIGHT", 0, E.Border*2)
|
||||
else
|
||||
level:SetPoint("LEFT", frame.Name, "RIGHT")
|
||||
level:SetJustifyH("LEFT")
|
||||
end
|
||||
|
||||
if self.db.units[frame.UnitType].health.enable or frame.isTarget then
|
||||
level:SetText(levelText)
|
||||
else
|
||||
level:SetFormattedText(" [%s]", levelText)
|
||||
end
|
||||
level:SetTextColor(r, g, b)
|
||||
end
|
||||
|
||||
function NP:Configure_Level(frame)
|
||||
local db = self.db.units[frame.UnitType].level
|
||||
frame.Level:FontTemplate(LSM:Fetch("font", db.font), db.fontSize, db.fontOutline)
|
||||
end
|
||||
|
||||
function NP:Construct_Level(frame)
|
||||
return frame:CreateFontString(nil, "OVERLAY")
|
||||
end
|
||||
@@ -0,0 +1,124 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
local LSM = E.Libs.LSM
|
||||
|
||||
--Lua functions
|
||||
local format = string.format
|
||||
local gmatch = gmatch
|
||||
local gsub = gsub
|
||||
local match = string.match
|
||||
local utf8lower = string.utf8lower
|
||||
local utf8sub = string.utf8sub
|
||||
--WoW API / Variables
|
||||
local UNKNOWN = UNKNOWN
|
||||
|
||||
local function abbrev(name)
|
||||
local letters, lastWord = "", match(name, ".+%s(.+)$")
|
||||
if lastWord then
|
||||
for word in gmatch(name, ".-%s") do
|
||||
local firstLetter = utf8sub(gsub(word, "^[%s%p]*", ""), 1, 1)
|
||||
if firstLetter ~= utf8lower(firstLetter) then
|
||||
letters = format("%s%s. ", letters, firstLetter)
|
||||
end
|
||||
end
|
||||
name = format("%s%s", letters, lastWord)
|
||||
end
|
||||
return name
|
||||
end
|
||||
|
||||
function NP:Update_Name(frame, triggered)
|
||||
if not triggered then
|
||||
if not self.db.units[frame.UnitType].name.enable then return end
|
||||
end
|
||||
|
||||
local name = frame.Name
|
||||
local nameText = frame.UnitName or UNKNOWN
|
||||
name:SetText(self.db.units[frame.UnitType].name.abbrev and abbrev(nameText) or nameText)
|
||||
|
||||
if not triggered then
|
||||
name:ClearAllPoints()
|
||||
if self.db.units[frame.UnitType].health.enable or (self.db.alwaysShowTargetHealth and frame.isTarget) then
|
||||
name:SetJustifyH("LEFT")
|
||||
name:SetPoint("BOTTOMLEFT", frame.Health, "TOPLEFT", 0, E.Border*2)
|
||||
name:SetPoint("BOTTOMRIGHT", frame.Level, "BOTTOMLEFT")
|
||||
else
|
||||
name:SetJustifyH("CENTER")
|
||||
name:SetPoint("TOP", frame)
|
||||
end
|
||||
end
|
||||
|
||||
local r, g, b = 1, 1, 1
|
||||
local class = frame.UnitClass
|
||||
|
||||
local classColor, useClassColor
|
||||
if class then
|
||||
classColor = E.media.herocolor
|
||||
useClassColor = self.db.units[frame.UnitType].name and self.db.units[frame.UnitType].name.useClassColor
|
||||
end
|
||||
|
||||
if useClassColor and (frame.UnitType == "FRIENDLY_PLAYER" or frame.UnitType == "ENEMY_PLAYER") then
|
||||
r, g, b = classColor.r, classColor.g, classColor.b
|
||||
elseif triggered or (not self.db.units[frame.UnitType].health.enable and not frame.isTarget) then
|
||||
local reactionType = frame.UnitReaction
|
||||
if reactionType then
|
||||
local db = self.db.colors
|
||||
if reactionType == 4 then
|
||||
r, g, b = db.reactions.neutral.r, db.reactions.neutral.g, db.reactions.neutral.b
|
||||
elseif reactionType > 4 then
|
||||
if frame.UnitType == "FRIENDLY_PLAYER" then
|
||||
r, g, b = db.reactions.friendlyPlayer.r, db.reactions.friendlyPlayer.g, db.reactions.friendlyPlayer.b
|
||||
else
|
||||
r, g, b = db.reactions.good.r, db.reactions.good.g, db.reactions.good.b
|
||||
end
|
||||
else
|
||||
r, g, b = db.reactions.bad.r, db.reactions.bad.g, db.reactions.bad.b
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- if for some reason the values failed just default to white
|
||||
if not (r and g and b) then
|
||||
r, g, b = 1, 1, 1
|
||||
end
|
||||
|
||||
if triggered or (r ~= frame.Name.r or g ~= frame.Name.g or b ~= frame.Name.b) then
|
||||
name:SetTextColor(r, g, b)
|
||||
if not triggered then
|
||||
frame.Name.r, frame.Name.g, frame.Name.b = r, g, b
|
||||
end
|
||||
end
|
||||
|
||||
if self.db.nameColoredGlow then
|
||||
name.NameOnlyGlow:SetVertexColor(r - 0.1, g - 0.1, b - 0.1, 1)
|
||||
else
|
||||
name.NameOnlyGlow:SetVertexColor(self.db.colors.glowColor.r, self.db.colors.glowColor.g, self.db.colors.glowColor.b, self.db.colors.glowColor.a)
|
||||
end
|
||||
end
|
||||
|
||||
function NP:Configure_Name(frame)
|
||||
local db = self.db.units[frame.UnitType].name
|
||||
frame.Name:FontTemplate(LSM:Fetch("font", db.font), db.fontSize, db.fontOutline)
|
||||
end
|
||||
|
||||
function NP:Configure_NameOnlyGlow(frame)
|
||||
local name = frame.Name
|
||||
name.NameOnlyGlow:ClearAllPoints()
|
||||
name.NameOnlyGlow:SetPoint("TOPLEFT", frame.IconOnlyChanged and frame.IconFrame or name, -20, 8)
|
||||
name.NameOnlyGlow:SetPoint("BOTTOMRIGHT", frame.IconOnlyChanged and frame.IconFrame or name, 20, -8)
|
||||
end
|
||||
|
||||
function NP:Construct_Name(frame)
|
||||
local name = frame:CreateFontString(nil, "OVERLAY")
|
||||
name:SetJustifyV("BOTTOM")
|
||||
name:SetWordWrap(false)
|
||||
|
||||
local g = frame:CreateTexture(nil, "BACKGROUND")
|
||||
g:SetTexture(E.Media.Textures.Spark)
|
||||
g:Hide()
|
||||
g:SetPoint("TOPLEFT", name, -20, 8)
|
||||
g:SetPoint("BOTTOMRIGHT", name, 20, -8)
|
||||
|
||||
name.NameOnlyGlow = g
|
||||
|
||||
return name
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local NP = E:GetModule("NamePlates")
|
||||
|
||||
--Lua functions
|
||||
--WoW API / Variables
|
||||
|
||||
function NP:Update_RaidIcon(frame)
|
||||
local db = self.db.units[frame.UnitType].raidTargetIndicator
|
||||
local icon = frame.RaidIcon
|
||||
|
||||
icon:SetSize(db.size, db.size)
|
||||
|
||||
icon:ClearAllPoints()
|
||||
if frame.Health:IsShown() then
|
||||
icon:SetPoint(E.InversePoints[db.position], frame.Health, db.position, db.xOffset, db.yOffset)
|
||||
else
|
||||
icon:SetPoint("BOTTOM", frame, "TOP", 0, 15)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user