-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMultiGroupIcon.lua
134 lines (105 loc) · 3.85 KB
/
MultiGroupIcon.lua
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
--[[ ArenaLive Core Functions: VoiceChat Icon Handler
Created by: Vadrak
Creation Date: 22.06.2013
Last Update: "
This file contains all relevant functions for the multi group button that was added in MoP.
]]--
local addonName = "ArenaLiveCore";
-- Local version is said to be faster.
local ArenaLiveCore = ArenaLiveCore;
-- Set up a new handler.
local MultiGroupIcon = ArenaLiveCore:AddHandler("MultiGroupIcon", "EventCore");
-- Get the global UnitFrame handler.
local UnitFrame = ArenaLiveCore:GetHandler("UnitFrame");
-- Register the handler for all needed events.
MultiGroupIcon:RegisterEvent("GROUP_ROSTER_UPDATE");
MultiGroupIcon:RegisterEvent("UPDATE_CHAT_COLOR");
-- *** FRAME FUNCTIONS ***
local function Update (self)
if ( IsInGroup(LE_PARTY_CATEGORY_HOME) and IsInGroup(LE_PARTY_CATEGORY_INSTANCE) ) then
self:UpdateColour();
self:Show();
else
self:Hide();
end
end
local function UpdateColour (self)
local public = ChatTypeInfo["INSTANCE_CHAT"];
local private = ChatTypeInfo["PARTY"];
self.HomePartyIcon:SetVertexColor(private.r, private.g, private.b);
self.InstancePartyIcon:SetVertexColor(public.r, public.g, public.b);
end
local function OnEnter (self)
GameTooltip_SetDefaultAnchor(GameTooltip, self);
self.homePlayers = GetHomePartyInfo(self.homePlayers);
if ( IsInRaid(LE_PARTY_CATEGORY_HOME) ) then
GameTooltip:SetText(PLAYER_IN_MULTI_GROUP_RAID_MESSAGE, nil, nil, nil, nil, true);
GameTooltip:AddLine(format(MEMBER_COUNT_IN_RAID_LIST, #self.homePlayers + 1), 1, 1, 1, true);
else
GameTooltip:AddLine(PLAYER_IN_MULTI_GROUP_PARTY_MESSAGE, 1, 1, 1, true);
local playerList = self.homePlayers[1] or "";
for i=2, #self.homePlayers do
playerList = playerList..PLAYER_LIST_DELIMITER..self.homePlayers[i];
end
GameTooltip:AddLine(format(MEMBERS_IN_PARTY_LIST, playerList));
end
GameTooltip:Show();
end
local function OnLeave (self)
GameTooltip:Hide();
end
local function Reset (self)
self:Hide();
end
-- *** HANDLER FUNCTIONS ***
function MultiGroupIcon:AddFrame (multiGroupIcon, HomePartyIcon, InstancePartyIcon, unitFrame)
-- Create a reference for the castbar inside the unit frame and vice versa.
unitFrame.multiGroupIcon = multiGroupIcon;
multiGroupIcon.unitFrame = unitFrame;
unitFrame.handlerList.multiGroupIcon = true;
-- Set references for textures.
multiGroupIcon.HomePartyIcon = HomePartyIcon;
multiGroupIcon.InstancePartyIcon = InstancePartyIcon;
-- Set the basic functions for the castbar.
multiGroupIcon.Update = Update;
multiGroupIcon.UpdateColour = UpdateColour;
multiGroupIcon.OnEnter = OnEnter;
multiGroupIcon.OnLeave = OnLeave;
multiGroupIcon.Reset = Reset;
multiGroupIcon:SetScript("OnEnter", multiGroupIcon.OnEnter);
multiGroupIcon:SetScript("OnLeave", multiGroupIcon.OnLeave);
end
--[[ Function: OnEvent
OnEvent function for the ready check handler.
Arguments:
event: The event that fired.
...: A list of arguments that accompany the event.
]]--
local affectedFrame;
function MultiGroupIcon:OnEvent (event, ...)
-- Filter for player as unit, because only player frames will show this info.
local unit = "player";
if ( event == "GROUP_ROSTER_UPDATE" ) then
if ( UnitFrame.UnitIDTable[unit] ) then
for key, value in pairs(UnitFrame.UnitIDTable[unit]) do
if ( value and UnitFrame.UnitFrameTable[key] ) then
affectedFrame = UnitFrame.UnitFrameTable[key];
if ( affectedFrame.handlerList.multiGroupIcon ) then
affectedFrame.multiGroupIcon:Update();
end
end
end
end
elseif ( event == "UPDATE_CHAT_COLOR" ) then
if ( UnitFrame.UnitIDTable[unit] ) then
for key, value in pairs(UnitFrame.UnitIDTable[unit]) do
if ( value and UnitFrame.UnitFrameTable[key] ) then
affectedFrame = UnitFrame.UnitFrameTable[key];
if ( affectedFrame.handlerList.multiGroupIcon ) then
affectedFrame.multiGroupIcon:UpdateColour();
end
end
end
end
end
end