Modules/NamePlates: Add support for new nameplates

This commit is contained in:
andrew6180
2024-04-09 16:41:00 -07:00
parent 7ca1b5967b
commit d2e86421cc
5 changed files with 44 additions and 31 deletions
+19
View File
@@ -396,6 +396,9 @@ function E:IncompatibleAddOn(addon, module)
end end
function E:IsAddOnEnabled(addon) function E:IsAddOnEnabled(addon)
if addon == "Ascension_NamePlates" then
return C_CVar.GetBool("useNewNamePlates")
end
local _, _, _, enabled, _, reason = GetAddOnInfo(addon) local _, _, _, enabled, _, reason = GetAddOnInfo(addon)
if reason ~= "MISSING" and enabled then if reason ~= "MISSING" and enabled then
return true return true
@@ -420,6 +423,10 @@ function E:CheckIncompatible()
self:IncompatibleAddOn("Healers-Have-To-Die", "NamePlates") self:IncompatibleAddOn("Healers-Have-To-Die", "NamePlates")
elseif self:IsAddOnEnabled("TidyPlates") then elseif self:IsAddOnEnabled("TidyPlates") then
self:IncompatibleAddOn("TidyPlates", "NamePlates") self:IncompatibleAddOn("TidyPlates", "NamePlates")
elseif self:IsAddOnEnabled("Ascension_NamePlates") then
self:IncompatibleAddOn("Ascension_NamePlates", "NamePlates")
elseif self:IsAddOnEnabled("Kui_Nameplates") then
self:IncompatibleAddOn("Kui_Nameplates", "NamePlates")
end end
end end
@@ -1111,6 +1118,18 @@ function E:DBConversions()
E:CopyTable(self.db.nameplates, P.nameplates) E:CopyTable(self.db.nameplates, P.nameplates)
end end
if E.db.version and E.db.version < 7.13 then
if E.db.nameplates.plateSize.enemyWidth then
E.db.nameplates.plateSize.width = E.db.nameplates.plateSize.enemyWidth
E.db.nameplates.plateSize.enemyWidth = nil
end
if E.db.nameplates.plateSize.enemyHeight then
E.db.nameplates.plateSize.width = E.db.nameplates.plateSize.enemyHeight
E.db.nameplates.plateSize.enemyHeight = nil
end
end
E.db.version = E.versionNum E.db.version = E.versionNum
end end
+8 -1
View File
@@ -166,7 +166,14 @@ E.PopupDialogs.DISABLE_INCOMPATIBLE_ADDON = {
E.PopupDialogs.INCOMPATIBLE_ADDON = { E.PopupDialogs.INCOMPATIBLE_ADDON = {
text = L["INCOMPATIBLE_ADDON"], text = L["INCOMPATIBLE_ADDON"],
OnAccept = function() DisableAddOn(E.PopupDialogs.INCOMPATIBLE_ADDON.addon) ReloadUI() end, OnAccept = function()
if E.PopupDialogs.INCOMPATIBLE_ADDON.addon == "Ascension_NamePlates" then
C_CVar.Set("useNewNamePlates", "0")
else
DisableAddOn(E.PopupDialogs.INCOMPATIBLE_ADDON.addon)
end
ReloadUI()
end,
OnCancel = function() E.private[strlower(E.PopupDialogs.INCOMPATIBLE_ADDON.module)].enable = false ReloadUI() end, OnCancel = function() E.private[strlower(E.PopupDialogs.INCOMPATIBLE_ADDON.module)].enable = false ReloadUI() end,
button3 = L["Disable Warning"], button3 = L["Disable Warning"],
OnAlt = function () OnAlt = function ()
+13 -17
View File
@@ -33,8 +33,15 @@ local UnitIsUnit = UnitIsUnit
local UnitName = UnitName local UnitName = UnitName
local UnitReaction = UnitReaction local UnitReaction = UnitReaction
local UnitThreatSituation = UnitThreatSituation local UnitThreatSituation = UnitThreatSituation
local C_NamePlate_SetNamePlateEnemySize = C_NamePlateManager.SetNamePlateEnemySize local C_NamePlateManager_SetNamePlateSize
local C_NamePlate_SetNamePlateFriendlySize = C_NamePlateManager.SetNamePlateFriendlySize if not C_NamePlateManager.GetNamePlateSize then -- if this function isnt set, we are on old version still
C_NamePlateManager_SetNamePlateSize = function(width, height)
C_NamePlateManager.SetNamePlateFriendlySize(width, height)
C_NamePlateManager.SetNamePlateEnemySize(width, height)
end
else
C_NamePlateManager_SetNamePlateSize = C_NamePlateManager.SetNamePlateSize
end
local hooksecurefunc = hooksecurefunc local hooksecurefunc = hooksecurefunc
do -- credit: oUF/private.lua do -- credit: oUF/private.lua
@@ -487,11 +494,7 @@ function NP:ConfigurePlates(init)
NP.SkipFading = true NP.SkipFading = true
if not init then -- these only need to happen when changing options if not init then -- these only need to happen when changing options
for nameplate in pairs(NP.Plates) do for nameplate in pairs(NP.Plates) do
if nameplate.frameType == 'FRIENDLY_PLAYER' or nameplate.frameType == 'FRIENDLY_NPC' then nameplate:Size(NP.db.plateSize.width, NP.db.plateSize.height)
nameplate:Size(NP.db.plateSize.friendlyWidth, NP.db.plateSize.friendlyHeight)
else
nameplate:Size(NP.db.plateSize.enemyWidth, NP.db.plateSize.enemyHeight)
end
nameplate.previousType = nil -- keep over the callback, we still need a full update nameplate.previousType = nil -- keep over the callback, we still need a full update
NP:NamePlateCallBack(nameplate, 'NAME_PLATE_UNIT_ADDED') NP:NamePlateCallBack(nameplate, 'NAME_PLATE_UNIT_ADDED')
@@ -557,14 +560,8 @@ function NP:UpdatePlateType(nameplate)
end end
function NP:UpdatePlateSize(nameplate) function NP:UpdatePlateSize(nameplate)
if nameplate.frameType == 'FRIENDLY_PLAYER' or nameplate.frameType == 'FRIENDLY_NPC' then nameplate.width, nameplate.height = NP.db.plateSize.width, NP.db.plateSize.height
nameplate.width, nameplate.height = NP.db.plateSize.friendlyWidth, NP.db.plateSize.friendlyHeight C_NamePlateManager_SetNamePlateSize(nameplate.width, nameplate.height)
C_NamePlate_SetNamePlateFriendlySize(nameplate.width, nameplate.height)
else
nameplate.width, nameplate.height = NP.db.plateSize.enemyWidth, NP.db.plateSize.enemyHeight
C_NamePlate_SetNamePlateEnemySize(nameplate.width, nameplate.height)
end
nameplate:Size(nameplate.width, nameplate.height) nameplate:Size(nameplate.width, nameplate.height)
end end
@@ -681,8 +678,7 @@ end
function NP:SetNamePlateSizes() function NP:SetNamePlateSizes()
--if InCombatLockdown() then return end --if InCombatLockdown() then return end
C_NamePlate_SetNamePlateEnemySize(NP.db.plateSize.enemyWidth, NP.db.plateSize.enemyHeight) C_NamePlateManager_SetNamePlateSize(NP.db.plateSize.width, NP.db.plateSize.height)
C_NamePlate_SetNamePlateFriendlySize(NP.db.plateSize.friendlyWidth, NP.db.plateSize.friendlyHeight)
end end
function NP:Initialize() function NP:Initialize()
+2 -4
View File
@@ -496,10 +496,8 @@ P.nameplates = {
plateSize = { plateSize = {
personalWidth = 150, personalWidth = 150,
personalHeight = 30, personalHeight = 30,
friendlyWidth = 150, width = 150,
friendlyHeight = 30, height = 30,
enemyWidth = 150,
enemyHeight = 30,
}, },
threat = { threat = {
enable = true, enable = true,
+2 -9
View File
@@ -430,15 +430,8 @@ NamePlates.generalGroup.args.bossMods.args.settings.args.growthDirection = ACH:S
NamePlates.generalGroup.args.clickableRange = ACH:Group(L["Clickable Size"], nil, 70, nil, function(info) return E.db.nameplates.plateSize[info[#info]] end, function(info, value) E.db.nameplates.plateSize[info[#info]] = value NP:ConfigureAll() end) NamePlates.generalGroup.args.clickableRange = ACH:Group(L["Clickable Size"], nil, 70, nil, function(info) return E.db.nameplates.plateSize[info[#info]] end, function(info, value) E.db.nameplates.plateSize[info[#info]] = value NP:ConfigureAll() end)
NamePlates.generalGroup.args.clickableRange.args.friendly = ACH:Group(L["Friendly"], nil, 2) NamePlates.generalGroup.args.clickableRange.args.width = ACH:Range(L["Clickable Width / Width"], L["Change the width and controls how big of an area on the screen will accept clicks to target unit."], 1, { min = 50, max = 250, step = 1 })
NamePlates.generalGroup.args.clickableRange.args.friendly.inline = true NamePlates.generalGroup.args.clickableRange.args.height = ACH:Range(L["Clickable Height"], L["Controls how big of an area on the screen will accept clicks to target unit."], 2, { min = 10, max = 75, step = 1 })
NamePlates.generalGroup.args.clickableRange.args.friendly.args.friendlyWidth = ACH:Range(L["Clickable Width / Width"], L["Change the width and controls how big of an area on the screen will accept clicks to target unit."], 1, { min = 50, max = 250, step = 1 })
NamePlates.generalGroup.args.clickableRange.args.friendly.args.friendlyHeight = ACH:Range(L["Clickable Height"], L["Controls how big of an area on the screen will accept clicks to target unit."], 2, { min = 10, max = 75, step = 1 })
NamePlates.generalGroup.args.clickableRange.args.enemy = ACH:Group(L["Enemy"], nil, 3)
NamePlates.generalGroup.args.clickableRange.args.enemy.inline = true
NamePlates.generalGroup.args.clickableRange.args.enemy.args.enemyWidth = ACH:Range(L["Clickable Width / Width"], L["Change the width and controls how big of an area on the screen will accept clicks to target unit."], 1, { min = 50, max = 250, step = 1 })
NamePlates.generalGroup.args.clickableRange.args.enemy.args.enemyHeight = ACH:Range(L["Clickable Height"], L["Controls how big of an area on the screen will accept clicks to target unit."], 2, { min = 10, max = 75, step = 1 })
NamePlates.generalGroup.args.cutaway = ACH:Group(L["Cutaway Bars"], nil, 75) NamePlates.generalGroup.args.cutaway = ACH:Group(L["Cutaway Bars"], nil, 75)
NamePlates.generalGroup.args.cutaway.args.health = ACH:Group(L["Health"], nil, 1, nil, function(info) return E.db.nameplates.cutaway.health[info[#info]] end, function(info, value) E.db.nameplates.cutaway.health[info[#info]] = value NP:ConfigureAll() end) NamePlates.generalGroup.args.cutaway.args.health = ACH:Group(L["Health"], nil, 1, nil, function(info) return E.db.nameplates.cutaway.health[info[#info]] end, function(info, value) E.db.nameplates.cutaway.health[info[#info]] = value NP:ConfigureAll() end)