File src/Chorus.xml changed (mode: 100644) (index f48f721..bdcba4f) |
6 |
6 |
Configuration is done in the snippet itself. --> |
Configuration is done in the snippet itself. --> |
7 |
7 |
<Script file="ChorusTest.lua"/> |
<Script file="ChorusTest.lua"/> |
8 |
8 |
<Include file="ChorusFont.xml"/> |
<Include file="ChorusFont.xml"/> |
|
9 |
|
<!-- Templates (abstract classes). --> |
9 |
10 |
<Include file="ChorusAuraButtonTemplate.xml"/> |
<Include file="ChorusAuraButtonTemplate.xml"/> |
10 |
11 |
<Include file="ChorusAuraFrameTemplate.xml"/> |
<Include file="ChorusAuraFrameTemplate.xml"/> |
11 |
12 |
<Include file="ChorusAuraTooltipFrameTemplate.xml"/> |
<Include file="ChorusAuraTooltipFrameTemplate.xml"/> |
|
26 |
27 |
<Include file="ChorusLargeUnitFrameTemplate.xml"/> |
<Include file="ChorusLargeUnitFrameTemplate.xml"/> |
27 |
28 |
<Include file="ChorusSmallUnitFrameTemplate.xml"/> |
<Include file="ChorusSmallUnitFrameTemplate.xml"/> |
28 |
29 |
<Include file="ChorusTinyUnitFrameTemplate.xml"/> |
<Include file="ChorusTinyUnitFrameTemplate.xml"/> |
|
30 |
|
<!-- Frames (concrete classes, interface implementations, object instances). --> |
29 |
31 |
<Include file="ChorusPartyFrame.xml"/> |
<Include file="ChorusPartyFrame.xml"/> |
30 |
32 |
<Include file="ChorusRaidFrame.xml"/> |
<Include file="ChorusRaidFrame.xml"/> |
|
33 |
|
<Include file="ChorusGroupFrame.xml"/> |
31 |
34 |
<Include file="ChorusPlayerFrame.xml"/> |
<Include file="ChorusPlayerFrame.xml"/> |
32 |
35 |
<Include file="ChorusTargetFrame.xml"/> |
<Include file="ChorusTargetFrame.xml"/> |
33 |
36 |
<Include file="ChorusFocusFrame.xml"/> |
<Include file="ChorusFocusFrame.xml"/> |
File src/ChorusGroupFrame.lua added (mode: 100644) (index 0000000..1eec3bd) |
|
1 |
|
local GetNumPartyMembers = Chorus.test.GetNumPartyMembers or GetNumPartyMembers |
|
2 |
|
local UnitInParty = Chorus.test.UnitInParty or UnitInParty |
|
3 |
|
local UnitInRaid = Chorus.test.UnitInRaid or UnitInRaid |
|
4 |
|
|
|
5 |
|
local Chorus = Chorus |
|
6 |
|
local ChorusPartyFrame = ChorusPartyFrame |
|
7 |
|
local ChorusRaidFrame = ChorusRaidFrame |
|
8 |
|
|
|
9 |
|
local function groupFrameEventProcessor(self) |
|
10 |
|
assert(self ~= nil) |
|
11 |
|
|
|
12 |
|
if IsActiveBattlefieldArena() then |
|
13 |
|
--[[ TODO Implement separate or additional arena unit group frame. ]]-- |
|
14 |
|
self:Show() |
|
15 |
|
ChorusPartyFrame:Show() |
|
16 |
|
ChorusRaidFrame:Hide() |
|
17 |
|
elseif UnitInRaid('player') then |
|
18 |
|
self:Show() |
|
19 |
|
ChorusPartyFrame:Hide() |
|
20 |
|
--[[ TODO Implement separate raid profiles for 10, 25 and 40 men raids. ]]-- |
|
21 |
|
ChorusRaidFrame:Show() |
|
22 |
|
elseif UnitInParty('player') and GetNumPartyMembers() >= 1 then |
|
23 |
|
self:Show() |
|
24 |
|
ChorusPartyFrame:Show() |
|
25 |
|
ChorusRaidFrame:Hide() |
|
26 |
|
else |
|
27 |
|
self:Hide() |
|
28 |
|
ChorusPartyFrame:Hide() |
|
29 |
|
ChorusRaidFrame:Hide() |
|
30 |
|
end |
|
31 |
|
end |
|
32 |
|
|
|
33 |
|
function Chorus.groupFrameMain(self) |
|
34 |
|
assert(self ~= nil) |
|
35 |
|
|
|
36 |
|
self:SetScript('OnEvent', groupFrameEventProcessor) |
|
37 |
|
|
|
38 |
|
self:RegisterEvent('BATTLEFIELDS_CLOSED'); |
|
39 |
|
self:RegisterEvent('BATTLEFIELDS_SHOW'); |
|
40 |
|
self:RegisterEvent('PARTY_CONVERTED_TO_RAID') |
|
41 |
|
self:RegisterEvent('PARTY_LEADER_CHANGED'); |
|
42 |
|
self:RegisterEvent('PARTY_MEMBERS_CHANGED') |
|
43 |
|
self:RegisterEvent('PARTY_MEMBER_DISABLE') |
|
44 |
|
self:RegisterEvent('PARTY_MEMBER_ENABLE') |
|
45 |
|
self:RegisterEvent('PLAYER_ALIVE'); |
|
46 |
|
self:RegisterEvent('PLAYER_LOGIN') |
|
47 |
|
self:RegisterEvent('RAID_ROSTER_UPDATE') |
|
48 |
|
self:RegisterEvent('UPDATE_BATTLEFIELD_STATUS'); |
|
49 |
|
end |
File src/ChorusPartyFrame.lua changed (mode: 100644) (index 55ea6f9..5f0bd9a) |
|
1 |
|
local SecureButton_GetUnit = SecureButton_GetUnit |
|
2 |
|
|
1 |
3 |
local Chorus = Chorus |
local Chorus = Chorus |
2 |
4 |
|
|
3 |
|
local GetNumPartyMembers = Chorus.test.GetNumPartyMembers or GetNumPartyMembers |
|
4 |
|
local UnitInParty = Chorus.test.UnitInParty or UnitInParty |
|
5 |
|
local UnitInRaid = Chorus.test.UnitInRaid or UnitInRaid |
|
|
5 |
|
--[[-- |
|
6 |
|
Given valid player unit designation, infer from it corresponding pet and target unit designations. |
6 |
7 |
|
|
7 |
|
local function partyFrameEventProcessor(self) |
|
8 |
|
assert(self ~= nil) |
|
|
8 |
|
Does not check if unit exists. |
|
9 |
|
Used in party frame initialization. |
9 |
10 |
|
|
10 |
|
if IsActiveBattlefieldArena() then |
|
11 |
|
self:Show() |
|
12 |
|
return |
|
13 |
|
end |
|
14 |
|
if UnitInRaid('player') then |
|
15 |
|
self:Hide() |
|
16 |
|
elseif UnitInParty('player') and GetNumPartyMembers() >= 1 then |
|
17 |
|
self:Show() |
|
18 |
|
else |
|
19 |
|
self:Hide() |
|
20 |
|
end |
|
21 |
|
end |
|
|
11 |
|
@function mapUnitDesignation |
|
12 |
|
|
|
13 |
|
@tparam string unitDesignation unit designation in the same format as native |
|
14 |
|
unit functions, specifically party, arena or raid members (party3, raid13, |
|
15 |
|
arena2) |
|
16 |
|
|
|
17 |
|
@treturn string sanitized given unit designation, for example party3 |
|
18 |
|
|
|
19 |
|
@treturn string given unit pet designation, for example partypet3 |
22 |
20 |
|
|
|
21 |
|
@treturn string given unit target designation, for example party3target |
|
22 |
|
]] |
23 |
23 |
local function mapUnitDesignation(unitDesignation) |
local function mapUnitDesignation(unitDesignation) |
24 |
24 |
assert(unitDesignation ~= nil) |
assert(unitDesignation ~= nil) |
25 |
25 |
|
|
26 |
26 |
if 'player' == unitDesignation then |
if 'player' == unitDesignation then |
27 |
27 |
return 'player', 'pet', 'target' |
return 'player', 'pet', 'target' |
28 |
|
elseif 'party1' == unitDesignation then |
|
29 |
|
return 'party1', 'partypet1', 'party1target' |
|
30 |
|
elseif 'party2' == unitDesignation then |
|
31 |
|
return 'party2', 'partypet2', 'party2target' |
|
32 |
|
elseif 'party3' == unitDesignation then |
|
33 |
|
return 'party3', 'partypet3', 'party3target' |
|
34 |
|
elseif 'party4' == unitDesignation then |
|
35 |
|
return 'party4', 'partypet4', 'party4target' |
|
|
28 |
|
elseif string.match(unitDesignation, 'raid') then |
|
29 |
|
local raidUnit = string.match(unitDesignation, 'raid%d+') |
|
30 |
|
local raidPet = 'raidpet' .. string.match(unitDesignation, 'raid(%d+)') |
|
31 |
|
local raidTarget = 'raid' .. string.match(unitDesignation, 'raid(%d+)') .. 'target' |
|
32 |
|
return raidUnit, raidPet, raidTarget |
|
33 |
|
elseif string.match(unitDesignation, 'party') then |
|
34 |
|
local partyUnit = string.match(unitDesignation, 'party%d+') |
|
35 |
|
local partyPet = 'partypet' .. string.match(unitDesignation, 'party(%d+)') |
|
36 |
|
local partyTarget = 'party' .. string.match(unitDesignation, 'party(%d+)') .. 'target' |
|
37 |
|
return partyUnit, partyPet, partyTarget |
|
38 |
|
elseif string.match(unitDesignation, 'arena') then |
|
39 |
|
local arenaUnit = string.match(unitDesignation, 'arena%d+') |
|
40 |
|
local arenaPet = 'arenapet' .. string.match(unitDesignation, 'arena(%d+)') |
|
41 |
|
local arenaTarget = 'arena' .. string.match(unitDesignation, 'arena(%d+)') .. 'target' |
|
42 |
|
return arenaUnit, arenaPet, arenaTarget |
36 |
43 |
else |
else |
37 |
|
error('unexpected value: expect at most four party members excluding player') |
|
|
44 |
|
error('invalid argument: must be a unit designation of a player character or a group member') |
38 |
45 |
end |
end |
39 |
46 |
end |
end |
40 |
47 |
|
|
41 |
|
local function initPartyMemberFrame(partyMemberFrame) |
|
|
48 |
|
local function partyMemberFrameInit(partyMemberFrame) |
42 |
49 |
assert(partyMemberFrame ~= nil) |
assert(partyMemberFrame ~= nil) |
43 |
50 |
|
|
44 |
51 |
local n = partyMemberFrame:GetName() |
local n = partyMemberFrame:GetName() |
45 |
52 |
assert(n ~= nil) |
assert(n ~= nil) |
46 |
53 |
|
|
47 |
54 |
local u = partyMemberFrame:GetAttribute('unit') |
local u = partyMemberFrame:GetAttribute('unit') |
|
55 |
|
|
|
56 |
|
if not u then |
|
57 |
|
u = SecureButton_GetUnit(partyMemberFrame) |
|
58 |
|
end |
|
59 |
|
|
48 |
60 |
local _, upet, utarget = mapUnitDesignation(u) |
local _, upet, utarget = mapUnitDesignation(u) |
49 |
61 |
|
|
50 |
62 |
local unitFrame = _G[n .. 'UnitFrame'] |
local unitFrame = _G[n .. 'UnitFrame'] |
|
... |
... |
local function initPartyMemberFrame(partyMemberFrame) |
59 |
71 |
targetFrame:SetAttribute('unit', utarget) |
targetFrame:SetAttribute('unit', utarget) |
60 |
72 |
end |
end |
61 |
73 |
|
|
62 |
|
local function partyFrameMain(self) |
|
63 |
|
assert(self ~= nil) |
|
64 |
|
|
|
65 |
|
local t = {self:GetChildren()} |
|
66 |
|
local i = 0 |
|
67 |
|
assert(5 == #t, 'invalid state: must be exactly five party member frames') |
|
68 |
|
while (i < #t) do |
|
69 |
|
i = i + 1 |
|
70 |
|
local partyMemberFrame = t[i] |
|
71 |
|
assert(partyMemberFrame ~= nil) |
|
72 |
|
|
|
73 |
|
initPartyMemberFrame(partyMemberFrame) |
|
74 |
|
end |
|
|
74 |
|
function Chorus.partyMemberFrameMain(partyMemberFrame) |
|
75 |
|
assert(partyMemberFrame ~= nil) |
75 |
76 |
|
|
76 |
|
self:SetScript('OnEvent', partyFrameEventProcessor) |
|
77 |
|
|
|
78 |
|
self:RegisterEvent('BATTLEFIELDS_CLOSED'); |
|
79 |
|
self:RegisterEvent('BATTLEFIELDS_SHOW'); |
|
80 |
|
self:RegisterEvent('PARTY_CONVERTED_TO_RAID') |
|
81 |
|
self:RegisterEvent('PARTY_LEADER_CHANGED'); |
|
82 |
|
self:RegisterEvent('PARTY_MEMBERS_CHANGED') |
|
83 |
|
self:RegisterEvent('PARTY_MEMBER_DISABLE') |
|
84 |
|
self:RegisterEvent('PARTY_MEMBER_ENABLE') |
|
85 |
|
self:RegisterEvent('PLAYER_ALIVE'); |
|
86 |
|
self:RegisterEvent('PLAYER_LOGIN') |
|
87 |
|
self:RegisterEvent('RAID_ROSTER_UPDATE') |
|
88 |
|
self:RegisterEvent('UPDATE_BATTLEFIELD_STATUS'); |
|
|
77 |
|
partyMemberFrame:RegisterEvent('ADDON_LOADED') |
|
78 |
|
partyMemberFrame:SetScript('OnEvent', partyMemberFrameInit) |
|
79 |
|
partyMemberFrame:SetScript('OnAttributeChanged', partyMemberFrameInit) |
89 |
80 |
end |
end |
90 |
81 |
|
|
91 |
|
Chorus.partyFrameMain = function(...) |
|
92 |
|
return partyFrameMain(...) |
|
|
82 |
|
function Chorus.partyFrameMain(self) |
|
83 |
|
assert(self ~= nil) |
93 |
84 |
end |
end |