-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathace.lua
72 lines (68 loc) · 1.78 KB
/
ace.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
local addonName, G = ...
local ace = LibStub('AceAddon-3.0'):NewAddon(addonName, 'AceComm-3.0', 'AceConsole-3.0', 'AceSerializer-3.0')
LibStub('AceConfig-3.0'):RegisterOptionsTable(addonName, {
type = 'group',
args = {
frames = (function()
local state = true
return {
name = 'Frames',
desc = 'Toggles Blizzard raid frames',
type = 'toggle',
get = function()
return state
end,
set = function(_, value)
local root = _G.FerronnizerRoot
local hidden = root.Hidden
state = value
CompactRaidFrameManager:SetParent(state and hidden or UIParent)
for i = 1, 4 do
root['Party' .. i]:SetParent(state and root or hidden)
end
end,
}
end)(),
},
})
local slash = 'ferronnizer'
local handleCommand = LibStub('AceConfigCmd-3.0').HandleCommand
ace:RegisterChatCommand(slash, function(input)
handleCommand(ace, slash, addonName, input)
end)
local commWatches = {
'following',
'on_hate_list',
'resting',
}
local pubs = {}
for i = 1, 4 do
local prefix = 'party' .. i .. '_'
local t = {}
for _, w in ipairs(commWatches) do
t[w] = G.RegisterDataWatch(prefix .. w)
end
table.insert(pubs, t)
end
ace:RegisterComm(addonName, function(_, msg, _, sender)
for i = 1, 4 do
if UnitIsUnit(sender, 'party' .. i) then
local _, t = assert(ace:Deserialize(msg))
for k, v in pairs(pubs[i]) do
v(t[k])
end
end
end
end)
local wargs = {}
for _, w in ipairs(commWatches) do
table.insert(wargs, 'player_' .. w)
end
table.insert(wargs, function(...)
local t = {}
for i, w in ipairs(commWatches) do
t[w] = select(i, ...)
end
ace:SendCommMessage(addonName, ace:Serialize(t), 'PARTY')
end)
G.DataWatch(unpack(wargs))