From a6eb1a4bccfd2a27f0ceeab9d9b9abbb742805ef Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 17 Oct 2020 12:33:54 +0200 Subject: [PATCH] nameplates: option to replace totem plates by icon --- api/config.lua | 1 + modules/gui.lua | 1 + modules/nameplates.lua | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/api/config.lua b/api/config.lua index 3e7395b0..b1ff8aec 100644 --- a/api/config.lua +++ b/api/config.lua @@ -649,6 +649,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("nameplates", nil, "friendlyplayer", "0") pfUI:UpdateConfig("nameplates", nil, "critters", "1") pfUI:UpdateConfig("nameplates", nil, "totems", "1") + pfUI:UpdateConfig("nameplates", nil, "totemicons", "0") pfUI:UpdateConfig("nameplates", nil, "showhp", "0") pfUI:UpdateConfig("nameplates", nil, "alwaysperc", "0") diff --git a/modules/gui.lua b/modules/gui.lua index 3e873943..006fba78 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -2120,6 +2120,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () CreateConfig(U["nameplates"], T["Right Click Auto Attack Threshold"], C.nameplates, "clickthreshold", nil, nil, nil, nil, nil, "vanilla") 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["Replace Totems With Icons"], C.nameplates, "totemicons", "checkbox") CreateConfig(nil, T["Castbar"], nil, nil, "header") CreateConfig(U["nameplates"], T["Enable Castbars"], C.nameplates, "showcastbar", "checkbox") diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 15593efc..f63cb0d1 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -54,6 +54,14 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () end end + local function TotemPlate(name) + if C.nameplates.totemicons == "1" then + for totem, icon in pairs(L["totems"]) do + if string.find(name, totem) then return icon end + end + end + end + local function HidePlate(unittype, name, fullhp, target) -- keep some plates always visible according to config if C.nameplates.fullhealth == "1" and not fullhp then return nil end @@ -251,6 +259,15 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () nameplate.raidicon:SetDrawLayer("OVERLAY") nameplate.raidicon:SetTexture(pfUI.media["img:raidicons"]) + nameplate.totem = CreateFrame("Frame", nil, nameplate) + nameplate.totem:SetPoint("CENTER", nameplate, "CENTER", 0, 0) + nameplate.totem:SetHeight(32) + nameplate.totem:SetWidth(32) + nameplate.totem.icon = nameplate.totem:CreateTexture(nil, "OVERLAY") + nameplate.totem.icon:SetTexCoord(.078, .92, .079, .937) + nameplate.totem.icon:SetAllPoints() + CreateBackdrop(nameplate.totem) + do -- debuffs local debuffs = {} for i=1, 16, 1 do @@ -487,14 +504,33 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () end -- hide frames according to the configuration - if HidePlate(unittype, name, (hpmax-hp == hpmin), target) then + local TotemIcon = TotemPlate(name) + + if TotemIcon then + -- create totem icon + plate.totem.icon:SetTexture("Interface\\Icons\\" .. TotemIcon) + + plate.glow:Hide() + plate.level:Hide() + plate.name:Hide() + plate.health:Hide() + plate.totem:Show() + elseif HidePlate(unittype, name, (hpmax-hp == hpmin), target) then plate.level:SetPoint("RIGHT", plate.name, "LEFT", -3, 0) plate.name:SetParent(plate) + + plate.level:Show() + plate.name:Show() plate.health:Hide() + plate.totem:Hide() else plate.level:SetPoint("RIGHT", plate.health, "LEFT", -3, 0) plate.name:SetParent(plate.health) + + plate.level:Show() + plate.name:Show() plate.health:Show() + plate.totem:Hide() end plate.name:SetText(name)