File choir.lua changed (mode: 100644) (index a88feb6..aa1ed74) |
... |
... |
end |
59 |
59 |
local function createSpoiler(spoilerParent, spoilerDesignation) |
local function createSpoiler(spoilerParent, spoilerDesignation) |
60 |
60 |
local spoiler = CreateFrame('BUTTON', spoilerDesignation, spoilerParent, 'SecureHandlerClickTemplate') |
local spoiler = CreateFrame('BUTTON', spoilerDesignation, spoilerParent, 'SecureHandlerClickTemplate') |
61 |
61 |
spoiler:EnableMouse(true) |
spoiler:EnableMouse(true) |
|
62 |
|
--[[ WARNING To assign the temporary override bindings to the buttons under a spoiler correctly, |
|
63 |
|
-- the children table must be sorted and be iterated over in a specific order. |
|
64 |
|
-- #GetChildList method seems to return the children in order they were created, |
|
65 |
|
-- but that might not be the case for #GetChildren variant or not at all. ]]-- |
|
66 |
|
--[[ TODO Check if it is possible to decouple the binding logic into a hooked script or something. |
|
67 |
|
-- That way the sibling and children toggling could be re-used. ]]-- |
62 |
68 |
spoiler:SetAttribute('_onclick', [=[ |
spoiler:SetAttribute('_onclick', [=[ |
63 |
69 |
local debugFlag = true |
local debugFlag = true |
|
70 |
|
|
64 |
71 |
local parentFrame = self:GetParent() |
local parentFrame = self:GetParent() |
65 |
72 |
local siblingTable = parentFrame:GetChildList(newtable()) |
local siblingTable = parentFrame:GetChildList(newtable()) |
66 |
73 |
local i = 0 |
local i = 0 |
|
... |
... |
local function createSpoiler(spoilerParent, spoilerDesignation) |
74 |
81 |
self:Show() |
self:Show() |
75 |
82 |
local j = 0 |
local j = 0 |
76 |
83 |
local childTable = self:GetChildList(newtable()) |
local childTable = self:GetChildList(newtable()) |
77 |
|
--[[local bindingTable = newtable( |
|
78 |
|
'A', 'S', 'D', 'F', 'G' |
|
79 |
|
)]]-- |
|
80 |
84 |
while (j < #childTable) do |
while (j < #childTable) do |
81 |
85 |
j = j + 1 |
j = j + 1 |
82 |
86 |
local child = childTable[j] |
local child = childTable[j] |
|
... |
... |
local function createSpoiler(spoilerParent, spoilerDesignation) |
88 |
92 |
else |
else |
89 |
93 |
child:Hide() |
child:Hide() |
90 |
94 |
end |
end |
91 |
|
print('child', child:GetName()) |
|
|
95 |
|
|
92 |
96 |
local key = GetBindingKey('CLICK ChoirUnitButton' .. tostring(j) .. ':LeftButton') |
local key = GetBindingKey('CLICK ChoirUnitButton' .. tostring(j) .. ':LeftButton') |
93 |
|
--local key = bindingTable[math.min(j, #childTable)] |
|
|
97 |
|
|
|
98 |
|
local actionBarSize = 12 |
|
99 |
|
if not key then |
|
100 |
|
if j >= 1 and j <= actionBarSize then |
|
101 |
|
key = GetBindingKey('ACTIONBUTTON' .. tostring(j)) |
|
102 |
|
elseif j > actionBarSize and j <= actionBarSize * 6 then |
|
103 |
|
local r = j % actionBarSize |
|
104 |
|
local n = j - r * actionBarSize |
|
105 |
|
key = GetBindingKey('MULTIACTIONBAR' .. r .. 'BUTTON' .. n) |
|
106 |
|
end |
|
107 |
|
end |
|
108 |
|
|
94 |
109 |
if key then |
if key then |
95 |
110 |
self:SetBindingClick(true, key, child) |
self:SetBindingClick(true, key, child) |
96 |
111 |
end |
end |
|
... |
... |
local function createGroup(rootFrame, groupNumber, unitTable) |
142 |
157 |
|
|
143 |
158 |
spoiler:WrapScript(b, 'OnClick', [=[ |
spoiler:WrapScript(b, 'OnClick', [=[ |
144 |
159 |
print('OnClick', self:GetName()) |
print('OnClick', self:GetName()) |
145 |
|
local parentFrame = self:GetParent() |
|
146 |
|
parentFrame:Hide() |
|
|
160 |
|
--[[ Assume that the parent frame is the relevant spoiler frame ]]-- |
|
161 |
|
local spoilerFrame = self:GetParent() |
|
162 |
|
spoilerFrame:ClearBindings() |
|
163 |
|
spoilerFrame:Hide() |
147 |
164 |
]=]) |
]=]) |
148 |
165 |
b:Hide() |
b:Hide() |
149 |
166 |
|
|
|
... |
... |
local function init(rootFrame) |
173 |
190 |
createGroup(rootFrame, 8) |
createGroup(rootFrame, 8) |
174 |
191 |
|
|
175 |
192 |
--[[ TODO Add Esc key that closes the spoiler without clicking any of the children buttons ]]-- |
--[[ TODO Add Esc key that closes the spoiler without clicking any of the children buttons ]]-- |
176 |
|
--[[ TODO Generalize the interface to be used with any kind of child frames, especially nested spoilers and spell buttons ]]-- |
|
|
193 |
|
--[[ TODO Generalize the interface to be used with any kind of child frames, |
|
194 |
|
-- especially nested spoilers and spell buttons. ]]-- |
|
195 |
|
--[[ NOTE To get a saved variables kind of table from a restricted frame snippet, use ``` |
|
196 |
|
-- local env = GetManagedEnvironment(headerRef) |
|
197 |
|
-- local t = env['MySavedVariableTable'] |
|
198 |
|
-- ``` |
|
199 |
|
-- See http://www.iriel.org/wow/docs/SecureHeadersGuide-4.0-r1.pdf ]]-- |
177 |
200 |
local spoilerParty = createGroup(rootFrame, 9, {'player', 'party1', 'party2', 'party3', 'party4'}) |
local spoilerParty = createGroup(rootFrame, 9, {'player', 'party1', 'party2', 'party3', 'party4'}) |
178 |
201 |
_G['BINDING_NAME_CLICK ' .. spoilerParty:GetName() .. ':LeftButton'] = 'Player party' |
_G['BINDING_NAME_CLICK ' .. spoilerParty:GetName() .. ':LeftButton'] = 'Player party' |
179 |
202 |
|
|