vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 CT_AddMovable("CT_HotbarLeft_Drag", CT_BARMOD_MOVABLE_LEFTHOTBAR, "BOTTOM", "BOTTOM", "UIParent", -490, 98, function(status)
2 if ( status and CT_HotbarLeft:IsVisible() ) then
3 CT_HotbarLeft_Drag:Show()
4 else
5 CT_HotbarLeft_Drag:Hide();
6 end
7 end);
8  
9 CT_AddMovable("CT_HotbarRight_Drag", CT_BARMOD_MOVABLE_RIGHTHOTBAR, "BOTTOM", "BOTTOM", "UIParent", 14, 98, function(status)
10 if ( status and CT_HotbarRight:IsVisible() ) then
11 CT_HotbarRight_Drag:Show()
12 else
13 CT_HotbarRight_Drag:Hide();
14 end
15 end);
16  
17 CT_AddMovable("CT_SidebarLeft_Drag", CT_BARMOD_MOVABLE_LEFTSIDEBAR, "TOPLEFT", "TOPLEFT", "UIParent", 15, -86, function(status)
18 if ( status and CT_SidebarFrame:IsVisible() ) then
19 CT_SidebarLeft_Drag:Show()
20 else
21 CT_SidebarLeft_Drag:Hide();
22 end
23 end);
24  
25 CT_AddMovable("CT_SidebarRight_Drag", CT_BARMOD_MOVABLE_RIGHTSIDEBAR, "TOPRIGHT", "TOPRIGHT", "UIParent", -15, -148, function(status)
26 if ( status and CT_SidebarFrame2:IsVisible() ) then
27 CT_SidebarRight_Drag:Show()
28 else
29 CT_SidebarRight_Drag:Hide();
30 end
31 end);
32  
33 CT_AddMovable("CT_HotbarTop_Drag", CT_BARMOD_MOVABLE_TOPHOTBAR, "BOTTOM", "BOTTOM", "UIParent", -28, 140, function(status)
34 if ( status and CT_HotbarTop:IsVisible() ) then
35 CT_HotbarTop_Drag:Show()
36 else
37 CT_HotbarTop_Drag:Hide();
38 end
39 end);
40  
41 CT_AddMovable("CT_PetBar_Drag", CT_BARMOD_MOVABLE_PETBAR, "BOTTOMLEFT", "BOTTOM", "UIParent", -453, 82, function(status)
42 if ( status and PetActionBarFrame:IsVisible() ) then
43 CT_PetBar_Drag:Show()
44 else
45 CT_PetBar_Drag:Hide();
46 end
47 end, function()
48 if ( CT_HotbarLeft:IsVisible() ) then
49 local x = CT_PetBar_Drag:GetLeft()-(UIParent:GetRight()/2);
50 local y = CT_PetBar_Drag:GetBottom()+40;
51 CT_PetBar_Drag:ClearAllPoints();
52 CT_PetBar_Drag:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOM", x, y);
53 end
54 end);
55  
56 CT_AddMovable("CT_BABar_Drag", CT_BARMOD_MOVABLE_CLASSBAR, "BOTTOMLEFT", "BOTTOM", "UIParent", -461, 88, function(status)
57 if ( status and ShapeshiftBarFrame:IsVisible() ) then
58 CT_BABar_Drag:Show()
59 else
60 CT_BABar_Drag:Hide();
61 end
62 end, function()
63 if ( CT_HotbarLeft:IsVisible() ) then
64 local x = CT_BABar_Drag:GetLeft()-(UIParent:GetRight()/2);
65 local y = CT_BABar_Drag:GetBottom()+40;
66 CT_BABar_Drag:ClearAllPoints();
67 CT_BABar_Drag:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOM", x, y);
68 end
69 end);
70  
71 local CT_Hotcast = 0;
72 CT_SelfCast = 0;
73 CT_CDCount = 0;
74 CT_FadeColor = { ["r"] = 1.0, ["g"] = 1.0, ["b"] = 1.0 };
75 CT_ActionBar_LockedPage = 1;
76 local CT_NextSelfCast;
77 CT_Hotbar = { };
78 CT_SidebarAxis = {
79 [1] = 2,
80 [2] = 2,
81 [3] = 1,
82 [4] = 1,
83 [5] = 2
84 };
85  
86 CT_LSidebar_Buttons = 12;
87 CT_RSidebar_Buttons = 12;
88 CT_Alt_Hotbar = 0;
89 CT_Hotbars_Locked = false;
90 CT_HotbarButtons_Locked = false;
91 CT_ShowGrid = 1;
92  
93 function CT_ButtonLock_Update(modid)
94 local val = CT_Mods[modid];
95 if ( val["modStatus"] == "off" ) then
96 CT_HotbarButtons_Locked = false;
97 else
98 CT_HotbarButtons_Locked = true;
99 end
100 end
101  
102 function CT_Sidebar_ButtonInUse(btn)
103 if ( ( strsub(btn:GetName(), 1, 3) == "CT3" and btn:GetID() <= CT_LSidebar_Buttons ) or ( strsub( btn:GetName(), 1, 3) == "CT4" and btn:GetID() <= CT_RSidebar_Buttons ) ) then
104 return 1;
105 else
106 return nil;
107 end
108 end
109  
110 function CT_HotbarcastUp(id)
111 CT_Hotbar[id] = nil;
112 end
113  
114 function CT_HotbarcastDown(id)
115 CT_Hotbar[id] = 1;
116 end
117  
118 function CT_ActionButton_Update()
119 -- Special case code for bonus bar buttons
120 -- Prevents the button from updating if the bonusbar is still in an animation transition
121 if ( this.isBonus and this.inTransition ) then
122 CT_ActionButton_UpdateUsable();
123 CT_ActionButton_UpdateCooldown();
124 return;
125 end
126  
127 local icon = getglobal(this:GetName().."Icon");
128 local buttonCooldown = getglobal(this:GetName().."Cooldown");
129 local texture = GetActionTexture(CT_ActionButton_GetPagedID(this));
130 if ( texture ) then
131 icon:SetTexture(texture);
132 icon:Show();
133 this.rangeTimer = -1;
134 this:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2");
135 -- Save texture if the button is a bonus button, will be needed later
136 if ( this.isBonus ) then
137 this.texture = texture;
138 end
139 else
140 icon:Hide();
141 buttonCooldown:Hide();
142 this.rangeTimer = nil;
143 this:SetNormalTexture("Interface\\Buttons\\UI-Quickslot");
144 getglobal(this:GetName().."HotKey"):SetVertexColor(0.6, 0.6, 0.6);
145 end
146 CT_ActionButton_UpdateCount();
147 if ( HasAction(CT_ActionButton_GetPagedID(this)) ) then
148 this:RegisterEvent("ACTIONBAR_UPDATE_STATE");
149 this:RegisterEvent("ACTIONBAR_UPDATE_USABLE");
150 this:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN");
151 this:RegisterEvent("UPDATE_INVENTORY_ALERTS");
152 this:RegisterEvent("PLAYER_AURAS_CHANGED");
153 this:RegisterEvent("PLAYER_TARGET_CHANGED");
154 this:RegisterEvent("UNIT_INVENTORY_CHANGED");
155 this:RegisterEvent("CRAFT_SHOW");
156 this:RegisterEvent("CRAFT_CLOSE");
157 this:RegisterEvent("TRADE_SKILL_SHOW");
158 this:RegisterEvent("TRADE_SKILL_CLOSE");
159 this:RegisterEvent("PLAYER_ENTER_COMBAT");
160 this:RegisterEvent("PLAYER_LEAVE_COMBAT");
161 this:RegisterEvent("START_AUTOREPEAT_SPELL");
162 this:RegisterEvent("STOP_AUTOREPEAT_SPELL");
163  
164 this:Show();
165 CT_ActionButton_UpdateState();
166 CT_ActionButton_UpdateUsable();
167 CT_ActionButton_UpdateCooldown();
168 CT_ActionButton_UpdateFlash();
169 else
170 this:UnregisterEvent("ACTIONBAR_UPDATE_STATE");
171 this:UnregisterEvent("ACTIONBAR_UPDATE_USABLE");
172 this:UnregisterEvent("ACTIONBAR_UPDATE_COOLDOWN");
173 this:UnregisterEvent("UPDATE_INVENTORY_ALERTS");
174 this:UnregisterEvent("PLAYER_AURAS_CHANGED");
175 this:UnregisterEvent("PLAYER_TARGET_CHANGED");
176 this:UnregisterEvent("UNIT_INVENTORY_CHANGED");
177 this:UnregisterEvent("CRAFT_SHOW");
178 this:UnregisterEvent("CRAFT_CLOSE");
179 this:UnregisterEvent("TRADE_SKILL_SHOW");
180 this:UnregisterEvent("TRADE_SKILL_CLOSE");
181 this:UnregisterEvent("PLAYER_ENTER_COMBAT");
182 this:UnregisterEvent("PLAYER_LEAVE_COMBAT");
183 this:UnregisterEvent("START_AUTOREPEAT_SPELL");
184 this:UnregisterEvent("STOP_AUTOREPEAT_SPELL");
185  
186 if ( this.showgrid == 0 ) then
187 this:Hide();
188 else
189 buttonCooldown:Hide();
190 end
191 end
192  
193 -- Add a green border if button is an equipped item
194 local border = getglobal(this:GetName().."Border");
195 if ( IsEquippedAction(CT_ActionButton_GetPagedID(this)) ) then
196 border:SetVertexColor(0, 1.0, 0, 0.35);
197 border:Show();
198 else
199 border:Hide();
200 end
201  
202 if ( GameTooltip:IsOwned(this) ) then
203 CT_ActionButton_SetTooltip();
204 else
205 this.updateTooltip = nil;
206 end
207  
208 -- Update Macro Text
209 local macroName = getglobal(this:GetName().."Name");
210 macroName:SetText(GetActionText(CT_ActionButton_GetPagedID(this)));
211 end
212  
213 function CT_ActionButton_UpdateFlash()
214 local pagedID = CT_ActionButton_GetPagedID(this);
215 if ( (IsAttackAction(pagedID) and IsCurrentAction(pagedID)) or IsAutoRepeatAction(pagedID) ) then
216 CT_ActionButton_StartFlash();
217 else
218 CT_ActionButton_StopFlash();
219 end
220 end
221  
222 function CT_ActionButton_HideGrid(button)
223 local btn;
224 if ( button ) then
225 btn = button;
226 else
227 btn = this;
228 end
229 local isException;
230 if (
231 ( GetBonusBarOffset() > 0 and strsub(btn:GetName(), 1, 12) ~= "ActionButton" ) or
232 ( strsub(btn:GetName(), 1, 12) == "MultiBarLeft" and not SHOW_MULTI_ACTIONBAR_4 ) or
233 ( strsub(btn:GetName(), 1, 13) == "MultiBarRight" and not SHOW_MULTI_ACTIONBAR_3 ) or
234 ( strsub(btn:GetName(), 1, 18) == "MultiBarBottomLeft" and not SHOW_MULTI_ACTIONBAR_1 ) or
235 ( strsub(btn:GetName(), 1, 19) == "MultiBarBottomRight" and not SHOW_MULTI_ACTIONBAR_2 ) or
236 ( GetBonusBarOffset() == 0 and strsub(btn:GetName(), 1, 17) ~= "BonusActionButton" )
237 ) then
238 isException = 1;
239 end
240 if ( CT_ShowGrid and isException ) then return; end
241 btn.showgrid = 0;
242 if ( not HasAction(CT_ActionButton_GetPagedID(btn)) or not isException ) then
243 btn:Hide();
244 end
245 end
246  
247 function CT_ActionButton_OnLoad()
248 if ( ( ( strsub( this:GetName(), 1, 3) == "CT3" and this:GetID() <= CT_LSidebar_Buttons ) or ( strsub( this:GetName(), 1, 3) == "CT4" and this:GetID() <= CT_RSidebar_Buttons ) ) and ( strsub( this:GetName(), 1, 3 ) == "CT3" or strsub( this:GetName(), 1, 3 ) == "CT4" ) ) then
249 this:Hide();
250 else
251 this:Show();
252 end
253 this.flashing = 0;
254 this.flashtime = 0;
255 ActionButton_Update();
256 this:RegisterForDrag("LeftButton", "RightButton");
257 this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
258 this:RegisterEvent("ACTIONBAR_SHOWGRID");
259 this:RegisterEvent("ACTIONBAR_HIDEGRID");
260 this:RegisterEvent("ACTIONBAR_PAGE_CHANGED");
261 this:RegisterEvent("ACTIONBAR_SLOT_CHANGED");
262 this:RegisterEvent("ACTIONBAR_UPDATE_STATE");
263 this:RegisterEvent("ACTIONBAR_UPDATE_USABLE");
264 this:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN");
265 this:RegisterEvent("PLAYER_AURAS_CHANGED");
266 this:RegisterEvent("PLAYER_TARGET_CHANGED");
267 this:RegisterEvent("UNIT_AURASTATE");
268 this:RegisterEvent("UNIT_INVENTORY_CHANGED");
269 this:RegisterEvent("CRAFT_SHOW");
270 this:RegisterEvent("CRAFT_CLOSE");
271 this:RegisterEvent("TRADE_SKILL_SHOW");
272 this:RegisterEvent("TRADE_SKILL_CLOSE");
273 this:RegisterEvent("UNIT_HEALTH");
274 this:RegisterEvent("UNIT_MANA");
275 this:RegisterEvent("UNIT_RAGE");
276 this:RegisterEvent("UNIT_FOCUS");
277 this:RegisterEvent("UNIT_ENERGY");
278 this:RegisterEvent("UPDATE_BONUS_ACTIONBAR");
279 this:RegisterEvent("PLAYER_ENTER_COMBAT");
280 this:RegisterEvent("PLAYER_LEAVE_COMBAT");
281 this:RegisterEvent("PLAYER_COMBO_POINTS");
282 this:RegisterEvent("UPDATE_BINDINGS");
283 this:RegisterEvent("START_AUTOREPEAT_SPELL");
284 this:RegisterEvent("STOP_AUTOREPEAT_SPELL");
285 CT_ActionButton_UpdateHotkeys();
286 this.showgrid = 2;
287 end
288  
289 function CT_ActionButton_UpdateHotkeys(actionbtn)
290 if ( not actionbtn ) then actionbtn = this; end
291 if ( CT_ShowHotkeys == -1 ) then
292 getglobal(actionbtn:GetName() .. "HotKey"):Hide();
293 return;
294 end
295 local hotkey = getglobal(actionbtn:GetName().."HotKey");
296 hotkey:Show();
297 if ( not CT_ShowHotkeys ) then
298 local key = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=" };
299 hotkey:SetText(key[actionbtn:GetID()]);
300 return;
301 end
302 local prefix;
303 if ( strsub(actionbtn:GetName(), 0, 3) == "CT_" ) then
304 prefix = "CT_HOTBAR1";
305 elseif ( strsub(actionbtn:GetName(), 0, 2) == "CT" ) then
306 prefix = "CT_HOTBAR" .. strsub(actionbtn:GetName(), 3, 3);
307 else
308 prefix = "ACTION";
309 end
310  
311 local action = prefix .. "BUTTON"..actionbtn:GetID();
312 local text = GetBindingText(GetBindingKey(action), "KEY_");
313  
314 text = string.gsub(text, "CTRL%-", "C-");
315 text = string.gsub(text, "ALT%-", "A-");
316 text = string.gsub(text, "SHIFT%-", "S-");
317 text = string.gsub(text, "Num Pad", "NP");
318 text = string.gsub(text, "Backspace", "Bksp");
319 text = string.gsub(text, "Spacebar", "Space");
320 text = string.gsub(text, "Page", "Pg");
321 text = string.gsub(text, "Down", "Dn");
322 text = string.gsub(text, "Arrow", "");
323 text = string.gsub(text, "Insert", "Ins");
324 text = string.gsub(text, "Delete", "Del");
325  
326 hotkey:SetText(text);
327 end
328  
329 function CT_ActionButton_UpdateState()
330 if ( IsCurrentAction(CT_ActionButton_GetPagedID(this)) or IsAutoRepeatAction(CT_ActionButton_GetPagedID(this)) ) then
331 this:SetChecked(1);
332 else
333 this:SetChecked(0);
334 end
335 end
336  
337 function CT_ActionButton_UpdateUsable()
338 local icon = getglobal(this:GetName().."Icon");
339 local normalTexture = getglobal(this:GetName().."NormalTexture");
340 local isUsable, notEnoughMana = IsUsableAction(CT_ActionButton_GetPagedID(this));
341 if ( isUsable ) then
342 if ( this.inRange and this.inRange == 0 ) then
343 icon:SetVertexColor(CT_FadeColor.r, CT_FadeColor.g, CT_FadeColor.b);
344 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(CT_FadeColor.r, CT_FadeColor.g, CT_FadeColor.b); end
345 else
346 icon:SetVertexColor(1.0, 1.0, 1.0);
347 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(1.0, 1.0, 1.0); end
348 end
349 elseif ( notEnoughMana ) then
350 icon:SetVertexColor(0.5, 0.5, 1.0);
351 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(0.5, 0.5, 1.0); end
352 else
353 icon:SetVertexColor(0.4, 0.4, 0.4);
354 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(0.4, 0.4, 0.4); end
355 end
356 end
357  
358 function CT_ActionButton_UpdateCount()
359 local text = getglobal(this:GetName().."Count");
360 local count = GetActionCount(CT_ActionButton_GetPagedID(this));
361 if ( count > 1 ) then
362 text:SetText(count);
363 else
364 text:SetText("");
365 end
366 end
367  
368 function CT_ActionButton_UpdateCooldown()
369 local cooldown = getglobal(this:GetName().."Cooldown");
370 local start, duration, enable = GetActionCooldown(CT_ActionButton_GetPagedID(this));
371 CooldownFrame_SetTimer(cooldown, start, duration, enable);
372 end
373  
374 function CT_ActionButton_OnEvent(event)
375 if ( event == "PLAYER_LEAVING_WORLD" ) then
376 this.disableEvents = true;
377 elseif ( event == "PLAYER_ENTERING_WORLD" ) then
378 this.disableEvents = nil;
379 elseif ( this.disableEvents ) then
380 return;
381 end
382 if ( event == "ACTIONBAR_SLOT_CHANGED" ) then
383 if ( arg1 == -1 or arg1 == CT_ActionButton_GetPagedID(this) ) then
384 CT_ActionButton_Update();
385 end
386 return;
387 end
388 if ( event == "ACTIONBAR_PAGE_CHANGED" or event == "PLAYER_AURAS_CHANGED" or event == "UPDATE_BONUS_ACTIONBAR" ) then
389 CT_BarMod_UpdateCooldownCount(this);
390 CT_ActionButton_Update();
391 CT_ActionButton_UpdateState();
392 return;
393 end
394 if ( event == "ACTIONBAR_SHOWGRID" ) then
395 CT_ActionButton_ShowGrid();
396 return;
397 end
398 if ( event == "ACTIONBAR_HIDEGRID" ) then
399 CT_ActionButton_HideGrid();
400 return;
401 end
402 if ( event == "UPDATE_BINDINGS" ) then
403 CT_ActionButton_UpdateHotkeys();
404 end
405  
406 -- All event handlers below this line MUST only be valid when the button is visible
407 if ( not this:IsVisible() ) then
408 return;
409 end
410  
411 if ( event == "PLAYER_TARGET_CHANGED" ) then
412 CT_ActionButton_UpdateUsable();
413 return;
414 end
415 if ( event == "UNIT_AURASTATE" ) then
416 if ( arg1 == "player" or arg1 == "target" ) then
417 CT_ActionButton_UpdateUsable();
418 end
419 return;
420 end
421 if ( event == "UNIT_INVENTORY_CHANGED" ) then
422 if ( arg1 == "player" ) then
423 CT_ActionButton_Update();
424 end
425 return;
426 end
427 if ( event == "ACTIONBAR_UPDATE_STATE" ) then
428 CT_ActionButton_UpdateState();
429 return;
430 end
431 if ( event == "ACTIONBAR_UPDATE_USABLE" ) then
432 CT_ActionButton_UpdateUsable();
433 return;
434 end
435 if ( event == "ACTIONBAR_UPDATE_COOLDOWN" ) then
436 CT_ActionButton_UpdateCooldown();
437 return;
438 end
439 if ( event == "CRAFT_SHOW" or event == "CRAFT_CLOSE" or event == "TRADE_SKILL_SHOW" or event == "TRADE_SKILL_CLOSE" ) then
440 CT_ActionButton_UpdateState();
441 return;
442 end
443 if ( arg1 == "player" and (event == "UNIT_HEALTH" or event == "UNIT_MANA" or event == "UNIT_RAGE" or event == "UNIT_FOCUS" or event == "UNIT_ENERGY") ) then
444 CT_ActionButton_UpdateUsable();
445 return;
446 end
447 if ( event == "PLAYER_ENTER_COMBAT" ) then
448 IN_ATTACK_MODE = 1;
449 if ( IsAttackAction(CT_ActionButton_GetPagedID(this)) ) then
450 CT_ActionButton_StartFlash();
451 end
452 return;
453 end
454 if ( event == "PLAYER_LEAVE_COMBAT" ) then
455 IN_ATTACK_MODE = 0;
456 if ( IsAttackAction(CT_ActionButton_GetPagedID(this)) ) then
457 CT_ActionButton_StopFlash();
458 end
459 return;
460 end
461 if ( event == "PLAYER_COMBO_POINTS" ) then
462 CT_ActionButton_UpdateUsable();
463 return;
464 end
465 if ( event == "START_AUTOREPEAT_SPELL" ) then
466 IN_AUTOREPEAT_MODE = 1;
467 if ( IsAutoRepeatAction(CT_ActionButton_GetPagedID(this)) ) then
468 CT_ActionButton_StartFlash();
469 end
470 return;
471 end
472 if ( event == "STOP_AUTOREPEAT_SPELL" ) then
473 IN_AUTOREPEAT_MODE = nil;
474 if ( ActionButton_IsFlashing() and not IsAttackAction(CT_ActionButton_GetPagedID(this)) ) then
475 CT_ActionButton_StopFlash();
476 end
477 return;
478 end
479 end
480  
481 function CT_ActionButton_StartFlash()
482 this.flashing = 1;
483 this.flashtime = 0;
484 CT_ActionButton_UpdateState();
485 end
486  
487 function CT_ActionButton_StopFlash()
488 this.flashing = 0;
489 getglobal(this:GetName().."Flash"):Hide();
490 CT_ActionButton_UpdateState();
491 end
492  
493 function CT_ActionButton_SetTooltip()
494 if ( GetCVar("UberTooltips") == "1" ) then
495 GameTooltip_SetDefaultAnchor(GameTooltip, this);
496 else
497 if ( this:GetCenter() < UIParent:GetCenter() ) then
498 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
499 else
500 GameTooltip:SetOwner(this, "ANCHOR_LEFT");
501 end
502 end
503  
504 if ( GameTooltip:SetAction(CT_ActionButton_GetPagedID(this)) ) then
505 this.updateTooltip = TOOLTIP_UPDATE_TIME;
506 else
507 this.updateTooltip = nil;
508 end
509 end
510  
511 function CT_ActionButton_GetPagedID(button)
512 if( button == nil ) then
513 return 0;
514 end
515 local page = CURRENT_ACTIONBAR_PAGE;
516 if ( CT_Hotbars_Locked ) then
517 page = CT_ActionBar_LockedPage;
518 end
519 local isBonus;
520 if ( not page ) then page = 1; end
521 if ( strsub( button:GetName(), 1, 3 ) == "CT2" ) then
522 page = page + 1;
523 elseif ( strsub( button:GetName(), 1, 3 ) == "CT3" ) then
524 page = page + 2;
525 elseif ( strsub( button:GetName(), 1, 3 ) == "CT4" ) then
526 page = page + 3;
527 elseif ( strsub( button:GetName(), 1, 3 ) == "CT5" ) then
528 page = page + 4;
529 elseif ( string.find(button:GetName(), "^ActionButton%d+$") ) then
530 page = page - 1;
531 elseif ( string.find(button:GetName(), "^BonusActionButton%d+$") or string.find(button:GetName(), "^MultiBar") ) then
532 return ActionButton_GetPagedID(button);
533 end
534 if ( page >= 6 and not isBonus ) then
535 page = page - 6;
536 end
537 return (button:GetID() + ((page) * NUM_ACTIONBAR_BUTTONS));
538 end
539  
540 function CT_ActionButtonDown(bar, id)
541 if ( bar == 1 ) then bar = ""; end -- First bar's buttons aren't named CT1
542 local button = getglobal("CT" .. bar .. "_ActionButton" .. id);
543 if ( button:GetButtonState() == "NORMAL" ) then
544 button:SetButtonState("PUSHED");
545 end
546  
547 if ( CT_SelfCastModifier ) then
548 CT_NextSelfCast = 1;
549 end
550 end
551  
552 function CT_ActionButtonUp(bar, id)
553 if ( bar == 1 ) then bar = ""; end -- First bar's buttons aren't named CT1
554 local button = getglobal("CT" .. bar .. "_ActionButton" .. id);
555 if ( button:GetButtonState() == "PUSHED" ) then
556 button:SetButtonState("NORMAL");
557 -- Used to save a macro
558 if ( MacroFrame_SaveMacro ) then
559 MacroFrame_SaveMacro();
560 end
561  
562 if ( CT_NextSelfCast ) then
563 UseAction(CT_ActionButton_GetPagedID(button), 0, 1);
564 else
565 UseAction(CT_ActionButton_GetPagedID(button), 1, nil);
566 if ( SpellIsTargeting() and CT_SelfCast == 1 and SpellCanTargetUnit("player") ) then
567 SpellTargetUnit("player");
568 end
569 end
570 if ( CT_DebuffTimers_AddDebuff ) then
571 CT_DebuffTimers_AddDebuff(CT_ActionButton_GetPagedID(button));
572 end
573 if ( IsCurrentAction(CT_ActionButton_GetPagedID(button)) ) then
574 button:SetChecked(1);
575 else
576 button:SetChecked(0);
577 end
578 end
579 CT_NextSelfCast = nil;
580 end
581  
582 CT_oldActionButtonUp = ActionButtonUp;
583  
584 function CT_newActionButtonUp(id, onSelf)
585 if ( CT_NextSelfCast ) then
586 CT_oldActionButtonUp(id, 1);
587 else
588 CT_oldActionButtonUp(id, onSelf);
589 if ( SpellIsTargeting() and CT_SelfCast == 1 and SpellCanTargetUnit("player") ) then
590 SpellTargetUnit("player");
591 end
592 end
593 CT_NextSelfCast = nil;
594 end
595  
596 ActionButtonUp = CT_newActionButtonUp;
597  
598 CT_oldActionButtonDown = ActionButtonDown;
599  
600 function CT_newActionButtonDown(id)
601 CT_oldActionButtonDown(id);
602 if ( CT_SelfCastModifier ) then
603 CT_NextSelfCast = 1;
604 end
605 end
606  
607 ActionButtonDown = CT_newActionButtonDown;
608  
609 function CT_LHotbar_Update()
610 local modStatusLeft = "on";
611 for key, val in CT_Mods do
612 if ( val["modName"] == BARMOD_MODNAME_LEFTHB ) then
613 modStatusLeft = val["modStatus"];
614 end
615 end
616 if ( modStatusLeft == "off" ) then
617 CT_HotbarLeft:Hide();
618 else
619 CT_HotbarLeft:Show();
620 if ( not CT_BABar_Drag:IsUserPlaced() ) then
621 CT_BABar_Drag:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOM", -461, 128);
622 end
623 if ( not CT_PetBar_Drag:IsUserPlaced() ) then
624 CT_PetBar_Drag:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOM", -453, 122);
625 end
626 end
627 end
628 function CT_RHotbar_Update()
629 local modStatusRight = "on";
630 for key, val in CT_Mods do
631 if ( val["modName"] == BARMOD_MODNAME_RIGHTHB ) then
632 modStatusRight = val["modStatus"];
633 end
634 end
635 if ( modStatusRight == "off" ) then
636 CT_HotbarRight:Hide();
637 else
638 CT_HotbarRight:Show();
639 end
640 end
641 function CT_THotbar_Update()
642 local modStatusTop = "on";
643 for key, val in CT_Mods do
644 if ( val["modName"] == BARMOD_MODNAME_TOPHB ) then
645 modStatusTop = val["modStatus"];
646 end
647 end
648 if ( modStatusTop == "off" ) then
649 CT_HotbarTop:Hide();
650 else
651 CT_HotbarTop:Show();
652 end
653 end
654  
655 function CT_ActionButton_ShowGrid()
656 if ( CT_Sidebar_ButtonInUse(this) or ( strsub( this:GetName(), 1, 3 ) ~= "CT3" and strsub( this:GetName(), 1, 3 ) ~= "CT4" ) ) then
657 this.showgrid = this.showgrid+1;
658 getglobal(this:GetName().."NormalTexture"):SetVertexColor(1.0, 1.0, 1.0, 1.0);
659 this:Show();
660 end
661 end
662  
663 function CT_GetBagColumns()
664 local freeScreenHeight = GetScreenHeight() - CONTAINER_OFFSET;
665 local index = 1;
666 local column = 0;
667 for i=1, NUM_CONTAINER_FRAMES, 1 do
668 if ( getglobal("ContainerFrame" .. i):IsVisible() ) then
669 column = 1; break;
670 end
671 end
672 while ContainerFrame1.bags[index] do
673 local frame = getglobal(ContainerFrame1.bags[index]);
674 -- freeScreenHeight determines when to start a new column of bags
675 if ( freeScreenHeight < frame:GetHeight() and index > 1 ) then
676 column = column + 1;
677 freeScreenHeight = UIParent:GetHeight() - CONTAINER_OFFSET;
678 end
679 freeScreenHeight = freeScreenHeight - frame:GetHeight() - VISIBLE_CONTAINER_SPACING;
680 index = index + 1;
681 end
682 return column;
683 end
684  
685 function CT_HideButtons(buttonname, unt, stop, hidebefore)
686 for i=1, stop, 1 do
687 local button = getglobal(buttonname .. i);
688 if ( i <= unt ) then
689 if ( hidebefore == 1 ) then
690 button:Hide();
691 else
692 button:Show();
693 end
694 else
695 if ( hidebefore == 1 ) then
696 button:Show();
697 else
698 button:Hide();
699 end
700 end
701 end
702 end
703  
704 CT_oldActionButton_OnUpdate = ActionButton_OnUpdate;
705  
706 function CT_newActionButton_OnUpdate(elapsed)
707 if ( this.rangeTimer and this.rangeTimer <= elapsed ) then
708 if ( IsActionInRange( ActionButton_GetPagedID(this)) == 0 ) then
709 this.inRange = 0;
710 else
711 this.inRange = 1;
712 end
713 ActionButton_UpdateUsable();
714 end
715 CT_oldActionButton_OnUpdate(elapsed);
716 end
717  
718 ActionButton_OnUpdate = CT_newActionButton_OnUpdate;
719  
720 CT_oldActionButton_UpdateUsable = ActionButton_UpdateUsable;
721  
722 function CT_newActionButton_UpdateUsable()
723 CT_oldActionButton_UpdateUsable();
724 local icon = getglobal(this:GetName().."Icon");
725 local isUsable, notEnoughMana = IsUsableAction(ActionButton_GetPagedID(this));
726 if ( isUsable ) then
727 if ( this.inRange and this.inRange == 0 ) then
728 icon:SetVertexColor(CT_FadeColor.r, CT_FadeColor.g, CT_FadeColor.b);
729 end
730 end
731 end
732  
733 ActionButton_UpdateUsable = CT_newActionButton_UpdateUsable;
734  
735 function CT_ActionButton_UpdateUsable()
736 local icon = getglobal(this:GetName().."Icon");
737 local normalTexture = getglobal(this:GetName().."NormalTexture");
738 local isUsable, notEnoughMana = IsUsableAction(CT_ActionButton_GetPagedID(this));
739 if ( isUsable ) then
740 if ( this.inRange and this.inRange == 0 ) then
741 icon:SetVertexColor(CT_FadeColor.r, CT_FadeColor.g, CT_FadeColor.b);
742 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(CT_FadeColor.r, CT_FadeColor.g, CT_FadeColor.b); end
743 else
744 icon:SetVertexColor(1.0, 1.0, 1.0);
745 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(1.0, 1.0, 1.0); end
746 end
747 elseif ( notEnoughMana ) then
748 icon:SetVertexColor(0.5, 0.5, 1.0);
749 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(0.5, 0.5, 1.0); end
750 else
751 icon:SetVertexColor(0.4, 0.4, 0.4);
752 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(0.4, 0.4, 0.4); end
753 end
754 end
755  
756 function CT_ActionButton_OnUpdate(elapsed)
757 if ( ActionButton_IsFlashing() ) then
758 this.flashtime = this.flashtime - elapsed;
759 if ( this.flashtime <= 0 ) then
760 local overtime = -this.flashtime;
761 if ( overtime >= ATTACK_BUTTON_FLASH_TIME ) then
762 overtime = 0;
763 end
764 this.flashtime = ATTACK_BUTTON_FLASH_TIME - overtime;
765  
766 local flashTexture = getglobal(this:GetName().."Flash");
767 if ( flashTexture:IsVisible() ) then
768 flashTexture:Hide();
769 else
770 flashTexture:Show();
771 end
772 end
773 end
774  
775  
776 if ( this.rangeTimer ) then
777 if ( this.rangeTimer < 0 ) then
778 local count = getglobal(this:GetName().."HotKey");
779 if ( IsActionInRange( CT_ActionButton_GetPagedID(this)) == 0 ) then
780 count:SetVertexColor(1.0, 0.1, 0.1);
781 this.inRange = 0;
782 else
783 count:SetVertexColor(1.0, 1.0, 1.0);
784 this.inRange = 1;
785 end
786 this.rangeTimer = TOOLTIP_UPDATE_TIME;
787 CT_ActionButton_UpdateUsable();
788 else
789 this.rangeTimer = this.rangeTimer - elapsed;
790 end
791 end
792  
793 if ( not this.updateTooltip ) then
794 return;
795 end
796  
797 this.updateTooltip = this.updateTooltip - elapsed;
798 if ( this.updateTooltip > 0 ) then
799 return;
800 end
801  
802 if ( GameTooltip:IsOwned(this) ) then
803 CT_ActionButton_SetTooltip();
804 else
805 this.updateTooltip = nil;
806 end
807 end
808  
809 function CT_Sidebar_ChangeAxis(bar, force)
810 local curraxis = CT_SidebarAxis[bar];
811 if ( force ) then
812 curraxis = force;
813 end
814 if ( curraxis == 1 ) then
815 CT_SidebarAxis[tonumber(bar)] = 2;
816 else
817 CT_SidebarAxis[tonumber(bar)] = 1;
818 end
819 if ( CT_BarModOptions_Options[UnitName("player")] ) then
820 CT_BarModOptions_RemoveSpaceBars(CT_BarModOptions_Options[UnitName("player")]["removeBars"])
821 else
822 CT_BarModOptions_RemoveSpaceBars();
823 end
824 end
825  
826 BLIZZARD_Original_updateContainerFrameAnchors = updateContainerFrameAnchors;
827  
828 function updateContainerFrameAnchors()
829 CT_Bag_Update();
830 end
831  
832 function CT_updateContainerFrameAnchors()
833 local freeScreenHeight = GetScreenHeight() - CONTAINER_OFFSET;
834 local index = 1;
835 local column = 0;
836 while ContainerFrame1.bags[index] do
837 local frame = getglobal(ContainerFrame1.bags[index]);
838 if ( index == 1 ) then
839 frame:SetPoint("BOTTOMRIGHT", frame:GetParent():GetName(), "BOTTOMRIGHT", -40, CONTAINER_OFFSET);
840 elseif ( freeScreenHeight < frame:GetHeight() ) then
841 column = column + 1;
842 freeScreenHeight = UIParent:GetHeight() - CONTAINER_OFFSET;
843 frame:SetPoint("BOTTOMRIGHT", frame:GetParent():GetName(), "BOTTOMRIGHT", -(column * CONTAINER_WIDTH + 40), CONTAINER_OFFSET);
844 else
845 frame:SetPoint("BOTTOMRIGHT", ContainerFrame1.bags[index - 1], "TOPRIGHT", 0, CONTAINER_SPACING);
846 end
847 freeScreenHeight = freeScreenHeight - frame:GetHeight() - VISIBLE_CONTAINER_SPACING;
848 index = index + 1;
849 end
850 return column;
851 end
852  
853 function CT_Bag_Update()
854 if ( CT_HotbarTop:IsVisible() ) then
855 CONTAINER_OFFSET = 110;
856 elseif ( CT_HotbarRight:IsVisible() ) then
857 CONTAINER_OFFSET = 90;
858 else
859 CONTAINER_OFFSET = 70;
860 end
861  
862 if ( CT_SidebarFrame2:IsVisible() ) then
863 CT_updateContainerFrameAnchors();
864 else
865 BLIZZARD_Original_updateContainerFrameAnchors();
866 end
867  
868 end
869  
870 CT_oldFCF_UpdateDockPosition = FCF_UpdateDockPosition;
871 CT_newFCF_UpdateDockPosition = function() end;
872  
873 function CT_GlobalFrame_OnUpdate(elapsed)
874 this.update = this.update + elapsed;
875 if ( SIMPLE_CHAT == "1" and this.update > 0.05 ) then
876 FCF_UpdateDockPosition = CT_newFCF_UpdateDockPosition;
877 this.update = this.update - 0.05;
878 ChatFrame2:SetPoint("BOTTOMRIGHT", "UIParent", "BOTTOMRIGHT", -32, 95);
879 if ( ShapeshiftBarFrame:IsVisible() ) then
880 ChatFrame1:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 32, 138);
881 elseif ( PetActionBarFrame:IsVisible() ) then
882 ChatFrame1:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 32, 130);
883 else
884 ChatFrame1:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 32, 95);
885 end
886 else
887 FCF_UpdateDockPosition = CT_oldFCF_UpdateDockPosition;
888 end
889 this.updateCDC = this.updateCDC + elapsed;
890 if ( this.updateCDC >= 0.25 ) then
891 this.updateCDC = 0;
892 local currTime = GetTime();
893 for k, v in CT_BarMod_Cooldowns do
894 CT_BarMod_Cooldowns[k][3] = floor((v[1]+v[2])-currTime);
895 if ( CT_BarMod_Cooldowns[k][3] <= 0 ) then
896 CT_BarMod_Cooldowns[k] = nil;
897 end
898 end
899 CT_BarMod_UpdateCooldownCount();
900 end
901 end
902  
903 sidebarfunction = function()
904 if ( CT_SidebarFrame:IsVisible() ) then
905 CT_SidebarFrame:Hide();
906 CT_SetModStatus(BARMOD_MODNAME_LEFTSB, "off");
907 CT_Print(BARMOD_OFF_LEFTSBAR, 1.0, 1.0, 0.0);
908 else
909 if ( CT_MF_ShowFrames ) then
910 CT_SidebarLeft_Drag:Show();
911 end
912 CT_SidebarFrame:Show();
913 CT_SetModStatus(BARMOD_MODNAME_LEFTSB, "on");
914 CT_Print(BARMOD_ON_LEFTSBAR, 1.0, 1.0, 0.0);
915 end
916 end
917 sidebarRfunction = function()
918 if ( CT_SidebarFrame2:IsVisible() ) then
919 CT_SidebarFrame2:Hide();
920 CT_SetModStatus(BARMOD_MODNAME_RIGHTSB, "off");
921 CT_Print(BARMOD_OFF_RIGHTSBAR, 1.0, 1.0, 0.0);
922 else
923 if ( CT_MF_ShowFrames ) then
924 CT_SidebarRight_Drag:Show();
925 end
926 CT_SidebarFrame2:Show();
927 CT_SetModStatus(BARMOD_MODNAME_RIGHTSB, "on");
928 CT_Print(BARMOD_ON_RIGHTSBAR, 1.0, 1.0, 0.0);
929 end
930 -- dbrong
931 CT_Bag_Update();
932 end
933 lsidebarbuttonsfunction = function(modID, text)
934 local val = CT_Mods[modID]["modValue"];
935 if ( val == "6" or val == 6 ) then
936 val = "9";
937 elseif ( val == "9" or val == 9 ) then
938 val = "12";
939 elseif ( val == "12" or val == 12 ) then
940 val = "6";
941 end
942 if ( text ) then text:SetText(val); end
943 CT_Mods[modID]["modValue"] = val;
944 LCT_SidebarBtns_Update(modID);
945 end
946 hotbarleftfunction = function (modId)
947 local val = CT_Mods[modId]["modStatus"];
948 if ( val == "off" ) then
949 CT_HotbarLeft:Hide();
950 CT_LeftHotbar_OnHide();
951 CT_Print(BARMOD_OFF_LEFTHBAR, 1.0, 1.0, 0.0);
952 else
953 if ( CT_MF_ShowFrames ) then
954 CT_HotbarLeft_Drag:Show();
955 end
956 local x = CT_PetBar_Drag:GetLeft()-(UIParent:GetRight()/2);
957 local y = CT_PetBar_Drag:GetBottom()+40;
958 CT_PetBar_Drag:ClearAllPoints();
959 CT_PetBar_Drag:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOM", x, y);
960  
961 x = CT_BABar_Drag:GetLeft()-(UIParent:GetRight()/2);
962 y = CT_BABar_Drag:GetBottom()+40;
963 CT_BABar_Drag:ClearAllPoints();
964 CT_BABar_Drag:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOM", x, y);
965 CT_HotbarLeft:Show();
966 CT_Print(BARMOD_ON_LEFTHBAR, 1.0, 1.0, 0.0);
967 end
968 end
969 hotbarrightfunction = function (modId)
970 local val = CT_Mods[modId]["modStatus"];
971 if ( val == "off" ) then
972 CT_HotbarRight:Hide();
973 CT_Print(BARMOD_OFF_RIGHTHBAR, 1.0, 1.0, 0.0);
974 else
975 if ( CT_MF_ShowFrames ) then
976 CT_HotbarRight_Drag:Show();
977 end
978 CT_HotbarRight:Show();
979 CT_Print(BARMOD_ON_RIGHTHBAR, 1.0, 1.0, 0.0);
980 end
981 CT_Bag_Update();
982 end
983  
984 hotbartopfunction = function ()
985 if ( CT_HotbarTop:IsVisible() ) then
986 CT_HotbarTop:Hide();
987 CT_SetModStatus(BARMOD_MODNAME_TOPHB, "off");
988 CT_Print(BARMOD_OFF_TOPBAR, 1.0, 1.0, 0.0);
989 else
990 if ( CT_MF_ShowFrames ) then
991 CT_HotbarTop_Drag:Show();
992 end
993 CT_HotbarTop:Show();
994 CT_SetModStatus(BARMOD_MODNAME_TOPHB, "on");
995 CT_Print(BARMOD_ON_TOPBAR, 1.0, 1.0, 0.0);
996 end
997 CT_Bag_Update();
998 end
999 function gridinitfunction(modId)
1000 local val = CT_Mods[modId]["modStatus"];
1001 local i;
1002 if ( val == "off" ) then
1003 CT_ShowGrid = 1;
1004 else
1005 CT_ShowGrid = 0;
1006 for i=1, 12, 1 do
1007 CT_ActionButton_HideGrid(getglobal("ActionButton" .. i));
1008 CT_ActionButton_HideGrid(getglobal("BonusActionButton" .. i));
1009 CT_ActionButton_HideGrid(getglobal("MultiBarLeftButton" .. i));
1010 CT_ActionButton_HideGrid(getglobal("MultiBarRightButton" .. i));
1011 CT_ActionButton_HideGrid(getglobal("MultiBarBottomLeftButton" .. i));
1012 CT_ActionButton_HideGrid(getglobal("MultiBarBottomRightButton" .. i));
1013 CT_ActionButton_HideGrid(getglobal("CT_ActionButton" .. i));
1014 CT_ActionButton_HideGrid(getglobal("CT2_ActionButton" .. i));
1015 CT_ActionButton_HideGrid(getglobal("CT3_ActionButton" .. i));
1016 CT_ActionButton_HideGrid(getglobal("CT4_ActionButton" .. i));
1017 CT_ActionButton_HideGrid(getglobal("CT5_ActionButton" .. i));
1018 end
1019 end
1020 end
1021  
1022 function movefunction(modId)
1023 local val = CT_Mods[modId]["modStatus"];
1024 if ( val == "off" ) then
1025 CT_Print(BARMOD_OFF_MOVEPARTYFRAME);
1026 CT_CheckPartyMove();
1027 elseif ( val == "on" ) then
1028 CT_Print(BARMOD_ON_MOVEPARTYFRAME);
1029 CT_CheckPartyMove();
1030 end
1031 end
1032  
1033 function CT_CheckPartyMove()
1034 if ( CT_MovableParty_IsInstalled ) then
1035 for i = 1, 4, 1 do
1036 CT_LinkFrameDrag(getglobal("PartyMemberFrame" .. i), getglobal("CT_MovableParty" .. i .. "_Drag"), "TOPLEFT", "TOPLEFT", -40, -7);
1037 end
1038 return;
1039 elseif ( CT_GetModStatus(BARMOD_MODNAME_MOVEPARTYFRAME) == "on" ) then
1040 local offset = -128;
1041 if ( UnitExists("pet") ) then
1042 offset = -160;
1043 end
1044 PartyMemberFrame1:ClearAllPoints();
1045 PartyMemberFrame1:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 50, offset);
1046 else
1047 local offset = -128;
1048 if ( UnitExists("pet") ) then
1049 offset = -160;
1050 end
1051 PartyMemberFrame1:ClearAllPoints();
1052 PartyMemberFrame1:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 10, offset);
1053 end
1054 for i = 2, 4, 1 do
1055 getglobal("PartyMemberFrame" .. i):ClearAllPoints();
1056 getglobal("PartyMemberFrame" .. i):SetPoint("TOPLEFT", "PartyMemberFrame" .. (i-1) .. "PetFrame", "BOTTOMLEFT", -23, -10);
1057 end
1058 end
1059  
1060 CT_oldPickupAction = PickupAction;
1061 CT_PickupAction = function(x)
1062 if ( not CT_HotbarButtons_Locked or IsShiftKeyDown() ) then
1063 if ( this ) then
1064 CT_BarMod_Cooldowns[this:GetName()] = nil;
1065 CT_BarMod_UpdateCooldownCount();
1066 end
1067 CT_oldPickupAction(x);
1068 end
1069 end
1070 PickupAction = CT_PickupAction;
1071  
1072 function cooldownfunction(modId)
1073 local val = CT_Mods[modId]["modStatus"];
1074 if ( val == "off" ) then
1075 CT_Print(BARMOD_OFF_COOLDOWNCOUNT, 1, 1, 0);
1076 CT_CDCount = 0;
1077 CT_BarMod_UpdateCooldownCount();
1078 elseif ( val == "on" ) then
1079 CT_Print(BARMOD_ON_COOLDOWNCOUNT, 1, 1, 0);
1080 CT_CDCount = 1;
1081 CT_BarMod_UpdateCooldownCount();
1082 end
1083 end
1084  
1085 function cooldowninitfunction(modId)
1086 local val = CT_Mods[modId]["modStatus"];
1087 if ( val == "off" ) then
1088 CT_CDCount = 0;
1089 CT_BarMod_UpdateCooldownCount();
1090 elseif ( val == "on" ) then
1091 CT_CDCount = 1;
1092 CT_BarMod_UpdateCooldownCount();
1093 end
1094 end
1095 --[[
1096 CT_RegisterMod(BARMOD_MODNAME_LEFTSB, BARMOD_ONOFFTOGGLE, 2, "Interface\\Icons\\Spell_Holy_MindVision", BARMOD_TOOLTIP_LEFTSB, "off", nil, sidebarfunction, CT_LSidebar_Update);
1097 CT_RegisterMod(BARMOD_MODNAME_RIGHTSB, BARMOD_ONOFFTOGGLE, 2, "Interface\\Icons\\Spell_Holy_MindVision", BARMOD_TOOLTIP_RIGHTSB, "off", nil, sidebarRfunction, CT_RSidebar_Update);
1098 CT_RegisterMod(BARMOD_MODNAME_LEFTHB, BARMOD_ONOFFTOGGLE, 2, "Interface\\Icons\\Spell_Holy_MindVision", BARMOD_TOOLTIP_LEFTHB, "off", nil, hotbarleftfunction, CT_LHotbar_Update);
1099 CT_RegisterMod(BARMOD_MODNAME_RIGHTHB, BARMOD_ONOFFTOGGLE, 2, "Interface\\Icons\\Spell_Holy_MindVision", BARMOD_TOOLTIP_RIGHTHB, "off", nil, hotbarrightfunction, CT_RHotbar_Update);
1100 CT_RegisterMod(BARMOD_MODNAME_TOPHB, BARMOD_ONOFFTOGGLE, 2, "Interface\\Icons\\Spell_Holy_MindVision", BARMOD_TOOLTIP_TOPHB, "off", nil, hotbartopfunction, CT_THotbar_Update);
1101  
1102 CT_RegisterMod(BARMOD_MODNAME_PAGELOCK, BARMOD_SUB_PAGELOCK, 2, "Interface\\Icons\\INV_Misc_Key_03", BARMOD_TOOLTIP_PAGELOCK, "off", nil, HotbarsLockFunction, HotbarsLockInitFunction);
1103 CT_RegisterMod(BARMOD_MODNAME_BUTTONLOCK, BARMOD_SUB_BUTTONLOCK, 2, "Interface\\Icons\\INV_Misc_Key_13", BARMOD_TOOLTIP_BUTTONLOCK, "off", nil, HotbarButtonsLockFunction, CT_ButtonLock_Update);
1104 CT_RegisterMod(BARMOD_MODNAME_HIDEGRID, BARMOD_SUB_HIDEGRID, 2, "Interface\\Icons\\Ability_Vanish", BARMOD_TOOLTIP_HIDEGRID, "off", nil, gridfunction, gridinitfunction);
1105 ]]
1106 CT_RegisterMod(BARMOD_MODNAME_MOVEPARTYFRAME, BARMOD_ONOFFTOGGLE, 2, "Interface\\Icons\\Spell_Holy_MindSooth", BARMOD_TOOLTIP_MOVEPARTYFRAME, "off", nil, movefunction, CT_CheckPartyMove);
1107 CT_RegisterMod(BARMOD_MODNAME_COOLDOWNCOUNT, BARMOD_SUB_COOLDOWNCOUNT, 2, "Interface\\Icons\\INV_Misc_PocketWatch_01", BARMOD_TOOLTIP_COOLDOWNCOUNT, "off", nil, cooldownfunction, cooldowninitfunction);
1108  
1109 CT_PetBar_DragFrame_Orientation = "H";
1110 CT_BABar_DragFrame_Orientation = "H";
1111 CT_Show_PetBarDrag = 0;
1112  
1113 function CT_Bar_DragFrame_OnMD(force)
1114 local var, type;
1115 if ( this == CT_PetBar_Drag ) then
1116 var = CT_PetBar_DragFrame_Orientation;
1117 type = "PetAction";
1118 else
1119 var = CT_BABar_DragFrame_Orientation;
1120 type = "Shapeshift";
1121 end
1122 if ( arg1 == "LeftButton" ) then
1123 this:StartMoving();
1124 else
1125 if ( var == "H" or force ) then
1126 var = "V";
1127 else
1128 var = "H";
1129 end
1130 local i;
1131 for i = 2, 10, 1 do
1132 getglobal(type .. "Button" .. i):ClearAllPoints();
1133 if ( var == "H" ) then
1134 getglobal(type .. "Button" .. i):SetPoint("LEFT", type .. "Button" .. (i-1), "RIGHT", 8, 0);
1135 else
1136 getglobal(type .. "Button" .. i):SetPoint("TOP", type .. "Button" .. (i-1), "BOTTOM", 0, -8);
1137 end
1138 end
1139 end
1140 if ( this == CT_PetBar_Drag ) then
1141 CT_PetBar_DragFrame_Orientation = var;
1142 else
1143 CT_BABar_DragFrame_Orientation = var;
1144 end
1145 if ( CT_BarModOptions_RemoveSpaceSpecial ) then
1146 CT_BarModOptions_RemoveSpaceSpecial(CT_BarModOptions_Options[UnitName("player")]["removeSpecial"]);
1147 end
1148 if ( CT_BottomBar_HideTextures ) then
1149 CT_BottomBar_HideTextures(CT_BottomBar_HiddenFrames[UnitName("player")]["ClassBackground"]);
1150 end
1151 end
1152  
1153 function CT_BarMod_CheckRotations()
1154 for key, val in CT_SidebarAxis do
1155 if ( val == 1 ) then val = 2; else val = 1; end
1156 CT_Sidebar_ChangeAxis(tonumber(key), val);
1157 end
1158 end
1159  
1160 local oorfunc = function(modId, text)
1161 local val = CT_Mods[modId]["modValue"];
1162 if ( val == "1" ) then
1163 val = "2"
1164 CT_FadeColor = { ["r"] = 0.5, ["g"] = 0.5, ["b"] = 0.5 };
1165 CT_Print(BARMOD_ON_OOR1, 1, 1, 0);
1166 elseif ( val == "2" ) then
1167 val = "3";
1168 CT_FadeColor = { ["r"] = 0.8, ["g"] = 0.4, ["b"] = 0.4 };
1169 CT_Print(BARMOD_ON_OOR2, 1, 1, 0);
1170 elseif ( val == "3" ) then
1171 val = "1";
1172 CT_FadeColor = { ["r"] = 1, ["g"] = 1, ["b"] = 1 };
1173 CT_Print(BARMOD_OFF_OOR, 1, 1, 0);
1174 end
1175 if ( text ) then text:SetText(val); end
1176 CT_Mods[modId]["modValue"] = val;
1177 CT_Mods[modId]["modStatus"] = "switch";
1178 end
1179  
1180 local oorinitfunc = function(modId)
1181 local val = CT_Mods[modId]["modValue"];
1182 if ( val == "2" ) then
1183 CT_FadeColor = { ["r"] = 0.5, ["g"] = 0.5, ["b"] = 0.5 };
1184 elseif ( val == "3" ) then
1185 CT_FadeColor = { ["r"] = 0.8, ["g"] = 0.4, ["b"] = 0.4 };
1186 elseif ( val == "1" ) then
1187 CT_FadeColor = { ["r"] = 1, ["g"] = 1, ["b"] = 1 };
1188 end
1189 end
1190  
1191 local selffunc = function(modId)
1192 local val = CT_Mods[modId]["modStatus"];
1193 if ( val == "on" ) then
1194 CT_SelfCast = 1;
1195 CT_Print(BARMOD_ON_SELFCAST, 1, 1, 0);
1196 else
1197 CT_Print(BARMOD_OFF_SELFCAST, 1, 1, 0);
1198 CT_SelfCast = 0;
1199 end
1200 end
1201  
1202 local selfinitfunc = function(modId)
1203 local val = CT_Mods[modId]["modStatus"];
1204 if ( val == "on" ) then
1205 CT_SelfCast = 1;
1206 else
1207 CT_SelfCast = 0;
1208 end
1209 end
1210  
1211 local hotkeyfunc = function(modId, text)
1212 local val = CT_Mods[modId]["modValue"];
1213 if ( val == "3" ) then
1214 val = "1";
1215 CT_ShowHotkeys = nil;
1216 CT_Print(BARMOD_ON_HOTKEY1, 1, 1, 0);
1217 elseif ( val == "1" ) then
1218 val = "2";
1219 CT_ShowHotkeys = 1;
1220 CT_Print(BARMOD_ON_HOTKEY2, 1, 1, 0);
1221 elseif ( val == "2" ) then
1222 val = "3";
1223 CT_ShowHotkeys = -1;
1224 CT_Print(BARMOD_OFF_HOTKEY, 1, 1, 0);
1225 end
1226 CT_BarMod_UpdateAllHotkeys();
1227 if ( text ) then
1228 text:SetText(val);
1229 end
1230 CT_Mods[modId]["modValue"] = val;
1231 end
1232  
1233 local hotkeyinitfunc = function(modId)
1234 local val = CT_Mods[modId]["modValue"];
1235 if ( val == "1" ) then
1236 CT_ShowHotkeys = nil;
1237 elseif ( val == "2" ) then
1238 CT_ShowHotkeys = 1;
1239 elseif ( val == "3" ) then
1240 CT_ShowHotkeys = -1;
1241 end
1242 CT_BarMod_UpdateAllHotkeys();
1243 CT_Mods[modId]["modStatus"] = "switch";
1244 end
1245  
1246 function cskeyfunc(modId, text)
1247 local val = CT_Mods[modId]["modValue"];
1248 if ( val == "Ctrl" ) then
1249 val = "Alt";
1250 CT_SelfCastModKey = IsAltKeyDown;
1251 CT_Print(BARMOD_ON_SCKEY2, 1, 1, 0);
1252 elseif ( val == "Alt" ) then
1253 val = "Shift";
1254 CT_SelfCastModKey = IsShiftKeyDown;
1255 CT_Print(BARMOD_ON_SCKEY3, 1, 1, 0);
1256 elseif ( val == "Shift" ) then
1257 val = "None";
1258 CT_SelfCastModKey = nil;
1259 CT_Print(BARMOD_ON_SCKEY4, 1, 1, 0);
1260 elseif ( val == "None" ) then
1261 val = "Ctrl";
1262 CT_SelfCastModKey = IsControlKeyDown;
1263 CT_Print(BARMOD_ON_SCKEY1, 1, 1, 0);
1264 end
1265 CT_Mods[modId]["modValue"] = val;
1266 if ( text ) then text:SetText(val); end
1267 end
1268  
1269 function cskeyinitfunc(modId, text)
1270 local val = CT_Mods[modId]["modValue"];
1271 if ( val == "Alt" ) then
1272 CT_SelfCastModKey = IsAltKeyDown;
1273 elseif ( val == "Shift" ) then
1274 CT_SelfCastModKey = IsShiftKeyDown;
1275 elseif ( val == "Ctrl" ) then
1276 CT_SelfCastModKey = IsControlKeyDown;
1277 end
1278 end
1279  
1280 CT_RegisterMod(BARMOD_MODNAME_OOR, BARMOD_SUB_OOR, 2, "Interface\\Icons\\Ability_TownWatch", BARMOD_TOOLTIP_OOR, "switch", "1", oorfunc, oorinitfunc);
1281 CT_RegisterMod(BARMOD_MODNAME_HOTKEYS, BARMOD_SUB_HOTKEYS, 2, "Interface\\Icons\\INV_Misc_Key_09", BARMOD_TOOLTIP_HOTKEYS, "switch", "1", hotkeyfunc, hotkeyinitfunc);
1282  
1283 --CT_RegisterMod(BARMOD_MODNAME_TTPOS, BARMOD_SUB_TTPOS, 5, "Interface\\Icons\\Ability_Mount_WhiteTiger", BARMOD_TOOLTIP_TTPOS, "off", nil, ttfunc, ttinitfunc);
1284  
1285 CT_RegisterMod(BARMOD_MODNAME_SCKEY, BARMOD_SUB_SCKEY, 4, "Interface\\Icons\\Spell_Holy_GreaterHeal", BARMOD_TOOLTIP_SCKEY, "switch", "None", cskeyfunc, cskeyinitfunc);
1286 CT_RegisterMod(BARMOD_MODNAME_SELFCAST, BARMOD_SUB_SELFCAST, 4, "Interface\\Icons\\Spell_Holy_GreaterHeal", BARMOD_TOOLTIP_SELFCAST, "off", nil, selffunc, selfinitfunc);
1287  
1288 function CT_ActionButton_OnClick()
1289 if ( ( strsub( this:GetName(), 1, 3 ) ~= "CT3" and strsub( this:GetName(), 1, 3 ) ~= "CT4" ) or CT_Sidebar_ButtonInUse(this) ) then
1290  
1291 if ( IsShiftKeyDown() ) then
1292 PickupAction(CT_ActionButton_GetPagedID(this));
1293 else
1294 if ( MacroFrame_SaveMacro ) then
1295 MacroFrame_SaveMacro();
1296 end
1297 if ( CT_NextSelfCast ) then
1298 UseAction(CT_ActionButton_GetPagedID(this), 0, 1);
1299 else
1300 UseAction(CT_ActionButton_GetPagedID(this), 1, nil);
1301 if ( SpellIsTargeting() and CT_SelfCast == 1 and not SpellCanTargetUnit("target") and SpellCanTargetUnit("player") ) then
1302 SpellTargetUnit("player");
1303 end
1304 end
1305 end
1306 CT_ActionButton_Update();
1307 CT_ActionButton_UpdateState();
1308 end
1309 end
1310  
1311 CT_oldUseAction = UseAction;
1312  
1313 function CT_newUseAction(id, cursor, onSelf)
1314 if ( ( CT_SelfCastModifier and CT_SelfCast == 1 ) or ( CT_SelfCastModKey and CT_SelfCastModKey() ) ) then
1315 onSelf = 1;
1316 end
1317 CT_oldUseAction(id, cursor, onSelf);
1318 if ( SpellIsTargeting() and CT_SelfCast == 1 and not SpellCanTargetUnit("target") and SpellCanTargetUnit("player") ) then
1319 SpellTargetUnit("player");
1320 end
1321 end
1322  
1323 UseAction = CT_newUseAction;
1324  
1325 CT_BarMod_oldUseContainerItem = UseContainerItem;
1326 function CT_BarMod_newUseContainerItem(bag, item)
1327 CT_BarMod_oldUseContainerItem(bag, item);
1328 if ( ( CT_SelfCast == 1 or ( CT_SelfCastModKey and CT_SelfCastModKey() ) ) and SpellIsTargeting() and not SpellCanTargetUnit("target") and SpellCanTargetUnit("player") ) then
1329 SpellTargetUnit("player");
1330 end
1331 end
1332 UseContainerItem = CT_BarMod_newUseContainerItem;
1333  
1334 function CT_BarMod_UpdateAllHotkeys()
1335 local key = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=" };
1336 local i;
1337 for i = 1, 12, 1 do
1338 CT_ActionButton_UpdateHotkeys(getglobal("CT_ActionButton" .. i));
1339 CT_ActionButton_UpdateHotkeys(getglobal("CT2_ActionButton" .. i));
1340 CT_ActionButton_UpdateHotkeys(getglobal("CT3_ActionButton" .. i));
1341 CT_ActionButton_UpdateHotkeys(getglobal("CT4_ActionButton" .. i));
1342 CT_ActionButton_UpdateHotkeys(getglobal("CT5_ActionButton" .. i));
1343  
1344 if ( CT_ShowHotkeys and CT_ShowHotkeys == -1 ) then
1345 getglobal("ActionButton" .. i .. "HotKey"):Hide();
1346 getglobal("BonusActionButton" .. i .. "HotKey"):Hide();
1347 getglobal("MultiBarBottomLeftButton" .. i .. "HotKey"):Hide();
1348 getglobal("MultiBarBottomRightButton" .. i .. "HotKey"):Hide();
1349 getglobal("MultiBarLeftButton" .. i .. "HotKey"):Hide();
1350 getglobal("MultiBarRightButton" .. i .. "HotKey"):Hide();
1351 else
1352 getglobal("ActionButton" .. i .. "HotKey"):Show();
1353 getglobal("BonusActionButton" .. i .. "HotKey"):Show();
1354 getglobal("MultiBarBottomLeftButton" .. i .. "HotKey"):Show();
1355 getglobal("MultiBarBottomRightButton" .. i .. "HotKey"):Show();
1356 getglobal("MultiBarLeftButton" .. i .. "HotKey"):Show();
1357 getglobal("MultiBarRightButton" .. i .. "HotKey"):Show();
1358 if ( not CT_ShowHotkeys ) then
1359 getglobal("ActionButton" .. i .. "HotKey"):SetText(key[i]);
1360 getglobal("BonusActionButton" .. i .. "HotKey"):SetText(key[i]);
1361 getglobal("MultiBarBottomLeftButton" .. i .. "HotKey"):Show();
1362 getglobal("MultiBarBottomRightButton" .. i .. "HotKey"):Show();
1363 getglobal("MultiBarLeftButton" .. i .. "HotKey"):Show();
1364 getglobal("MultiBarRightButton" .. i .. "HotKey"):Show();
1365 else
1366 getglobal("ActionButton" .. i .. "HotKey"):SetText(GetBindingText(GetBindingKey("ACTIONBUTTON" .. i), "KEY_"));
1367 getglobal("BonusActionButton" .. i .. "HotKey"):SetText(GetBindingText(GetBindingKey("ACTIONBUTTON" .. i), "KEY_"));
1368 getglobal("MultiBarBottomLeftButton" .. i .. "HotKey"):SetText(GetBindingText(GetBindingKey("MULTIACTIONBAR1BUTTON" .. i), "KEY_"));
1369 getglobal("MultiBarBottomRightButton" .. i .. "HotKey"):SetText(GetBindingText(GetBindingKey("MULTIACTIONBAR2BUTTON" .. i), "KEY_"));
1370 getglobal("MultiBarLeftButton" .. i .. "HotKey"):SetText(GetBindingText(GetBindingKey("MULTIACTIONBAR4BUTTON" .. i), "KEY_"));
1371 getglobal("MultiBarRightButton" .. i .. "HotKey"):SetText(GetBindingText(GetBindingKey("MULTIACTIONBAR3BUTTON" .. i), "KEY_"));
1372 end
1373 end
1374 end
1375 end
1376  
1377 CT_oldActionButton_UpdateHotkeys = ActionButton_UpdateHotkeys;
1378  
1379 function CT_newActionButton_UpdateHotkeys()
1380 local key = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=" };
1381 if ( not CT_ShowHotkeys ) then
1382 getglobal(this:GetName() .. "HotKey"):SetText(key[this:GetID()]);
1383 getglobal(this:GetName() .. "HotKey"):Show();
1384 else
1385 CT_ActionButton_UpdateHotkeys();
1386 end
1387 end
1388  
1389 ActionButton_UpdateHotkeys = CT_newActionButton_UpdateHotkeys;
1390  
1391 CT_oldPickupPetAction = PickupPetAction;
1392 function CT_newPickupPetAction(arg)
1393 if ( not CT_HotbarButtons_Locked or IsShiftKeyDown() ) then
1394 CT_oldPickupPetAction(arg);
1395 end
1396 end
1397 PickupPetAction = CT_newPickupPetAction;
1398  
1399 function CT_HotbarToggle(num)
1400 local arr = {
1401 "CT_HotbarLeft",
1402 "CT_HotbarRight",
1403 "CT_SidebarFrame",
1404 "CT_SidebarFrame2",
1405 "CT_HotbarTop"
1406 };
1407  
1408 if ( getglobal(arr[num]):IsVisible() ) then
1409 getglobal(arr[num]):Hide();
1410 else
1411 getglobal(arr[num]):Show();
1412 end
1413 end
1414  
1415 CT_oldSPAB = ShowPetActionBar;
1416 function CT_newSPAB()
1417 CT_oldSPAB();
1418 if ( PetActionBarFrame:IsVisible() and CT_MF_ShowFrames ) then
1419 CT_PetBar_Drag:Show();
1420 else
1421 CT_PetBar_Drag:Hide();
1422 end
1423 end
1424 ShowPetActionBar = CT_newSPAB;
1425  
1426 function CT_LeftHotbar_OnHide()
1427 local x = CT_BABar_Drag:GetLeft()-(UIParent:GetRight()/2);
1428 local y = CT_BABar_Drag:GetBottom()-40;
1429 CT_BABar_Drag:ClearAllPoints();
1430 CT_BABar_Drag:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOM", x, y);
1431  
1432 x = CT_PetBar_Drag:GetLeft()-(UIParent:GetRight()/2);
1433 y = CT_PetBar_Drag:GetBottom()-40;
1434 CT_PetBar_Drag:ClearAllPoints();
1435 CT_PetBar_Drag:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOM", x, y);
1436 end
1437  
1438 -- Functions to display grid
1439  
1440 function CT_updateActionButtons()
1441 for i = 1, 12, 1 do
1442 local ab = getglobal("ActionButton" .. i);
1443 if ( CT_BottomBar_Enabled and CT_BottomBar_Enabled[UnitName("player")] and CT_BottomBar_HiddenFrames[UnitName("player")]["BarHotbar"] ) then
1444 ab.showgrid = 0;
1445 ab:Hide();
1446 elseif ( not HasAction(ActionButton_GetPagedID(ab)) ) then
1447 if ( CT_ShowGrid ) then
1448 ab.showgrid = 1;
1449 ab:Show();
1450 else
1451 ab.showgrid = 0;
1452 ab:Hide();
1453 end
1454 elseif ( GetBonusBarOffset() > 0 ) then
1455 ab.showgrid = 0;
1456 ab:Hide();
1457 else
1458 ab.showgrid = 1;
1459 ab:Show();
1460 end
1461 --[[local ab = getglobal("ActionButton" .. i);
1462 if ( not HasAction(ActionButton_GetPagedID(ab)) or CT_ShowGrid ) then
1463 if (
1464 ( not CT_ShowGrid and not HasAction(CT_ActionButton_GetPagedID(ab)) ) or
1465 GetBonusBarOffset() > 0 or
1466 ( not CT_BottomBar_Enabled or not CT_BottomBar_Enabled[UnitName("player")] or
1467 ( not CT_BottomBar_RotatedFrames[UnitName("player")]["Bars"] and
1468 not CT_BottomBar_HiddenFrames[UnitName("player")]["BarHotbarBackgroundLeft"] )
1469 )
1470 ) then
1471 ab.showgrid = 0;
1472 ab:Hide();
1473 else
1474 ab.showgrid = 1;
1475 ab:Show();
1476 end
1477 end
1478 ab = getglobal("BonusActionButton" .. i);
1479 if ( not HasAction(ActionButton_GetPagedID(ab)) or CT_ShowGrid ) then
1480 if (
1481 GetBonusBarOffset() == 0 or
1482 ( not CT_ShowGrid and not HasAction(CT_ActionButton_GetPagedID(ab)) ) or
1483 ( not CT_BottomBar_Enabled or not CT_BottomBar_Enabled[UnitName("player")] or
1484 ( not CT_BottomBar_RotatedFrames[UnitName("player")]["Bars"] and
1485 not CT_BottomBar_HiddenFrames[UnitName("player")]["BarHotbarBackgroundLeft"] )
1486 )
1487 ) then
1488 ab.showgrid = 0;
1489 ab:Hide();
1490 else
1491 ab.showgrid = 1;
1492 ab:Show();
1493 end
1494 end]]
1495 local ab = getglobal("BonusActionButton" .. i);
1496 if ( CT_BottomBar_Enabled and CT_BottomBar_Enabled[UnitName("player")] and CT_BottomBar_HiddenFrames[UnitName("player")]["BarHotbar"] ) then
1497 ab.showgrid = 0;
1498 ab:Hide();
1499 elseif ( not HasAction(ActionButton_GetPagedID(ab)) ) then
1500 if ( CT_ShowGrid ) then
1501 ab.showgrid = 1;
1502 ab:Show();
1503 else
1504 ab.showgrid = 0;
1505 ab:Hide();
1506 end
1507 elseif ( GetBonusBarOffset() == 0 ) then
1508 ab.showgrid = 0;
1509 ab:Hide();
1510 else
1511 ab.showgrid = 1;
1512 ab:Show();
1513 end
1514 ab = getglobal("MultiBarBottomLeftButton" .. i);
1515 if ( not HasAction(ActionButton_GetPagedID(ab)) and ab.showgrid == 0 ) then
1516 if ( not CT_ShowGrid ) then
1517 ab.showgrid = 0;
1518 ab:Hide();
1519 else
1520 ab.showgrid = 1;
1521 ab:Show();
1522 end
1523 end
1524 ab = getglobal("MultiBarBottomRightButton" .. i);
1525 if ( not HasAction(ActionButton_GetPagedID(ab)) and ab.showgrid == 0 ) then
1526 if ( not CT_ShowGrid ) then
1527 ab.showgrid = 0;
1528 ab:Hide();
1529 else
1530 ab.showgrid = 1;
1531 ab:Show();
1532 end
1533 end
1534 ab = getglobal("MultiBarLeftButton" .. i);
1535 if ( not HasAction(ActionButton_GetPagedID(ab)) and ab.showgrid == 0 ) then
1536 if ( not CT_ShowGrid ) then
1537 ab.showgrid = 0;
1538 ab:Hide();
1539 else
1540 ab.showgrid = 1;
1541 ab:Show();
1542 end
1543 end
1544 ab = getglobal("MultiBarRightButton" .. i);
1545 if ( not HasAction(ActionButton_GetPagedID(ab)) and ab.showgrid == 0 ) then
1546 if ( not CT_ShowGrid ) then
1547 ab.showgrid = 0;
1548 ab:Hide();
1549 else
1550 ab.showgrid = 1;
1551 ab:Show();
1552 end
1553 end
1554 end
1555 end
1556  
1557 CT_oldActionButton_Update = ActionButton_Update;
1558 function CT_newActionButton_Update()
1559 CT_oldActionButton_Update();
1560 if ( not HasAction(CT_ActionButton_GetPagedID(this)) and this.showgrid == 0 ) then
1561 if ( not CT_ShowGrid or ( ( not CT_BottomBar_Enabled or not CT_BottomBar_Enabled[UnitName("player")] or ( not CT_BottomBar_RotatedFrames[UnitName("player")]["Bars"] and not CT_BottomBar_HiddenFrames[UnitName("player")]["BarHotbarBackgroundLeft"] ) ) and ( strsub(this:GetName(), 1, 12) == "ActionButton" or strsub(this:GetName(), 1, 17) == "BonusActionButton" ) ) ) then
1562 this.showgrid = 0;
1563 this:Hide();
1564 return;
1565 else
1566 this.showgrid = 1;
1567 this:Show();
1568 return;
1569 end
1570 end
1571 if (
1572 ( strsub(this:GetName(), 1, 12) == "ActionButton" and GetBonusBarOffset() > 0 ) or
1573 ( strsub(this:GetName(), 1, 12) == "MultiBarLeft" and not SHOW_MULTI_ACTIONBAR_4 ) or
1574 ( strsub(this:GetName(), 1, 13) == "MultiBarRight" and not SHOW_MULTI_ACTIONBAR_3 ) or
1575 ( strsub(this:GetName(), 1, 18) == "MultiBarBottomLeft" and not SHOW_MULTI_ACTIONBAR_1 ) or
1576 ( strsub(this:GetName(), 1, 19) == "MultiBarBottomRight" and not SHOW_MULTI_ACTIONBAR_2 ) or
1577 ( strsub(this:GetName(), 1, 17) == "BonusActionButton" and GetBonusBarOffset() == 0 )
1578 ) then
1579 this.showgrid = 0;
1580 this:Hide();
1581 elseif ( CT_ShowGrid ) then
1582 this.showgrid = 1;
1583 this:Show();
1584 end
1585 end
1586 ActionButton_Update = CT_newActionButton_Update;
1587  
1588 function CT_newActionButton_UpdateUsable()
1589 local icon = getglobal(this:GetName().."Icon");
1590 if ( not icon ) then
1591 return;
1592 end
1593 local normalTexture = getglobal(this:GetName().."NormalTexture");
1594 local isUsable, notEnoughMana = IsUsableAction(ActionButton_GetPagedID(this));
1595 if ( isUsable ) then
1596 if ( this.inRange and this.inRange == 0 ) then
1597 icon:SetVertexColor(CT_FadeColor.r, CT_FadeColor.g, CT_FadeColor.b);
1598 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(CT_FadeColor.r, CT_FadeColor.g, CT_FadeColor.b); end
1599 else
1600 icon:SetVertexColor(1.0, 1.0, 1.0);
1601 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(1.0, 1.0, 1.0); end
1602 end
1603 elseif ( notEnoughMana ) then
1604 icon:SetVertexColor(0.5, 0.5, 1.0);
1605 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(0.5, 0.5, 1.0); end
1606 else
1607 icon:SetVertexColor(0.4, 0.4, 0.4);
1608 if ( not CT_ShowGrid ) then normalTexture:SetVertexColor(0.4, 0.4, 0.4); end
1609 end
1610 end
1611 ActionButton_UpdateUsable = CT_newActionButton_UpdateUsable;
1612  
1613 ActionButton_HideGrid = CT_ActionButton_HideGrid;
1614  
1615 function CT_newActionButton_ShowGrid(button)
1616 if ( not button ) then
1617 button = this;
1618 end
1619 button.showgrid = button.showgrid+1;
1620 getglobal(button:GetName().."NormalTexture"):SetVertexColor(1.0, 1.0, 1.0, 1.0);
1621  
1622 if (
1623 ( strsub(button:GetName(), 1, 12) == "ActionButton" and ( ( CT_BottomBar_Enabled and CT_BottomBar_Enabled[UnitName("player")] and CT_BottomBar_HiddenFrames[UnitName("player")] and CT_BottomBar_HiddenFrames[UnitName("player")]["BarHotbar"] ) or GetBonusBarOffset() > 0 ) ) or
1624 ( strsub(button:GetName(), 1, 12) == "MultiBarLeft" and not SHOW_MULTI_ACTIONBAR_4 ) or
1625 ( strsub(button:GetName(), 1, 13) == "MultiBarRight" and not SHOW_MULTI_ACTIONBAR_3 ) or
1626 ( strsub(button:GetName(), 1, 18) == "MultiBarBottomLeft" and not SHOW_MULTI_ACTIONBAR_1 ) or
1627 ( strsub(button:GetName(), 1, 19) == "MultiBarBottomRight" and not SHOW_MULTI_ACTIONBAR_2 )
1628 ) then
1629 button:Hide();
1630 elseif ( strsub(button:GetName(), 1, 17) == "BonusActionButton" and ( ( CT_BottomBar_Enabled and CT_BottomBar_Enabled[UnitName("player")] and CT_BottomBar_HiddenFrames[UnitName("player")] and CT_BottomBar_HiddenFrames[UnitName("player")]["BarHotbar"] ) or GetBonusBarOffset() == 0 ) ) then
1631 button:Hide();
1632 else
1633 button:Show();
1634 end
1635 end
1636 ActionButton_ShowGrid = CT_newActionButton_ShowGrid;
1637  
1638 CT_oldActionButton_OnEvent = ActionButton_OnEvent;
1639 function CT_newActionButton_OnEvent(event)
1640  
1641 if ( event == "UPDATE_BONUS_ACTIONBAR" ) then
1642 ActionButton_Update();
1643 else
1644 CT_oldActionButton_OnEvent(event);
1645 end
1646 end
1647 ActionButton_OnEvent = CT_newActionButton_OnEvent;
1648  
1649 MultiActionBar_UpdateGrid = function(barName)
1650 for i=1, NUM_MULTIBAR_BUTTONS do
1651 if ( CT_ShowGrid ) then
1652 ActionButton_ShowGrid(getglobal(barName.."Button"..i));
1653 else
1654 ActionButton_HideGrid(getglobal(barName.."Button"..i));
1655 end
1656 end
1657 end
1658  
1659 function CT_BarMod_GetSpellName(id)
1660 if ( not CTTooltip ) then
1661 return;
1662 end
1663 CTTooltipTextLeft1:SetText("");
1664 CTTooltip:SetAction(id);
1665 local name = CTTooltipTextLeft1:GetText();
1666 if ( name and name ~= "" ) then
1667 return name;
1668 end
1669 end
1670  
1671 CT_BarMod_Cooldowns = { };
1672 CT_BarMod_oldCooldownFrame_SetTimer = CooldownFrame_SetTimer;
1673 function CT_BarMod_newCooldownFrame_SetTimer(this, start, duration, enable)
1674 CT_BarMod_oldCooldownFrame_SetTimer(this, start, duration, enable);
1675 if ( duration >= 2 and start > 0 and enable > 0 ) then
1676 CT_BarMod_Cooldowns[this:GetParent():GetName()] = { start, duration, duration, CT_BarMod_GetSpellName(CT_ActionButton_GetPagedID(this:GetParent())) };
1677 else
1678 CT_BarMod_Cooldowns[this:GetParent():GetName()] = nil;
1679 end
1680 end
1681 CooldownFrame_SetTimer = CT_BarMod_newCooldownFrame_SetTimer;
1682  
1683 function CT_BarMod_UpdateCooldownCount(btn)
1684 if ( not btn ) then
1685 for b = 1, 7, 1 do
1686 local prefix = "CT" .. b .. "_";
1687 if ( b == 1 ) then
1688 prefix = "CT_";
1689 elseif ( b == 6 ) then
1690 prefix = "";
1691 elseif ( b == 7 ) then
1692 prefix = "Bonus";
1693 end
1694 for i = 1, 12, 1 do
1695 if ( CT_CDCount == 1 ) then
1696 local name = prefix .. "ActionButton" .. i;
1697 local btn = getglobal(name);
1698 local id = CT_ActionButton_GetPagedID(btn);
1699 local count = getglobal(name .. "CDCount");
1700 if ( CT_BarMod_Cooldowns[name] and CT_BarMod_Cooldowns[name][3] > 0 ) then
1701 local form = CT_BarMod_FormatCooldown(CT_BarMod_Cooldowns[name][3]);
1702 count:Show();
1703 count:SetText(form);
1704 else
1705 count:Hide();
1706 end
1707 else
1708 getglobal(prefix .. "ActionButton" .. i .. "CDCount"):Hide();
1709 end
1710 end
1711 end
1712 else
1713 if ( CT_CDCount == 1 ) then
1714 local name = btn:GetName();
1715 local id = CT_ActionButton_GetPagedID(btn);
1716 local count = getglobal(btn:GetName() .. "CDCount");
1717 if ( CT_BarMod_Cooldowns[name] and CT_BarMod_Cooldowns[name][3] > 0 ) then
1718 local form = CT_BarMod_FormatCooldown(CT_BarMod_Cooldowns[name][3]);
1719 count:Show();
1720 count:SetText(form);
1721 else
1722 count:Hide();
1723 end
1724 else
1725 getglobal(btn:GetName() .. "CDCount"):Hide();
1726 end
1727 end
1728 end
1729  
1730 function CT_BarMod_FormatCooldown(cd)
1731 if ( cd >= 3600 ) then
1732 return floor(cd/3600) .. "h";
1733 elseif ( cd > 60 ) then
1734 local m = mod(cd, 60);
1735 if ( m < 10 ) then
1736 m = "0" .. m;
1737 end
1738 return floor(cd/60) .. ":" .. m;
1739 else
1740 return cd;
1741 end
1742 end
1743  
1744 function CT_BarMod_FindRanges()
1745 CT_BarMod_MaxRanges = { };
1746 CT_BarMod_MinRanges = { };
1747 for i = 1, 120, 1 do
1748 CTTooltipTextLeft1:SetText("");
1749 CTTooltip:SetAction(i);
1750 if ( CTTooltipTextLeft1:GetText() and CTTooltipTextLeft1:GetText() ~= "" ) then
1751 local range;
1752 for y = 1, CTTooltip:NumLines(), 1 do
1753 CT_Print("Looping " .. y .. "/" .. CTTooltip:NumLines());
1754 local useless, useless, maxRange = string.find(getglobal("CTTooltipTextRight" .. y):GetText() or "", "^(%d+) yd range$");
1755 if ( maxRange ) then
1756 CT_BarMod_MaxRanges[i] = tonumber(maxRange);
1757 break;
1758 else
1759 local useless, useless, maxRange = string.find(getglobal("CTTooltipTextLeft" .. y):GetText() or "", "^(%d+) yd range$");
1760 if ( maxRange ) then
1761 CT_BarMod_MaxRanges[i] = tonumber(maxRange);
1762 break;
1763 else
1764 local useless, useless, minRange, maxRange = string.find(getglobal("CTTooltipTextRight" .. y):GetText() or "", "^(%d+)%-(%d+) yd range$");
1765 if ( str ) then
1766 CT_BarMod_MaxRanges[i] = tonumber(maxRange);
1767 CT_BarMod_MinRanges[i] = tonumber(minRange);
1768 break;
1769 else
1770 local useless, useless, minRange, maxRange = string.find(getglobal("CTTooltipTextLeft" .. y):GetText() or "", "^(%d+)%-(%d+) yd range$");
1771 if ( str ) then
1772 CT_BarMod_MaxRanges[i] = tonumber(maxRange);
1773 CT_BarMod_MinRanges[i] = tonumber(minRange);
1774 break;
1775 end
1776 end
1777 end
1778 end
1779 end
1780 end
1781 end
1782 end
1783  
1784 function CT_BarMod_FindTargetRange()
1785 if ( not UnitExists("target") ) then
1786 return "";
1787 end
1788 local currMin = 0;
1789 local currMax = 1000;
1790 for k, v in CT_BarMod_MaxRanges do
1791 if ( IsActionInRange(v) == 1 and v < currMax ) then
1792 break;
1793 end
1794 end
1795 end
1796  
1797 function CT_BarMod_SetCCScaling(scale)
1798 if ( not CT_BarMod_EnteredWorld ) then
1799 CT_BarMod_RequiresScalingUpdate = scale;
1800 return;
1801 end
1802 for i = 1, 12, 1 do
1803 getglobal("CT_ActionButton" .. i .. "CD"):SetScale(scale);
1804 getglobal("CT2_ActionButton" .. i .. "CD"):SetScale(scale);
1805 getglobal("CT3_ActionButton" .. i .. "CD"):SetScale(scale);
1806 getglobal("CT4_ActionButton" .. i .. "CD"):SetScale(scale);
1807 getglobal("CT5_ActionButton" .. i .. "CD"):SetScale(scale);
1808 getglobal("ActionButton" .. i .. "CD"):SetScale(scale);
1809 getglobal("BonusActionButton" .. i .. "CD"):SetScale(scale);
1810  
1811 getglobal("CT_ActionButton" .. i .. "CD").scale = scale;
1812 getglobal("CT2_ActionButton" .. i .. "CD").scale = scale;
1813 getglobal("CT3_ActionButton" .. i .. "CD").scale = scale;
1814 getglobal("CT4_ActionButton" .. i .. "CD").scale = scale;
1815 getglobal("CT5_ActionButton" .. i .. "CD").scale = scale;
1816 getglobal("ActionButton" .. i .. "CD").scale = scale;
1817 getglobal("BonusActionButton" .. i .. "CD").scale = scale;
1818 end
1819 end
1820  
1821 if ( CT_CPFrame_ShowSlider ) then
1822 -- Add stuff for CC scaling
1823 local function ccscalingonchangefunc(modName, value)
1824 if ( value ) then
1825 CT_Mods[modName]["modValue"] = value;
1826 CT_BarMod_SetCCScaling(value);
1827 CT_SaveInfoName(modName);
1828 end
1829 end
1830  
1831 local function ccscalinginitfunction(modName)
1832 CT_BarMod_SetCCScaling(CT_Mods[modName]["modValue"] or 1);
1833 end
1834  
1835 local function ccscalingfunction(modName, button)
1836 if ( CT_CPFrame_IsSliderVisible() ) then
1837 CT_CPFrame_HideSlider();
1838 else
1839 CT_CPFrame_ShowSlider(button, modName, ( CT_Mods[modName]["modValue"] or 1 ), ccscalingonchangefunc, 0.75, 1.5, 0.05, "0.75", "1.5", modName, "Drag this slider to increase or decrease the size of the CooldownCount text", "%s");
1840 end
1841 end
1842 CT_RegisterMod(BARMOD_MODNAME_CCSCALING, BARMOD_SUB_CCSCALING, 2, "Interface\\Icons\\Spell_Holy_MindVision", BARMOD_TOOLTIP_CCSCALING, "slider", nil, ccscalingfunction, ccscalinginitfunction);
1843 end