From eb6cd0df73e1e247ef6401311ae8236c3570c0e7 Mon Sep 17 00:00:00 2001 From: Timo Bier Date: Sun, 15 Oct 2023 21:30:09 +0200 Subject: [PATCH] adding lfd roles added lfdRole indicator --- ShadowedUnitFrames.lua | 3 +++ modules/defaultlayout.lua | 1 + modules/indicators.lua | 38 ++++++++++++++++++++++++++++++++++++-- options/config.lua | 4 ++-- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/ShadowedUnitFrames.lua b/ShadowedUnitFrames.lua index 1b8135afb..bca80429f 100755 --- a/ShadowedUnitFrames.lua +++ b/ShadowedUnitFrames.lua @@ -377,6 +377,7 @@ function ShadowUF:LoadUnitDefaults() self.defaults.profile.units.player.xpBar = {enabled = false} self.defaults.profile.units.player.fader = {enabled = false} self.defaults.profile.units.player.comboPoints = {enabled = true, isBar = true} + self.defaults.profile.units.player.indicators.lfdRole = {enabled = true, size = 0, x = 0, y = 0} table.insert(self.defaults.profile.units.player.text, {enabled = true, text = "", anchorTo = "", anchorPoint = "C", size = 0, x = 0, y = 0, default = true}) table.insert(self.defaults.profile.units.player.text, {enabled = true, text = "", anchorTo = "", anchorPoint = "C", size = 0, x = 0, y = 0, default = true}) table.insert(self.defaults.profile.units.player.text, {enabled = true, text = "", anchorTo = "", anchorPoint = "C", size = 0, x = 0, y = 0, default = true}) @@ -396,6 +397,7 @@ function ShadowUF:LoadUnitDefaults() self.defaults.profile.units.focustarget.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60} -- TARGET self.defaults.profile.units.target.enabled = true + self.defaults.profile.units.target.indicators.lfdRole = {enabled = false, size = 0, x = 0, y = 0} self.defaults.profile.units.target.indicators.questBoss = {enabled = true, size = 0, x = 0, y = 0} self.defaults.profile.units.target.comboPoints = {enabled = false, isBar = true} self.defaults.profile.units.target.auras.buffs.approximateEnemyData = true @@ -408,6 +410,7 @@ function ShadowUF:LoadUnitDefaults() self.defaults.profile.units.party.auras.buffs.maxRows = 1 self.defaults.profile.units.party.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60} self.defaults.profile.units.party.combatText.enabled = false + self.defaults.profile.units.party.indicators.lfdRole = {enabled = true, size = 0, x = 0, y = 0} self.defaults.profile.units.party.indicators.phase = {enabled = true, size = 0, x = 0, y = 0} -- ARENA self.defaults.profile.units.arena.enabled = false diff --git a/modules/defaultlayout.lua b/modules/defaultlayout.lua index 28ae3d377..c092593cc 100755 --- a/modules/defaultlayout.lua +++ b/modules/defaultlayout.lua @@ -257,6 +257,7 @@ function ShadowUF:LoadDefaultLayout(useMerge) ready = {anchorTo = "$parent", anchorPoint = "LC", size = 24, x = 35, y = 0}, role = {anchorTo = "$parent", anchorPoint = "TL", size = 14, x = 30, y = -11}, status = {anchorTo = "$parent", anchorPoint = "LB", size = 16, x = 12, y = -2}, + lfdRole = {enabled = true, anchorPoint = "BR", size = 14, x = 3, y = 14, anchorTo = "$parent"} }, highlight = {size = 10}, combatText = {anchorTo = "$parent", anchorPoint = "C", x = 0, y = 0}, diff --git a/modules/indicators.lua b/modules/indicators.lua index 4632f7292..ed9169746 100755 --- a/modules/indicators.lua +++ b/modules/indicators.lua @@ -1,4 +1,4 @@ -local Indicators = {list = {"status", "pvp", "leader", "resurrect", "masterLoot", "raidTarget", "ready", "role", "class", "phase", "happiness" }} +local Indicators = {list = {"status", "pvp", "leader", "resurrect", "masterLoot", "raidTarget", "ready", "role", "lfdRole", "class", "phase", "happiness" }} ShadowUF:RegisterModule(Indicators, "indicators", ShadowUF.L["Indicators"]) @@ -98,6 +98,7 @@ end function Indicators:GroupRosterUpdate(frame) self:UpdateMasterLoot(frame) self:UpdateRole(frame) + self:UpdateLFDRole(frame) self:UpdateLeader(frame) end @@ -118,6 +119,31 @@ function Indicators:UpdatePVPFlag(frame) end end +function Indicators:UpdateLFDRole(frame, event) + if( not frame.indicators.lfdRole or not frame.indicators.lfdRole.enabled ) then return end + + local role + if( frame.unitType ~= "arena" ) then + role = UnitGroupRolesAssigned(frame.unitOwner) + else + local specID = GetArenaOpponentSpec(frame.unitID) + role = specID and select(6, GetSpecializationInfoByID(specID)) + end + + if( role == "TANK" ) then + frame.indicators.lfdRole:SetTexCoord(0, 19/64, 22/64, 41/64) + frame.indicators.lfdRole:Show() + elseif( role == "HEALER" ) then + frame.indicators.lfdRole:SetTexCoord(20/64, 39/64, 1/64, 20/64) + frame.indicators.lfdRole:Show() + elseif( role == "DAMAGER" ) then + frame.indicators.lfdRole:SetTexCoord(20/64, 39/64, 22/64, 41/64) + frame.indicators.lfdRole:Show() + else + frame.indicators.lfdRole:Hide() + end +end + -- Non-player units do not give events when they enter or leave combat, so polling is necessary local function combatMonitor(self, elapsed) self.timeElapsed = self.timeElapsed + elapsed @@ -340,6 +366,14 @@ function Indicators:OnEnable(frame) frame.indicators.ready = frame.indicators.ready or frame.indicators:CreateTexture(nil, "OVERLAY") end + if( config.indicators.lfdRole and config.indicators.lfdRole.enabled ) then + frame:RegisterNormalEvent("PLAYER_ROLES_ASSIGNED", self, "UpdateLFDRole") + frame:RegisterUpdateFunc(self, "UpdateLFDRole") + + frame.indicators.lfdRole = frame.indicators.lfdRole or frame.indicators:CreateTexture(nil, "OVERLAY") + frame.indicators.lfdRole:SetTexture("Interface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES") + end + if( config.indicators.happiness and config.indicators.happiness.enabled ) then frame:RegisterUnitEvent("UNIT_HAPPINESS", self, "UpdateHappiness") frame:RegisterUpdateFunc(self, "UpdateHappiness") @@ -349,7 +383,7 @@ function Indicators:OnEnable(frame) end -- As they all share the function, register it as long as one is active - if( frame.indicators.leader or frame.indicators.masterLoot or frame.indicators.role ) then + if( frame.indicators.leader or frame.indicators.masterLoot or frame.indicators.role or ( frame.unit ~= "player" and frame.indicators.lfdRole ) ) then frame:RegisterNormalEvent("GROUP_ROSTER_UPDATE", self, "GroupRosterUpdate") end end diff --git a/options/config.lua b/options/config.lua index 272dad69d..7f8e1b886 100755 --- a/options/config.lua +++ b/options/config.lua @@ -50,10 +50,10 @@ local PAGE_DESC = { ["tags"] = L["Advanced tag management, allows you to add your own custom tags."], ["filter"] = L["Simple aura filtering by whitelists and blacklists."], } -local INDICATOR_NAMES = {["leader"] = L["Leader / Assist"], ["masterLoot"] = L["Master Looter"], ["pvp"] = L["PvP Flag"], ["raidTarget"] = L["Raid Target"], ["ready"] = L["Ready Status"], ["role"] = L["Raid Role"], ["status"] = L["Combat Status"], ["class"] = L["Class Icon"], ["resurrect"] = L["Resurrect Status"], ["phase"] = L["Other Party/Phase Status"], ["happiness"] = L["Pet Happiness"]} +local INDICATOR_NAMES = {["leader"] = L["Leader / Assist"], ["lfdRole"] = L["Class Role"], ["masterLoot"] = L["Master Looter"], ["pvp"] = L["PvP Flag"], ["raidTarget"] = L["Raid Target"], ["ready"] = L["Ready Status"], ["role"] = L["Raid Role"], ["status"] = L["Combat Status"], ["class"] = L["Class Icon"], ["resurrect"] = L["Resurrect Status"], ["phase"] = L["Other Party/Phase Status"], ["happiness"] = L["Pet Happiness"]} local AREA_NAMES = {["arena"] = L["Arenas"],["none"] = L["Everywhere else"], ["party"] = L["Party instances"], ["pvp"] = L["Battleground"], ["raid"] = L["Raid instances"]} local INDICATOR_DESC = { - ["leader"] = L["Crown indicator for group leader or assistants."], + ["leader"] = L["Crown indicator for group leader or assistants."], ["lfdRole"] = L["Role the unit is playing."], ["masterLoot"] = L["Bag indicator for master looters."], ["pvp"] = L["PVP flag indicator, Horde for Horde flagged pvpers and Alliance for Alliance flagged pvpers."], ["raidTarget"] = L["Raid target indicator."], ["ready"] = L["Ready status of group members."], ["phase"] = L["Shows when a party member is in a different phase or another group."], ["role"] = L["Raid role indicator, adds a shield indicator for main tanks and a sword icon for main assists."], ["status"] = L["Status indicator, shows if the unit is currently in combat. For the player it will also show if you are rested."], ["class"] = L["Class icon for players."],