452 lines
17 KiB
Lua
452 lines
17 KiB
Lua
BNP = BNP or {}
|
|
|
|
BNP.defaults = BNP.defaults or {
|
|
nameplateScale = 1.0,
|
|
nameplateYOffset = 0,
|
|
comboPointsYOffset = 0,
|
|
nameFontSize = 12,
|
|
nameFontYOffset = 0,
|
|
nonTargetAlpha = 1.0,
|
|
iconSize = 18,
|
|
auraFontSize = 8,
|
|
ccIconSize = 18,
|
|
debuffYOffset = 0,
|
|
ccYOffset = 0,
|
|
debuffPosition = "top",
|
|
ccPosition = "top",
|
|
tankMode = false,
|
|
invertTankColors = false,
|
|
classColors = true,
|
|
darkNameplateBorder = false,
|
|
blackHealthbarBackground = false,
|
|
darkComboPointBorder = false,
|
|
hidePlayerNames = false,
|
|
hideNPCNames = false,
|
|
castbars = true,
|
|
castbarIcon = true,
|
|
debuffs = true,
|
|
crowdControl = true,
|
|
separateCCRow = true,
|
|
showOtherCCs = true,
|
|
pvpImmunities = true,
|
|
immunityIconSize = 18,
|
|
immunityPosition = "top",
|
|
immunityYOffset = 0,
|
|
castbarHeight = 6,
|
|
castbarFontSize = 10,
|
|
castbarStyle = "modern",
|
|
castbarXOffset = 0,
|
|
castbarYOffset = 0,
|
|
minimapAngle = 225,
|
|
healthPercent = false,
|
|
healthText = "off",
|
|
healthTextFontSize = 9,
|
|
healthTextOutline = "outline",
|
|
targetFocus = true,
|
|
targetGlowColor = "white",
|
|
targetGlowSize = 0,
|
|
targetGlowOpacity = 1.0,
|
|
targetArrows = false,
|
|
targetArrowColor = "match",
|
|
targetArrowSize = 14,
|
|
targetArrowThick = false,
|
|
targetArrowStyle = "chevron",
|
|
comboPoints = true,
|
|
totemIndicators = true,
|
|
totemIconSize = 24,
|
|
}
|
|
|
|
function BNP:InitConfig()
|
|
BNP_DB = BNP_DB or {}
|
|
|
|
if BNP_DB.nameplateScale == nil then BNP_DB.nameplateScale = self.defaults.nameplateScale end
|
|
if BNP_DB.nameplateYOffset == nil then BNP_DB.nameplateYOffset = self.defaults.nameplateYOffset end
|
|
if BNP_DB.comboPointsYOffset == nil then BNP_DB.comboPointsYOffset = self.defaults.comboPointsYOffset end
|
|
-- nameFontSize intentionally stays nil until the user moves the slider.
|
|
-- This preserves the exact font size provided by Blizzard/skin addons on update.
|
|
if BNP_DB.nameFontYOffset == nil then BNP_DB.nameFontYOffset = self.defaults.nameFontYOffset end
|
|
if BNP_DB.nonTargetAlpha == nil then BNP_DB.nonTargetAlpha = self.defaults.nonTargetAlpha end
|
|
if BNP_DB.iconSize == nil then BNP_DB.iconSize = self.defaults.iconSize end
|
|
if BNP_DB.auraFontSize == nil then BNP_DB.auraFontSize = self.defaults.auraFontSize end
|
|
if BNP_DB.ccIconSize == nil then BNP_DB.ccIconSize = BNP_DB.iconSize or self.defaults.ccIconSize end
|
|
if BNP_DB.debuffYOffset == nil then BNP_DB.debuffYOffset = self.defaults.debuffYOffset end
|
|
if BNP_DB.ccYOffset == nil then BNP_DB.ccYOffset = self.defaults.ccYOffset end
|
|
if BNP_DB.debuffPosition == nil then BNP_DB.debuffPosition = self.defaults.debuffPosition end
|
|
if BNP_DB.ccPosition == nil then BNP_DB.ccPosition = BNP_DB.debuffPosition or self.defaults.ccPosition end
|
|
if BNP_DB.tankMode == nil then BNP_DB.tankMode = self.defaults.tankMode end
|
|
if BNP_DB.invertTankColors == nil then BNP_DB.invertTankColors = self.defaults.invertTankColors end
|
|
if BNP_DB.classColors == nil then BNP_DB.classColors = self.defaults.classColors end
|
|
if BNP_DB.darkNameplateBorder == nil then BNP_DB.darkNameplateBorder = self.defaults.darkNameplateBorder end
|
|
if BNP_DB.blackHealthbarBackground == nil then BNP_DB.blackHealthbarBackground = self.defaults.blackHealthbarBackground end
|
|
if BNP_DB.darkComboPointBorder == nil then BNP_DB.darkComboPointBorder = self.defaults.darkComboPointBorder end
|
|
if BNP_DB.hidePlayerNames == nil then BNP_DB.hidePlayerNames = self.defaults.hidePlayerNames end
|
|
if BNP_DB.hideNPCNames == nil then BNP_DB.hideNPCNames = self.defaults.hideNPCNames end
|
|
if BNP_DB.castbars == nil then BNP_DB.castbars = self.defaults.castbars end
|
|
if BNP_DB.castbarIcon == nil then BNP_DB.castbarIcon = self.defaults.castbarIcon end
|
|
-- Retired: castbar spark/end glow is now always enabled.
|
|
BNP_DB.castbarEndGlow = nil
|
|
if BNP_DB.debuffs == nil then BNP_DB.debuffs = self.defaults.debuffs end
|
|
if BNP_DB.crowdControl == nil then BNP_DB.crowdControl = (BNP_DB.debuffs ~= false) and true or false end
|
|
if BNP_DB.separateCCRow == nil then BNP_DB.separateCCRow = self.defaults.separateCCRow end
|
|
if BNP_DB.showOtherCCs == nil then BNP_DB.showOtherCCs = self.defaults.showOtherCCs end
|
|
if BNP_DB.pvpImmunities == nil then BNP_DB.pvpImmunities = self.defaults.pvpImmunities end
|
|
if BNP_DB.immunityIconSize == nil then BNP_DB.immunityIconSize = BNP_DB.iconSize or self.defaults.immunityIconSize end
|
|
if BNP_DB.immunityPosition == nil then BNP_DB.immunityPosition = self.defaults.immunityPosition end
|
|
if BNP_DB.immunityYOffset == nil then BNP_DB.immunityYOffset = self.defaults.immunityYOffset end
|
|
-- Position migration from the temporary all-Bottom test build.
|
|
if BNP_DB.debuffPosition == "bottom" then BNP_DB.debuffPosition = "bottom_mid" end
|
|
if BNP_DB.ccPosition == "bottom" then BNP_DB.ccPosition = "top" end
|
|
if BNP_DB.immunityPosition == "bottom" then BNP_DB.immunityPosition = "top" end
|
|
if BNP_DB.castbarHeight == nil then BNP_DB.castbarHeight = self.defaults.castbarHeight end
|
|
-- Retired: Castbar Y Offset now owns vertical placement by itself.
|
|
BNP_DB.castbarSpacing = nil
|
|
if BNP_DB.castbarFontSize == nil then BNP_DB.castbarFontSize = self.defaults.castbarFontSize end
|
|
if BNP_DB.castbarStyle == nil then BNP_DB.castbarStyle = self.defaults.castbarStyle end
|
|
if BNP_DB.castbarXOffset == nil then BNP_DB.castbarXOffset = self.defaults.castbarXOffset end
|
|
if BNP_DB.castbarYOffset == nil then BNP_DB.castbarYOffset = self.defaults.castbarYOffset end
|
|
if BNP_DB.minimapAngle == nil then BNP_DB.minimapAngle = self.defaults.minimapAngle end
|
|
if BNP_DB.healthPercent == nil then BNP_DB.healthPercent = self.defaults.healthPercent end
|
|
if BNP_DB.healthText == nil then
|
|
-- Backwards-compatible migration from the old Health % checkbox.
|
|
BNP_DB.healthText = BNP_DB.healthPercent and "percent" or self.defaults.healthText
|
|
end
|
|
if BNP_DB.healthTextFontSize == nil then BNP_DB.healthTextFontSize = self.defaults.healthTextFontSize end
|
|
if BNP_DB.healthTextOutline == nil then BNP_DB.healthTextOutline = self.defaults.healthTextOutline end
|
|
if BNP_DB.targetFocus == nil then BNP_DB.targetFocus = self.defaults.targetFocus end
|
|
if BNP_DB.targetGlowColor == nil then BNP_DB.targetGlowColor = self.defaults.targetGlowColor end
|
|
if BNP_DB.targetGlowSize == nil then BNP_DB.targetGlowSize = self.defaults.targetGlowSize end
|
|
if BNP_DB.targetGlowOpacity == nil then BNP_DB.targetGlowOpacity = self.defaults.targetGlowOpacity end
|
|
if BNP_DB.targetArrows == nil then BNP_DB.targetArrows = self.defaults.targetArrows end
|
|
if BNP_DB.targetArrowColor == nil then BNP_DB.targetArrowColor = self.defaults.targetArrowColor end
|
|
if BNP_DB.targetArrowSize == nil then BNP_DB.targetArrowSize = self.defaults.targetArrowSize end
|
|
if BNP_DB.targetArrowThick == nil then BNP_DB.targetArrowThick = self.defaults.targetArrowThick end
|
|
if BNP_DB.targetArrowStyle == nil then BNP_DB.targetArrowStyle = self.defaults.targetArrowStyle end
|
|
if BNP_DB.comboPoints == nil then BNP_DB.comboPoints = self.defaults.comboPoints end
|
|
if BNP_DB.totemIndicators == nil then BNP_DB.totemIndicators = self.defaults.totemIndicators end
|
|
if BNP_DB.totemIconSize == nil then BNP_DB.totemIconSize = self.defaults.totemIconSize end
|
|
end
|
|
|
|
function BNP:GetNameplateScale()
|
|
return (BNP_DB and tonumber(BNP_DB.nameplateScale)) or self.defaults.nameplateScale
|
|
end
|
|
|
|
function BNP:GetNameplateYOffset()
|
|
local value = (BNP_DB and tonumber(BNP_DB.nameplateYOffset)) or self.defaults.nameplateYOffset or 0
|
|
if value < 0 then value = 0 end
|
|
if value > 50 then value = 50 end
|
|
return value
|
|
end
|
|
|
|
|
|
local function ClampVisualYOffset(value)
|
|
value = tonumber(value) or 0
|
|
if value < -50 then value = -50 end
|
|
if value > 50 then value = 50 end
|
|
return value >= 0 and math.floor(value + 0.5) or math.ceil(value - 0.5)
|
|
end
|
|
|
|
function BNP:GetComboPointsYOffset()
|
|
return ClampVisualYOffset(BNP_DB and BNP_DB.comboPointsYOffset or self.defaults.comboPointsYOffset)
|
|
end
|
|
|
|
function BNP:GetNameFontSize()
|
|
local explicit = BNP_DB and tonumber(BNP_DB.nameFontSize)
|
|
local value = explicit or tonumber(self.defaultNameFontSize) or self.defaults.nameFontSize or 12
|
|
if value < 8 then value = 8 end
|
|
if value > 24 then value = 24 end
|
|
return math.floor(value + 0.5)
|
|
end
|
|
|
|
function BNP:GetNameFontYOffset()
|
|
return ClampVisualYOffset(BNP_DB and BNP_DB.nameFontYOffset or self.defaults.nameFontYOffset)
|
|
end
|
|
|
|
function BNP:GetDebuffYOffset()
|
|
return ClampVisualYOffset(BNP_DB and BNP_DB.debuffYOffset or self.defaults.debuffYOffset)
|
|
end
|
|
|
|
function BNP:GetCCYOffset()
|
|
return ClampVisualYOffset(BNP_DB and BNP_DB.ccYOffset or self.defaults.ccYOffset)
|
|
end
|
|
|
|
function BNP:GetImmunityYOffset()
|
|
return ClampVisualYOffset(BNP_DB and BNP_DB.immunityYOffset or self.defaults.immunityYOffset)
|
|
end
|
|
|
|
function BNP:GetNonTargetAlpha()
|
|
local value = (BNP_DB and tonumber(BNP_DB.nonTargetAlpha)) or self.defaults.nonTargetAlpha or 1.0
|
|
if value < 0.30 then value = 0.30 end
|
|
if value > 1.00 then value = 1.00 end
|
|
return value
|
|
end
|
|
|
|
function BNP:GetIconSize()
|
|
return (BNP_DB and tonumber(BNP_DB.iconSize)) or self.defaults.iconSize
|
|
end
|
|
|
|
function BNP:GetAuraFontSize()
|
|
local value = (BNP_DB and tonumber(BNP_DB.auraFontSize)) or self.defaults.auraFontSize or 8
|
|
if value < 6 then value = 6 end
|
|
if value > 18 then value = 18 end
|
|
return math.floor(value + 0.5)
|
|
end
|
|
|
|
function BNP:GetCCIconSize()
|
|
local value = (BNP_DB and tonumber(BNP_DB.ccIconSize)) or self.defaults.ccIconSize or self:GetIconSize()
|
|
if value < 12 then value = 12 end
|
|
if value > 32 then value = 32 end
|
|
return value
|
|
end
|
|
|
|
function BNP:GetDebuffPosition()
|
|
local position = (BNP_DB and BNP_DB.debuffPosition) or self.defaults.debuffPosition or "top"
|
|
-- Migrate the first Bottom implementation to the new centered Bottom option.
|
|
if position == "bottom" then position = "bottom_mid" end
|
|
if position ~= "top" and position ~= "top_left" and position ~= "top_right"
|
|
and position ~= "left" and position ~= "right"
|
|
and position ~= "bottom_mid" and position ~= "bottom_left" and position ~= "bottom_right" then
|
|
position = "top"
|
|
end
|
|
return position
|
|
end
|
|
|
|
function BNP:GetCCPosition()
|
|
local position = (BNP_DB and BNP_DB.ccPosition) or self.defaults.ccPosition or "top"
|
|
-- Bottom is intentionally not supported for CCs.
|
|
if position ~= "top" and position ~= "left" and position ~= "right" then
|
|
position = "top"
|
|
end
|
|
return position
|
|
end
|
|
|
|
function BNP:GetImmunityIconSize()
|
|
local value = (BNP_DB and tonumber(BNP_DB.immunityIconSize)) or self.defaults.immunityIconSize or self:GetIconSize()
|
|
if value < 12 then value = 12 end
|
|
if value > 32 then value = 32 end
|
|
return value
|
|
end
|
|
|
|
function BNP:GetImmunityPosition()
|
|
local position = (BNP_DB and BNP_DB.immunityPosition) or self.defaults.immunityPosition or "top"
|
|
-- Bottom is intentionally not supported for immunities.
|
|
if position ~= "top" and position ~= "left" and position ~= "right" then
|
|
position = "top"
|
|
end
|
|
return position
|
|
end
|
|
|
|
|
|
function BNP:IsTankModeEnabled()
|
|
return BNP_DB and BNP_DB.tankMode and true or false
|
|
end
|
|
|
|
function BNP:AreTankModeColorsInverted()
|
|
return BNP_DB and BNP_DB.invertTankColors and true or false
|
|
end
|
|
|
|
function BNP:AreClassColorsEnabled()
|
|
return not BNP_DB or BNP_DB.classColors ~= false
|
|
end
|
|
|
|
function BNP:IsDarkNameplateBorderEnabled()
|
|
return BNP_DB and BNP_DB.darkNameplateBorder and true or false
|
|
end
|
|
|
|
function BNP:IsBlackHealthbarBackgroundEnabled()
|
|
return BNP_DB and BNP_DB.blackHealthbarBackground and true or false
|
|
end
|
|
|
|
function BNP:HidePlayerNamesEnabled()
|
|
return BNP_DB and BNP_DB.hidePlayerNames and true or false
|
|
end
|
|
|
|
function BNP:HideNPCNamesEnabled()
|
|
return BNP_DB and BNP_DB.hideNPCNames and true or false
|
|
end
|
|
|
|
function BNP:AreCastbarsEnabled()
|
|
return not BNP_DB or BNP_DB.castbars ~= false
|
|
end
|
|
|
|
function BNP:IsCastbarIconEnabled()
|
|
return not BNP_DB or BNP_DB.castbarIcon ~= false
|
|
end
|
|
|
|
function BNP:GetCastbarHeight()
|
|
local value = (BNP_DB and tonumber(BNP_DB.castbarHeight)) or self.defaults.castbarHeight
|
|
local style = (BNP_DB and BNP_DB.castbarStyle) or self.defaults.castbarStyle or "modern"
|
|
local minValue = style == "classic" and 8 or 4
|
|
if value < minValue then value = minValue end
|
|
if value > 20 then value = 20 end
|
|
return value
|
|
end
|
|
|
|
function BNP:GetCastbarFontSize()
|
|
local value = (BNP_DB and tonumber(BNP_DB.castbarFontSize)) or self.defaults.castbarFontSize or 10
|
|
if value < 6 then value = 6 end
|
|
if value > 18 then value = 18 end
|
|
return math.floor(value + 0.5)
|
|
end
|
|
|
|
function BNP:GetCastbarStyle()
|
|
local style = (BNP_DB and BNP_DB.castbarStyle) or self.defaults.castbarStyle or "modern"
|
|
if style ~= "modern" and style ~= "classic" then style = "modern" end
|
|
return style
|
|
end
|
|
|
|
function BNP:GetCastbarXOffset()
|
|
return ClampVisualYOffset(BNP_DB and BNP_DB.castbarXOffset or self.defaults.castbarXOffset)
|
|
end
|
|
|
|
function BNP:GetCastbarYOffset()
|
|
return ClampVisualYOffset(BNP_DB and BNP_DB.castbarYOffset or self.defaults.castbarYOffset)
|
|
end
|
|
|
|
function BNP:GetHealthTextMode()
|
|
local mode = (BNP_DB and BNP_DB.healthText) or self.defaults.healthText or "off"
|
|
if mode ~= "off" and mode ~= "percent" and mode ~= "hp" and mode ~= "both" then
|
|
mode = "off"
|
|
end
|
|
return mode
|
|
end
|
|
|
|
function BNP:IsHealthPercentEnabled()
|
|
local mode = self:GetHealthTextMode()
|
|
return mode == "percent" or mode == "both"
|
|
end
|
|
|
|
function BNP:IsHealthTextEnabled()
|
|
return self:GetHealthTextMode() ~= "off"
|
|
end
|
|
|
|
function BNP:GetHealthTextFontSize()
|
|
local value = (BNP_DB and tonumber(BNP_DB.healthTextFontSize)) or self.defaults.healthTextFontSize or 9
|
|
if value < 8 then value = 8 end
|
|
if value > 20 then value = 20 end
|
|
return math.floor(value + 0.5)
|
|
end
|
|
|
|
function BNP:GetHealthTextOutline()
|
|
local value = (BNP_DB and BNP_DB.healthTextOutline) or self.defaults.healthTextOutline or "outline"
|
|
if value ~= "none" and value ~= "outline" and value ~= "thick" then
|
|
value = "outline"
|
|
end
|
|
return value
|
|
end
|
|
|
|
function BNP:IsTargetFocusEnabled()
|
|
return not BNP_DB or BNP_DB.targetFocus ~= false
|
|
end
|
|
|
|
-- Shared immutable target colors. Keeping this table outside the getters avoids
|
|
-- allocating two new color maps over and over from the per-frame target path.
|
|
local TARGET_INDICATOR_COLORS = {
|
|
white = { 1.00, 1.00, 1.00 },
|
|
gold = { 1.00, 0.82, 0.10 },
|
|
blue = { 0.25, 0.55, 1.00 },
|
|
green = { 0.25, 1.00, 0.35 },
|
|
red = { 1.00, 0.20, 0.20 },
|
|
purple = { 0.75, 0.35, 1.00 },
|
|
black = { 0.00, 0.00, 0.00 },
|
|
}
|
|
|
|
function BNP:GetTargetGlowColor()
|
|
local key = (BNP_DB and BNP_DB.targetGlowColor) or self.defaults.targetGlowColor or "white"
|
|
local c = TARGET_INDICATOR_COLORS[key] or TARGET_INDICATOR_COLORS.white
|
|
return c[1], c[2], c[3], key
|
|
end
|
|
|
|
|
|
function BNP:GetTargetGlowSize()
|
|
local value = (BNP_DB and tonumber(BNP_DB.targetGlowSize)) or self.defaults.targetGlowSize or 0
|
|
if value < 0 then value = 0 end
|
|
if value > 20 then value = 20 end
|
|
return value
|
|
end
|
|
|
|
function BNP:GetTargetGlowOpacity()
|
|
local value = (BNP_DB and tonumber(BNP_DB.targetGlowOpacity)) or self.defaults.targetGlowOpacity or 1.0
|
|
if value < 0.20 then value = 0.20 end
|
|
if value > 1.00 then value = 1.00 end
|
|
return value
|
|
end
|
|
|
|
function BNP:AreTargetArrowsEnabled()
|
|
return BNP_DB and BNP_DB.targetArrows == true
|
|
end
|
|
|
|
function BNP:GetTargetArrowColor()
|
|
local key = (BNP_DB and BNP_DB.targetArrowColor) or self.defaults.targetArrowColor or "match"
|
|
if key == "match" then
|
|
local r, g, b = self:GetTargetGlowColor()
|
|
return r, g, b, key
|
|
end
|
|
|
|
local c = TARGET_INDICATOR_COLORS[key] or TARGET_INDICATOR_COLORS.white
|
|
return c[1], c[2], c[3], key
|
|
end
|
|
|
|
function BNP:GetTargetArrowSize()
|
|
local value = (BNP_DB and tonumber(BNP_DB.targetArrowSize)) or self.defaults.targetArrowSize or 14
|
|
if value < 10 then value = 10 end
|
|
if value > 24 then value = 24 end
|
|
return value
|
|
end
|
|
|
|
function BNP:AreTargetArrowsThick()
|
|
return BNP_DB and BNP_DB.targetArrowThick == true
|
|
end
|
|
|
|
function BNP:GetTargetArrowStyle()
|
|
local style = (BNP_DB and BNP_DB.targetArrowStyle) or self.defaults.targetArrowStyle or "chevron"
|
|
if style ~= "chevron" and style ~= "triangle" and style ~= "slim_triangle"
|
|
and style ~= "double_chevron" and style ~= "diamond_tip" then
|
|
style = "chevron"
|
|
end
|
|
return style
|
|
end
|
|
|
|
function BNP:AreComboPointsEnabled()
|
|
return not BNP_DB or BNP_DB.comboPoints ~= false
|
|
end
|
|
|
|
function BNP:IsDarkComboPointBorderEnabled()
|
|
return BNP_DB and BNP_DB.darkComboPointBorder == true
|
|
end
|
|
|
|
function BNP:AreTotemIndicatorsEnabled()
|
|
return not BNP_DB or BNP_DB.totemIndicators ~= false
|
|
end
|
|
|
|
function BNP:GetTotemIconSize()
|
|
local value = (BNP_DB and tonumber(BNP_DB.totemIconSize)) or self.defaults.totemIconSize or 24
|
|
if value < 16 then value = 16 end
|
|
if value > 36 then value = 36 end
|
|
return value
|
|
end
|
|
|
|
|
|
function BNP:AreDebuffsEnabled()
|
|
return not BNP_DB or BNP_DB.debuffs ~= false
|
|
end
|
|
|
|
function BNP:AreCrowdControlEnabled()
|
|
return not BNP_DB or BNP_DB.crowdControl ~= false
|
|
end
|
|
|
|
function BNP:AreAnyAurasEnabled()
|
|
return self:AreDebuffsEnabled() or self:AreCrowdControlEnabled()
|
|
end
|
|
|
|
function BNP:IsSeparateCCRowEnabled()
|
|
return not BNP_DB or BNP_DB.separateCCRow ~= false
|
|
end
|
|
|
|
function BNP:ShowOtherPlayersCCs()
|
|
return not BNP_DB or BNP_DB.showOtherCCs ~= false
|
|
end
|
|
|
|
function BNP:ArePvPImmunitiesEnabled()
|
|
return not BNP_DB or BNP_DB.pvpImmunities ~= false
|
|
end
|