-
Notifications
You must be signed in to change notification settings - Fork 5
/
HealComm.lua
629 lines (554 loc) · 21.5 KB
/
HealComm.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
--[[
Author: Aviana
Last modified by: LiuCJonathan
Notes:
Documentation by LiuCJonathan.
If the documentation mentions a "non-functional" variable/parameter, it means it has no use in that specific function
At some point, the ambiguous "self" parameter in some functions should be renamed to "frame"
--]]
local libCHC = LibStub("LibHealComm-4.0", true)
if not HealCommSettings then
HealCommSettings = {
overhealpercent = 20,
timeframe = 4,
showHots = true,
healColor = {red=0,green=1,blue=0,alpha=60}
}
end
HealComm = select(2, ...)
HealComm.version = "1.1.4"
local hpBars = {}
local frames = {
["player"] = { bar = getglobal("PlayerFrameHealthBar"), frame = _G["PlayerFrame"] },
["pet"] = { bar = getglobal("PetFrameHealthBar"), frame = _G["PetFrame"] },
["target"] = { bar = getglobal("TargetFrameHealthBar"), frame = _G["TargetFrame"] },
["party1"] = { bar = getglobal("PartyMemberFrame1HealthBar"), frame = _G["PartyMemberFrame1"] },
["partypet1"] = { bar = getglobal("PartyMemberFrame1PetFrameHealthBar"), frame = _G["PartyMemberFrame1PetFrame"] },
["party2"] = { bar = getglobal("PartyMemberFrame2HealthBar"), frame = _G["PartyMemberFrame2"] },
["partypet2"] = { bar = getglobal("PartyMemberFrame2PetFrameHealthBar"), frame = _G["PartyMemberFrame2PetFrame"] },
["party3"] = { bar = getglobal("PartyMemberFrame3HealthBar"), frame = _G["PartyMemberFrame3"] },
["partypet3"] = { bar = getglobal("PartyMemberFrame3PetFrameHealthBar"), frame = _G["PartyMemberFrame3PetFrame"] },
["party4"] = { bar = getglobal("PartyMemberFrame4HealthBar"), frame = _G["PartyMemberFrame4"] },
["partypet4"] = { bar = getglobal("PartyMemberFrame4PetFrameHealthBar"), frame = _G["PartyMemberFrame4PetFrame"] },
}
local partyGUIDs = {
[UnitGUID("player")] = "player",
}
local currentHeals = {}
--[[
Function: RaidPulloutButton_OnLoadHook
Purpose:(???)
Created by: Aviana
Last modified by: Aviana
Inputs: Frame
Where Frame is a unit frame to update
Notes:
Possibly removable without any functionality impact
]]--
local function RaidPulloutButton_OnLoadHook(self)
if not hpBars[self] then
hpBars[getglobal(self:GetParent():GetName().."HealthBar")] = CreateFrame("StatusBar", self:GetName().."HealthBarIncHeal" , self)
hpBars[getglobal(self:GetParent():GetName().."HealthBar")]:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
hpBars[getglobal(self:GetParent():GetName().."HealthBar")]:SetMinMaxValues(0, 1)
hpBars[getglobal(self:GetParent():GetName().."HealthBar")]:SetValue(1)
hpBars[getglobal(self:GetParent():GetName().."HealthBar")]:SetStatusBarColor(HealCommSettings.healColor.red, HealCommSettings.healColor.green, HealCommSettings.healColor.blue, HealCommSettings.healColor.alpha)
end
end
--[[
Function: UnitFrameHealthBar_OnValueChangedHook
Purpose: Updates unit frames when a unit's max health changes
Created by: Aviana
Last modified by: Aviana
Inputs: Frame
Where Frame is a unit frame to update
]]--
local function UnitFrameHealthBar_OnValueChangedHook(self)
HealComm:UpdateFrame(self, self.unit, currentHeals[UnitGUID(self.unit)] or 0)
end
--[[
Function: UnitFrameHealthBar_OnUpdateHook
Purpose: Updates unit frames when a unit's health changes
Created by: Aviana
Last modified by: Aviana
Inputs: Frame
Where Frame is a unit frame to update
Notes:
Function hook happens immediately after function definition
]]--
local function UnitFrameHealthBar_OnUpdateHook(self)
if self.unit ~= "player" then return end
HealComm:UpdateFrame(self, self.unit, currentHeals[UnitGUID(self.unit)] or 0)
end
hooksecurefunc("UnitFrameHealthBar_OnUpdate", UnitFrameHealthBar_OnUpdateHook) -- This needs early hooking
--[[
Function: CompactUnitFrame_UpdateHealthHook
Purpose: Update raid heal bars when a unit's health changes
Created by: Aviana
Last modified by: Aviana
Inputs: Frame
Where Frame is a unit frame to update
]]--
local function CompactUnitFrame_UpdateHealthHook(self)
if not hpBars[self.healthBar] then return end
HealComm:UpdateFrame(self.healthBar, self.displayedUnit, currentHeals[UnitGUID(self.displayedUnit)] or 0)
end
--[[
Function: CompactUnitFrame_UpdateMaxHealthHook
Purpose: Update heal calculations after a max health change
Created by: Aviana
Last modified by: Aviana
Inputs: Frame
Where Frame is a unit frame to update
]]--
local function CompactUnitFrame_UpdateMaxHealthHook(self)
if not hpBars[self.healthBar] then return end
HealComm:UpdateFrame(self.healthBar, self.displayedUnit, currentHeals[UnitGUID(self.displayedUnit)] or 0)
end
--[[
Function: CompactUnitFrame_SetUnitHook
Purpose: Create new heal bar when a new unit joins the raid (?)
Created by: Aviana
Last modified by: Aviana
Inputs: Frame, Unit
Where Frame is a parent frame to attach to
Where Unit is the UnitID of the unit being added
Notes:
Function hook happens immediately after function definition
]]--
local function CompactUnitFrame_SetUnitHook(self, unit)
if not hpBars[self.healthBar] then
hpBars[self.healthBar] = CreateFrame("StatusBar", nil, self)
hpBars[self.healthBar]:SetStatusBarTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill")
hpBars[self.healthBar]:SetMinMaxValues(0, 1)
hpBars[self.healthBar]:SetValue(1)
hpBars[self.healthBar]:SetStatusBarColor(HealCommSettings.healColor.red, HealCommSettings.healColor.green, HealCommSettings.healColor.blue, HealCommSettings.healColor.alpha)
end
end
hooksecurefunc("CompactUnitFrame_SetUnit", CompactUnitFrame_SetUnitHook) -- This needs early hooking
--[[
Function: OnInitialize
Purpose: Initalize necessary functions and set hooks, callbacks
Created by: Aviana
Last modified by: LiuCJonathan
]]--
function HealComm:OnInitialize()
--Initalize new options for 1.1.0
HealCommSettings.healColor = HealCommSettings.healColor or {red=0,green=1,blue=0,alpha=60}
self:CreateBars()
hooksecurefunc("RaidPulloutButton_OnLoad", RaidPulloutButton_OnLoadHook)
hooksecurefunc("UnitFrameHealthBar_OnValueChanged", UnitFrameHealthBar_OnValueChangedHook)
hooksecurefunc("CompactUnitFrame_UpdateHealth", CompactUnitFrame_UpdateHealthHook)
hooksecurefunc("CompactUnitFrame_UpdateMaxHealth", CompactUnitFrame_UpdateMaxHealthHook)
libCHC.RegisterCallback(HealComm, "HealComm_HealStarted", "HealComm_HealUpdated")
libCHC.RegisterCallback(HealComm, "HealComm_HealStopped")
libCHC.RegisterCallback(HealComm, "HealComm_HealDelayed", "HealComm_HealUpdated")
libCHC.RegisterCallback(HealComm, "HealComm_HealUpdated")
libCHC.RegisterCallback(HealComm, "HealComm_ModifierChanged")
libCHC.RegisterCallback(HealComm, "HealComm_GUIDDisappeared")
end
--[[
Function: CreateBars
Purpose: Create and initalize heal bars for all frames
Created by: Aviana
Last modified by: Aviana
]]--
function HealComm:CreateBars()
for unit,v in pairs(frames) do
if not hpBars[v] then
hpBars[v.bar] = CreateFrame("StatusBar", "IncHealBar"..unit, v.frame)
hpBars[v.bar]:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
hpBars[v.bar]:SetMinMaxValues(0, 1)
hpBars[v.bar]:SetValue(1)
hpBars[v.bar]:SetStatusBarColor(HealCommSettings.healColor.red, HealCommSettings.healColor.green, HealCommSettings.healColor.blue, HealCommSettings.healColor.alpha)
end
end
end
--[[
Function: UpdateBars
Purpose: Update the color of all heal bars
Created by: LiuCJonathan
Last modified by: LiuCJonathan
]]--
function HealComm:UpdateBars()
for unit,v in pairs(frames) do
if hpBars[v.bar] then
hpBars[v.bar]:SetStatusBarColor(HealCommSettings.healColor.red, HealCommSettings.healColor.green, HealCommSettings.healColor.blue, HealCommSettings.healColor.alpha)
end
end
end
--[[
Function: UNIT_PET
Purpose: Update pet heal bars
Created by: Aviana
Last modified by: Aviana
Inputs: Unit
Where Unit is the UnitID of the pet being updated
]]--
function HealComm:UNIT_PET(unit)
if unit ~= "player" and strsub(unit,1,5) ~= "party" then return end
petunit = unit == "player" and "pet" or "partypet"..strsub(unit,6)
for guid,unit in pairs(partyGUIDs) do
if unit == petunit then
partyGUIDs[guid] = nil
break
end
end
if UnitExists(petunit) then
partyGUIDs[UnitGUID(petunit)] = petunit
end
if hpBars[frames[petunit].bar] then
self:UpdateFrame(frames[petunit].bar, petunit, currentHeals[UnitGUID("pet")] or 0)
end
end
function HealComm:PLAYER_TARGET_CHANGED()
self:UpdateFrame(frames["target"].bar, "target", currentHeals[UnitGUID("target")] or 0)
end
--[[
Function: PLAYER_ROLES_ASSIGNED
Purpose: Update party and raid heal bars after a raid role assignment
Created by: Aviana
Last modified by: Aviana
]]--
function HealComm:PLAYER_ROLES_ASSIGNED()
local frame, unitframe, num
for guid,unit in pairs(partyGUIDs) do
if strsub(unit,1,5) == "party" then
partyGUIDs[guid] = nil
end
end
if UnitInParty("player") then
for i=1, MAX_PARTY_MEMBERS do
local p = "party"..i
if UnitExists(p) then
partyGUIDs[UnitGUID(p)] = p
else
break
end
end
unitframe = _G["CompactPartyFrameMember1"]
num = 1
while unitframe do
if unitframe.displayedUnit and UnitExists(unitframe.displayedUnit) then
self:UpdateFrame(unitframe.healthBar, unitframe.displayedUnit, amount)
end
num = num + 1
unitframe = _G["CompactPartyFrameMember"..num]
end
unitframe = _G["CompactRaidFrame1"]
num = 1
while unitframe do
if unitframe.displayedUnit and UnitExists(unitframe.displayedUnit) then
self:UpdateFrame(unitframe.healthBar, unitframe.displayedUnit, amount)
end
num = num + 1
unitframe = _G["CompactRaidFrame"..num]
end
end
if UnitInRaid("player") then
for k=1, NUM_RAID_PULLOUT_FRAMES do
frame = getglobal("RaidPullout"..k)
for z=1, frame.numPulloutButtons do
unitframe = getglobal(frame:GetName().."Button"..z)
if unitframe.unit and UnitExists(unitframe.unit) then
self:UpdateFrame(getglobal(unitframe:GetName().."HealthBar"), unitframe.unit, currentHeals[UnitGUID(unitframe.unit)] or 0)
end
end
end
for i=1, 8 do
local grpHeader = "CompactRaidGroup"..i
if _G[grpHeader] then
for k=1, 5 do
unitframe = _G[grpHeader.."Member"..k]
if unitframe and unitframe.displayedUnit and UnitExists(unitframe.displayedUnit) then
self:UpdateFrame(unitframe.healthBar, unitframe.displayedUnit, currentHeals[UnitGUID(unitframe.displayedUnit)] or 0)
end
end
end
end
end
end
--[[
Function: HealComm_HealUpdated
Purpose: HealCommLib callback handler
Redirect callback
Created by: Aviana
Last modified by: Aviana
Inputs: event, casterGUID, spellID, healType, interrupted, args
Where event, casterGUID, spellID, etc. are non-functional
Where args is a table of GUIDs to update
--]]
function HealComm:HealComm_HealUpdated(event, casterGUID, spellID, healType, endTime, ...)
self:UpdateIncoming(...)
end
--[[
Function: HealComm_HealStopped
Purpose: HealCommLib callback handler
Redirect callback
Created by: Aviana
Last modified by: Aviana
Inputs: event, casterGUID, spellID, healType, interrupted, args
Where event, casterGUID, spellID, etc. are non-functional
Where args is a table of GUIDs to update
--]]
function HealComm:HealComm_HealStopped(event, casterGUID, spellID, healType, interrupted, ...)
self:UpdateIncoming(...)
end
--[[
Function: HealComm_ModifierChanged
Purpose: HealCommLib callback handler
Redirect callback
Created by: Aviana
Last modified by: Aviana
Inputs: Event, GUID
Where Event is non-functional
Where GUID is the GUID to update
--]]
function HealComm:HealComm_ModifierChanged(event, guid)
self:UpdateIncoming(guid)
end
--[[
Function: SliderConstructor
Purpose: Template for sliders
Created by: Aviana
Last modified by: Aviana
Inputs: Event, GUID
Where Event is non-functional
Where GUID is the GUID that disappeared
--]]
function HealComm:HealComm_GUIDDisappeared(event, guid)
self:UpdateIncoming(guid)
end
--[[
Function: UpdateIncoming
Purpose: HealCommLib callback handler. Updates heal bars
Created by: Aviana
Last modified by: Aviana
Inputs: args
A table of GUIDs to update
--]]
function HealComm:UpdateIncoming(...)
local amount, targetGUID, num, frame, unitframe, healType
if HealCommSettings.showHots then
healType = libCHC.ALL_HEALS
else
healType = libCHC.CASTED_HEALS
end
for i=1, select("#", ...) do
targetGUID = select(i, ...)
amount = (libCHC:GetHealAmount(targetGUID, healType, GetTime()+ HealCommSettings.timeframe) or 0) * (libCHC:GetHealModifier(targetGUID) or 1)
currentHeals[targetGUID] = amount > 0 and amount
if UnitGUID("target") == targetGUID then
self:UpdateFrame(frames["target"].bar, "target", amount)
end
if partyGUIDs[targetGUID] then
self:UpdateFrame(frames[partyGUIDs[targetGUID]].bar, partyGUIDs[targetGUID], amount)
end
if UnitInParty("player") then
unitframe = _G["CompactPartyFrameMember1"]
num = 1
while unitframe do
if unitframe.displayedUnit and UnitExists(unitframe.displayedUnit) and UnitGUID(unitframe.displayedUnit) == targetGUID then
self:UpdateFrame(unitframe.healthBar, unitframe.displayedUnit, amount)
end
num = num + 1
unitframe = _G["CompactPartyFrameMember"..num]
end
unitframe = _G["CompactRaidFrame1"]
num = 1
while unitframe do
if unitframe.displayedUnit and UnitExists(unitframe.displayedUnit) and UnitGUID(unitframe.displayedUnit) == targetGUID then
self:UpdateFrame(unitframe.healthBar, unitframe.displayedUnit, amount)
end
num = num + 1
unitframe = _G["CompactRaidFrame"..num]
end
end
if UnitInRaid("player") then
for k=1, NUM_RAID_PULLOUT_FRAMES do
frame = getglobal("RaidPullout"..k)
for z=1, frame.numPulloutButtons do
unitframe = getglobal(frame:GetName().."Button"..z)
if unitframe.unit and UnitExists(unitframe.unit) and UnitGUID(unitframe.unit) == targetGUID then
self:UpdateFrame(getglobal(unitframe:GetName().."HealthBar"), unitframe.unit, amount)
end
end
end
for j=1, 8 do
local grpHeader = "CompactRaidGroup"..j
if _G[grpHeader] then
for k=1, 5 do
unitframe = _G[grpHeader.."Member"..k]
if unitframe and unitframe.displayedUnit and UnitExists(unitframe.displayedUnit) and UnitGUID(unitframe.displayedUnit) == targetGUID then
self:UpdateFrame(unitframe.healthBar, unitframe.displayedUnit, currentHeals[UnitGUID(unitframe.displayedUnit)] or 0)
end
end
end
end
end
end
end
--[[
Function: UpdateFrame
Purpose: HealCommLib callback handler. Updates heal bars
Created by: Aviana
Last modified by: Aviana
Inputs: Frame, Unit, HealAmount
Where Frame is the heal bar frame to update
Where Unit is the UnitID that the heal bar references
Where HealAmount is the amount of incoming healing
--]]
function HealComm:UpdateFrame(frame, unit, amount)
local health, maxHealth = UnitHealth(unit), UnitHealthMax(unit)
if( amount and amount > 0 and (health < maxHealth or HealCommSettings.overhealpercent > 0 )) and frame:IsVisible() then
hpBars[frame]:Show()
local healthWidth = frame:GetWidth() * (health / maxHealth)
local incWidth = frame:GetWidth() * (amount / maxHealth)
if (healthWidth + incWidth) > (frame:GetWidth() * (1+(HealCommSettings.overhealpercent/100)) ) then
incWidth = frame:GetWidth() * (1+(HealCommSettings.overhealpercent/100)) - healthWidth
end
hpBars[frame]:SetWidth(incWidth)
hpBars[frame]:SetHeight(frame:GetHeight())
hpBars[frame]:ClearAllPoints()
hpBars[frame]:SetPoint("TOPLEFT", frame, "TOPLEFT", healthWidth, 0)
else
hpBars[frame]:Hide()
end
end
--[[
Code section: Config: Main Options Tab
Purpose: Add and attach options page
Created by: Aviana
Last modified by: LiuCJonathan
]]--
local options = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
options.name = "HealComm"
options:Hide()
options:SetScript("OnShow", function(self)
--[[
Function: BoxConstructor
Purpose: Template for checkboxes
Created by: Aviana
Last modified by: Aviana
Inputs: Name, Description, Function(frame_object, value)
Where frame_object is a frame to attach to
Where value is a variable to send checkbox value updates to
Return: A new checkbox object
--]]
local function BoxConstructor(name, desc, clickFunc)
local box = CreateFrame("CheckButton", "HealCommOptionsBox" .. name, self, "InterfaceOptionsCheckButtonTemplate")
box:SetScript("OnClick", function(thisBox)
clickFunc(thisBox, thisBox:GetChecked())
end)
box.label = _G[box:GetName() .. "Text"]
box.label:SetText(name)
box.tooltipText = name
box.tooltipRequirement = desc
return box
end
--[[
Function: SliderConstructor
Purpose: Template for sliders
Created by: Aviana
Last modified by: Aviana
Inputs: Name, Description, Function(frame_object, value)
Where frame_object is a frame to attach to
Where value is a variable to send slider value updates to
Return: A new slider object
--]]
local function SliderConstructor(name, desc, valueFunc)
local slider = CreateFrame("Slider", "HealCommOptionsSlider" .. name, self, "OptionsSliderTemplate")
slider:SetScript("OnValueChanged", function(thisSlider)
thisSlider.High:SetText(thisSlider:GetValue())
valueFunc(thisSlider, thisSlider:GetValue())
end)
slider.label = _G[slider:GetName() .. "Text"]
slider.label:SetText(name)
slider.Low:Hide()
slider.High:ClearAllPoints()
slider.High:SetPoint("TOP", slider, "BOTTOM", 0, 0)
slider.tooltipText = name
slider.tooltipRequirement = desc
return slider
end
-- Options and text to be added
local header = self:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
header:SetPoint("TOPLEFT", 16, -16)
header:SetText("HealComm")
local version = self:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
version:SetText("Version: "..HealComm.version)
version:SetPoint("TOPLEFT", header, "BOTTOMLEFT", 0, -16)
local donate = self:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
donate:SetText("Donate to the original creator: paypal.me/LunaUnitFrames")
donate:SetPoint("TOPLEFT", version, "BOTTOMLEFT", 0, -16)
local showHots = BoxConstructor("Show Hots", "Show hots in the healing prediction", function(self, value) HealCommSettings.showHots = value end)
showHots:SetChecked(HealCommSettings.showHots)
showHots:SetPoint("TOPLEFT", donate, "BOTTOMLEFT", 0, -16)
local overhealSlider = SliderConstructor("Extend Overheal", "How many percent of the frame to go over it when showing heals", function(self, value) HealCommSettings.overhealpercent = value end)
overhealSlider:SetMinMaxValues(0, 30)
overhealSlider:SetValueStep(1)
overhealSlider:SetObeyStepOnDrag(true)
overhealSlider:SetValue(HealCommSettings.overhealpercent)
overhealSlider:SetPoint("TOPLEFT", showHots, "BOTTOMLEFT", 0, -16)
local timeframeSlider = SliderConstructor("Timeframe", "How many seconds to predict into the future", function(self, value) HealCommSettings.timeframe = value end)
timeframeSlider:SetMinMaxValues(3, 10)
timeframeSlider:SetValueStep(1)
timeframeSlider:SetObeyStepOnDrag(true)
timeframeSlider:SetValue(HealCommSettings.timeframe)
timeframeSlider:SetPoint("TOPLEFT", overhealSlider, "BOTTOMLEFT", 0, -26)
local colorLabel = self:CreateFontString(nil, "ARTWORK", "GameFontHighlightLarge")
colorLabel:SetText("Heal Color:")
colorLabel:SetPoint("TOPLEFT", timeframeSlider, "BOTTOMLEFT", 0, -36)
local redSlider = SliderConstructor("Red", "What color to make the heal bars", function(self, value) HealCommSettings.healColor.red = value/255 end)
redSlider:SetMinMaxValues(0, 255)
redSlider:SetValueStep(1)
redSlider:SetObeyStepOnDrag(true)
redSlider:SetValue(HealCommSettings.healColor.red*255)
redSlider:SetPoint("TOPLEFT", colorLabel, "BOTTOMLEFT", 0, -26)
local greenSlider = SliderConstructor("Green", "What color to make the heal bars", function(self, value) HealCommSettings.healColor.green = value/255 end)
greenSlider:SetMinMaxValues(0, 255)
greenSlider:SetValueStep(1)
greenSlider:SetObeyStepOnDrag(true)
greenSlider:SetValue(HealCommSettings.healColor.green*255)
greenSlider:SetPoint("TOPLEFT", redSlider, "BOTTOMLEFT", 0, -26)
local blueSlider = SliderConstructor("Blue", "What color to make the heal bars", function(self, value) HealCommSettings.healColor.blue = value/255 end)
blueSlider:SetMinMaxValues(0, 255)
blueSlider:SetValueStep(1)
blueSlider:SetObeyStepOnDrag(true)
blueSlider:SetValue(HealCommSettings.healColor.blue*255)
blueSlider:SetPoint("TOPLEFT", greenSlider, "BOTTOMLEFT", 0, -26)
local alphaSlider = SliderConstructor("Alpha", "What color to make the heal bars", function(self, value) HealCommSettings.healColor.alpha = value/100 end)
alphaSlider:SetMinMaxValues(0, 100)
alphaSlider:SetValueStep(1)
alphaSlider:SetObeyStepOnDrag(true)
alphaSlider:SetValue(HealCommSettings.healColor.alpha*100)
alphaSlider:SetPoint("TOPLEFT", blueSlider, "BOTTOMLEFT", 0, -26)
local updateColors = CreateFrame("Button", "updateHealColor", options, "UIPanelButtonTemplate")
updateColors:SetSize(80 ,22)
updateColors:SetText("Update")
updateColors:SetPoint("TOPLEFT", alphaSlider, "BOTTOMLEFT", 0, -22)
updateColors:SetScript("OnClick",function()HealComm:UpdateBars() end)
self:SetScript("OnShow", nil)
end)
InterfaceOptions_AddCategory(options)
--[[End of "Config: Main Options Tab" code section]]--
--[[
Code section: Event Registration
Purpose: Set event to initalize HealComm on first login and
update targets after target/pet/raid role change
Created by: Aviana
Last modified by: Aviana
--]]
local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("PLAYER_TARGET_CHANGED")
frame:RegisterEvent("PLAYER_ROLES_ASSIGNED")
frame:RegisterEvent("UNIT_PET")
frame:SetScript("OnEvent", function(self, event, ...)
if( event == "PLAYER_LOGIN" ) then
HealComm:OnInitialize()
self:UnregisterEvent("PLAYER_LOGIN")
else
HealComm[event](HealComm, ...)
end
end)
--[[ End of "Event Registration" code section ]]--