-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocial.lua
More file actions
93 lines (80 loc) · 3.2 KB
/
Copy pathsocial.lua
File metadata and controls
93 lines (80 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
local _, ns = ...
---------------------------------------------------------------------------
-- Guild / Party / Raid Awareness
-- Provides role icons and info next to conversation names
---------------------------------------------------------------------------
-- Cache guild roster
ns.guildCache = {}
function ns.RefreshGuildRoster()
wipe(ns.guildCache)
if not IsInGuild() then return end
local numTotal = GetNumGuildMembers()
for i = 1, numTotal do
local name, rankName, rankIndex, level, className, _, _, _, isOnline = GetGuildRosterInfo(i)
if name then
local shortName = Ambiguate(name, "none")
ns.guildCache[shortName:lower()] = {
rank = rankName,
rankIndex = rankIndex,
level = level,
className = className,
online = isOnline,
}
end
end
end
-- Check relationships for a player
function ns.GetPlayerRelationship(name)
if not name then return nil end
local lower = name:lower()
local tags = {}
-- Guild
if ns.guildCache[lower] then
local info = ns.guildCache[lower]
table.insert(tags, { icon = "|TInterface\\GossipFrame\\TabardGossipIcon:12|t", text = info.rank, type = "guild" })
end
-- Party/Raid
if UnitInParty(name) then
local role = UnitGroupRolesAssigned(name)
local roleIcon = ""
if role == "TANK" then
roleIcon = "|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES:12:12:0:0:64:64:0:19:22:41|t "
elseif role == "HEALER" then
roleIcon = "|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES:12:12:0:0:64:64:20:39:1:20|t "
elseif role == "DAMAGER" then
roleIcon = "|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES:12:12:0:0:64:64:20:39:22:41|t "
end
table.insert(tags, { icon = roleIcon, text = "Party", type = "party" })
elseif UnitInRaid(name) then
table.insert(tags, { icon = "|TInterface\\GroupFrame\\UI-Group-LeaderIcon:12|t", text = "Raid", type = "raid" })
end
-- Friend (already tracked by messages.lua, but add tag)
if ns.IsFriend(name) then
table.insert(tags, { icon = "", text = "Friend", type = "friend" })
end
return tags
end
-- Format relationship tags as a colored string for display
function ns.FormatRelationshipTags(name)
local tags = ns.GetPlayerRelationship(name)
if not tags or #tags == 0 then return "" end
local parts = {}
for _, tag in ipairs(tags) do
local color = "|cff888888"
if tag.type == "guild" then color = "|cff40c040" end
if tag.type == "party" then color = "|cff5599ff" end
if tag.type == "raid" then color = "|cffff9900" end
table.insert(parts, color .. (tag.icon or "") .. tag.text .. "|r")
end
return table.concat(parts, " ")
end
---------------------------------------------------------------------------
-- Hook into guild roster updates
---------------------------------------------------------------------------
function ns:GUILD_ROSTER_UPDATE()
ns.RefreshGuildRoster()
-- Scan roster for player info cache (class/race data)
if ns.ScanGuildRoster then
ns.ScanGuildRoster()
end
end