nameplate: add option to show guild names

This commit is contained in:
Cameron Weaver (Clutch)
2024-02-26 17:41:29 +01:00
committed by GitHub
parent afcf45f404
commit 2e8d3e2f7a
11 changed files with 53 additions and 14 deletions
+1
View File
@@ -699,6 +699,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("nameplates", nil, "critters", "1") pfUI:UpdateConfig("nameplates", nil, "critters", "1")
pfUI:UpdateConfig("nameplates", nil, "totems", "1") pfUI:UpdateConfig("nameplates", nil, "totems", "1")
pfUI:UpdateConfig("nameplates", nil, "totemicons", "0") pfUI:UpdateConfig("nameplates", nil, "totemicons", "0")
pfUI:UpdateConfig("nameplates", nil, "showguildname", "0")
pfUI:UpdateConfig("nameplates", nil, "outfriendly", "0") pfUI:UpdateConfig("nameplates", nil, "outfriendly", "0")
pfUI:UpdateConfig("nameplates", nil, "outfriendlynpc", "1") pfUI:UpdateConfig("nameplates", nil, "outfriendlynpc", "1")
+1
View File
@@ -633,6 +633,7 @@ pfUI_translation["deDE"] = {
["Show Duration Inside Buff"] = nil, ["Show Duration Inside Buff"] = nil,
["Show Empty Buttons"] = nil, ["Show Empty Buttons"] = nil,
["Show FPS and Latency Colors"] = nil, ["Show FPS and Latency Colors"] = nil,
["Show Guild Name"] = nil,
["Show Happiness Icon"] = nil, ["Show Happiness Icon"] = nil,
["Show Health Points"] = nil, ["Show Health Points"] = nil,
["Show/Hide TimeManager"] = nil, ["Show/Hide TimeManager"] = nil,
+1
View File
@@ -633,6 +633,7 @@ pfUI_translation["enUS"] = {
["Show Duration Inside Buff"] = nil, ["Show Duration Inside Buff"] = nil,
["Show Empty Buttons"] = nil, ["Show Empty Buttons"] = nil,
["Show FPS and Latency Colors"] = nil, ["Show FPS and Latency Colors"] = nil,
["Show Guild Name"] = nil,
["Show Happiness Icon"] = nil, ["Show Happiness Icon"] = nil,
["Show Health Points"] = nil, ["Show Health Points"] = nil,
["Show/Hide TimeManager"] = nil, ["Show/Hide TimeManager"] = nil,
+1
View File
@@ -633,6 +633,7 @@ pfUI_translation["esES"] = {
["Show Duration Inside Buff"] = "Mostrar la duración dentro del beneficios", ["Show Duration Inside Buff"] = "Mostrar la duración dentro del beneficios",
["Show Empty Buttons"] = "Mostrar botones vacíos", ["Show Empty Buttons"] = "Mostrar botones vacíos",
["Show FPS and Latency Colors"] = "Mostrar FPS y colores de latencia", ["Show FPS and Latency Colors"] = "Mostrar FPS y colores de latencia",
["Show Guild Name"] = nil,
["Show Happiness Icon"] = "Mostrar icono de felicidad", ["Show Happiness Icon"] = "Mostrar icono de felicidad",
["Show Health Points"] = "Mostrar puntos de salud", ["Show Health Points"] = "Mostrar puntos de salud",
["Show/Hide TimeManager"] = "Mostrar/Ocultar el gestor de tiempo", ["Show/Hide TimeManager"] = "Mostrar/Ocultar el gestor de tiempo",
+1
View File
@@ -633,6 +633,7 @@ pfUI_translation["frFR"] = {
["Show Duration Inside Buff"] = "Afficher la durée à l'intérieur des améliorations", ["Show Duration Inside Buff"] = "Afficher la durée à l'intérieur des améliorations",
["Show Empty Buttons"] = "Afficher les boutons vides", ["Show Empty Buttons"] = "Afficher les boutons vides",
["Show FPS and Latency Colors"] = nil, ["Show FPS and Latency Colors"] = nil,
["Show Guild Name"] = nil,
["Show Happiness Icon"] = "Afficher l'icône Heureux du familier", ["Show Happiness Icon"] = "Afficher l'icône Heureux du familier",
["Show Health Points"] = "Afficher les points de vie", ["Show Health Points"] = "Afficher les points de vie",
["Show/Hide TimeManager"] = "Afficher/cacher le gestionnaire de temps", ["Show/Hide TimeManager"] = "Afficher/cacher le gestionnaire de temps",
+1
View File
@@ -633,6 +633,7 @@ pfUI_translation["ruRU"] = {
["Show Duration Inside Buff"] = "Показать продолжительность внутри баффа", ["Show Duration Inside Buff"] = "Показать продолжительность внутри баффа",
["Show Empty Buttons"] = "Показать пустые кнопки", ["Show Empty Buttons"] = "Показать пустые кнопки",
["Show FPS and Latency Colors"] = "Показать частоту кадров и задержку в цвете", ["Show FPS and Latency Colors"] = "Показать частоту кадров и задержку в цвете",
["Show Guild Name"] = nil,
["Show Happiness Icon"] = "Показать иконку счастья", ["Show Happiness Icon"] = "Показать иконку счастья",
["Show Health Points"] = "Показать здоровье", ["Show Health Points"] = "Показать здоровье",
["Show/Hide TimeManager"] = "Показать/Скрыть менеджер времени", ["Show/Hide TimeManager"] = "Показать/Скрыть менеджер времени",
+1
View File
@@ -634,6 +634,7 @@ pfUI_translation["zhCN"] = {
["Show Dispel Indicators"] = "显示驱散指示器", ["Show Dispel Indicators"] = "显示驱散指示器",
["Show Duration Inside Buff"] = "显示持续时间在Buff里面", ["Show Duration Inside Buff"] = "显示持续时间在Buff里面",
["Show Empty Buttons"] = "显示空按钮", ["Show Empty Buttons"] = "显示空按钮",
["Show Guild Name"] = nil,
["Show FPS and Latency Colors"] = "显示帧数以及延迟颜色", ["Show FPS and Latency Colors"] = "显示帧数以及延迟颜色",
["Show Happiness Icon"] = "显示高兴值图标", ["Show Happiness Icon"] = "显示高兴值图标",
["Show Health Points"] = "显示生命值", ["Show Health Points"] = "显示生命值",
+1
View File
@@ -633,6 +633,7 @@ pfUI_translation["zhTW"] = {
["Show Duration Inside Buff"] = "顯示持續時間在Buff裏面", ["Show Duration Inside Buff"] = "顯示持續時間在Buff裏面",
["Show Empty Buttons"] = nil, ["Show Empty Buttons"] = nil,
["Show FPS and Latency Colors"] = nil, ["Show FPS and Latency Colors"] = nil,
["Show Guild Name"] = nil,
["Show Happiness Icon"] = nil, ["Show Happiness Icon"] = nil,
["Show Health Points"] = "顯示生命值", ["Show Health Points"] = "顯示生命值",
["Show/Hide TimeManager"] = nil, ["Show/Hide TimeManager"] = nil,
+17 -11
View File
@@ -19,6 +19,7 @@ setfenv(1, pfUI:GetEnvironment())
-- level[Number] - The level of the unit -- level[Number] - The level of the unit
-- elite[String] - The elite state of the unit (See UnitClassification()) -- elite[String] - The elite state of the unit (See UnitClassification())
-- player[Boolean] - Returns true if unit is a player -- player[Boolean] - Returns true if unit is a player
-- guild[String] - Returns guild name of unit is a player
-- --
-- Internal functions: -- Internal functions:
-- libunitscan:AddData(db, name, class, level, elite) -- libunitscan:AddData(db, name, class, level, elite)
@@ -34,23 +35,24 @@ local queue = { }
function GetUnitData(name, active) function GetUnitData(name, active)
if units["players"][name] then if units["players"][name] then
local ret = units["players"][name] local ret = units["players"][name]
return ret.class, ret.level, ret.elite, true return ret.class, ret.level, ret.elite, true, ret.guild
elseif units["mobs"][name] then elseif units["mobs"][name] then
local ret = units["mobs"][name] local ret = units["mobs"][name]
return ret.class, ret.level, ret.elite, nil return ret.class, ret.level, ret.elite, nil, nil
elseif active then elseif active then
queue[name] = true queue[name] = true
libunitscan:Show() libunitscan:Show()
end end
end end
local function AddData(db, name, class, level, elite) local function AddData(db, name, class, level, elite, guild)
if not name or not db then return end if not name or not db then return end
units[db] = units[db] or {} units[db] = units[db] or {}
units[db][name] = units[db][name] or {} units[db][name] = units[db][name] or {}
units[db][name].class = class or units[db][name].class units[db][name].class = class or units[db][name].class
units[db][name].level = level or units[db][name].level units[db][name].level = level or units[db][name].level
units[db][name].elite = elite or units[db][name].elite units[db][name].elite = elite or units[db][name].elite
units[db][name].guild = guild or units[db][name].guild
queue[name] = nil queue[name] = nil
end end
@@ -74,7 +76,8 @@ libunitscan:SetScript("OnEvent", function()
local name = UnitName("player") local name = UnitName("player")
local _, class = UnitClass("player") local _, class = UnitClass("player")
local level = UnitLevel("player") local level = UnitLevel("player")
AddData("players", name, class, level) local guild = GetGuildInfo("player")
AddData("players", name, class, level, nil, guild)
elseif event == "FRIENDLIST_UPDATE" then elseif event == "FRIENDLIST_UPDATE" then
local name, class, level local name, class, level
@@ -87,11 +90,12 @@ libunitscan:SetScript("OnEvent", function()
end end
elseif event == "GUILD_ROSTER_UPDATE" then elseif event == "GUILD_ROSTER_UPDATE" then
local name, class, level, _ local name, class, level, _, guild
for i = 1, GetNumGuildMembers() do for i = 1, GetNumGuildMembers() do
name, _, _, level, class = GetGuildRosterInfo(i) name, _, _, level, class = GetGuildRosterInfo(i)
guild = GetGuildInfo("player")
class = L["class"][class] or nil class = L["class"][class] or nil
AddData("players", name, class, level) AddData("players", name, class, level, nil, guild)
end end
elseif event == "RAID_ROSTER_UPDATE" then elseif event == "RAID_ROSTER_UPDATE" then
@@ -103,21 +107,22 @@ libunitscan:SetScript("OnEvent", function()
end end
elseif event == "PARTY_MEMBERS_CHANGED" then elseif event == "PARTY_MEMBERS_CHANGED" then
local name, class, level, unit, _ local name, class, level, unit, _, guild
for i = 1, GetNumPartyMembers() do for i = 1, GetNumPartyMembers() do
unit = "party" .. i unit = "party" .. i
_, class = UnitClass(unit) _, class = UnitClass(unit)
name = UnitName(unit) name = UnitName(unit)
level = UnitLevel(unit) level = UnitLevel(unit)
AddData("players", name, class, level) guild = GetGuildInfo(unit)
AddData("players", name, class, level, nil, guild)
end end
elseif event == "WHO_LIST_UPDATE" or event == "CHAT_MSG_SYSTEM" then elseif event == "WHO_LIST_UPDATE" or event == "CHAT_MSG_SYSTEM" then
local name, class, level, _ local name, class, level, _
for i = 1, GetNumWhoResults() do for i = 1, GetNumWhoResults() do
name, _, level, _, class, _ = GetWhoInfo(i) name, guild, level, _, class, _ = GetWhoInfo(i)
class = L["class"][class] or nil class = L["class"][class] or nil
AddData("players", name, class, level) AddData("players", name, class, level, nil, guild)
end end
elseif event == "UPDATE_MOUSEOVER_UNIT" or event == "PLAYER_TARGET_CHANGED" then elseif event == "UPDATE_MOUSEOVER_UNIT" or event == "PLAYER_TARGET_CHANGED" then
@@ -127,7 +132,8 @@ libunitscan:SetScript("OnEvent", function()
_, class = UnitClass(scan) _, class = UnitClass(scan)
level = UnitLevel(scan) level = UnitLevel(scan)
name = UnitName(scan) name = UnitName(scan)
AddData("players", name, class, level) guild = GetGuildInfo(scan)
AddData("players", name, class, level, nil, guild)
else else
_, class = UnitClass(scan) _, class = UnitClass(scan)
elite = UnitClassification(scan) elite = UnitClassification(scan)
+1
View File
@@ -2202,6 +2202,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
CreateConfig(U["nameplates"], T["Use Unit Fonts"], C.nameplates, "use_unitfonts", "checkbox") CreateConfig(U["nameplates"], T["Use Unit Fonts"], C.nameplates, "use_unitfonts", "checkbox")
CreateConfig(U["nameplates"], T["Font Style"], C.nameplates.name, "fontstyle", "dropdown", pfUI.gui.dropdowns.fontstyle) CreateConfig(U["nameplates"], T["Font Style"], C.nameplates.name, "fontstyle", "dropdown", pfUI.gui.dropdowns.fontstyle)
CreateConfig(U["nameplates"], T["Replace Totems With Icons"], C.nameplates, "totemicons", "checkbox") CreateConfig(U["nameplates"], T["Replace Totems With Icons"], C.nameplates, "totemicons", "checkbox")
CreateConfig(U["nameplates"], T["Show Guild Name"], C.nameplates, "showguildname", "checkbox")
CreateConfig(nil, T["Raid Icon"], nil, nil, "header") CreateConfig(nil, T["Raid Icon"], nil, nil, "header")
CreateConfig(U["nameplates"], T["Raid Icon Position"], C.nameplates, "raidiconpos", "dropdown", pfUI.gui.dropdowns.positions) CreateConfig(U["nameplates"], T["Raid Icon Position"], C.nameplates, "raidiconpos", "dropdown", pfUI.gui.dropdowns.positions)
+27 -3
View File
@@ -307,6 +307,9 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
nameplate.glow:SetTexture(pfUI.media["img:dot"]) nameplate.glow:SetTexture(pfUI.media["img:dot"])
nameplate.glow:Hide() nameplate.glow:Hide()
nameplate.guild = nameplate:CreateFontString(nil, "OVERLAY")
nameplate.guild:SetPoint("BOTTOM", nameplate.health, "BOTTOM", 0, 0)
nameplate.level = nameplate:CreateFontString(nil, "OVERLAY") nameplate.level = nameplate:CreateFontString(nil, "OVERLAY")
nameplate.level:SetPoint("RIGHT", nameplate.health, "LEFT", -3, 0) nameplate.level:SetPoint("RIGHT", nameplate.health, "LEFT", -3, 0)
@@ -433,6 +436,8 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
nameplate.health.text:SetFont(font, font_size - 2, "OUTLINE") nameplate.health.text:SetFont(font, font_size - 2, "OUTLINE")
nameplate.health.text:SetJustifyH(C.nameplates.hptextpos) nameplate.health.text:SetJustifyH(C.nameplates.hptextpos)
nameplate.guild:SetFont(font, font_size, font_style)
nameplate.glow:SetWidth(C.nameplates.width + 60) nameplate.glow:SetWidth(C.nameplates.width + 60)
nameplate.glow:SetHeight(C.nameplates.heighthealth + 30) nameplate.glow:SetHeight(C.nameplates.heighthealth + 30)
nameplate.glow:SetVertexColor(glowr, glowg, glowb, glowa) nameplate.glow:SetVertexColor(glowr, glowg, glowb, glowa)
@@ -486,12 +491,13 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
local hpmin, hpmax = plate.original.healthbar:GetMinMaxValues() local hpmin, hpmax = plate.original.healthbar:GetMinMaxValues()
local name = plate.original.name:GetText() local name = plate.original.name:GetText()
local level = plate.original.level:IsShown() and plate.original.level:GetObjectType() == "FontString" and tonumber(plate.original.level:GetText()) or "??" local level = plate.original.level:IsShown() and plate.original.level:GetObjectType() == "FontString" and tonumber(plate.original.level:GetText()) or "??"
local class, ulevel, elite, player = GetUnitData(name, true) local class, ulevel, elite, player, guild = GetUnitData(name, true)
local target = plate.istarget local target = plate.istarget
local mouseover = UnitExists("mouseover") and plate.original.glow:IsShown() or nil local mouseover = UnitExists("mouseover") and plate.original.glow:IsShown() or nil
local unitstr = target and "target" or mouseover and "mouseover" or nil local unitstr = target and "target" or mouseover and "mouseover" or nil
local red, green, blue = plate.original.healthbar:GetStatusBarColor() local red, green, blue = plate.original.healthbar:GetStatusBarColor()
local unittype = GetUnitType(red, green, blue) or "ENEMY_NPC" local unittype = GetUnitType(red, green, blue) or "ENEMY_NPC"
local font_size = C.nameplates.use_unitfonts == "1" and C.global.font_unit_size or C.global.font_size
-- ignore players with npc names if plate level is lower than player level -- ignore players with npc names if plate level is lower than player level
if ulevel and ulevel > (level == "??" and -1 or level) then player = nil end if ulevel and ulevel > (level == "??" and -1 or level) then player = nil end
@@ -564,20 +570,26 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
plate.level:Hide() plate.level:Hide()
plate.name:Hide() plate.name:Hide()
plate.health:Hide() plate.health:Hide()
plate.glow:SetPoint("CENTER", plate.health, "CENTER", 0, 16) plate.guild:Hide()
plate.totem:Show() plate.totem:Show()
elseif HidePlate(unittype, name, (hpmax-hp == hpmin), target) then elseif HidePlate(unittype, name, (hpmax-hp == hpmin), target) then
plate.level:SetPoint("RIGHT", plate.name, "LEFT", -3, 0) plate.level:SetPoint("RIGHT", plate.name, "LEFT", -3, 0)
plate.name:SetParent(plate) plate.name:SetParent(plate)
plate.guild:SetPoint("BOTTOM", plate.name, "BOTTOM", -2, -(font_size + 2))
plate.level:Show() plate.level:Show()
plate.name:Show() plate.name:Show()
plate.health:Hide() plate.health:Hide()
plate.glow:SetPoint("CENTER", plate.health, "CENTER", 0, 16) if guild and C.nameplates.showguildname == "1" then
plate.glow:SetPoint("CENTER", plate.name, "CENTER", 0, -(font_size / 2) - 2)
else
plate.glow:SetPoint("CENTER", plate.name, "CENTER", 0, 0)
end
plate.totem:Hide() plate.totem:Hide()
else else
plate.level:SetPoint("RIGHT", plate.health, "LEFT", -5, 0) plate.level:SetPoint("RIGHT", plate.health, "LEFT", -5, 0)
plate.name:SetParent(plate.health) plate.name:SetParent(plate.health)
plate.guild:SetPoint("BOTTOM", plate.health, "BOTTOM", 0, -(font_size + 4))
plate.level:Show() plate.level:Show()
plate.name:Show() plate.name:Show()
@@ -589,6 +601,18 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
plate.name:SetText(name) plate.name:SetText(name)
plate.level:SetText(string.format("%s%s", level, (elitestrings[elite] or ""))) plate.level:SetText(string.format("%s%s", level, (elitestrings[elite] or "")))
if guild and C.nameplates.showguildname == "1" then
plate.guild:SetText(guild)
if guild == GetGuildInfo("player") then
plate.guild:SetTextColor(0, 0.9, 0, 1)
else
plate.guild:SetTextColor(0.8, 0.8, 0.8, 1)
end
plate.guild:Show()
else
plate.guild:Hide()
end
plate.health:SetMinMaxValues(hpmin, hpmax) plate.health:SetMinMaxValues(hpmin, hpmax)
plate.health:SetValue(hp) plate.health:SetValue(hp)