vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | |||
3 | FixCTGroups v0.2b by Tim Mullin |
||
4 | |||
5 | This mod simply lines up the CT_RaidAssist group frames nicely. |
||
6 | You no longer need to try to align them perfectly manually. It |
||
7 | also allows you to drag a group and drag the rest of the groups |
||
8 | with it. |
||
9 | |||
10 | Use /fixctroups, /fctg or /ctg to bring up the configuratioin frame. |
||
11 | |||
12 | If you wish to be able to drag each group individually again, |
||
13 | check the box next to Default CTRA Style. |
||
14 | |||
15 | A checkbox is provided to hide or show all groups at once as a |
||
16 | conveinance, it functions exactly the same as the Show All Groups |
||
17 | checkbox on the CTRaid tab. |
||
18 | |||
19 | Click the Groups button to bring up the Group Positioning frame. |
||
20 | Here you can drag and drop groups to set up their relative positions. |
||
21 | All vertically and horizontally adjacent groups (not diagonal) will |
||
22 | be linked together. The groups can be dragged in a similar manner to |
||
23 | how one drags raid members into different groups. |
||
24 | |||
25 | You can create smaller groupings of groups that can be seperately |
||
26 | moved by leaving space between the groups. For example, |
||
27 | ........ |
||
28 | ........ |
||
29 | ........ |
||
30 | .12..56. |
||
31 | .34..78. |
||
32 | ........ |
||
33 | ........ |
||
34 | ........ |
||
35 | |||
36 | The Group Positioning frame serves only to define the relationships |
||
37 | between groups. It does not determine the position of the groups |
||
38 | onscreen. If you have an arrangement, it does not matter how many |
||
39 | blank spaces surround it, |
||
40 | ........ |
||
41 | .1234... |
||
42 | .5678... |
||
43 | ........ |
||
44 | ........ |
||
45 | ........ |
||
46 | ........ |
||
47 | |||
48 | appears the same onscreen as |
||
49 | |||
50 | ........ |
||
51 | ........ |
||
52 | ........ |
||
53 | ..1234.. |
||
54 | ..5678.. |
||
55 | ........ |
||
56 | ........ |
||
57 | ........ |
||
58 | |||
59 | Likewise, if you have several smaller groupings of groups, it does |
||
60 | not matter how many blank spaces are between them, the onscreen |
||
61 | position will be the same and controlled by where you drag that |
||
62 | group to. |
||
63 | |||
64 | Note that only rectangular arrangements of groups work at this time. |
||
65 | Some arrangements may produce unexpected results. If anything gets |
||
66 | really screwed up, just click the Defaults button. |
||
67 | |||
68 | Example arrangements that should work: |
||
69 | 1234 |
||
70 | 5678 |
||
71 | |||
72 | 12 56 |
||
73 | 34 78 |
||
74 | |||
75 | 15 |
||
76 | 26 |
||
77 | 37 |
||
78 | 48 |
||
79 | |||
80 | Example arrangements that might not work (where . means an empty slot) |
||
81 | 123 ..5 |
||
82 | 4.. 678 |
||
83 | |||
84 | 12 34 |
||
85 | 5. .6 |
||
86 | 7. .8 |
||
87 | |||
88 | ]] |
||
89 | |||
90 | FIXCTGROUPSVERSION = "0.2b"; |
||
91 | |||
92 | local FixCTGroupsVariablesLoaded = false; |
||
93 | |||
94 | local FixCTGroupsDefaultConfig = { |
||
95 | ctradefault = 0, |
||
96 | linkall = 1, |
||
97 | dx = -3, |
||
98 | dy = -20, |
||
99 | groups = { |
||
100 | [ 1] = 0, [ 2] = 0, [ 3] = 0, [ 4] = 0, [ 5] = 0, [ 6] = 0, [ 7] = 0, [ 8] = 0, |
||
101 | [ 9] = 0, [10] = 0, [11] = 0, [12] = 0, [13] = 0, [14] = 0, [15] = 0, [16] = 0, |
||
102 | [17] = 0, [18] = 0, [19] = 0, [20] = 0, [21] = 0, [22] = 0, [23] = 0, [24] = 0, |
||
103 | [25] = 0, [26] = 0, [27] = 1, [28] = 2, [29] = 3, [30] = 4, [31] = 0, [32] = 0, |
||
104 | [33] = 0, [34] = 0, [35] = 5, [36] = 6, [37] = 7, [38] = 8, [39] = 0, [40] = 0, |
||
105 | [41] = 0, [42] = 0, [43] = 0, [44] = 0, [45] = 0, [46] = 0, [47] = 0, [48] = 0, |
||
106 | [49] = 0, [50] = 0, [51] = 0, [52] = 0, [53] = 0, [54] = 0, [55] = 0, [56] = 0, |
||
107 | [57] = 0, [58] = 0, [59] = 0, [60] = 0, [61] = 0, [62] = 0, [63] = 0, [64] = 0 |
||
108 | } |
||
109 | }; |
||
110 | |||
111 | function FixCTGroupsInit() |
||
112 | local k, v; |
||
113 | |||
114 | -- set up config |
||
115 | if not FixCTGroupsConfig then |
||
116 | FixCTGroupsConfig = { }; |
||
117 | end |
||
118 | |||
119 | for k, v in pairs(FixCTGroupsDefaultConfig) do |
||
120 | if k ~= "groups" and not FixCTGroupsConfig[k] then |
||
121 | FixCTGroupsConfig[k] = v; |
||
122 | end |
||
123 | end |
||
124 | |||
125 | if not FixCTGroupsConfig.groups then |
||
126 | FixCTGroupsConfig.groups = { }; |
||
127 | |||
128 | for k, v in pairs(FixCTGroupsDefaultConfig.groups) do |
||
129 | FixCTGroupsConfig.groups[k] = v; |
||
130 | end |
||
131 | end |
||
132 | |||
133 | -- set up slash command |
||
134 | SlashCmdList["FIXCTGROUPS"] = function(msg) |
||
135 | DEFAULT_CHAT_FRAME:AddMessage("FixCTGroups v"..FIXCTGROUPSVERSION, 1, 1, 1); |
||
136 | FixCTGroupsConfigFrame:Show(); |
||
137 | end |
||
138 | SLASH_FIXCTGROUPS1 = "/fixctgroups"; |
||
139 | SLASH_FIXCTGROUPS2 = "/fctg"; |
||
140 | SLASH_FIXCTGROUPS3 = "/ctg"; |
||
141 | |||
142 | FixCTGroupsConfigChanged(); |
||
143 | |||
144 | FixCTGroupsVariablesLoaded = true; |
||
145 | end |
||
146 | |||
147 | function FixCTGroupsClearPoints() |
||
148 | local f; |
||
149 | |||
150 | for i = 2, 8 do |
||
151 | f = getglobal("CT_RAGroup"..i); |
||
152 | f:ClearAllPoints(); |
||
153 | end |
||
154 | end |
||
155 | |||
156 | function FixCTGroupsArrangeGroups() |
||
157 | local i, group, left, up, right, down; |
||
158 | local c = FixCTGroupsConfig; |
||
159 | local g = c.groups; |
||
160 | local p = "FixCTGroups"; |
||
161 | |||
162 | -- reset then fix it |
||
163 | FixCTGroupsCTRADefault(); |
||
164 | |||
165 | for i = 1, 64 do |
||
166 | if g[i] ~= 0 then |
||
167 | --ezheal_msg("i: "..i.."; group: "..g[i]); |
||
168 | group = getglobal("CT_RAGroup"..g[i]); |
||
169 | |||
170 | -- is there a group to the left of this one? |
||
171 | if (i > 1) and (math.mod(i - 1, 8) ~= 0) and (g[i - 1] ~= 0) then |
||
172 | left = getglobal("CT_RAGroup"..g[i - 1]); |
||
173 | else |
||
174 | left = nil; |
||
175 | end |
||
176 | |||
177 | -- is there a group above this one? |
||
178 | if (i > 8) and (g[i - 8] ~= 0) then |
||
179 | up = getglobal("CT_RAGroup"..g[i - 8]); |
||
180 | else |
||
181 | up = nil; |
||
182 | end |
||
183 | |||
184 | --[[ if i < 64 and math.mod(i, 8) ~= 0 and g[i + 1] ~= 0 then |
||
185 | right = getglobal("CT_RAGroup"..g[i + 1]); |
||
186 | else |
||
187 | right = nil; |
||
188 | end |
||
189 | |||
190 | if i < 57 and g[i + 8] ~= 0 then |
||
191 | down = getglobal("CT_RAGroup"..g[i + 8]); |
||
192 | else |
||
193 | down = nil; |
||
194 | end |
||
195 | ]] |
||
196 | if left or up --[[or right or down]] then |
||
197 | group:ClearAllPoints(); |
||
198 | |||
199 | if left then |
||
200 | --ezheal_msg(group:GetName().."'s left is "..left:GetName()); |
||
201 | group:SetPoint("TOPLEFT", left, "TOPRIGHT", c.dx, 0); |
||
202 | end |
||
203 | |||
204 | if up then |
||
205 | --ezheal_msg(group:GetName().."'s up is "..up:GetName()); |
||
206 | group:SetPoint("TOPRIGHT", up, "BOTTOMRIGHT", 0, 0-c.dy); |
||
207 | end |
||
208 | |||
209 | --[[ if right then |
||
210 | group:SetPoint("BOTTOMRIGHT", right, "BOTTOMLEFT", c.dx, 0); |
||
211 | end |
||
212 | |||
213 | if down then |
||
214 | group:SetPoint("BOTTOMLEFT", down, "TOPLEFT", 0, 0-c.dy); |
||
215 | end]] |
||
216 | end |
||
217 | |||
218 | end |
||
219 | end |
||
220 | end |
||
221 | |||
222 | function FixCTGroupsXLink(f, g) |
||
223 | f:ClearAllPoints(); |
||
224 | f:SetPoint("TOPLEFT", g, "TOPRIGHT", FixCTGroupsConfig.dx, 0); |
||
225 | end |
||
226 | |||
227 | function FixCTGroupsYLink(f, g) |
||
228 | f:ClearAllPoints(); |
||
229 | f:SetPoint("TOPLEFT", g, "BOTTOMLEFT", 0, 0-FixCTGroupsConfig.dy); |
||
230 | end |
||
231 | |||
232 | function FixCTGroupsConfigFrameOnShow() |
||
233 | local f = FixCTGroupsConfigFrame; |
||
234 | local c = FixCTGroupsConfig; |
||
235 | |||
236 | if not FixCTGroupsVariablesLoaded then |
||
237 | f:Hide(); |
||
238 | return; |
||
239 | end |
||
240 | |||
241 | getglobal(f:GetName().."SpacingX"):SetValue(c.dx); |
||
242 | getglobal(f:GetName().."SpacingY"):SetValue(c.dy); |
||
243 | |||
244 | getglobal(f:GetName().."CTRADefault"):SetChecked(c.ctradefault); |
||
245 | --getglobal(f:GetName().."LinkAllGroups"):SetChecked(c.linkall); |
||
246 | getglobal(f:GetName().."ShowGroups"):SetChecked(CT_RACheckAllGroups:GetChecked()); |
||
247 | end |
||
248 | |||
249 | function FixCTGroupsSetDefaultConfig() |
||
250 | local k, v; |
||
251 | |||
252 | if not FixCTGroupsVariablesLoaded then |
||
253 | return; |
||
254 | end |
||
255 | |||
256 | for k, v in pairs(FixCTGroupsDefaultConfig) do |
||
257 | if k ~= "groups" then |
||
258 | FixCTGroupsConfig[k] = v; |
||
259 | end |
||
260 | end |
||
261 | |||
262 | FixCTGroupsConfig.groups = nil; |
||
263 | FixCTGroupsConfig.groups = { }; |
||
264 | |||
265 | local i; |
||
266 | |||
267 | for k, v in pairs(FixCTGroupsDefaultConfig.groups) do |
||
268 | FixCTGroupsConfig.groups[k] = v; |
||
269 | end |
||
270 | |||
271 | FixCTGroupsConfigChanged(); |
||
272 | end |
||
273 | |||
274 | function FixCTGroupsConfigFrameOptionOnClick() |
||
275 | local c = FixCTGroupsConfig; |
||
276 | |||
277 | if not FixCTGroupsVariablesLoaded then |
||
278 | this:GetParent():Hide(); |
||
279 | return; |
||
280 | end |
||
281 | |||
282 | local name = this:GetName(); |
||
283 | local parent = this:GetParent():GetName(); |
||
284 | |||
285 | if name == parent.."SpacingX" then |
||
286 | c.dx = this:GetValue(); |
||
287 | elseif name == parent.."SpacingY" then |
||
288 | c.dy = this:GetValue(); |
||
289 | elseif name == parent.."CTRADefault" then |
||
290 | c.ctradefault = this:GetChecked(); |
||
291 | elseif name == parent.."LinkAllGroups" then |
||
292 | c.linkall = this:GetChecked(); |
||
293 | elseif name == parent.."ShowGroups" then |
||
294 | CT_RACheckAllGroups:SetChecked(getglobal(parent.."ShowGroups"):GetChecked()); |
||
295 | CT_RA_CheckAllGroups(); |
||
296 | end |
||
297 | |||
298 | FixCTGroupsConfigChanged(); |
||
299 | end |
||
300 | |||
301 | function FixCTGroupsConfigChanged() |
||
302 | local fn = nil; |
||
303 | local c = FixCTGroupsConfig; |
||
304 | |||
305 | FixCTGroupsConfigFrameOnShow(); |
||
306 | |||
307 | if c.ctradefault == 1 then |
||
308 | FixCTGroupsCTRADefault(); |
||
309 | else |
||
310 | FixCTGroupsArrangeGroups(); |
||
311 | end |
||
312 | end |
||
313 | |||
314 | -- mimic what happens when ctraid loads to make each |
||
315 | -- group draggable |
||
316 | function FixCTGroupsCTRADefault() |
||
317 | local f, g; |
||
318 | |||
319 | for i = 1, 8 do |
||
320 | f = getglobal("CT_RAGroup"..i); |
||
321 | g = getglobal("CT_RAGroupDrag"..i); |
||
322 | |||
323 | CT_RA_LinkDrag(f, g, "TOP", "TOP", 0, 10); |
||
324 | end |
||
325 | end |
||
326 | |||
327 | |||
328 | ------------------------- |
||
329 | -- functions for the group cells frame |
||
330 | ------------------------- |
||
331 | |||
332 | local FIXCTGROUPS_MOVING_GROUP = nil; |
||
333 | local FIXCTGROUPS_TARGET_SLOT = nil; |
||
334 | |||
335 | function FixCTGroupsCellsFrameOnShow() |
||
336 | local i, slot, button; |
||
337 | local p = "FixCTGroupsCellsFrameCell"; |
||
338 | |||
339 | for i = 1, 64 do |
||
340 | slot = getglobal(p.."Slot"..i); |
||
341 | slot.button = nil; |
||
342 | |||
343 | if FixCTGroupsConfig.groups[i] and FixCTGroupsConfig.groups[i] ~= 0 then |
||
344 | button = getglobal(p..FixCTGroupsConfig.groups[i]); |
||
345 | |||
346 | button.slot = slot; |
||
347 | slot.button = button; |
||
348 | |||
349 | button:ClearAllPoints(); |
||
350 | button:SetPoint("TOPLEFT", slot, "TOPLEFT", 0, 0); |
||
351 | end |
||
352 | end |
||
353 | end |
||
354 | |||
355 | function FixCTGroupsCellsFrameOnHide() |
||
356 | local i, f; |
||
357 | |||
358 | for i = 1, 64 do |
||
359 | f = getglobal("FixCTGroupsCellsFrameCellSlot"..i); |
||
360 | |||
361 | if f.button then |
||
362 | FixCTGroupsConfig.groups[i] = tonumber(getglobal(f.button:GetName().."Label"):GetText()); |
||
363 | else |
||
364 | FixCTGroupsConfig.groups[i] = 0; |
||
365 | end |
||
366 | end |
||
367 | |||
368 | FixCTGroupsConfigChanged(); |
||
369 | end |
||
370 | |||
371 | function FixCTGroupsCellOnDragStart() |
||
372 | local cursorX, cursorY = GetCursorPosition(); |
||
373 | this:SetBackdropColor(this.hover.r, this.hover.g, this.hover.b); |
||
374 | this:SetFrameLevel(this:GetFrameLevel() + 10); |
||
375 | this:ClearAllPoints(); |
||
376 | this:SetPoint("CENTER", nil, "BOTTOMLEFT", cursorX*GetScreenWidthScale(), cursorY*GetScreenHeightScale()); |
||
377 | this:StartMoving(); |
||
378 | FIXCTGROUPS_MOVING_GROUP = this; |
||
379 | end |
||
380 | |||
381 | function FixCTGroupsCellOnDragStop(raidButton) |
||
382 | if ( not raidButton ) then |
||
383 | raidButton = this; |
||
384 | end |
||
385 | |||
386 | raidButton:StopMovingOrSizing(); |
||
387 | raidButton:SetBackdropColor(raidButton.bg.r, raidButton.bg.g, raidButton.bg.b); |
||
388 | raidButton:SetFrameLevel(raidButton:GetFrameLevel() - 10); |
||
389 | FIXCTGROUPS_MOVING_GROUP = nil; |
||
390 | |||
391 | if ( FIXCTGROUPS_TARGET_SLOT and FIXCTGROUPS_TARGET_SLOT:GetID() ~= raidButton.slot:GetID() ) then |
||
392 | if (FIXCTGROUPS_TARGET_SLOT.button) then |
||
393 | --ezheal_msg("currently a button there"); |
||
394 | local oldButton = FIXCTGROUPS_TARGET_SLOT.button; |
||
395 | local newSlot = FIXCTGROUPS_TARGET_SLOT; |
||
396 | local oldSlot = raidButton.slot; |
||
397 | |||
398 | oldButton:SetPoint("TOPLEFT", raidButton.slot, "TOPLEFT", 0, 0); |
||
399 | oldButton:SetBackdropColor(oldButton.bg.r, oldButton.bg.g, oldButton.bg.b); |
||
400 | oldButton.slot = oldSlot; |
||
401 | oldSlot.button = oldButton; |
||
402 | |||
403 | raidButton:SetPoint("TOPLEFT", newSlot, "TOPLEFT", 0, 0); |
||
404 | raidButton.slot = newSlot; |
||
405 | newSlot.button = raidButton; |
||
406 | else |
||
407 | --ezheal_msg("no button there"); |
||
408 | local newSlot = FIXCTGROUPS_TARGET_SLOT; |
||
409 | local oldSlot = raidButton.slot; |
||
410 | |||
411 | newSlot:UnlockHighlight(); |
||
412 | |||
413 | raidButton:SetPoint("TOPLEFT", newSlot, "TOPLEFT", 0, 0); |
||
414 | oldSlot.button = nil; |
||
415 | |||
416 | newSlot.button = raidButton; |
||
417 | |||
418 | raidButton.slot = newSlot; |
||
419 | end |
||
420 | else |
||
421 | if ( FIXCTGROUPS_TARGET_SLOT ) then |
||
422 | -- dragged to same slot it was already on |
||
423 | --ezheal_msg("same slot as before"); |
||
424 | local slot = FIXCTGROUPS_TARGET_SLOT; |
||
425 | slot:SetBackdropColor(slot.bg.r, slot.bg.g, slot.bg.b); |
||
426 | slot:UnlockHighlight(); |
||
427 | end |
||
428 | raidButton:SetPoint("TOPLEFT", raidButton.slot, "TOPLEFT", 0, 0); |
||
429 | end |
||
430 | end |
||
431 | |||
432 | function FixCTGroupsCellsFrameOnUpdate(elapsed) |
||
433 | if ( FIXCTGROUPS_MOVING_GROUP ) then |
||
434 | local button, slot; |
||
435 | FIXCTGROUPS_TARGET_SLOT = nil; |
||
436 | |||
437 | for i = 1, 64 do |
||
438 | slot = getglobal("FixCTGroupsCellsFrameCellSlot"..i); |
||
439 | button = slot.button; |
||
440 | |||
441 | if ( MouseIsOver(slot) ) then |
||
442 | FIXCTGROUPS_TARGET_SLOT = slot; |
||
443 | |||
444 | slot:SetBackdropColor(slot.hover.r, slot.hover.g, slot.hover.b); |
||
445 | slot:LockHighlight(); |
||
446 | |||
447 | if button and button ~= FIXCTGROUPS_MOVING_GROUP then |
||
448 | button:SetBackdropColor(slot.hover.r, slot.hover.g, slot.hover.b); |
||
449 | end |
||
450 | else |
||
451 | slot:SetBackdropColor(slot.bg.r, slot.bg.g, slot.bg.b); |
||
452 | slot:UnlockHighlight(); |
||
453 | |||
454 | if button and button ~= FIXCTGROUPS_MOVING_GROUP then |
||
455 | button:SetBackdropColor(button.bg.r, button.bg.g, button.bg.b); |
||
456 | end |
||
457 | end |
||
458 | end |
||
459 | end |
||
460 | end |