vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 SmartHeal.default['hotlist']={}
2 SmartHeal.default['hotlist']['enablepet']=false
3  
4 SmartHeal.BlackListTimeout=5 -- 5 sec timeout
5 SmartHeal.HotListStatusBarHeight=16
6  
7 SmartHeal.AutoTargetOptionList={
8 ['PRIEST']={SH_UNASSIGNED,
9 SH_RENEW,SH_FLASH_HEAL,SH_LESSER_GREATER_HEALS,SH_GREATER_HEAL,SH_HEAL,SH_LESSER_HEAL,SH_PRAYER_OF_HEALING,SH_POWERWORD_SHIELD,
10 },
11  
12 ['PALADIN']={SH_UNASSIGNED,
13 SH_FLASH_OF_LIGHT,SH_HOLY_LIGHT,
14 },
15  
16 ['DRUID']={SH_UNASSIGNED,
17 SH_REJUVENATION,SH_HEALING_TOUCH,SH_REGROWTH,SH_SWIFTMEND,
18 },
19  
20 ['SHAMAN']={SH_UNASSIGNED,
21 SH_LESSER_HEALING_WAVE,SH_HEALING_WAVE,SH_CHAIN_HEAL,
22 },
23  
24 }
25  
26 SmartHeal.HotListDefaultHotkey={
27 ['PRIEST']={['hotkey1']=3,['hotkey2']=4,['hotkey3']=8,},
28 ['PALADIN']={['hotkey1']=2,['hotkey2']=3,['hotkey3']=1,},
29 ['DRUID']={['hotkey1']=2,['hotkey2']=3,['hotkey3']=4,},
30 ['SHAMAN']={['hotkey1']=2,['hotkey2']=3,['hotkey3']=4,},
31 }
32  
33 SmartHeal.HotListClassTypeList={
34 ["Alliance"]={"PLAYER","PARTY","WARRIOR","PRIEST","MAGE","WARLOCK","ROGUE","HUNTER","DRUID","PALADIN"},
35 ["Horde"]={"PLAYER","PARTY","WARRIOR","PRIEST","MAGE","WARLOCK","ROGUE","HUNTER","DRUID","SHAMAN"},
36 }
37  
38 SmartHeal.default['hotlist']={
39 ["Triggerclasstype1"]=50,
40 ["Triggerclasstype2"]=50,
41 ["Triggerclasstype3"]=70,
42 ["Triggerclasstype4"]=50,
43 ["Triggerclasstype5"]=50,
44 ["Triggerclasstype6"]=50,
45 ["Triggerclasstype7"]=50,
46 ["Triggerclasstype8"]=40,
47 ["Triggerclasstype9"]=30,
48 ["Triggerclasstype10"]=30,
49 ["Colorclasstype1"]="ff172b",
50 ["Colorclasstype2"]="ff6b60",
51 ["Colorclasstype3"]="96410d",
52 ["Colorclasstype4"]="c3c3c3",
53 ["Colorclasstype5"]="2846ff",
54 ["Colorclasstype6"]="a03fff",
55 ["Colorclasstype7"]="ffe923",
56 ["Colorclasstype8"]="34b526",
57 ["Colorclasstype9"]="ff931d",
58 ["Colorclasstype10"]="ff7bb9",
59 ['BGColor']="0c0c0c",
60 ['BGColorOpacity']=0.35,
61 }
62  
63 SmartHeal.HotListCastBlackList={}
64  
65 function SmartHeal:InitHotList()
66  
67 SmartHeal.playerFactionGroup=UnitFactionGroup("player")
68 SmartHeal.default['hotlist']['enable']=1
69  
70 for option,value in SmartHeal.HotListDefaultHotkey[SmartHeal.playerClass] do
71 SmartHeal.default['hotlist'][option]=value
72 end
73  
74 for i=1,table.getn(SmartHeal.HotListClassTypeList[SmartHeal.playerFactionGroup]) do
75 SmartHeal.default['hotlist']["classtype"..i]=i
76 end
77  
78 -- hotlist frame settings
79 SmartHeal.default['hotlist']['listlength']=90
80 SmartHeal.default['hotlist']['listwidth']=130
81 SmartHeal.default['hotlist']['enablepriority']=1
82  
83 end
84  
85 function SmartHeal:ReinitializeHotList()
86 SmartHeal.HealthRatioList={}
87 SmartHeal.HotListData={}
88 SmartHeal.AutoTargetBlackList={}
89 SmartHeal.HotListProcessing=nil
90 SmartHeal.AutotargetName=nil
91 end
92  
93 function SmartHeal:HotListGetClassColor(unitClass)
94 local index
95  
96 -- search ClassType table for index
97 for i=1,table.getn(SmartHeal.HotListClassTypeList[SmartHeal.playerFactionGroup]) do
98  
99 if (SmartHeal.HotListClassTypeList[SmartHeal.playerFactionGroup][i]==unitClass) then
100 index=i break
101 end
102  
103 end
104  
105 -- search config color table for color
106 for i=1,table.getn(SmartHeal.HotListClassTypeList[SmartHeal.playerFactionGroup]) do
107  
108 if(SmartHeal:getConfig("classtype"..i,"hotlist")==index) then
109 return SmartHeal:getConfig("Colorclasstype"..i,"hotlist")
110 end
111  
112 end
113 end
114  
115 SmartHeal.HotListIgnoreList={}
116  
117 function SmartHeal:HotListGroupIgnore(UnitInfo)
118  
119 for i=1,table.getn(SmartHeal.HotListIgnoreList) do
120 if (SmartHeal.HotListIgnoreList[i]==UnitInfo.group) then
121 return true
122 end
123 end
124  
125 return false
126  
127 end
128  
129 SmartHeal.HotListNamedTargetList={}
130  
131 SmartHeal.HealthRatioList={}
132 SmartHeal.HotListData={}
133  
134 function SmartHeal:UpdateUnitHealth()
135  
136 SmartHeal.HealthRatioList={}
137  
138 if(GetNumRaidMembers()>0) then
139 for i=1,40 do
140 SmartHeal:UpdateUnitHealthType("raid",i)
141 if (SmartHeal:getConfig('enablepet','hotlist')) then
142 SmartHeal:UpdateUnitHealthType("raidpet",i)
143 end
144 end
145 elseif(GetNumPartyMembers()>0) then
146 for i=1,4 do
147 SmartHeal:UpdateUnitHealthType("party",i)
148 if (SmartHeal:getConfig('enablepet','hotlist')) then
149 SmartHeal:UpdateUnitHealthType("partypet",i)
150 end
151 end
152 SmartHeal:UpdateUnitHealthType("player")
153 if (SmartHeal:getConfig('enablepet','hotlist')) then
154 SmartHeal:UpdateUnitHealthType("pet")
155 end
156 else
157 -- for testing purposes
158 --SmartHeal:UpdateUnitHealthType("player")
159 end
160  
161 end
162  
163 function SmartHeal:UpdateUnitHealthType(groupType,index)
164  
165 local UnitId,group,unitClass,online,isDead,_
166  
167 if(groupType=="raid") then
168 UnitId=groupType..index
169 _,_,group,_,_,unitClass,_,online,isDead=GetRaidRosterInfo(index)
170 elseif(groupType=="party") then
171 UnitId=groupType..index
172 online=UnitIsConnected(UnitId)
173 --name,rank,level,classLocale,class,isDead
174 _,_,_,_,unitClass,isDead=GetPartyRosterInfo(index)
175 elseif(groupType=="player" or groupType=="pet") then
176 UnitId=groupType
177 online=UnitIsConnected("player")
178 _,unitClass=UnitClass("player")
179 isDead=UnitIsDeadOrGhost(UnitId)
180 elseif(groupType=="partypet") then
181 UnitId=groupType..index
182 online=UnitIsConnected("party"..index)
183 _,unitClass=UnitClass("party"..index)
184 isDead=UnitIsDeadOrGhost(UnitId)
185 elseif(groupType=="raidpet") then
186 UnitId=groupType..index
187 online=UnitIsConnected("raid"..index)
188 _,unitClass=UnitClass("raid"..index)
189 isDead=UnitIsDeadOrGhost(UnitId)
190 end
191  
192 if (UnitIsVisible(UnitId) and UnitExists(UnitId) and not isDead and online) then
193  
194 local UnitHealth,UnitHealthMax=UnitHealth(UnitId),UnitHealthMax(UnitId)
195 local hpRatio=UnitHealth/UnitHealthMax
196 local UnitInfo={name=UnitName(UnitId), hpRatio=hpRatio, hp=UnitHealth, hpMax=UnitHealthMax, class=unitClass, UnitId=UnitId, InParty=(UnitPlayerOrPetInParty(UnitId) or UnitIsUnit(UnitId,"player")), group=group}
197  
198 if (UnitHealth>0 and not SmartHeal:HotListGroupIgnore(UnitInfo) and not (hpRatio==1 and SmartHeal:getConfig('hideHPFull','hotlist')) ) then
199  
200 local updated=false
201  
202 for j=1,table.getn(SmartHeal.HealthRatioList) do
203 if (hpRatio<SmartHeal.HealthRatioList[j].hpRatio) then
204 table.insert(SmartHeal.HealthRatioList,j,UnitInfo)
205 updated=true
206 break
207 end
208 end
209  
210 if (not updated) then
211 table.insert(SmartHeal.HealthRatioList,UnitInfo)
212 end
213  
214 end -- if (UnitHealth>0)
215  
216 end -- if (UnitExists(UnitId))
217  
218 end
219  
220 function SmartHeal:GetHealthInfo(class,hpRatioCap)
221  
222 local PriorityList={}
223  
224 if (string.lower(class)=="player") then
225  
226 local _,unitClass=UnitClass("player")
227 local UnitHealth,UnitHealthMax=UnitHealth("player"),UnitHealthMax("player")
228  
229 if (not hpRatioCap or (UnitHealth/UnitHealthMax*100)<=hpRatioCap) then
230 table.insert(PriorityList,{name=UnitName("player"), hpRatio=(UnitHealth/UnitHealthMax) ,hp=UnitHealth, hpMax=UnitHealthMax, class=unitClass, UnitId="player"})
231 end
232  
233 elseif (string.lower(class)=="party") then
234  
235 for i=1,table.getn(SmartHeal.HealthRatioList) do
236  
237 if(SmartHeal.HealthRatioList[i].InParty and (not hpRatioCap or SmartHeal.HealthRatioList[i].hpRatio*100<=hpRatioCap)) then
238  
239 table.insert(PriorityList,SmartHeal.HealthRatioList[i])
240  
241 end
242  
243 end
244  
245 elseif (string.lower(class)=="raid") then
246  
247 for i=1,table.getn(SmartHeal.HealthRatioList) do
248  
249 if(not hpRatioCap or SmartHeal.HealthRatioList[i].hpRatio*100<=hpRatioCap) then
250  
251 table.insert(PriorityList,SmartHeal.HealthRatioList[i])
252  
253 end
254  
255 end
256  
257 else
258  
259 for i=1,table.getn(SmartHeal.HealthRatioList) do
260  
261 if( string.upper(class)==SmartHeal.HealthRatioList[i].class and (not hpRatioCap or SmartHeal.HealthRatioList[i].hpRatio*100<=hpRatioCap) ) then
262  
263 table.insert(PriorityList,SmartHeal.HealthRatioList[i])
264  
265 end
266  
267 end
268  
269 end
270  
271 return PriorityList
272 end
273  
274 function SmartHeal:BuildRaidHealthList(limit)
275  
276 local HotListData={}
277 local HotListRef={}
278 local UnitEntry=SmartHeal:GetHealthInfo("RAID")
279  
280 for j=1,table.getn(UnitEntry) do
281  
282 if (not HotListRef[UnitEntry[j].name]) then
283 UnitEntry[j].matchClass=UnitEntry[j].class
284 table.insert(HotListData,UnitEntry[j])
285 HotListRef[UnitEntry[j].name]=table.getn(HotListData)
286 if (table.getn(HotListData)>=limit) then
287 SmartHeal.HotListData=HotListData
288 return
289 end
290 end
291  
292  
293 end
294  
295 SmartHeal.HotListData=HotListData
296  
297 end
298  
299 function SmartHeal:BuildPriorityList(limit)
300  
301 local HotListData={}
302 local HotListRef={}
303 local UnitEntry
304  
305 ---- Get Named Target
306 UnitEntry=SmartHeal:GetHealthInfo("RAID")
307 for i=1,table.getn(SmartHeal.HotListNamedTargetList) do
308 for j=1,table.getn(UnitEntry) do
309 if (SmartHeal.HotListNamedTargetList[i]==UnitEntry[j].name) then
310 table.insert(HotListData,UnitEntry[j])
311 HotListRef[UnitEntry[j].name]=table.getn(HotListData)
312  
313 if (table.getn(HotListData)>=limit) then
314 SmartHeal.HotListData=HotListData
315 return
316 end
317 end
318 end
319 end
320 ----
321  
322 for i=1,table.getn(SmartHeal.HotListClassTypeList[SmartHeal.playerFactionGroup]) do
323  
324 local class=SmartHeal.HotListClassTypeList[SmartHeal.playerFactionGroup][SmartHeal:getConfig("classtype"..i,"hotlist")]
325 UnitEntry=SmartHeal:GetHealthInfo(class,SmartHeal:getConfig("Triggerclasstype"..i,"hotlist"))
326  
327 for j=1,table.getn(UnitEntry) do
328 if (not HotListRef[UnitEntry[j].name]) then
329 UnitEntry[j].matchClass=class
330 table.insert(HotListData,UnitEntry[j])
331 HotListRef[UnitEntry[j].name]=table.getn(HotListData)
332  
333 if (table.getn(HotListData)>=limit) then
334 SmartHeal.HotListData=HotListData
335 return
336 end
337  
338 end
339 end
340  
341 end
342  
343 SmartHeal.HotListData=HotListData
344  
345 end
346  
347 -- hexcolor to rgb
348 function RGB_hextodec(hex)
349  
350 local HextoDecTable = {["0"]=0,["1"]=1,["2"]=2,["3"]=3,["4"]=4,["5"]=5,["6"]=6,["7"]=7,["8"]=8,["9"]=9,a=10,b=11,c=12,d=13,e=14,f=15}
351  
352 local r1 = HextoDecTable[string.lower(string.sub(hex,1,1))] * 16;
353 local r2 = HextoDecTable[string.lower(string.sub(hex,2,2))];
354 local r = (r1 + r2) / 255;
355  
356 local g1 = HextoDecTable[string.lower(string.sub(hex,3,3))] * 16;
357 local g2 = HextoDecTable[string.lower(string.sub(hex,4,4))];
358 local g = (g1 + g2) / 255;
359  
360 local b1 = HextoDecTable[string.lower(string.sub(hex,5,5))] * 16;
361 local b2 = HextoDecTable[string.lower(string.sub(hex,6,6))];
362 local b = (b1 + b2) / 255;
363  
364 return r,g,b
365 end
366  
367 -- decimal to hex
368 function RGB_dectohex(red,green,blue)
369 if ( not red or not green or not blue ) then
370 return "ffffff"
371 end
372  
373 red = floor(red * 255)
374 green = floor(green * 255)
375 blue = floor(blue * 255)
376  
377 local a,b,c,d,e,f
378  
379 local DecToHexTable = {["0"]=0,["1"]=1,["2"]=2,["3"]=3,["4"]=4,["5"]=5,["6"]=6,["7"]=7,["8"]=8,["9"]=9,
380 ["10"]="a",["11"]="b",["12"]="c",["13"]="d",["14"]="e",["15"]="f"}
381  
382 a = ""..DecToHexTable[tostring(floor(red / 16))]
383 b = ""..DecToHexTable[tostring(math.mod(red,16))]
384 c = ""..DecToHexTable[tostring(floor(green / 16))]
385 d = ""..DecToHexTable[tostring(math.mod(green,16))]
386 e = ""..DecToHexTable[tostring(floor(blue / 16))]
387 f = ""..DecToHexTable[tostring(math.mod(blue,16))]
388  
389 return a..b..c..d..e..f
390 end
391  
392 function SmartHeal:ColorPicker_OnClick(frameName,Id,opacity)
393 local r, g, b = RGB_hextodec(SmartHeal:getConfig(Id,"hotlist"))
394 ColorPickerFrame.cancelFunc = SH_ColorPickerCancelled
395 ColorPickerFrame.func = SH_ColorPickerColorChanged
396 ColorPickerFrame.RefId = Id
397 ColorPickerFrame.RefFrameName = frameName
398 local a
399 if (opacity==1) then
400 a= SmartHeal:getConfig(Id.."Opacity","hotlist") or 1
401 ColorPickerFrame.opacityFunc = SH_ColorPickerColorChanged
402 ColorPickerFrame.opacity = a
403 OpacitySliderFrame:SetValue(a)
404 ColorPickerFrame.hasOpacity = true
405 else
406 ColorPickerFrame.hasOpacity = false
407 end
408 ColorPickerFrame.previousValues = {r, g, b, a}
409  
410 ColorPickerFrame:SetColorRGB(r,g,b)
411 ColorPickerFrame:ClearAllPoints()
412 ColorPickerFrame:SetPoint("TOPLEFT", getglobal(frameName), "TOPRIGHT", 0, 0)
413 ColorPickerFrame:SetFrameStrata("DIALOG")
414 ColorPickerFrame:Show()
415 end
416  
417 function SH_ColorPickerColorChanged()
418 local r, g, b = ColorPickerFrame:GetColorRGB()
419 if (ColorPickerFrame.hasOpacity) then
420 a = OpacitySliderFrame:GetValue()
421 SmartHeal:setConfig(ColorPickerFrame.RefId.."Opacity",a,"hotlist")
422 end
423  
424 SmartHeal:setConfig(ColorPickerFrame.RefId,RGB_dectohex(r,g,b),"hotlist")
425  
426 getglobal(ColorPickerFrame.RefFrameName):SetTexture(r,g,b,a or 1)
427  
428 end
429  
430 function SH_ColorPickerCancelled(color)
431 local r,g,b,a = unpack(color)
432  
433 if (ColorPickerFrame.hasOpacity) then
434 SmartHeal:setConfig(ColorPickerFrame.RefId.."Opacity",a,"hotlist")
435 end
436  
437 SmartHeal:setConfig(ColorPickerFrame.RefId,RGB_dectohex(r,g,b),"hotlist");
438  
439 getglobal(ColorPickerFrame.RefFrameName):SetTexture(r,g,b,a or 1) -- SetTexture SetBackdropColor SetTextColor
440  
441 end
442  
443 function SmartHeal.HotList_MoveClassTypePriority(Id,status)
444  
445 local AffectedId=tonumber(Id)+status
446  
447 local tempClassType=SmartHeal:getConfig("classtype"..Id,"hotlist")
448 local tempTriggerClassType=SmartHeal:getConfig("Triggerclasstype"..Id,"hotlist")
449 local tempColorClassType=SmartHeal:getConfig("Colorclasstype"..Id,"hotlist")
450  
451 SmartHeal:setConfig("classtype"..Id,SmartHeal:getConfig("classtype"..AffectedId,"hotlist"),"hotlist")
452 SmartHeal:setConfig("Triggerclasstype"..Id,SmartHeal:getConfig("Triggerclasstype"..AffectedId,"hotlist"),"hotlist")
453 SmartHeal:setConfig("Colorclasstype"..Id,SmartHeal:getConfig("Colorclasstype"..AffectedId,"hotlist"),"hotlist")
454  
455 SmartHeal:setConfig("classtype"..AffectedId,tempClassType,"hotlist")
456 SmartHeal:setConfig("Triggerclasstype"..AffectedId,tempTriggerClassType,"hotlist")
457 SmartHeal:setConfig("Colorclasstype"..AffectedId,tempColorClassType,"hotlist")
458  
459 end
460  
461 function SmartHeal:HotListClickHeal(button,unit)
462  
463 local KeyDownType=SmartHeal:GetClickHealButton()
464  
465 if KeyDownType=="undetermined" then
466 return
467 elseif KeyDownType then
468 SmartHeal:ClickHeal(KeyDownType..button,unit)
469 else
470 TargetUnit(unit)
471 end
472  
473 end
474  
475 SmartHeal.AutoTargetBlackList={}
476  
477 function SmartHeal:AutoTargetAddToBlackList()
478  
479 if (SmartHeal.AutotargetName) then
480  
481 SmartHeal.AutoTargetBlackList[SmartHeal.AutotargetName]=0
482  
483 end
484  
485 SmartHeal.AutotargetName=nil
486  
487 end
488  
489 function SmartHeal:AutoTargetUpdateBlackList(arg1)
490  
491 local current_timelapse
492  
493 for name,timelapse in SmartHeal.AutoTargetBlackList do
494  
495 current_timelapse=timelapse+arg1
496 if(current_timelapse>SmartHeal.BlackListTimeout) then
497 SmartHeal.AutoTargetBlackList[name]=nil
498 else
499 SmartHeal.AutoTargetBlackList[name]=current_timelapse
500 end
501  
502 end
503  
504 end
505  
506 function SmartHeal:HotListCast(hotkeyNum)
507  
508 if (SmartHeal.AutoTargetOptionList[SmartHeal.playerClass]) then
509 local spell=SmartHeal.AutoTargetOptionList[SmartHeal.playerClass][hotkeyNum]
510 SmartHeal:AutoTargetCast(spell)
511 end
512  
513 end
514  
515 function SmartHeal:AutoTargetCast(spell)
516 local unit
517 local clearTarget,Attacking
518 SmartHeal.AttackingBeforeCast=nil
519  
520 for i=1,table.getn(SmartHeal.HotListData) do
521 if (not SmartHeal.AutoTargetBlackList[UnitName(SmartHeal.HotListData[i].UnitId)]) then
522 unit=SmartHeal.HotListData[i].UnitId
523 SmartHeal.AutotargetName=UnitName(unit)
524 break
525 end
526 end
527  
528 if(GetNumRaidMembers()==0 and GetNumPartyMembers()==0) then unit="player" end
529  
530 if not unit then return end
531  
532 if (UnitIsUnit("player",unit)) then
533 SmartHeal.selfCast=1
534 else
535 SmartHeal.selfCast=0
536 end
537  
538 if (UnitIsUnit("player",unit) or UnitIsUnit("target",unit)) then
539 SmartHeal:Cast(spell)
540  
541 else
542  
543 if(not UnitExists("target")) then clearTarget=1
544 elseif (SmartHeal.Attacking) then Attacking=1 end
545  
546 TargetUnit(unit)
547  
548 SmartHeal:Cast(spell)
549  
550 if (SpellIsTargeting() and not SpellCanTargetUnit(unit)) then
551 SpellStopTargeting()
552  
553 if(clearTarget) then
554 ClearTarget()
555 else
556 TargetLastTarget()
557 end
558  
559 if(Attacking) then
560 SmartHeal.ResumeAttack=1
561 end
562 else
563  
564 if(clearTarget) then
565 ClearTarget()
566 else
567 TargetLastTarget()
568 end
569  
570 if(Attacking) then
571 SmartHeal.AttackingBeforeCast=1
572 end
573 end
574  
575 end
576  
577 end
578  
579 function SmartHeal:GetHotListUnitId(index)
580  
581 if (SmartHeal.HotListData[index]) then
582 return SmartHeal.HotListData[index].UnitId
583 end
584  
585 end
586  
587  
588 ---- Mouse Dragging/Clicking on Frame
589  
590 function SmartHeal:HotListTitleButton_OnMouseDown()
591  
592 local button = arg1;
593 if ( button == "LeftButton" ) then
594 if ( this:GetButtonState() == "PUSHED" ) then
595 SH_HotListFrame:StartMoving()
596 else
597 SH_HotListFrame:StopMovingOrSizing()
598 end
599 end
600  
601 end
602  
603 function SmartHeal:HotListOnEvent(event)
604  
605 if (this:IsShown() and SmartHeal.Loaded) then
606  
607 if ((event=="UNIT_HEALTH" or event=="UNIT_MAXHEALTH") and not SmartHeal.HotListProcessing) then
608  
609 SmartHeal.HotListProcessing=true
610 SmartHeal:UpdateUnitHealth()
611 if(SmartHeal:getConfig("enablepriority","hotlist")) then
612 SmartHeal:BuildPriorityList(15)
613 else
614 SmartHeal:BuildRaidHealthList(15)
615 end
616 SmartHeal:HotListStatusBarOnEvent()
617 SmartHeal.HotListProcessing=nil
618  
619 end
620  
621 if (event=="SPELLCAST_FAILED") then
622 SmartHeal:AutoTargetAddToBlackList()
623 end
624  
625 end
626  
627 end
628  
629 function SmartHeal:HotListStatusBarOnEvent()
630  
631 local width=this:GetWidth()
632 local StatusBarPrefix="SH_HotListFrameCanvas_Unit"
633  
634 local i=1
635 while(getglobal(StatusBarPrefix..i)) do
636 local StatusBarFrame=getglobal(StatusBarPrefix..i)
637 local UnitButton=getglobal(StatusBarPrefix..i.."_UnitButton")
638 local UnitButtonLabel=getglobal(StatusBarPrefix..i.."_UnitButtonLabel")
639 local StatusBar=getglobal(StatusBarPrefix..i.."_StatusBar")
640  
641 if (SmartHeal.HotListData[i]) then
642  
643 -- status bar frame settings
644 StatusBarFrame:SetHeight(SmartHeal.HotListStatusBarHeight)
645 StatusBarFrame:SetPoint("TOPLEFT","$parent","TOPLEFT",0,-SmartHeal.HotListStatusBarHeight*(i-1));
646  
647 -- status bar settings
648 local hpRatio=floor(SmartHeal.HotListData[i].hpRatio*100)
649 local label=SmartHeal.HotListData[i].hp.."("..hpRatio.."%) "..UnitName(SmartHeal.HotListData[i].UnitId)
650 StatusBar:SetValue(SmartHeal.HotListData[i].hpRatio)
651 StatusBar:SetStatusBarColor(RGB_hextodec(SmartHeal:HotListGetClassColor(SmartHeal.HotListData[i].matchClass)))
652  
653 -- Set Text to Hidden Text layer
654 UnitButtonLabel.HiddenText=label
655  
656 -- status bar button settings
657 local UnitId=SmartHeal.HotListData[i].UnitId
658 UnitButton:SetScript("OnClick", function() SmartHeal:HotListClickHeal(arg1,UnitId) end)
659  
660 else
661  
662 UnitButtonLabel.HiddenText=""
663 StatusBar:SetValue(0)
664  
665 end
666  
667 i=i+1
668 end -- end of while loop
669  
670 end
671  
672 function SmartHeal:HotListVisualOnUpdate()
673  
674 local StatusBarPrefix="SH_HotListFrameCanvas_Unit"
675 local barCount=floor((this:GetParent():GetHeight()-30)/SmartHeal.HotListStatusBarHeight)
676 local width=this:GetParent():GetWidth()-10
677  
678 local i=1
679 while(getglobal(StatusBarPrefix..i)) do
680 local StatusBarFrame=getglobal(StatusBarPrefix..i)
681 local UnitButton=getglobal(StatusBarPrefix..i.."_UnitButton")
682 local UnitButtonLabel=getglobal(StatusBarPrefix..i.."_UnitButtonLabel")
683  
684 if (i<=barCount and UnitButtonLabel.HiddenText~="") then
685  
686 -- Set Hidden Text to Button
687 UnitButtonLabel:SetText(UnitButtonLabel.HiddenText)
688  
689 -- Truncate StatusBar Text
690 SmartHeal:TruncateText(width,UnitButtonLabel.HiddenText,UnitButton,UnitButtonLabel)
691  
692 StatusBarFrame:Show()
693 else
694  
695 StatusBarFrame:Hide()
696  
697 end
698  
699 i=i+1
700 end -- end of while loop
701  
702 end
703  
704 function SmartHeal:TruncateText(width,text,button,buttonlabel)
705  
706 -- Truncate StatusBar Text if text width > frame width
707 if (button:GetTextWidth()>width) then
708  
709 local j=0
710 while (button:GetTextWidth()>(width-5) and string.len(buttonlabel:GetText())>1) do
711 buttonlabel:SetText(string.sub(text,1, -2-j))
712 j=j+1
713 end
714  
715 buttonlabel:SetText(buttonlabel:GetText().."...")
716 end
717  
718 end
719  
720 function GetPartyRosterInfo(index)
721  
722 local unitId="party"..index
723 local name=UnitName(unitId)
724  
725 local rank=0
726 if(index==GetPartyLeaderIndex()) then rank=1 end
727  
728 local level=UnitLevel(unitId)
729 local classLocale,class=UnitClass(unitId)
730 local isDead=UnitIsDeadOrGhost(unitId)
731  
732 --name,rank,level,classLocale,class,isDead
733 return name,rank,level,classLocale,class,isDead
734  
735 end
736  
737 function SH_HotList_PrepareMenu()
738  
739 local info
740  
741 -- Title
742 info = {}
743 info.isTitle = true
744 info.text = "SMH HotList"
745 UIDropDownMenu_AddButton(info);
746  
747 -- Enable Priority
748 info = {}
749 info.text = SH_ENABLE_PRIORITY
750 if (SmartHeal:getConfig('enablepriority','hotlist')) then
751 info.checked = 1
752 end
753 info.func = SH_HotListPriority_Toggle
754 UIDropDownMenu_AddButton(info)
755  
756 -- Enable Pet
757 info = {}
758 info.text = SH_PET
759 if (SmartHeal:getConfig('enablepet','hotlist')) then
760 info.checked = 1
761 end
762 info.func = SH_HotListPet_Toggle
763 UIDropDownMenu_AddButton(info)
764  
765 -- Hide HP>100%
766 info = {}
767 info.text = SH_HIDE_HP_AT_100
768 if (SmartHeal:getConfig('hideHPFull','hotlist')) then
769 info.checked = 1
770 end
771 info.func = SH_HideHPFull
772 UIDropDownMenu_AddButton(info)
773  
774 -- Reset HealStack(CTRA)
775 info = {}
776 info.text = SH_RESET_HEALSTACK
777 info.notCheckable = 1
778 info.value = "ResetHealStack"
779 info.func = SH_ResetHealStack
780 UIDropDownMenu_AddButton(info)
781  
782 -- Ignore List
783 info = {}
784 info.text = SH_GROUP_IGNORE_LIST
785 info.notCheckable = 1
786 info.value = "IgnoreList"
787 info.func = SH_GroupIgnoreList_Show
788 UIDropDownMenu_AddButton(info)
789  
790 -- Named Target
791 info = {}
792 info.text = SH_NAMED_TARGET_LIST
793 info.notCheckable = 1
794 info.value = "NamedList"
795 info.func = SH_NamedTargetList_Show
796 UIDropDownMenu_AddButton(info)
797  
798 -- Spacer
799 --info = {};
800 --info.disabled = 1;
801 --UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
802  
803 end
804  
805  
806 function SH_HideHPFull()
807 if(SmartHeal:getConfig('hideHPFull','hotlist')) then
808 SmartHeal:setConfig('hideHPFull',false,'hotlist')
809 else
810 SmartHeal:setConfig('hideHPFull',true,'hotlist')
811 end
812 end
813  
814 function SH_ResetHealStack()
815 SmartHeal.HealStack={}
816 end
817  
818 function SH_HotListPet_Toggle()
819 if(SmartHeal:getConfig('enablepet','hotlist')) then
820 SmartHeal:setConfig('enablepet',false,'hotlist')
821 else
822 SmartHeal:setConfig('enablepet',true,'hotlist')
823 end
824 end
825  
826 function SH_HotListPriority_Toggle()
827 if(SmartHeal:getConfig('enablepriority','hotlist')) then
828 SmartHeal:setConfig('enablepriority',false,'hotlist')
829 else
830 SmartHeal:setConfig('enablepriority',true,'hotlist')
831 end
832 end
833  
834 function SH_GroupIgnoreList_Show()
835 SH_GroupIgnoreList:Show()
836 end
837  
838 function SH_NamedTargetList_Show()
839 SH_NamedTargetList:Show()
840 end
841