File src/ChorusGroupFrame.lua changed (mode: 100644) (index 875db12..472e6a5) |
2 |
2 |
@submodule chorus |
@submodule chorus |
3 |
3 |
]] |
]] |
4 |
4 |
|
|
5 |
|
local GetInstanceInfo = Chorus.test.GetInstanceInfo or GetInstanceInfo |
|
6 |
5 |
local GetNumRaidMembers = Chorus.test.GetNumRaidMembers or GetNumRaidMembers |
local GetNumRaidMembers = Chorus.test.GetNumRaidMembers or GetNumRaidMembers |
7 |
6 |
local InCombatLockdown = Chorus.test.InCombatLockdown or InCombatLockdown |
local InCombatLockdown = Chorus.test.InCombatLockdown or InCombatLockdown |
8 |
7 |
|
|
|
8 |
|
local MAX_RAID_MEMBERS = MAX_RAID_MEMBERS or 40 |
|
9 |
|
|
9 |
10 |
local Chorus = Chorus |
local Chorus = Chorus |
10 |
11 |
local ChorusLargeRaidFrame = ChorusLargeRaidFrame |
local ChorusLargeRaidFrame = ChorusLargeRaidFrame |
11 |
12 |
local ChorusPartyFrame = ChorusPartyFrame |
local ChorusPartyFrame = ChorusPartyFrame |
12 |
13 |
local ChorusSmallRaidFrame = ChorusSmallRaidFrame |
local ChorusSmallRaidFrame = ChorusSmallRaidFrame |
13 |
14 |
local ChorusTinyRaidFrame = ChorusTinyRaidFrame |
local ChorusTinyRaidFrame = ChorusTinyRaidFrame |
14 |
15 |
|
|
|
16 |
|
Chorus.groupProfileSet = { |
|
17 |
|
ChorusPartyFrame, |
|
18 |
|
ChorusLargeRaidFrame, |
|
19 |
|
ChorusSmallRaidFrame, |
|
20 |
|
ChorusTinyRaidFrame |
|
21 |
|
} |
|
22 |
|
|
|
23 |
|
local function produceSecureCommand() |
|
24 |
|
local t = { |
|
25 |
|
{'arena', 5, ChorusPartyFrame}, |
|
26 |
|
{'party', 4, ChorusPartyFrame}, |
|
27 |
|
{'raid', 5, ChorusLargeRaidFrame}, |
|
28 |
|
{'raid', 25, ChorusSmallRaidFrame}, |
|
29 |
|
{'raid', 40, ChorusTinyRaidFrame}, |
|
30 |
|
} |
|
31 |
|
|
|
32 |
|
local secureCmd = '' |
|
33 |
|
local i = 0 |
|
34 |
|
while (i < #t) do |
|
35 |
|
i = i + 1 |
|
36 |
|
|
|
37 |
|
local r = t[i] |
|
38 |
|
|
|
39 |
|
assert(r ~= nil) |
|
40 |
|
assert('table' == type(r)) |
|
41 |
|
assert(3 == #r) |
|
42 |
|
|
|
43 |
|
local j = 0 |
|
44 |
|
|
|
45 |
|
local u = r[1] |
|
46 |
|
assert(u ~= nil) |
|
47 |
|
assert('string' == type(u)) |
|
48 |
|
--[[ select(2, GetInstanceInfo()) == u ]]-- |
|
49 |
|
assert('arena' == u or 'party' == u or 'raid' == u) |
|
50 |
|
|
|
51 |
|
local n = r[2] |
|
52 |
|
assert(n ~= nil) |
|
53 |
|
assert('number' == type(n)) |
|
54 |
|
n = math.abs(math.ceil(n)) |
|
55 |
|
assert(n >= 1) |
|
56 |
|
assert(n <= MAX_RAID_MEMBERS) |
|
57 |
|
|
|
58 |
|
local statement = '' |
|
59 |
|
while (j < n) do |
|
60 |
|
j = j + 1 |
|
61 |
|
local predicate = string.format("[@%s%d,exists]", u, j) |
|
62 |
|
statement = statement .. predicate |
|
63 |
|
end |
|
64 |
|
|
|
65 |
|
local f = r[3] |
|
66 |
|
assert(f ~= nil) |
|
67 |
|
assert('table' == type(f) and 'userdata' == type(f[0])) |
|
68 |
|
|
|
69 |
|
local m = f:GetName() |
|
70 |
|
assert(m ~= nil) |
|
71 |
|
assert('string' == type(m)) |
|
72 |
|
m = strtrim(m) |
|
73 |
|
assert(string.len(m) >= 1) |
|
74 |
|
|
|
75 |
|
statement = string.format("%s %s;\n", statement, m) |
|
76 |
|
|
|
77 |
|
secureCmd = secureCmd .. statement |
|
78 |
|
end |
|
79 |
|
|
|
80 |
|
return secureCmd |
|
81 |
|
end |
|
82 |
|
|
|
83 |
|
|
15 |
84 |
--[[-- |
--[[-- |
16 |
85 |
Toggle the visibility raid group profile frame. |
Toggle the visibility raid group profile frame. |
17 |
86 |
|
|
|
... |
... |
and during combat. |
31 |
100 |
@function groupFrameToggleInsecure |
@function groupFrameToggleInsecure |
32 |
101 |
@return nothing |
@return nothing |
33 |
102 |
]] |
]] |
34 |
|
function Chorus.groupFrameToggleInsecure() |
|
|
103 |
|
function Chorus.groupFrameToggleInsecure(...) |
35 |
104 |
--[[ @fixme ]]-- |
--[[ @fixme ]]-- |
36 |
105 |
if InCombatLockdown() then |
if InCombatLockdown() then |
37 |
106 |
return |
return |
38 |
107 |
end |
end |
39 |
108 |
|
|
40 |
|
local t = {ChorusLargeRaidFrame, ChorusPartyFrame, |
|
41 |
|
ChorusSmallRaidFrame, ChorusTinyRaidFrame} |
|
42 |
|
|
|
43 |
|
local i = 0 |
|
44 |
|
while (i < #t) do |
|
45 |
|
i = i + 1 |
|
46 |
|
local f = t[i] |
|
47 |
|
if f then |
|
48 |
|
f:Hide() |
|
49 |
|
end |
|
50 |
|
end |
|
51 |
|
|
|
52 |
|
local thef = nil |
|
53 |
|
local _, instanceType = GetInstanceInfo() |
|
54 |
|
if 'arena' == instanceType then |
|
55 |
|
--[[-- @todo Add real arena group frame, with enemy frames. |
|
56 |
|
]] |
|
57 |
|
thef = ChorusPartyFrame |
|
58 |
|
elseif 'raid' == instanceType or 'none' == instanceType then |
|
59 |
|
local n = GetNumRaidMembers() |
|
60 |
|
if n > 25 then |
|
61 |
|
thef = ChorusTinyRaidFrame |
|
62 |
|
elseif n > 5 then |
|
63 |
|
thef = ChorusSmallRaidFrame |
|
64 |
|
else |
|
65 |
|
thef = ChorusLargeRaidFrame |
|
|
109 |
|
if 'ADDON_LOADED' == select(2, ...) then |
|
110 |
|
if 'chorus' ~= select(3, ...) then |
|
111 |
|
return |
66 |
112 |
end |
end |
67 |
|
elseif 'party' == instanceType or 'none' == instanceType then |
|
68 |
|
thef = ChorusPartyFrame |
|
69 |
113 |
end |
end |
70 |
114 |
|
|
71 |
|
if thef then |
|
72 |
|
thef:Show() |
|
|
115 |
|
local n = GetNumRaidMembers() or 0 |
|
116 |
|
|
|
117 |
|
if n > 25 then |
|
118 |
|
ChorusLargeRaidFrame:Hide() |
|
119 |
|
ChorusPartyFrame:Hide() |
|
120 |
|
ChorusSmallRaidFrame:Hide() |
|
121 |
|
ChorusTinyRaidFrame:Show() |
|
122 |
|
elseif n > 5 then |
|
123 |
|
ChorusLargeRaidFrame:Hide() |
|
124 |
|
ChorusPartyFrame:Hide() |
|
125 |
|
ChorusSmallRaidFrame:Show() |
|
126 |
|
ChorusTinyRaidFrame:Hide() |
|
127 |
|
elseif n >= 1 then |
|
128 |
|
ChorusLargeRaidFrame:Show() |
|
129 |
|
ChorusPartyFrame:Hide() |
|
130 |
|
ChorusSmallRaidFrame:Hide() |
|
131 |
|
ChorusTinyRaidFrame:Hide() |
|
132 |
|
elseif UnitPlayerOrPetInParty('party1') then |
|
133 |
|
ChorusLargeRaidFrame:Hide() |
|
134 |
|
ChorusPartyFrame:Show() |
|
135 |
|
ChorusSmallRaidFrame:Hide() |
|
136 |
|
ChorusTinyRaidFrame:Hide() |
|
137 |
|
elseif n <= 0 then |
|
138 |
|
ChorusLargeRaidFrame:Hide() |
|
139 |
|
ChorusPartyFrame:Hide() |
|
140 |
|
ChorusSmallRaidFrame:Hide() |
|
141 |
|
ChorusTinyRaidFrame:Hide() |
73 |
142 |
end |
end |
74 |
143 |
end |
end |
75 |
144 |
|
|
|
... |
... |
function Chorus.groupFrameMain(self) |
115 |
184 |
--[[ NOTE: The order of switch cases in the macro is significant. The |
--[[ NOTE: The order of switch cases in the macro is significant. The |
116 |
185 |
first match takes precedence. ]]-- |
first match takes precedence. ]]-- |
117 |
186 |
|
|
118 |
|
local secureCmd = [=[[@arena1,exists] ChorusPartyFrame; |
|
119 |
|
[@raid26,exists][@raid31,exists][@raid36,exists] ChorusTinyRaidFrame; |
|
120 |
|
[@raid6,exists][@raid11,exists][@raid16,exists][@raid21,exists] ChorusSmallRaidFrame; |
|
121 |
|
[@raid1,exists] ChorusLargeRaidFrame; |
|
122 |
|
[@party1,exists] ChorusPartyFrame;]=] |
|
|
187 |
|
local secureCmd = produceSecureCommand() |
123 |
188 |
RegisterStateDriver(secureHandler, 'group', secureCmd) |
RegisterStateDriver(secureHandler, 'group', secureCmd) |
124 |
189 |
|
|
125 |
190 |
--[[ When the property `group` of the given protected frame |
--[[ When the property `group` of the given protected frame |
|
... |
... |
function Chorus.groupFrameMain(self) |
130 |
195 |
]] |
]] |
131 |
196 |
|
|
132 |
197 |
secureHandler:WrapScript(secureHandler, 'OnAttributeChanged', [[ |
secureHandler:WrapScript(secureHandler, 'OnAttributeChanged', [[ |
133 |
|
if name ~= 'state-group' then |
|
134 |
|
return |
|
135 |
|
end |
|
136 |
|
value = strtrim(value) |
|
137 |
|
|
|
138 |
|
local currentGroupFrame = self:GetFrameRef(value) |
|
139 |
|
|
|
140 |
|
local t = newtable() |
|
141 |
|
table.insert(t, 'ChorusArenaFrame') |
|
142 |
|
table.insert(t, 'ChorusPartyFrame') |
|
143 |
|
table.insert(t, 'ChorusHugeRaidFrame') |
|
144 |
|
table.insert(t, 'ChorusLargeRaidFrame') |
|
145 |
|
table.insert(t, 'ChorusSmallRaidFrame') |
|
146 |
|
table.insert(t, 'ChorusTinyRaidFrame') |
|
|
198 |
|
local ChorusLargeRaidFrame = self:GetFrameRef('ChorusLargeRaidFrame') |
|
199 |
|
local ChorusPartyFrame = self:GetFrameRef('ChorusPartyFrame') |
|
200 |
|
local ChorusSmallRaidFrame = self:GetFrameRef('ChorusSmallRaidFrame') |
|
201 |
|
local ChorusTinyRaidFrame = self:GetFrameRef('ChorusTinyRaidFrame') |
147 |
202 |
|
|
148 |
203 |
local i = 0 |
local i = 0 |
149 |
|
while(i < #t) do |
|
|
204 |
|
local n = 0 |
|
205 |
|
while (i < 40) do |
150 |
206 |
i = i + 1 |
i = i + 1 |
151 |
|
|
|
152 |
|
local f = self:GetFrameRef(t[i]) |
|
153 |
|
if f and f ~= currentGroupFrame then |
|
154 |
|
f:Hide() |
|
|
207 |
|
if UnitPlayerOrPetInRaid('raid' .. tostring(i)) then |
|
208 |
|
n = n + 1 |
155 |
209 |
end |
end |
156 |
210 |
end |
end |
157 |
211 |
|
|
158 |
|
if currentGroupFrame then |
|
159 |
|
currentGroupFrame:Show() |
|
|
212 |
|
if n > 25 then |
|
213 |
|
ChorusLargeRaidFrame:Hide() |
|
214 |
|
ChorusPartyFrame:Hide() |
|
215 |
|
ChorusSmallRaidFrame:Hide() |
|
216 |
|
ChorusTinyRaidFrame:Show() |
|
217 |
|
elseif n > 5 then |
|
218 |
|
ChorusLargeRaidFrame:Hide() |
|
219 |
|
ChorusPartyFrame:Hide() |
|
220 |
|
ChorusSmallRaidFrame:Show() |
|
221 |
|
ChorusTinyRaidFrame:Hide() |
|
222 |
|
elseif n >= 1 then |
|
223 |
|
ChorusLargeRaidFrame:Show() |
|
224 |
|
ChorusPartyFrame:Hide() |
|
225 |
|
ChorusSmallRaidFrame:Hide() |
|
226 |
|
ChorusTinyRaidFrame:Hide() |
|
227 |
|
elseif UnitPlayerOrPetInParty('party1') then |
|
228 |
|
ChorusLargeRaidFrame:Hide() |
|
229 |
|
ChorusPartyFrame:Show() |
|
230 |
|
ChorusSmallRaidFrame:Hide() |
|
231 |
|
ChorusTinyRaidFrame:Hide() |
|
232 |
|
elseif n <= 0 then |
|
233 |
|
ChorusLargeRaidFrame:Hide() |
|
234 |
|
ChorusPartyFrame:Hide() |
|
235 |
|
ChorusSmallRaidFrame:Hide() |
|
236 |
|
ChorusTinyRaidFrame:Hide() |
160 |
237 |
end |
end |
161 |
238 |
]]) |
]]) |
162 |
239 |
|
|
163 |
|
self:RegisterEvent('PARTY_MEMBERS_CHANGED') |
|
|
240 |
|
self:RegisterEvent('PARTY_CONVERTED_TO_RAID') |
164 |
241 |
self:RegisterEvent('PLAYER_LOGIN') |
self:RegisterEvent('PLAYER_LOGIN') |
165 |
|
self:RegisterEvent('RAID_ROSTER_UPDATE') |
|
|
242 |
|
self:RegisterEvent('ZONE_CHANGED') |
|
243 |
|
self:RegisterEvent('ADDON_LOADED') |
166 |
244 |
self:SetScript('OnEvent', Chorus.groupFrameToggleInsecure) |
self:SetScript('OnEvent', Chorus.groupFrameToggleInsecure) |
167 |
245 |
end |
end |