vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local ElkBuffBar = {}
2  
3 function ElkBuffBar:Init()
4 BuffFrame:Hide()
5 TemporaryEnchantFrame:Hide()
6  
7 self.frame = ElkBuffBarFrame
8 self.frame:ClearAllPoints()
9 self.frame.owner = self
10 self.frame:SetScript("OnEvent", function() this.owner:OnEvent() end)
11 self.frame:RegisterEvent("ADDON_LOADED")
12  
13 self.tooltip = ElkBuffTooltip
14  
15 self.numBuffButtons = 0
16 self.numBuffsShown = 0
17 self.UpdateTime = 0
18 self.FlashTime = 0
19 self.FlashState = 0
20  
21 self.Layout = {}
22  
23 self.old_hasMainHandEnchant = nil
24 self.old_mainHandName = ""
25 self.old_mainHandExpiration = 0
26 self.old_mainHandCharges = 0
27 self.old_hasOffHandEnchant = nil
28 self.old_offHandName = ""
29 self.old_offHandExpiration = 0
30 self.old_offHandCharges = 0
31  
32 self.compost = AceLibrary("Compost-2.0")
33  
34 if (IsAddOnLoaded("ItemDB_Money")) then
35 EquipCompare_RegisterExclusion("^ElkBuffButton")
36 end
37 end
38  
39 function ElkBuffBar:OnEvent()
40 if event == "ADDON_LOADED" and arg1 == "ElkBuffBar" then
41 self.frame:UnregisterEvent("ADDON_LOADED")
42 self:InitSettings()
43 self.frame:RegisterEvent("PLAYER_AURAS_CHANGED")
44 self.frame:SetScript("OnUpdate", function() this.owner:OnUpdate(arg1) end)
45 self.frame:SetScript("OnLeave", function() this.owner:StopMoving() end)
46 SLASH_ELKBUFFBAR1 = "/ebb"
47 SLASH_ELKBUFFBAR2 = "/elkbuffbar"
48 SlashCmdList["ELKBUFFBAR"] = function(msg) ElkBuffBarFrame.owner:SlashCommandHandler(msg) end
49 elseif event == "PLAYER_AURAS_CHANGED" then
50 self:UpdateBuffs()
51 end
52 end
53  
54 function ElkBuffBar:InitSettings()
55 if not ElkBuffBarOptions then
56 ElkBuffBarOptions = {
57 ["width"] = 250,
58 ["height"] = 20,
59 ["scale"] = 1,
60 ["anchor"] = "TOPRIGHT",
61 ["locked"] = nil,
62 ["alpha"] = 1,
63 ["icon"] = "LEFT",
64 ["sort"] = "DEFAULT",
65 ["timer"] = "DEFAULT",
66 ["invert"] = nil,
67 ["spacing"] = 0,
68 ["group"] = 5,
69 ["dbcolor"] = true,
70 }
71 end
72 if not ElkBuffBarOptions.width then ElkBuffBarOptions.width = 250 end
73 if not ElkBuffBarOptions.height then ElkBuffBarOptions.height = 20 end
74 if not ElkBuffBarOptions.scale then ElkBuffBarOptions.scale = 1 end
75 if not ElkBuffBarOptions.anchor then ElkBuffBarOptions.anchor = "TOPRIGHT" end
76 if not ElkBuffBarOptions.alpha then ElkBuffBarOptions.alpha = 1 end
77 if not ElkBuffBarOptions.icon then ElkBuffBarOptions.icon = "LEFT" end
78 if not ElkBuffBarOptions.sort then ElkBuffBarOptions.sort = "DEFAULT" end
79 if not ElkBuffBarOptions.timer then ElkBuffBarOptions.timer = "DEFAULT" end
80 if not ElkBuffBarOptions.spacing then ElkBuffBarOptions.spacing = 0 end
81 if not ElkBuffBarOptions.group then ElkBuffBarOptions.group = 5 end
82 if not ElkBuffBarOptions.dbcolor then ElkBuffBarOptions.dbcolor = true end
83 if not ElkBuffBarOptions.x then ElkBuffBarOptions.x = floor(GetScreenWidth() * .5 / (GetCVar("uiscale") * ElkBuffBarOptions.scale)) end
84 if not ElkBuffBarOptions.y then ElkBuffBarOptions.y = floor(GetScreenHeight() * .5 / (GetCVar("uiscale") * ElkBuffBarOptions.scale)) end
85 self:UpdateLayout()
86 end
87  
88 local function buffssort_bytimeleft(a, b)
89 if (not a or not b) then
90 return true
91 end
92 if a[5] == 1 then
93 if b[5] == 1 then
94 return a[2] < b[2]
95 else
96 return true
97 end
98 end
99 if b[5] == 1 then
100 return false
101 end
102 if a[3] > b[3] then
103 return true
104 end
105 if a[3] < b[3] then
106 return false
107 end
108 return a[2] < b[2]
109 end
110  
111 local function buffssort_bytimemax(a, b)
112 if (not a or not b) then
113 return true
114 end
115 if a[5] == 1 then
116 if b[5] == 1 then
117 return a[2] < b[2]
118 else
119 return true
120 end
121 end
122 if b[5] == 1 then
123 return false
124 end
125 if a[4] > b[4] then
126 return true
127 end
128 if a[4] < b[4] then
129 return false
130 end
131 return a[2] < b[2]
132 end
133  
134 local function isEmpty(ttbl)
135 for _,_ in ttbl do
136 return false
137 end
138 return true
139 end
140  
141 function ElkBuffBar:UpdateBuffs()
142 local maxtimes = self.compost:Acquire()
143 local buffssort = self.compost:Acquire()
144 for i = 1, self.numBuffsShown do
145 local button = getglobal("ElkBuffButton"..i)
146 if not maxtimes[button.name] or maxtimes[button.name] < button.maxtime then
147 maxtimes[button.name] = button.maxtime
148 end
149 end
150 local numBuffs = 0
151 local buffIndex, untilCancelled
152 local i = 0
153 while true do
154 buffIndex, untilCancelled = GetPlayerBuff(i, "HELPFUL")
155 if buffIndex < 0 then break end
156  
157 local timeleft = GetPlayerBuffTimeLeft(buffIndex)
158 local timemax = timeleft
159  
160 local name = self:GetBuffName(buffIndex)
161 if (name) then
162 if maxtimes[name] and timemax < maxtimes[name] then
163 timemax = maxtimes[name]
164 end
165 end
166  
167 table.insert(buffssort, self.compost:Acquire(buffIndex, name, timeleft, timemax, untilCancelled))
168 i = i + 1
169 end
170 if ElkBuffBarOptions.sort == "TIMEMAX" then
171 table.sort(buffssort, buffssort_bytimemax)
172 elseif ElkBuffBarOptions.sort == "TIMELEFT" then
173 table.sort(buffssort, buffssort_bytimeleft)
174 end
175 for it = 1, table.getn(buffssort) do
176 numBuffs = numBuffs + 1
177 self:SetBuffButtonBuff(numBuffs, buffssort[it][1], buffssort[it][2], buffssort[it][3], buffssort[it][4], buffssort[it][5])
178 end
179 buffssort = self.compost:Reclaim(buffssort, 1)
180 buffssort = self.compost:Acquire()
181 i = 0
182 while true do
183 buffIndex, untilCancelled = GetPlayerBuff(i, "HARMFUL")
184 if buffIndex < 0 then break end
185 local timeleft = GetPlayerBuffTimeLeft(buffIndex)
186 local timemax = timeleft
187  
188 local name = self:GetBuffName(buffIndex)
189 if (name) then
190 if maxtimes[name] and timemax < maxtimes[name] then
191 timemax = maxtimes[name]
192 end
193 end
194  
195 table.insert(buffssort, self.compost:Acquire(buffIndex, name, timeleft, timemax, untilCancelled))
196 i = i + 1
197 end
198 if ElkBuffBarOptions.sort == "TIMEMAX" then
199 table.sort(buffssort, buffssort_bytimemax)
200 elseif ElkBuffBarOptions.sort == "TIMELEFT" then
201 table.sort(buffssort, buffssort_bytimeleft)
202 end
203 for it = 1, table.getn(buffssort) do
204 numBuffs = numBuffs + 1
205 self:SetBuffButtonDebuff(numBuffs, buffssort[it][1], buffssort[it][2], buffssort[it][3], buffssort[it][4], buffssort[it][5])
206 end
207 buffssort = self.compost:Reclaim(buffssort, 1)
208 buffssort = self.compost:Acquire()
209 local hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo()
210 if ( hasMainHandEnchant ) then
211 local timeleft = mainHandExpiration / 1000
212 local timemax = timeleft
213  
214 local id = GetInventorySlotInfo("MainHandSlot")
215 local name = self:GetTempBuffName(id)
216 if (name) then
217 if maxtimes[name] and timemax < maxtimes[name] then
218 timemax = maxtimes[name]
219 end
220 end
221 table.insert(buffssort, self.compost:Acquire(id, name, timeleft, timemax, mainHandCharges))
222 end
223 if ( hasOffHandEnchant ) then
224 local timeleft = offHandExpiration / 1000
225 local timemax = timeleft
226  
227 local id = GetInventorySlotInfo("SecondaryHandSlot")
228 local name = self:GetTempBuffName(id)
229 if (name) then
230 if maxtimes[name] and timemax < maxtimes[name] then
231 timemax = maxtimes[name]
232 end
233 end
234 oldn = table.getn(buffssort)
235 table.insert(buffssort, self.compost:Acquire(id, name, timeleft, timemax, offHandCharges))
236 end
237 if ElkBuffBarOptions.sort == "TIMEMAX" then
238 table.sort(buffssort, buffssort_bytimemax)
239 elseif ElkBuffBarOptions.sort == "TIMELEFT" then
240 table.sort(buffssort, buffssort_bytimeleft)
241 end
242 for it = 1, table.getn(buffssort) do
243 numBuffs = numBuffs + 1
244 self:SetBuffButtonWeapon(numBuffs, buffssort[it][1], buffssort[it][2], buffssort[it][3], buffssort[it][4], buffssort[it][5])
245 end
246 self:Cleanup(numBuffs)
247 self.numBuffsShown = numBuffs
248 self:UpdateButtonPositions()
249 maxtimes = self.compost:Reclaim(maxtimes)
250 buffssort = self.compost:Reclaim(buffssort, 1)
251 end
252  
253 function ElkBuffBar:SetBuffButtonBuff(buttonid, id, buffname, timeleft, timemax, cancel)
254 self:CreateButtons(buttonid)
255 local button = getglobal("ElkBuffButton"..buttonid)
256 local bar = getglobal("ElkBuffButton"..buttonid.."TimeBar")
257 local icon = getglobal("ElkBuffButton"..buttonid.."Icon")
258 local name = getglobal("ElkBuffButton"..buttonid.."DescribeText")
259 local buffCount = getglobal("ElkBuffButton"..buttonid.."Count")
260 local duration = getglobal("ElkBuffButton"..buttonid.."DurationText")
261 local debuff = getglobal("ElkBuffButton"..buttonid.."DebuffBorder")
262 local tench = getglobal("ElkBuffButton"..buttonid.."TEnchBorder")
263  
264 button:SetAlpha(self.frame:GetAlpha())
265 button.type = "BUFF"
266 button.id = id
267 button.untilCancelled = cancel
268 button:SetBackdropColor(0.3, 0.5, 1, 0.5)
269 bar:SetStatusBarColor(0, 0.5, 1, 0.8)
270 icon:SetTexture(GetPlayerBuffTexture(id))
271  
272 button.timeleft = timeleft
273 button.maxtime = timemax
274 bar:SetMinMaxValues(0, button.maxtime)
275  
276 button.name = buffname or "Buff "..id
277 local count = GetPlayerBuffApplications(id)
278 if ( count > 1 ) then
279 name:SetText((buffname or "Buff "..id).." x"..count)
280 buffCount:SetText(count)
281 buffCount:Show()
282 else
283 name:SetText(buffname or "Buff "..id)
284 buffCount:Hide()
285 end
286 debuff:Hide()
287 tench:Hide()
288 button:Show()
289 end
290  
291 function ElkBuffBar:SetBuffButtonDebuff(buttonid, id, buffname, timeleft, timemax, cancel)
292 self:CreateButtons(buttonid)
293 local button = getglobal("ElkBuffButton"..buttonid)
294 local bar = getglobal("ElkBuffButton"..buttonid.."TimeBar")
295 local icon = getglobal("ElkBuffButton"..buttonid.."Icon")
296 local name = getglobal("ElkBuffButton"..buttonid.."DescribeText")
297 local buffCount = getglobal("ElkBuffButton"..buttonid.."Count")
298 local duration = getglobal("ElkBuffButton"..buttonid.."DurationText")
299 local debuff = getglobal("ElkBuffButton"..buttonid.."DebuffBorder")
300 local tench = getglobal("ElkBuffButton"..buttonid.."TEnchBorder")
301  
302 button:SetAlpha(self.frame:GetAlpha())
303 button.type = "DEBUFF"
304 button.id = id
305 button.untilCancelled = cancel
306 button:SetBackdropColor(1, 0, 0, 0.5)
307 icon:SetTexture(GetPlayerBuffTexture(id))
308  
309 button.timeleft = timeleft
310 button.maxtime = timemax
311 bar:SetMinMaxValues(0, button.maxtime)
312  
313 button.name = buffname or "Debuff "..id
314 local count = GetPlayerBuffApplications(id)
315 if ( count > 1 ) then
316 name:SetText((buffname or "Debuff "..id).." x"..count)
317 buffCount:SetText(count)
318 buffCount:Show()
319 else
320 name:SetText(buffname or "Debuff "..id)
321 buffCount:Hide()
322 end
323 local color
324 local debuffType = GetPlayerBuffDispelType(id)
325 if ( debuffType ) then
326 color = DebuffTypeColor[debuffType]
327 else
328 color = DebuffTypeColor["none"]
329 end
330 debuff:SetVertexColor(color.r, color.g, color.b)
331 if ElkBuffBarOptions.dbcolor then
332 bar:SetStatusBarColor(color.r, color.g, color.b, 0.8)
333 else
334 bar:SetStatusBarColor(1, 0, 0, 0.8)
335 end
336 debuff:Show()
337 tench:Hide()
338 button:Show()
339 end
340  
341 function ElkBuffBar:SetBuffButtonWeapon(buttonid, id, buffname, timeleft, timemax, count)
342 self:CreateButtons(buttonid)
343 local button = getglobal("ElkBuffButton"..buttonid)
344 local bar = getglobal("ElkBuffButton"..buttonid.."TimeBar")
345 local icon = getglobal("ElkBuffButton"..buttonid.."Icon")
346 local name = getglobal("ElkBuffButton"..buttonid.."DescribeText")
347 local buffCount = getglobal("ElkBuffButton"..buttonid.."Count")
348 local duration = getglobal("ElkBuffButton"..buttonid.."DurationText")
349 local debuff = getglobal("ElkBuffButton"..buttonid.."DebuffBorder")
350 local tench = getglobal("ElkBuffButton"..buttonid.."TEnchBorder")
351  
352 button:SetAlpha(self.frame:GetAlpha())
353 button.type = "WEAPON"
354 button.id = id
355 button.untilCancelled = 0
356 button:SetBackdropColor(0.5, 0, 0.5, 0.5)
357 bar:SetStatusBarColor(0.5, 0, 0.5, 0.8)
358 icon:SetTexture(GetInventoryItemTexture("player", id))
359  
360 button.timeleft = timeleft
361 button.maxtime = timemax
362 bar:SetMinMaxValues(0, button.maxtime)
363 button.name = buffname or "Weapon "..id
364  
365 if ( count > 1 ) then
366 name:SetText((buffname or "Weapon "..id).." x"..count)
367 buffCount:SetText(count)
368 buffCount:Show()
369 else
370 name:SetText(buffname or "Weapon "..id)
371 buffCount:Hide()
372 end
373 debuff:Hide()
374 tench:Show()
375 button:Show()
376 end
377  
378 function ElkBuffBar:CreateButtons(numButtons)
379 if numButtons > self.numBuffButtons then
380 for i = self.numBuffButtons + 1, numButtons do
381 local f = CreateFrame("Button", "ElkBuffButton"..i, self.frame, "ElkBuffBar_BuffButtonTemplate")
382 self:UpdateButtonPosition(i)
383 self:UpdateButtonHeight(i)
384 self:UpdateButtonIcon(i)
385 self:UpdateButtonTimer(i)
386 f.owner = self
387 f:SetScript("OnMouseDown", function() if arg1 == "LeftButton" then this.isMoving = true; this.owner:StartMoving() end end)
388 f:SetScript("OnMouseUp", function() if arg1 == "LeftButton" then this.isMoving = false; this.owner:StopMoving() end end)
389 f:SetScript("OnHide", function() if this.isMoving then this.owner:StopMoving() end end)
390 f:RegisterForClicks("RightButtonUp")
391 f:SetScript("OnClick", function() this.owner:ButtonOnClick() end)
392 f:SetScript("OnEnter", function() this.owner:ButtonOnEnter() end)
393 f:SetScript("OnLeave", function() this.owner:ButtonOnLeave() end)
394 getglobal("ElkBuffButton"..i.."DescribeText"):SetTextColor(1, 1, 1)
395 getglobal("ElkBuffButton"..i.."DurationText"):SetTextColor(1, 1, 1)
396 end
397 self.numBuffButtons = numButtons
398 end
399 end
400  
401 function ElkBuffBar:Cleanup(numBuffs)
402 if numBuffs < self.numBuffButtons then
403 for i = numBuffs + 1, self.numBuffButtons do
404 local button = getglobal("ElkBuffButton"..i)
405 button.id = nil
406 button:Hide()
407 end
408 end
409 end
410  
411 function ElkBuffBar:GetBuffName(id)
412 self.tooltip:SetPlayerBuff(id)
413 local toolTipText = getglobal("ElkBuffTooltipTextLeft1")
414 if (toolTipText) then
415 return toolTipText:GetText() or id
416 end
417 return id
418 end
419  
420 function ElkBuffBar:GetTempBuffName(id)
421 self.tooltip:SetInventoryItem("player", id)
422 for i=1,self.tooltip:NumLines() do
423 local toolTipText = getglobal("ElkBuffTooltipTextLeft" .. i)
424 local _, _, buffname = string.find(toolTipText:GetText(), "^([^%(]+) %(%d+ [^%)]+%)")
425 if buffname then
426 return buffname
427 end
428 end
429 local itemlink = GetInventoryItemLink("player", id);
430 if (itemlink) then
431 local _, _, name = string.find(itemlink, "|c%x+|Hitem:%d+:%d+:%d+:%d+|h%[(.-)%]|h|r");
432 return name or "Weapon "..id
433 end
434 return "Weapon "..id
435 end
436  
437 function ElkBuffBar:OnUpdate(elapsed)
438 local hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo()
439 local mainHandName = ""
440 if hasMainHandEnchant then
441 mainHandName = self:GetTempBuffName(GetInventorySlotInfo("MainHandSlot"))
442 end
443 local offHandName = ""
444 if hasOffHandEnchant then
445 offHandName = self:GetTempBuffName(GetInventorySlotInfo("SecondaryHandSlot"))
446 end
447  
448 hasMainHandEnchant = hasMainHandEnchant or false
449 mainHandName = mainHandName or ""
450 mainHandExpiration = mainHandExpiration or 0
451 mainHandCharges = mainHandCharges or 0
452 hasOffHandEnchant = hasOffHandEnchant or false
453 offHandName = offHandName or ""
454 offHandExpiration = offHandExpiration or 0
455 offHandCharges = offHandCharges or 0
456  
457 if hasMainHandEnchant ~= self.old_hasMainHandEnchant or mainHandName ~= self.old_mainHandName or mainHandExpiration > self.old_mainHandExpiration or mainHandCharges ~= self.old_mainHandCharges or hasOffHandEnchant ~= self.old_hasOffHandEnchant or offHandName ~= self.old_offHandName or offHandExpiration > self.old_offHandExpiration or offHandCharges ~= self.old_offHandCharges then
458 self:UpdateBuffs()
459 end
460 self.old_hasMainHandEnchant = hasMainHandEnchant
461 self.old_mainHandName = mainHandName
462 self.old_mainHandExpiration = mainHandExpiration
463 self.old_mainHandCharges = mainHandCharges
464 self.old_hasOffHandEnchant = hasOffHandEnchant
465 self.old_offHandName = offHandName
466 self.old_offHandExpiration = offHandExpiration
467 self.old_offHandCharges = offHandCharges
468  
469 if ( self.UpdateTime > 0 ) then
470 self.UpdateTime = self.UpdateTime - elapsed
471 else
472 self.UpdateTime = self.UpdateTime + TOOLTIP_UPDATE_TIME
473 end
474  
475 self.FlashTime = self.FlashTime - elapsed
476 if ( self.FlashTime < 0 ) then
477 local overtime = -self.FlashTime
478 if ( self.FlashState == 0 ) then
479 self.FlashState = 1
480 self.FlashTime = BUFF_FLASH_TIME_ON
481 else
482 self.FlashState = 0
483 self.FlashTime = BUFF_FLASH_TIME_OFF
484 end
485 if ( overtime < self.FlashTime ) then
486 self.FlashTime = self.FlashTime - overtime
487 end
488 end
489  
490 if ( self.FlashState == 1 ) then
491 self.BuffAlphaValue = (BUFF_FLASH_TIME_ON - self.FlashTime) / BUFF_FLASH_TIME_ON
492 else
493 self.BuffAlphaValue = self.FlashTime / BUFF_FLASH_TIME_ON
494 end
495 self.BuffAlphaValue = ((self.BuffAlphaValue * (1 - BUFF_MIN_ALPHA)) + BUFF_MIN_ALPHA) * self.frame:GetAlpha()
496  
497 local mustupdate = nil
498 for i = 1, self.numBuffsShown do
499 local button = getglobal("ElkBuffButton"..i)
500 local duration = getglobal("ElkBuffButton"..i.."DurationText")
501 local bar = getglobal("ElkBuffButton"..i.."TimeBar")
502 if button.untilCancelled ~= 1 then
503 local timeleft = 0
504 if button.type == "BUFF" or button.type == "DEBUFF" then
505 timeleft = GetPlayerBuffTimeLeft(button.id)
506 elseif button.type == "WEAPON" then
507 local hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo()
508 if button.id == GetInventorySlotInfo("MainHandSlot") then
509 timeleft = mainHandExpiration / 1000
510 end
511 if button.id == GetInventorySlotInfo("SecondaryHandSlot") then
512 timeleft = offHandExpiration / 1000
513 end
514 end
515 if ( timeleft < BUFF_WARNING_TIME ) then
516 button:SetAlpha(self.BuffAlphaValue)
517 else
518 button:SetAlpha(self.frame:GetAlpha())
519 end
520 if ElkBuffBarOptions.timer == "DEFAULT" then
521 duration:SetText(SecondsToTimeAbbrev(timeleft))
522 duration:Show()
523 elseif ElkBuffBarOptions.timer == "FULL" then
524 local seconds = timeleft
525 local temptime
526 local time = ""
527 if seconds >= 3600 then
528 tempTime = floor(seconds / 3600)
529 time = time..tempTime..":"
530 seconds = mod(seconds, 3600)
531 end
532 if seconds >= 60 then
533 tempTime = floor(seconds / 60)
534 if time ~= "" and tempTime < 10 then
535 time = time.."0"..tempTime..":"
536 else
537 time = time..tempTime..":"
538 end
539 seconds = mod(seconds, 60)
540 end
541 if seconds >= 0 then
542 tempTime = format("%d", seconds)
543 if time ~= "" and seconds < 10 then
544 time = time.."0"..tempTime
545 else
546 time = time..tempTime
547 end
548 end
549 duration:SetText(time)
550 duration:Show()
551 else
552 duration:Hide()
553 end
554 bar:SetValue(timeleft)
555 bar:Show()
556 if button.timeleft < timeleft then
557 mustupdate = true
558 end
559 button.timeleft = timeleft
560 else
561 duration:Hide()
562 bar:Hide()
563 end
564 end
565  
566 if mustupdate then
567 self:UpdateBuffs()
568 end
569  
570 if ( self.UpdateTime > 0 ) then
571 return
572 end
573 if ( GameTooltip:IsOwned(this) ) then
574 self:ButtonOnEnter()
575 end
576 end
577  
578 function ElkBuffBar:ButtonOnEnter()
579 if this.type == "BUFF" or this.type == "DEBUFF" then
580 GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT")
581 GameTooltip:SetPlayerBuff(this.id)
582 elseif this.type == "WEAPON" then
583 GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT")
584 GameTooltip:SetInventoryItem("player", this.id)
585 end
586 end
587  
588 function ElkBuffBar:ButtonOnLeave()
589 GameTooltip:Hide()
590 end
591  
592 function ElkBuffBar:ButtonOnClick()
593 if this.type == "BUFF" or this.type == "DEBUFF" then
594 CancelPlayerBuff(this.id)
595 end
596 end
597  
598 function ElkBuffBar:StartMoving()
599 if not self.Layout.locked then
600 self.frame:StartMoving()
601 end
602 end
603  
604 function ElkBuffBar:StopMoving()
605 self.frame:StopMovingOrSizing()
606 if ElkBuffBarOptions.anchor == "TOPLEFT" then
607 ElkBuffBarOptions.x = floor(self.frame:GetLeft() + .5)
608 ElkBuffBarOptions.y = floor(self.frame:GetTop() + .5)
609 elseif ElkBuffBarOptions.anchor == "TOPRIGHT" then
610 ElkBuffBarOptions.x = floor(self.frame:GetRight() + .5)
611 ElkBuffBarOptions.y = floor(self.frame:GetTop() + .5)
612 elseif ElkBuffBarOptions.anchor == "BOTTOMLEFT" then
613 ElkBuffBarOptions.x = floor(self.frame:GetLeft() + .5)
614 ElkBuffBarOptions.y = floor(self.frame:GetBottom() + .5)
615 elseif ElkBuffBarOptions.anchor == "BOTTOMRIGHT" then
616 ElkBuffBarOptions.x = floor(self.frame:GetRight() + .5)
617 ElkBuffBarOptions.y = floor(self.frame:GetBottom() + .5)
618 end
619 self:UpdateLayout()
620 end
621  
622 function ElkBuffBar:UpdateLayout()
623 if not self.Layout.width or self.Layout.width ~= ElkBuffBarOptions.width then
624 self.frame:SetWidth(ElkBuffBarOptions.width)
625 self.Layout.width = ElkBuffBarOptions.width
626 end
627 if not self.Layout.height or self.Layout.height ~= ElkBuffBarOptions.height then
628 for i = 1, self.numBuffButtons do
629 self:UpdateButtonHeight(i)
630 end
631 self.Layout.height = ElkBuffBarOptions.height
632 end
633 if not self.Layout.scale or self.Layout.scale ~= ElkBuffBarOptions.scale then
634 self.frame:SetScale(ElkBuffBarOptions.scale)
635 if self.Layout.scale and ElkBuffBarOptions.x and ElkBuffBarOptions.y then
636 ElkBuffBarOptions.x = floor(ElkBuffBarOptions.x * self.Layout.scale / ElkBuffBarOptions.scale)
637 ElkBuffBarOptions.y = floor(ElkBuffBarOptions.y * self.Layout.scale / ElkBuffBarOptions.scale)
638 end
639 self.Layout.scale = ElkBuffBarOptions.scale
640 end
641 if ElkBuffBarOptions.x and ElkBuffBarOptions.y and ((not self.Layout.x or self.Layout.x ~= ElkBuffBarOptions.x) or (not self.Layout.y or self.Layout.y ~= ElkBuffBarOptions.y) or (not self.Layout.anchor or self.Layout.anchor ~= ElkBuffBarOptions.anchor)) then
642 if self.Layout.anchor and self.Layout.anchor ~= ElkBuffBarOptions.anchor then
643 local x, y
644 if self.Layout.anchor == "TOPLEFT" then
645 x = ElkBuffBarOptions.x
646 y = ElkBuffBarOptions.y - self.frame:GetHeight()
647 elseif self.Layout.anchor == "TOPRIGHT" then
648 x = ElkBuffBarOptions.x - self.frame:GetWidth()
649 y = ElkBuffBarOptions.y - self.frame:GetHeight()
650 elseif self.Layout.anchor == "BOTTOMLEFT" then
651 x = ElkBuffBarOptions.x
652 y = ElkBuffBarOptions.y
653 elseif self.Layout.anchor == "BOTTOMRIGHT" then
654 x = ElkBuffBarOptions.x - self.frame:GetWidth()
655 y = ElkBuffBarOptions.y
656 end
657 if ElkBuffBarOptions.anchor == "TOPLEFT" then
658 ElkBuffBarOptions.x = floor(x + .5)
659 ElkBuffBarOptions.y = floor(y + self.frame:GetHeight() + .5)
660 elseif ElkBuffBarOptions.anchor == "TOPRIGHT" then
661 ElkBuffBarOptions.x = floor(x + self.frame:GetWidth() + .5)
662 ElkBuffBarOptions.y = floor(y + self.frame:GetHeight() + .5)
663 elseif ElkBuffBarOptions.anchor == "BOTTOMLEFT" then
664 ElkBuffBarOptions.x = floor(x + .5)
665 ElkBuffBarOptions.y = floor(y + .5)
666 elseif ElkBuffBarOptions.anchor == "BOTTOMRIGHT" then
667 ElkBuffBarOptions.x = floor(x + self.frame:GetWidth() + .5)
668 ElkBuffBarOptions.y = floor(y + .5)
669 end
670 end
671 self.frame:ClearAllPoints()
672 self.frame:SetPoint(ElkBuffBarOptions.anchor, UIParent, "BOTTOMLEFT", ElkBuffBarOptions.x, ElkBuffBarOptions.y)
673 self.Layout.x = ElkBuffBarOptions.x
674 self.Layout.y = ElkBuffBarOptions.y
675 self.Layout.anchor = ElkBuffBarOptions.anchor
676 end
677 if (not self.Layout.locked and ElkBuffBarOptions.locked) or (self.Layout.locked and not ElkBuffBarOptions.locked) then
678 self.Layout.locked = ElkBuffBarOptions.locked
679 end
680 if not self.Layout.alpha or self.Layout.alpha ~= ElkBuffBarOptions.alpha then
681 self.frame:SetAlpha(ElkBuffBarOptions.alpha)
682 self.Layout.alpha = ElkBuffBarOptions.alpha
683 end
684 if not self.Layout.icon or self.Layout.icon ~= ElkBuffBarOptions.icon then
685 for i = 1, self.numBuffButtons do
686 self:UpdateButtonIcon(i)
687 end
688 self.Layout.icon = ElkBuffBarOptions.icon
689 end
690 if not self.Layout.sort or self.Layout.sort ~= ElkBuffBarOptions.sort then
691 self:UpdateBuffs()
692 self.Layout.sort = ElkBuffBarOptions.sort
693 end
694 if not self.Layout.timer or self.Layout.timer ~= ElkBuffBarOptions.timer then
695 for i = 1, self.numBuffButtons do
696 self:UpdateButtonTimer(i)
697 end
698 self.Layout.timer = ElkBuffBarOptions.timer
699 end
700 if (not self.Layout.invert and ElkBuffBarOptions.invert) or (self.Layout.invert and not ElkBuffBarOptions.invert) then
701 self:UpdateButtonPositions()
702 self.Layout.invert = ElkBuffBarOptions.invert
703 end
704 if not self.Layout.spacing or self.Layout.spacing ~= ElkBuffBarOptions.spacing then
705 self:UpdateButtonPositions()
706 self.Layout.spacing = ElkBuffBarOptions.spacing
707 end
708 if not self.Layout.group or self.Layout.group ~= ElkBuffBarOptions.group then
709 self:UpdateButtonPositions()
710 self.Layout.group = ElkBuffBarOptions.group
711 end
712 if not self.Layout.dbcolor or self.Layout.dbcolor ~= ElkBuffBarOptions.dbcolor then
713 self:UpdateBuffs()
714 self.Layout.dbcolor = ElkBuffBarOptions.dbcolor
715 end
716 end
717  
718 function ElkBuffBar:UpdateButtonHeight(buttonid)
719 local button = getglobal("ElkBuffButton"..buttonid)
720 local icon = getglobal("ElkBuffButton"..buttonid.."Icon")
721 button:SetHeight(ElkBuffBarOptions.height)
722 icon:SetWidth(ElkBuffBarOptions.height)
723 icon:SetHeight(ElkBuffBarOptions.height)
724 self:UpdateButtonIcon(buttonid)
725 self:UpdateButtonPositions(true)
726 end
727  
728 function ElkBuffBar:UpdateButtonIcon(buttonid)
729 local button = getglobal("ElkBuffButton"..buttonid)
730 local icon = getglobal("ElkBuffButton"..buttonid.."Icon")
731 local bar = getglobal("ElkBuffButton"..buttonid.."TimeBar")
732 if ElkBuffBarOptions.icon == "LEFT" then
733 icon:ClearAllPoints()
734 icon:SetPoint("TOPLEFT", button, "TOPLEFT")
735 icon:Show()
736 bar:ClearAllPoints()
737 bar:SetPoint("TOPLEFT", button, "TOPLEFT", ElkBuffBarOptions.height, 0)
738 bar:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT")
739 elseif ElkBuffBarOptions.icon == "RIGHT" then
740 icon:ClearAllPoints()
741 icon:SetPoint("TOPRIGHT", button, "TOPRIGHT")
742 icon:Show()
743 bar:ClearAllPoints()
744 bar:SetPoint("TOPLEFT", button, "TOPLEFT")
745 bar:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -ElkBuffBarOptions.height, 0)
746 else
747 icon:Hide()
748 bar:ClearAllPoints()
749 bar:SetPoint("TOPLEFT", button, "TOPLEFT")
750 bar:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT")
751 end
752 end
753  
754 function ElkBuffBar:UpdateButtonTimer(buttonid)
755 local name = getglobal("ElkBuffButton"..buttonid.."DescribeText")
756 local duration = getglobal("ElkBuffButton"..buttonid.."DurationText")
757 if ElkBuffBarOptions.timer == "NONE" then
758 name:SetPoint("RIGHT", -2, 0)
759 duration:SetText("")
760 duration:Hide()
761 else
762 name:SetPoint("RIGHT", -35, 0)
763 duration:SetText("")
764 duration:Show()
765 end
766 end
767  
768 function ElkBuffBar:UpdateButtonPosition(buttonid, space)
769 local space = space or 0
770 local button = getglobal("ElkBuffButton"..buttonid)
771 button:ClearAllPoints()
772 button:SetPoint("LEFT", self.frame, "LEFT")
773 button:SetPoint("RIGHT", self.frame, "RIGHT")
774 if buttonid > 1 then
775 if (ElkBuffBarOptions.invert) then
776 button:SetPoint("BOTTOM", getglobal("ElkBuffButton"..(buttonid-1)), "TOP", 0, space)
777 else
778 button:SetPoint("TOP", getglobal("ElkBuffButton"..(buttonid-1)), "BOTTOM", 0, -space)
779 end
780 else
781 if (ElkBuffBarOptions.invert) then
782 button:SetPoint("BOTTOM", self.frame, "BOTTOM")
783 else
784 button:SetPoint("TOP", self.frame, "TOP")
785 end
786 end
787 end
788  
789 function ElkBuffBar:UpdateButtonPositions(onlyheight)
790 if self.numBuffsShown > 0 then
791 local groupspacer = 0
792 local lasttype
793 for i = 1, self.numBuffsShown do
794 local button = getglobal("ElkBuffButton"..i)
795 if lasttype and button.type ~= lasttype then
796 if not onlyheight then
797 self:UpdateButtonPosition(i, ElkBuffBarOptions.spacing + ElkBuffBarOptions.group)
798 end
799 groupspacer = groupspacer + 1
800 elseif not onlyheight then
801 self:UpdateButtonPosition(i, ElkBuffBarOptions.spacing)
802 end
803 lasttype = button.type
804 end
805 self.frame:SetHeight(self.numBuffsShown * ElkBuffBarOptions.height + (self.numBuffsShown - 1) * ElkBuffBarOptions.spacing + groupspacer * ElkBuffBarOptions.group)
806 else
807 self.frame:SetHeight(ElkBuffBarOptions.height)
808 end
809 end
810  
811 function ElkBuffBar:SlashCommandHandler(msg)
812 local _, _, carg1, carg2 = string.find(msg, "^([^ ]+)$")
813 if not carg1 then
814 _, _, carg1, carg2 = string.find(msg, "^([^ ]+)[ ]+([^ ]+)")
815 end
816 if carg1 then
817 carg1 = string.lower(carg1)
818 end
819 -- print("|cffffff00[ElkBuffBar]|r msg is >|cffff0000"..(msg or "NIL").."|r<, carg1 is >|cffff0000"..(carg1 or "NIL").."|r<, carg2 is >|cffff0000"..(carg2 or "NIL").."|r<")
820 if not carg1 then
821 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r command line options:")
822 DEFAULT_CHAT_FRAME:AddMessage(" - reset : resets all values to default")
823 DEFAULT_CHAT_FRAME:AddMessage(" - resetpos : resets position and scale to default")
824 DEFAULT_CHAT_FRAME:AddMessage(" - width [100+] : sets the button's width (is |cffff0000"..ElkBuffBarOptions.width.."|r)")
825 DEFAULT_CHAT_FRAME:AddMessage(" - height [10+] : sets the button's height (is |cffff0000"..ElkBuffBarOptions.height.."|r)")
826 DEFAULT_CHAT_FRAME:AddMessage(" - scale [0.0+] : sets the button's scale (is |cffff0000"..ElkBuffBarOptions.scale.."|r)")
827 DEFAULT_CHAT_FRAME:AddMessage(" - anchor [TOPLEFT/-RIGHT/BOTTOMLEFT/-RIGHT] : sets anchor (is |cffff0000"..ElkBuffBarOptions.anchor.."|r)")
828 DEFAULT_CHAT_FRAME:AddMessage(" - locked [TRUE/FALSE] : toggles locked state (is |cffff0000"..(ElkBuffBarOptions.locked and "TRUE" or "FALSE").."|r)")
829 DEFAULT_CHAT_FRAME:AddMessage(" - alpha [0.0-1.0] : sets the button's alpha value (is |cffff0000"..ElkBuffBarOptions.alpha.."|r)")
830 DEFAULT_CHAT_FRAME:AddMessage(" - icon [LEFT/RIGHT/NONE] : sets the icon positions (is |cffff0000"..ElkBuffBarOptions.icon.."|r)")
831 DEFAULT_CHAT_FRAME:AddMessage(" - sort [DEFAULT/TIMEMAX/TIMELEFT] : sets the sort style (is |cffff0000"..ElkBuffBarOptions.sort.."|r)")
832 DEFAULT_CHAT_FRAME:AddMessage(" - timer [DEFAULT/NONE/FULL] : sets the timer style (is |cffff0000"..ElkBuffBarOptions.timer.."|r)")
833 DEFAULT_CHAT_FRAME:AddMessage(" - invert [TRUE/FALSE] : toggles inverting of buffs (is |cffff0000"..(ElkBuffBarOptions.invert and "TRUE" or "FALSE").."|r)")
834 DEFAULT_CHAT_FRAME:AddMessage(" - spacing [0+] : set space between bars (is |cffff0000"..ElkBuffBarOptions.spacing.."|r)")
835 DEFAULT_CHAT_FRAME:AddMessage(" - group [0+] : set additionsl space between the buff groups (is |cffff0000"..ElkBuffBarOptions.group.."|r)")
836 DEFAULT_CHAT_FRAME:AddMessage(" - dbcolor [TRUE/FALSE] : toggles type colored debuffs (is |cffff0000"..(ElkBuffBarOptions.dbcolor and "TRUE" or "FALSE").."|r)")
837 elseif carg1 == "reset" then
838 ElkBuffBarOptions = nil
839 self:InitSettings()
840 elseif carg1 == "resetpos" then
841 ElkBuffBarOptions.scale = nil
842 ElkBuffBarOptions.x = nil
843 ElkBuffBarOptions.y = nil
844 self:InitSettings()
845 elseif carg1 == "width" then
846 if carg2 then
847 carg2 = floor(tonumber(carg2))
848 if carg2 < 100 then
849 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r WIDTH must be >= 100")
850 else
851 ElkBuffBarOptions.width = carg2
852 self:UpdateLayout()
853 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r WIDTH now set to |cffff0000"..ElkBuffBarOptions.width.."|r")
854 end
855 else
856 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r WIDTH is |cffff0000"..ElkBuffBarOptions.width.."|r")
857 end
858 elseif carg1 == "height" then
859 if carg2 then
860 carg2 = floor(tonumber(carg2))
861 if carg2 < 10 then
862 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r HEIGHT must be >= 10")
863 else
864 ElkBuffBarOptions.height = carg2
865 self:UpdateLayout()
866 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r HEIGHT now set to |cffff0000"..ElkBuffBarOptions.height.."|r")
867 end
868 else
869 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r HEIGHT is |cffff0000"..ElkBuffBarOptions.height.."|r")
870 end
871 elseif carg1 == "scale" then
872 if carg2 then
873 carg2 = tonumber(carg2)
874 if carg2 <= 0 then
875 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r SCALE must be > 0.0")
876 else
877 ElkBuffBarOptions.scale = carg2
878 self:UpdateLayout()
879 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r SCALE now set to |cffff0000"..ElkBuffBarOptions.scale.."|r")
880 end
881 else
882 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r SCALE is |cffff0000"..ElkBuffBarOptions.scale.."|r")
883 end
884 elseif carg1 == "anchor" then
885 if carg2 then
886 carg2 = string.upper(carg2)
887 if carg2 ~= "TOPLEFT" and carg2 ~= "TOPRIGHT" and carg2 ~= "BOTTOMLEFT" and carg2 ~= "BOTTOMRIGHT" then
888 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r ANCHOR must be TOPLEFT, TOPRIGHT, BOTTOMLEFT or BOTTOMRIGHT")
889 else
890 ElkBuffBarOptions.anchor = carg2
891 self:UpdateLayout()
892 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r ANCHOR now set to |cffff0000"..ElkBuffBarOptions.anchor.."|r")
893 end
894 else
895 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r ANCHOR is |cffff0000"..ElkBuffBarOptions.anchor.."|r")
896 end
897 elseif carg1 == "locked" then
898 if carg2 then
899 carg2 = string.lower(carg2)
900 if carg2 ~= "true" and carg2 ~= "false" then
901 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r LOCKED must be TRUE or FALSE")
902 else
903 if carg2 == "true" then
904 ElkBuffBarOptions.locked = true
905 else
906 ElkBuffBarOptions.locked = nil
907 end
908 self:UpdateLayout()
909 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r LOCKED now set to |cffff0000"..(ElkBuffBarOptions.locked and "TRUE" or "FALSE").."|r")
910 end
911 else
912 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r LOCKED is |cffff0000"..(ElkBuffBarOptions.locked and "TRUE" or "FALSE").."|r")
913 end
914 elseif carg1 == "alpha" then
915 if carg2 then
916 carg2 = tonumber(carg2)
917 if carg2 < 0 or carg2 > 1 then
918 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r ALPHA must be >= 0.0 and <= 1.0")
919 else
920 ElkBuffBarOptions.alpha = carg2
921 self:UpdateLayout()
922 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r ALPHA now set to |cffff0000"..ElkBuffBarOptions.alpha.."|r")
923 end
924 else
925 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r ALPHA is |cffff0000"..ElkBuffBarOptions.alpha.."|r")
926 end
927 elseif carg1 == "icon" then
928 if carg2 then
929 carg2 = string.upper(carg2)
930 if carg2 ~= "LEFT" and carg2 ~= "RIGHT" and carg2 ~= "NONE" then
931 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r ICON must be LEFT, RIGHT or NONE")
932 else
933 ElkBuffBarOptions.icon = carg2
934 self:UpdateLayout()
935 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r ICON now set to |cffff0000"..ElkBuffBarOptions.icon.."|r")
936 end
937 else
938 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r ICON is |cffff0000"..ElkBuffBarOptions.icon.."|r")
939 end
940 elseif carg1 == "sort" then
941 if carg2 then
942 carg2 = string.upper(carg2)
943 if carg2 ~= "DEFAULT" and carg2 ~= "TIMEMAX" and carg2 ~= "TIMELEFT" then
944 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r SORT must be DEFAULT, TIMEMAX or TIMELEFT")
945 else
946 ElkBuffBarOptions.sort = carg2
947 self:UpdateLayout()
948 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r SORT now set to |cffff0000"..ElkBuffBarOptions.sort.."|r")
949 end
950 else
951 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r SORT is |cffff0000"..ElkBuffBarOptions.sort.."|r")
952 end
953 elseif carg1 == "timer" then
954 if carg2 then
955 carg2 = string.upper(carg2)
956 if carg2 ~= "DEFAULT" and carg2 ~= "NONE" and carg2 ~= "FULL" then
957 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r TIMER must be DEFAULT, NONE or FULL")
958 else
959 ElkBuffBarOptions.timer = carg2
960 self:UpdateLayout()
961 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r TIMER now set to |cffff0000"..ElkBuffBarOptions.timer.."|r")
962 end
963 else
964 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r TIMER is |cffff0000"..ElkBuffBarOptions.timer.."|r")
965 end
966 elseif carg1 == "invert" then
967 if carg2 then
968 carg2 = string.lower(carg2)
969 if carg2 ~= "true" and carg2 ~= "false" then
970 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r INVERT must be TRUE or FALSE")
971 else
972 if carg2 == "true" then
973 ElkBuffBarOptions.invert = true
974 else
975 ElkBuffBarOptions.invert = nil
976 end
977 self:UpdateLayout()
978 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r INVERT now set to |cffff0000"..(ElkBuffBarOptions.invert and "TRUE" or "FALSE").."|r")
979 end
980 else
981 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r INVERT is |cffff0000"..(ElkBuffBarOptions.invert and "TRUE" or "FALSE").."|r")
982 end
983 elseif carg1 == "spacing" then
984 if carg2 then
985 carg2 = floor(tonumber(carg2))
986 if carg2 < 0 then
987 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r SPACING must be >= 0")
988 else
989 ElkBuffBarOptions.spacing = carg2
990 self:UpdateLayout()
991 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r SPACING now set to |cffff0000"..ElkBuffBarOptions.spacing.."|r")
992 end
993 else
994 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r SPACING is |cffff0000"..ElkBuffBarOptions.spacing.."|r")
995 end
996 elseif carg1 == "group" then
997 if carg2 then
998 carg2 = floor(tonumber(carg2))
999 if carg2 < 0 then
1000 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r GROUP must be >= 0")
1001 else
1002 ElkBuffBarOptions.group = carg2
1003 self:UpdateLayout()
1004 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r GROUP now set to |cffff0000"..ElkBuffBarOptions.group.."|r")
1005 end
1006 else
1007 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r GROUP is |cffff0000"..ElkBuffBarOptions.group.."|r")
1008 end
1009 elseif carg1 == "dbcolor" then
1010 if carg2 then
1011 carg2 = string.lower(carg2)
1012 if carg2 ~= "true" and carg2 ~= "false" then
1013 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r DBCOLOR must be TRUE or FALSE")
1014 else
1015 if carg2 == "true" then
1016 ElkBuffBarOptions.dbcolor = true
1017 else
1018 ElkBuffBarOptions.dbcolor = nil
1019 end
1020 self:UpdateLayout()
1021 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r DBCOLOR now set to |cffff0000"..(ElkBuffBarOptions.dbcolor and "TRUE" or "FALSE").."|r")
1022 end
1023 else
1024 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r DBCOLOR is |cffff0000"..(ElkBuffBarOptions.dbcolor and "TRUE" or "FALSE").."|r")
1025 end
1026 else
1027 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00[ElkBuffBar]|r "..carg1.." is no valid parameter.")
1028 end
1029 end
1030  
1031 ElkBuffBar:Init()