Skip to content

Commit

Permalink
Add enviroment conditions settings to control nameplate cvars automat…
Browse files Browse the repository at this point in the history
…ically toggling under certain conditions.
  • Loading branch information
Elv-Tukui committed Jan 5, 2025
1 parent 5938e8c commit e669d34
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
58 changes: 58 additions & 0 deletions ElvUI/Core/Defaults/Profile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -934,14 +934,72 @@ P.nameplates = {
minus = true,
pets = false,
totems = false,
enviromentConditionals = {
enabled = true,
dungeons = true,
raids = true,
arena = true,
battleground = true,
resting = true,
world = true,
},
},
friendly = {
guardians = false,
minions = false,
npcs = true,
pets = false,
totems = false,
enviromentConditionals = {
enabled = true,
dungeons = false,
raids = false,
arena = false,
battleground = false,
resting = true,
world = true,
},
},
stackingNameplates = {
enviromentConditionals = {
enabled = true,
dungeons = true,
raids = true,
arena = true,
battleground = true,
resting = false,
world = true,
},
},
},
enviromentConditions = {
enemyEnabled = true,
enemy = {
dungeons = true,
raids = true,
arena = true,
battleground = true,
resting = true,
world = true,
},
friendlyEnabled = true,
friendly = {
dungeons = false,
raids = false,
arena = false,
battleground = false,
resting = true,
world = true,
},
stackingEnabled = true,
stackingNameplates = {
dungeons = true,
raids = true,
arena = true,
battleground = true,
resting = false,
world = true,
},
},
cutaway = {
health = {
Expand Down
73 changes: 73 additions & 0 deletions ElvUI/Core/Modules/Nameplates/Nameplates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,81 @@ function NP:GROUP_LEFT()
wipe(NP.GroupRoles)
end

function NP:ToggleNameplates(friendly, enabled)
if friendly then
SetCVar("nameplateShowFriends", enabled and 1 or 0)
else
SetCVar("nameplateShowEnemies", enabled and 1 or 0)
end
end


function NP:ToggleStackingNameplates(enabled)
SetCVar("nameplateMotion", enabled and 1 or 0)
end

function NP:EnviromentConditionals()
local inInstance, instanceType = IsInInstance()
local isResting = IsResting()
local db = self.db.enviromentConditions
-- Handle friendly nameplates
if db.friendlyEnabled then
if inInstance and instanceType == "party" then
self:ToggleNameplates(true, db.friendly.dungeons)
elseif inInstance and instanceType == "raid" then
self:ToggleNameplates(true, db.friendly.raids)
elseif inInstance and instanceType == "arena" then
self:ToggleNameplates(true, db.friendly.arena)
elseif inInstance and instanceType == "pvp" then
self:ToggleNameplates(true, db.friendly.battleground)
elseif isResting then
self:ToggleNameplates(true, db.friendly.resting)
else
self:ToggleNameplates(true, db.friendly.world)
end
end

-- Handle enemy nameplates
if db.enemyEnabled then
if inInstance and instanceType == "party" then
self:ToggleNameplates(false, db.enemy.dungeons)
elseif inInstance and instanceType == "raid" then
self:ToggleNameplates(false, db.enemy.raids)
elseif inInstance and instanceType == "arena" then
self:ToggleNameplates(false, db.enemy.arena)
elseif inInstance and instanceType == "pvp" then
self:ToggleNameplates(false, db.enemy.battleground)
elseif isResting then
self:ToggleNameplates(false, db.enemy.resting)
else
self:ToggleNameplates(false, db.enemy.world)
end
end

-- Handle stacking nameplates
if db.stackingEnabled then
if inInstance and instanceType == "party" then
self:ToggleStackingNameplates(db.stackingNameplates.dungeons)
elseif inInstance and instanceType == "raid" then
self:ToggleStackingNameplates(db.stackingNameplates.raids)
elseif inInstance and instanceType == "arena" then
self:ToggleStackingNameplates(db.stackingNameplates.arena)
elseif inInstance and instanceType == "pvp" then
self:ToggleStackingNameplates(db.stackingNameplates.battleground)
elseif isResting then
self:ToggleStackingNameplates(db.stackingNameplates.resting)
else
self:ToggleStackingNameplates(db.stackingNameplates.world)
end
end
end

function NP:PLAYER_ENTERING_WORLD(_, initLogin, isReload)
if initLogin or isReload then
NP:ConfigureAll(true)
end

self:EnviromentConditionals()
end

function NP:ToggleStaticPlate()
Expand Down Expand Up @@ -1038,6 +1109,8 @@ function NP:Initialize()
NP:RegisterEvent('PLAYER_REGEN_ENABLED')
NP:RegisterEvent('PLAYER_REGEN_DISABLED')
NP:RegisterEvent('PLAYER_ENTERING_WORLD')
NP:RegisterEvent("ZONE_CHANGED_NEW_AREA", "EnviromentConditionals")
NP:RegisterEvent("PLAYER_UPDATE_RESTING", "EnviromentConditionals")
NP:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
NP:RegisterEvent('GROUP_ROSTER_UPDATE')
NP:RegisterEvent('GROUP_LEFT')
Expand Down
8 changes: 8 additions & 0 deletions ElvUI_Options/Core/Nameplates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,14 @@ NamePlates.generalGroup.args.plateVisibility.args.playerVisibility.args.alphaDel
NamePlates.generalGroup.args.plateVisibility.args.enemyVisibility = ACH:MultiSelect(L["Enemy"], nil, 10, { guardians = L["Guardians"], minions = L["Minions"], minus = L["Minus"], pets = L["Pets"], totems = L["Totems"] }, nil, nil, function(_, key) return E.db.nameplates.visibility.enemy[key] end, function(_, key, value) E.db.nameplates.visibility.enemy[key] = value NP:SetCVars() NP:ConfigureAll() end, function() return not E.db.nameplates.visibility.showAll end)
NamePlates.generalGroup.args.plateVisibility.args.friendlyVisibility = ACH:MultiSelect(L["Friendly"], nil, 15, { guardians = L["Guardians"], minions = L["Minions"], npcs = L["NPC"], pets = L["Pets"], totems = L["Totems"] }, nil, nil, function(_, key) return E.db.nameplates.visibility.friendly[key] end, function(_, key, value) E.db.nameplates.visibility.friendly[key] = value NP:SetCVars() NP:ConfigureAll() end, function() return not E.db.nameplates.visibility.showAll end)

NamePlates.generalGroup.args.enviromentConditions = ACH:Group(L["Enviroment Conditions"], nil, 51)
NamePlates.generalGroup.args.enviromentConditions.args.enemyEnabled = ACH:Toggle(L["Enemy Enabled"], L["This option controls whether nameplates will follow the visibility settings below."], 9, nil, nil, 250, function(info) return E.db.nameplates.enviromentConditions[info[#info]] end, function(info, value) E.db.nameplates.enviromentConditions[info[#info]] = value NP:EnviromentConditionals() end)
NamePlates.generalGroup.args.enviromentConditions.args.enemy = ACH:MultiSelect(L["Enemy"], nil, 10, { dungeons = L["Dungeons"], raids = L["Raids"], arena = L["Arena"], battleground = L["Battleground"], resting = L["Resting"], world = L["World"] }, nil, nil, function(_, key) return E.db.nameplates.enviromentConditions.enemy[key] end, function(_, key, value) E.db.nameplates.enviromentConditions.enemy[key] = value NP:EnviromentConditionals() end, nil)
NamePlates.generalGroup.args.enviromentConditions.args.friendlyEnabled = ACH:Toggle(L["Friendly Enabled"], L["This option controls whether nameplates will follow the visibility settings below."], 19, nil, nil, 250, function(info) return E.db.nameplates.enviromentConditions[info[#info]] end, function(info, value) E.db.nameplates.enviromentConditions[info[#info]] = value NP:EnviromentConditionals() end)
NamePlates.generalGroup.args.enviromentConditions.args.friendly = ACH:MultiSelect(L["Friendly"], nil, 20, { dungeons = L["Dungeons"], raids = L["Raids"], arena = L["Arena"], battleground = L["Battleground"], resting = L["Resting"], world = L["World"] }, nil, nil, function(_, key) return E.db.nameplates.enviromentConditions.friendly[key] end, function(_, key, value) E.db.nameplates.visibility.enviromentConditions.friendly[key] = value NP:EnviromentConditionals() end, nil)
NamePlates.generalGroup.args.enviromentConditions.args.stackingEnabled = ACH:Toggle(L["Stacking Enabled"], L["This option controls whether nameplates will follow the settings below."], 29, nil, nil, 250, function(info) return E.db.nameplates.enviromentConditions[info[#info]] end, function(info, value) E.db.nameplates.enviromentConditions[info[#info]] = value NP:EnviromentConditionals() end)
NamePlates.generalGroup.args.enviromentConditions.args.stacking = ACH:MultiSelect(L["Stacking Plates"], nil, 30, { dungeons = L["Dungeons"], raids = L["Raids"], arena = L["Arena"], battleground = L["Battleground"], resting = L["Resting"], world = L["World"] }, nil, nil, function(_, key) return E.db.nameplates.enviromentConditions.stackingNameplates[key] end, function(_, key, value) E.db.nameplates.enviromentConditions.stackingNameplates[key] = value NP:EnviromentConditionals() end, nil)

NamePlates.generalGroup.args.bossMods = ACH:Group(L["Boss Mod Auras"], nil, 55, nil, function(info) return E.db.nameplates.bossMods[info[#info]] end, function(info, value) E.db.nameplates.bossMods[info[#info]] = value NP:ConfigureAll() end)
NamePlates.generalGroup.args.bossMods.args.enable = ACH:Toggle(L["Enable"], nil, 0)
NamePlates.generalGroup.args.bossMods.args.supported = ACH:Group(L["Supported"], nil, 1)
Expand Down

0 comments on commit e669d34

Please sign in to comment.