File src/ChorusConfFrame.lua changed (mode: 100644) (index f40d192..1255367) |
|
1 |
|
local movableFrameList = { |
|
2 |
|
ChorusSoloFrame, |
|
3 |
|
ChorusPartyFrame, |
|
4 |
|
ChorusTinyRaidFrame, |
|
5 |
|
ChorusSmallRaidFrame, |
|
6 |
|
ChorusLargeRaidFrame, |
|
7 |
|
} |
|
8 |
|
|
1 |
9 |
local function movableEnable(frame) |
local function movableEnable(frame) |
2 |
10 |
assert(frame ~= nil) |
assert(frame ~= nil) |
3 |
11 |
|
|
|
... |
... |
local function movableDisable(frame) |
46 |
54 |
end |
end |
47 |
55 |
end |
end |
48 |
56 |
|
|
|
57 |
|
local function savePoints(conf, profileName, frame) |
|
58 |
|
assert(conf ~= nil) |
|
59 |
|
assert('table' == type(conf)) |
|
60 |
|
|
|
61 |
|
assert(profileName ~= nil) |
|
62 |
|
assert('string' == type(profileName)) |
|
63 |
|
profileName = strtrim(profileName) |
|
64 |
|
assert(string.len(profileName) >= 1) |
|
65 |
|
assert(string.len(profileName) <= 256) |
|
66 |
|
|
|
67 |
|
assert(frame ~= nil) |
|
68 |
|
|
|
69 |
|
local n = frame:GetName() |
|
70 |
|
assert(n ~= nil) |
|
71 |
|
assert('string' == type(n)) |
|
72 |
|
n = strtrim(n) |
|
73 |
|
assert(string.len(n) >= 1) |
|
74 |
|
assert(string.len(n) <= 256) |
|
75 |
|
|
|
76 |
|
if InCombatLockdown() then |
|
77 |
|
return |
|
78 |
|
end |
|
79 |
|
|
|
80 |
|
local confProfile = conf[profileName] |
|
81 |
|
assert(confProfile ~= nil) |
|
82 |
|
assert('table' == type(confProfile)) |
|
83 |
|
|
|
84 |
|
local frameSettings = confProfile[n] |
|
85 |
|
if not frameSettings then |
|
86 |
|
frameSettings = {} |
|
87 |
|
end |
|
88 |
|
assert(frameSettings ~= nil) |
|
89 |
|
assert('table' == type(frameSettigns)) |
|
90 |
|
|
|
91 |
|
local record = {} |
|
92 |
|
local i = 0 |
|
93 |
|
while (i < 8) do |
|
94 |
|
i = i + 1 |
|
95 |
|
local point = {frame:GetPoint(i)} |
|
96 |
|
record[i] = point |
|
97 |
|
end |
|
98 |
|
|
|
99 |
|
frameSettings.points = record |
|
100 |
|
|
|
101 |
|
confProfile[n] = frameSettings |
|
102 |
|
end |
|
103 |
|
|
|
104 |
|
local function loadPoints(conf, profileName, frame) |
|
105 |
|
assert(conf ~= nil) |
|
106 |
|
assert('table' == type(conf)) |
|
107 |
|
|
|
108 |
|
assert(profileName ~= nil) |
|
109 |
|
assert('string' == type(profileName)) |
|
110 |
|
profileName = strtrim(profileName) |
|
111 |
|
assert(string.len(profileName) >= 1) |
|
112 |
|
assert(string.len(profileName) <= 256) |
|
113 |
|
|
|
114 |
|
assert(frame ~= nil) |
|
115 |
|
|
|
116 |
|
local n = frame:GetName() |
|
117 |
|
assert(n ~= nil) |
|
118 |
|
assert('string' == type(n)) |
|
119 |
|
n = strtrim(n) |
|
120 |
|
assert(string.len(n) >= 1) |
|
121 |
|
assert(string.len(n) <= 256) |
|
122 |
|
|
|
123 |
|
if InCombatLockdown() then |
|
124 |
|
return |
|
125 |
|
end |
|
126 |
|
|
|
127 |
|
local confProfile = conf[profileName] |
|
128 |
|
assert(confProfile ~= nil, |
|
129 |
|
'profile "' .. profileName .. '" does not exist') |
|
130 |
|
|
|
131 |
|
local frameSettings = confProfile[n] |
|
132 |
|
if not frameSettings then |
|
133 |
|
print('ChorusConfFrame.lua: empty settings for frame "' .. n .. '"') |
|
134 |
|
return |
|
135 |
|
end |
|
136 |
|
|
|
137 |
|
local points = frameSettings.points |
|
138 |
|
assert(points ~= nil, 'no frame position saved') |
|
139 |
|
assert('table' == type(points)) |
|
140 |
|
local i = 0 |
|
141 |
|
while (i < 8) do |
|
142 |
|
i = i + 1 |
|
143 |
|
local point = points[i] |
|
144 |
|
assert(point ~= nil) |
|
145 |
|
assert('table' == type(point)) |
|
146 |
|
if point[3] and point[4] and point[5] then |
|
147 |
|
frame:SetPoint(point[3], point[4], point[5]) |
|
148 |
|
end |
|
149 |
|
end |
|
150 |
|
end |
|
151 |
|
|
49 |
152 |
local function confApply(confFrame) |
local function confApply(confFrame) |
50 |
153 |
assert(confFrame ~= nil) |
assert(confFrame ~= nil) |
51 |
154 |
|
|
52 |
155 |
local flag = ChorusConfMovableCheckBox:GetChecked() |
local flag = ChorusConfMovableCheckBox:GetChecked() |
53 |
156 |
|
|
54 |
157 |
if flag then |
if flag then |
55 |
|
movableEnable(ChorusSoloFrame) |
|
|
158 |
|
local i = 0 |
|
159 |
|
while (i < #movableFrameList) do |
|
160 |
|
i = i + 1 |
|
161 |
|
local f = movableFrameList[i] |
|
162 |
|
assert(f ~= nil) |
|
163 |
|
movableEnable(f) |
|
164 |
|
end |
56 |
165 |
else |
else |
57 |
|
movableDisable(ChorusSoloFrame) |
|
|
166 |
|
local i = 0 |
|
167 |
|
while (i < #movableFrameList) do |
|
168 |
|
i = i + 1 |
|
169 |
|
local f = movableFrameList[i] |
|
170 |
|
assert(f ~= nil) |
|
171 |
|
movableDisable(f) |
|
172 |
|
savePoints(ChorusConf, ChorusConfProfileName, f) |
|
173 |
|
end |
|
174 |
|
end |
|
175 |
|
end |
|
176 |
|
|
|
177 |
|
local function confCancel(confFrame) |
|
178 |
|
ChorusConfMovableCheckBox:SetChecked(false) |
|
179 |
|
|
|
180 |
|
confApply(confFrame) |
|
181 |
|
end |
|
182 |
|
|
|
183 |
|
local function confDefault(confFrame) |
|
184 |
|
ChorusConfMovableCheckBox:SetChecked(false) |
|
185 |
|
|
|
186 |
|
local i = 0 |
|
187 |
|
while (i < #movableFrameList) do |
|
188 |
|
i = i + 1 |
|
189 |
|
local f = movableFrameList[i] |
|
190 |
|
assert(f ~= nil) |
|
191 |
|
f:ClearAllPoints() |
|
192 |
|
end |
|
193 |
|
|
|
194 |
|
--[[ Bypass as much of the saving mechanism on purpose, to provide |
|
195 |
|
sane defaults even when saving breaks. ]]-- |
|
196 |
|
|
|
197 |
|
ChorusSoloFrame:SetPoint('CENTER', 0, 0) |
|
198 |
|
ChorusPartyFrame:SetPoint('TOPLEFT', 0, 0) |
|
199 |
|
ChorusTinyRaidFrame:SetPoint('TOPLEFT', 0, 0) |
|
200 |
|
ChorusSmallRaidFrame:SetPoint('TOPLEFT', 0, 0) |
|
201 |
|
ChorusLargeRaidFrame:SetPoint('TOPLEFT', 0, 0) |
|
202 |
|
|
|
203 |
|
confApply(confFrame) |
|
204 |
|
end |
|
205 |
|
|
|
206 |
|
local function confFrameEventProcessor(confFrame) |
|
207 |
|
ChorusConf = ChorusConf or {['main'] = {}} |
|
208 |
|
ChorusConfProfileName = ChorusConfProfileName or 'main' |
|
209 |
|
|
|
210 |
|
local i = 0 |
|
211 |
|
while (i < #movableFrameList) do |
|
212 |
|
i = i + 1 |
|
213 |
|
local f = movableFrameList[i] |
|
214 |
|
assert(f ~= nil) |
|
215 |
|
loadPoints(ChorusConf, ChorusConfProfileName, f) |
58 |
216 |
end |
end |
59 |
217 |
end |
end |
60 |
218 |
|
|
|
... |
... |
function Chorus.confFrameMain(confFrame) |
70 |
228 |
|
|
71 |
229 |
confFrame.okay = confApply |
confFrame.okay = confApply |
72 |
230 |
|
|
73 |
|
confFrame.cancel = function(self) |
|
74 |
|
ChorusConfMovableCheckBox:SetChecked(false) |
|
75 |
|
confApply(self) |
|
76 |
|
end |
|
|
231 |
|
confFrame.cancel = confCancel |
77 |
232 |
|
|
78 |
|
confFrame.default = function(self) |
|
79 |
|
ChorusConfMovableCheckBox:SetChecked(false) |
|
80 |
|
ChorusSoloFrame:ClearAllPoints() |
|
81 |
|
ChorusSoloFrame:SetPoint('CENTER', 0, 0) |
|
82 |
|
confApply(self) |
|
83 |
|
end |
|
|
233 |
|
confFrame.default = confDefault |
84 |
234 |
|
|
85 |
235 |
confFrame.refresh = confApply |
confFrame.refresh = confApply |
86 |
236 |
|
|
87 |
237 |
InterfaceOptions_AddCategory(confFrame) |
InterfaceOptions_AddCategory(confFrame) |
|
238 |
|
|
|
239 |
|
confFrame:RegisterEvent('VARIABLES_LOADED') |
|
240 |
|
confFrame:SetScript('OnEvent', confFrameEventProcessor) |
88 |
241 |
end |
end |
File src/ChorusConfFrame.xml changed (mode: 100644) (index aa64ae3..f864461) |
37 |
37 |
</Layers> |
</Layers> |
38 |
38 |
<Frames> |
<Frames> |
39 |
39 |
<!-- See FrameXML/InterfaceOptionsPanels.xml --> |
<!-- See FrameXML/InterfaceOptionsPanels.xml --> |
|
40 |
|
<!-- Movable toggle. --> |
40 |
41 |
<CheckButton name="ChorusConfMovableCheckBox" inherits="InterfaceOptionsCheckButtonTemplate"> |
<CheckButton name="ChorusConfMovableCheckBox" inherits="InterfaceOptionsCheckButtonTemplate"> |
41 |
42 |
<Anchors> |
<Anchors> |
42 |
43 |
<Anchor point="TOPLEFT" relativeTo="$parentSubText" relativePoint="BOTTOMLEFT"> |
<Anchor point="TOPLEFT" relativeTo="$parentSubText" relativePoint="BOTTOMLEFT"> |
|
51 |
52 |
</OnLoad> |
</OnLoad> |
52 |
53 |
</Scripts> |
</Scripts> |
53 |
54 |
</CheckButton> |
</CheckButton> |
54 |
|
<!-- |
|
55 |
|
<Button name="ChorusConfDragEnableButton" inherits="UIPanelButtonTemplate" text="Drag Enable"> |
|
|
55 |
|
<!-- Visibility toggle buttons. --> |
|
56 |
|
<Button name="ChorusConfSoloToggleButton" inherits="UIPanelButtonTemplate" text="Toggle Solo"> |
56 |
57 |
<Size> |
<Size> |
57 |
|
<AbsDimension x="96" y="22"/> |
|
|
58 |
|
<AbsDimension x="128" y="22"/> |
58 |
59 |
</Size> |
</Size> |
59 |
60 |
<Anchors> |
<Anchors> |
60 |
|
<Anchor point="TOPLEFT"> |
|
|
61 |
|
<Anchor point="BOTTOMLEFT"> |
61 |
62 |
<Offset> |
<Offset> |
62 |
|
<AbsDimension x="12" y="-36"/> |
|
|
63 |
|
<AbsDimension x="48" y="30"/> |
63 |
64 |
</Offset> |
</Offset> |
64 |
65 |
</Anchor> |
</Anchor> |
65 |
66 |
</Anchors> |
</Anchors> |
|
67 |
|
<Scripts> |
|
68 |
|
<OnClick> |
|
69 |
|
local owner = ChorusSoloFrame |
|
70 |
|
if owner:IsShown() then |
|
71 |
|
owner:Hide() |
|
72 |
|
else |
|
73 |
|
owner:Show() |
|
74 |
|
end |
|
75 |
|
</OnClick> |
|
76 |
|
</Scripts> |
|
77 |
|
</Button> |
|
78 |
|
<Button name="ChorusConfPartyToggleButton" inherits="UIPanelButtonTemplate" text="Toggle Party"> |
|
79 |
|
<Size> |
|
80 |
|
<AbsDimension x="128" y="22"/> |
|
81 |
|
</Size> |
|
82 |
|
<Anchors> |
|
83 |
|
<Anchor point="BOTTOMLEFT"> |
|
84 |
|
<Offset> |
|
85 |
|
<AbsDimension x="48" y="60"/> |
|
86 |
|
</Offset> |
|
87 |
|
</Anchor> |
|
88 |
|
</Anchors> |
|
89 |
|
<Scripts> |
|
90 |
|
<OnClick> |
|
91 |
|
local owner = ChorusPartyFrame |
|
92 |
|
if owner:IsShown() then |
|
93 |
|
owner:Hide() |
|
94 |
|
else |
|
95 |
|
owner:Show() |
|
96 |
|
end |
|
97 |
|
</OnClick> |
|
98 |
|
</Scripts> |
|
99 |
|
</Button> |
|
100 |
|
<Button name="ChorusConfTinyRaidToggleButton" inherits="UIPanelButtonTemplate" text="Toggle Tiny Raid"> |
|
101 |
|
<Size> |
|
102 |
|
<AbsDimension x="128" y="22"/> |
|
103 |
|
</Size> |
|
104 |
|
<Anchors> |
|
105 |
|
<Anchor point="BOTTOMLEFT"> |
|
106 |
|
<Offset> |
|
107 |
|
<AbsDimension x="48" y="90"/> |
|
108 |
|
</Offset> |
|
109 |
|
</Anchor> |
|
110 |
|
</Anchors> |
|
111 |
|
<Scripts> |
|
112 |
|
<OnClick> |
|
113 |
|
local owner = ChorusTinyRaidFrame |
|
114 |
|
if owner:IsShown() then |
|
115 |
|
owner:Hide() |
|
116 |
|
else |
|
117 |
|
owner:Show() |
|
118 |
|
end |
|
119 |
|
</OnClick> |
|
120 |
|
</Scripts> |
|
121 |
|
</Button> |
|
122 |
|
<Button name="ChorusConfSmallRaidToggleButton" inherits="UIPanelButtonTemplate" text="Toggle Small Raid"> |
|
123 |
|
<Size> |
|
124 |
|
<AbsDimension x="128" y="22"/> |
|
125 |
|
</Size> |
|
126 |
|
<Anchors> |
|
127 |
|
<Anchor point="BOTTOMLEFT"> |
|
128 |
|
<Offset> |
|
129 |
|
<AbsDimension x="48" y="120"/> |
|
130 |
|
</Offset> |
|
131 |
|
</Anchor> |
|
132 |
|
</Anchors> |
|
133 |
|
<Scripts> |
|
134 |
|
<OnClick> |
|
135 |
|
local owner = ChorusSmallRaidFrame |
|
136 |
|
if owner:IsShown() then |
|
137 |
|
owner:Hide() |
|
138 |
|
else |
|
139 |
|
owner:Show() |
|
140 |
|
end |
|
141 |
|
</OnClick> |
|
142 |
|
</Scripts> |
|
143 |
|
</Button> |
|
144 |
|
<Button name="ChorusConfLargeRaidToggleButton" inherits="UIPanelButtonTemplate" text="Toggle Large Raid"> |
|
145 |
|
<Size> |
|
146 |
|
<AbsDimension x="128" y="22"/> |
|
147 |
|
</Size> |
|
148 |
|
<Anchors> |
|
149 |
|
<Anchor point="BOTTOMLEFT"> |
|
150 |
|
<Offset> |
|
151 |
|
<AbsDimension x="48" y="150"/> |
|
152 |
|
</Offset> |
|
153 |
|
</Anchor> |
|
154 |
|
</Anchors> |
|
155 |
|
<Scripts> |
|
156 |
|
<OnClick> |
|
157 |
|
local owner = ChorusLargeRaidFrame |
|
158 |
|
if owner:IsShown() then |
|
159 |
|
owner:Hide() |
|
160 |
|
else |
|
161 |
|
owner:Show() |
|
162 |
|
end |
|
163 |
|
</OnClick> |
|
164 |
|
</Scripts> |
66 |
165 |
</Button> |
</Button> |
67 |
|
--> |
|
68 |
166 |
</Frames> |
</Frames> |
69 |
167 |
<Scripts> |
<Scripts> |
70 |
168 |
<OnLoad>Chorus.confFrameMain(self);</OnLoad> |
<OnLoad>Chorus.confFrameMain(self);</OnLoad> |