TotemPlates add option to show friendly/enemy icons

This commit is contained in:
Sumsebrum 2021-05-17 23:22:07 +02:00
parent cf8b961a1b
commit f640f6fa6a

View File

@ -1,5 +1,5 @@
local select, pairs, string_lower, tremove, tinsert, format, string_gsub, ipairs = select, pairs, string.lower, tremove, tinsert, format, string.gsub, ipairs local select, pairs, string_lower, tremove, tinsert, format, string_gsub, ipairs = select, pairs, string.lower, tremove, tinsert, format, string.gsub, ipairs
local UnitExists, UnitIsUnit, UnitName = UnitExists, UnitIsUnit, UnitName local UnitExists, UnitIsUnit, UnitName, UnitIsEnemy = UnitExists, UnitIsUnit, UnitName, UnitIsEnemy
local C_NamePlate = C_NamePlate local C_NamePlate = C_NamePlate
local Gladdy = LibStub("Gladdy") local Gladdy = LibStub("Gladdy")
local L = Gladdy.L local L = Gladdy.L
@ -222,6 +222,8 @@ end
local TotemPlates = Gladdy:NewModule("TotemPlates", nil, { local TotemPlates = Gladdy:NewModule("TotemPlates", nil, {
npTotems = true, npTotems = true,
npTotemsShowFriendly = true,
npTotemsShowEnemy = true,
npTotemPlatesBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp", npTotemPlatesBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
npTotemPlatesSize = 40, npTotemPlatesSize = 40,
npTotemPlatesWidthFactor = 1, npTotemPlatesWidthFactor = 1,
@ -303,6 +305,13 @@ end
function TotemPlates:NAME_PLATE_UNIT_ADDED(...) function TotemPlates:NAME_PLATE_UNIT_ADDED(...)
local unitID = ... local unitID = ...
local isEnemy = UnitIsEnemy("player", unitID)
if not Gladdy.db.npTotemsShowEnemy and isEnemy then
return
end
if not Gladdy.db.npTotemsShowFriendly and not isEnemy then
return
end
local nameplateName = UnitName(unitID) local nameplateName = UnitName(unitID)
local totemName = string_gsub(nameplateName, "^%s+", "") --trim local totemName = string_gsub(nameplateName, "^%s+", "") --trim
totemName = string_gsub(totemName, "%s+$", "") --trim totemName = string_gsub(totemName, "%s+$", "") --trim
@ -414,6 +423,21 @@ function TotemPlates:GetOptions()
name = L["Totem icons on/off"], name = L["Totem icons on/off"],
desc = L["Turns totem icons instead of nameplates on or off. (Requires reload)"], desc = L["Turns totem icons instead of nameplates on or off. (Requires reload)"],
order = 3, order = 3,
width = 0.9,
}),
npTotemsShowFriendly = Gladdy:option({
type = "toggle",
name = L["Show friendly"],
desc = L["Turns totem icons instead of nameplates on or off. (Requires reload)"],
order = 4,
width = 0.65,
}),
npTotemsShowEnemy = Gladdy:option({
type = "toggle",
name = L["Show enemy"],
desc = L["Turns totem icons instead of nameplates on or off. (Requires reload)"],
order = 5,
width = 0.6,
}), }),
group = { group = {
type = "group", type = "group",