-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeadsupGUI.lua
More file actions
1152 lines (1022 loc) · 37.2 KB
/
Copy pathHeadsupGUI.lua
File metadata and controls
1152 lines (1022 loc) · 37.2 KB
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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Headsup Configuration Interface
-- Compatible with WotLK 3.3.5a
-- Scroll frame for spell list
local spellListFrame = nil
local spellListScrollFrame = nil
local spellListContent = nil
local spellButtons = {}
function Headsup:LOAD_INTERFACE()
assert(self ~= nil, "ERROR: Headsup addon must be loaded first before trying to load the interface")
--[[ Option table ]] --
local optionsFrameModel = {
name = "Headsup",
handler = Headsup,
type = "group",
args = {
credits = {
type = "description",
name = "Headsup - Displays important buffs in the middle of the screen\nCompatible with WotLK 3.3.5a",
fontSize = "small",
width = "full",
order = 1
},
spacer1 = {
type = "description",
name = " ",
fontSize = "medium",
width = "full",
order = 2
},
-- GENERAL SETTINGS
generalHeader = {
type = "header",
name = "General Settings",
order = 3
},
enable = {
type = "toggle",
name = "Enable Addon",
desc = "Enable or disable the Headsup addon",
get = "IsHeadsupEnabled",
set = "ToggleEnable",
width = "full",
order = 4
},
testButton = {
type = "execute",
name = "Test Display",
desc = "Show test buffs to preview your current settings",
func = "TestDisplay",
width = "normal",
order = 5
},
clearButton = {
type = "execute",
name = "Clear All",
desc = "Clear all currently displayed buffs",
func = "ClearAllBuffs",
width = "normal",
order = 6
},
-- DISPLAY SETTINGS
displayHeader = {
type = "header",
name = "Display Settings",
order = 10
},
yOffset = {
type = "range",
name = "Vertical Position",
desc = "Set the vertical position offset from screen center (-400 to 400 pixels)",
min = -400,
max = 400,
step = 5,
get = "GetYOffset",
set = "SetYOffset",
width = "full",
order = 11
},
iconSize = {
type = "range",
name = "Icon Size",
desc = "Set the size of buff icons (8-128 pixels)",
min = 8,
max = 128,
step = 1,
get = "GetIconSize",
set = "SetIconSize",
width = "double",
order = 12
},
spacing = {
type = "range",
name = "Icon Spacing",
desc = "Set the spacing between buff icons (0-50 pixels)",
min = 0,
max = 50,
step = 1,
get = "GetSpacing",
set = "SetSpacing",
width = "double",
order = 13
},
-- TEXT SETTINGS
textHeader = {
type = "header",
name = "Text Settings",
order = 20
},
showSpellName = {
type = "toggle",
name = "Show Spell Names",
desc = "Show spell names below the buff icons",
get = "GetShowSpellName",
set = "SetShowSpellName",
width = "full",
order = 21
},
timerFontSize = {
type = "range",
name = "Timer Font Size",
desc = "Set the font size for timer text (6-24)",
min = 6,
max = 24,
step = 1,
get = "GetTimerFontSize",
set = "SetTimerFontSize",
width = "double",
order = 22
},
spellNameFontSize = {
type = "range",
name = "Spell Name Font Size",
desc = "Set the font size for spell name text (6-24)",
min = 6,
max = 24,
step = 1,
get = "GetSpellNameFontSize",
set = "SetSpellNameFontSize",
width = "double",
order = 23
},
-- VISUAL EFFECTS
visualEffectsHeader = {
type = "header",
name = "Visual Effects",
order = 30
},
enableFlashEffect = {
type = "toggle",
name = "Enable Flash Effect",
desc = "Flash buff icons when they are about to expire",
get = "GetEnableFlashEffect",
set = "SetEnableFlashEffect",
width = "full",
order = 31
},
flashThreshold = {
type = "range",
name = "Flash Threshold",
desc = "Start flashing when buff has this many seconds left (1-30)",
min = 1,
max = 30,
step = 1,
get = "GetFlashThreshold",
set = "SetFlashThreshold",
width = "double",
order = 32
},
flashSpeed = {
type = "range",
name = "Flash Speed",
desc = "How fast the flash effect cycles (0.1-2.0 seconds)",
min = 0.1,
max = 2.0,
step = 0.1,
get = "GetFlashSpeed",
set = "SetFlashSpeed",
width = "double",
order = 33
},
testFlashButton = {
type = "execute",
name = "Test Flash Effect",
desc = "Show a test buff with flash effect",
func = "TestFlashEffect",
width = "normal",
order = 34
},
-- SOUND SETTINGS
soundHeader = {
type = "header",
name = "Sound Settings",
order = 40
},
enableSound = {
type = "toggle",
name = "Enable Sound",
desc = "Play a sound when a tracked spell is applied (not when refreshed)",
get = "GetEnableSound",
set = "SetEnableSound",
width = "full",
order = 41
},
soundChoice = {
type = "select",
name = "Sound to Play",
desc = "Choose which sound to play when a tracked spell is applied",
values = {
["Sound\\Spells\\ShaysBell.wav"] = "ShaysBell",
["Sound\\Spells\\FluteRun.wav"] = "Flute",
["Sound\\Spells\\NetherwindFocusImpact.wav"] = "Netherwind",
["Sound\\Spells\\PolyMorphCow.wav"] = "PolyCow",
["Sound\\Spells\\RockBiterImpact.wav"] = "Rockbiter",
["Sound\\Spells\\YarrrrImpact.wav"] = "Yarrrr!",
["Sound\\Spells\\valentines_brokenheart.wav"] = "Broken Heart",
["Sound\\Creature\\MillhouseManastorm\\TEMPEST_Millhouse_Ready01.wav"] = "Millhouse 1!",
["Sound\\Creature\\MillhouseManastorm\\TEMPEST_Millhouse_Pyro01.wav"] = "Millhouse 2!",
["Sound\\Creature\\Satyre\\SatyrePissed4.wav"] = "Pissed Satyr",
["Sound\\Creature\\Mortar Team\\MortarTeamPissed9.wav"] = "Pissed Dwarf"
},
get = "GetSoundChoice",
set = "SetSoundChoice",
width = "full",
order = 42
},
testSoundButton = {
type = "execute",
name = "Test Sound",
desc = "Play the selected sound to test it",
func = "TestSound",
width = "normal",
order = 43
},
-- BUFF WHISPER MESSAGES
whisperHeader = {
type = "header",
name = "Buff Whisper Messages",
order = 44
},
enableWhispers = {
type = "toggle",
name = "Enable Buff Whispers",
desc = "Send whispers when casting/receiving certain buffs (Focus Magic, Innervate, Power Infusion, Slowfall). Leave a message blank to disable that specific whisper.",
get = "GetEnableWhispers",
set = "SetEnableWhispers",
width = "full",
order = 45
},
whisperSpacer1 = {
type = "description",
name = "Outgoing whispers (when YOU cast on others):",
fontSize = "medium",
width = "full",
order = 46
},
whisperSlowfall1 = {
type = "input",
name = "Slowfall Msg 1",
desc = "Whisper sent to target when casting Slowfall",
get = "GetWhisperSlowfall1",
set = "SetWhisperSlowfall1",
width = "double",
order = 47
},
whisperSlowfall2 = {
type = "input",
name = "Slowfall Msg 2",
desc = "Alternative whisper sent to target when casting Slowfall",
get = "GetWhisperSlowfall2",
set = "SetWhisperSlowfall2",
width = "double",
order = 48
},
whisperSlowfall3 = {
type = "input",
name = "Slowfall Msg 3",
desc = "Alternative whisper sent to target when casting Slowfall",
get = "GetWhisperSlowfall3",
set = "SetWhisperSlowfall3",
width = "double",
order = 49
},
whisperFocusMagicOut1 = {
type = "input",
name = "Focus Magic Out 1",
desc = "Whisper sent to target when casting Focus Magic",
get = "GetWhisperFocusMagicOut1",
set = "SetWhisperFocusMagicOut1",
width = "double",
order = 50
},
whisperFocusMagicOut2 = {
type = "input",
name = "Focus Magic Out 2",
desc = "Alternative whisper sent to target when casting Focus Magic",
get = "GetWhisperFocusMagicOut2",
set = "SetWhisperFocusMagicOut2",
width = "double",
order = 51
},
whisperFocusMagicOut3 = {
type = "input",
name = "Focus Magic Out 3",
desc = "Alternative whisper sent to target when casting Focus Magic",
get = "GetWhisperFocusMagicOut3",
set = "SetWhisperFocusMagicOut3",
width = "double",
order = 52
},
whisperSpacer2 = {
type = "description",
name = "Incoming thank-you whispers (when YOU receive from others):",
fontSize = "medium",
width = "full",
order = 53
},
whisperFocusMagicIn1 = {
type = "input",
name = "Focus Magic Thanks 1",
desc = "Whisper sent to caster when receiving Focus Magic",
get = "GetWhisperFocusMagicIn1",
set = "SetWhisperFocusMagicIn1",
width = "double",
order = 54
},
whisperFocusMagicIn2 = {
type = "input",
name = "Focus Magic Thanks 2",
desc = "Alternative whisper sent to caster when receiving Focus Magic",
get = "GetWhisperFocusMagicIn2",
set = "SetWhisperFocusMagicIn2",
width = "double",
order = 55
},
whisperInnervate1 = {
type = "input",
name = "Innervate Thanks 1",
desc = "Whisper sent to caster when receiving Innervate",
get = "GetWhisperInnervate1",
set = "SetWhisperInnervate1",
width = "double",
order = 56
},
whisperInnervate2 = {
type = "input",
name = "Innervate Thanks 2",
desc = "Alternative whisper sent to caster when receiving Innervate",
get = "GetWhisperInnervate2",
set = "SetWhisperInnervate2",
width = "double",
order = 57
},
whisperPowerInfusion = {
type = "input",
name = "Power Infusion Thanks",
desc = "Whisper sent to caster when receiving Power Infusion",
get = "GetWhisperPowerInfusion",
set = "SetWhisperPowerInfusion",
width = "double",
order = 58
},
-- SPELL MANAGEMENT
spellManagementHeader = {
type = "header",
name = "Spell Management",
order = 70
},
showSpellListButton = {
type = "execute",
name = "Manage Tracked Spells",
desc = "Open an interactive window to view and remove tracked spells",
func = "ShowSpellListFrame",
width = "full",
order = 71
},
spacer2 = {
type = "description",
name = " ",
fontSize = "small",
width = "full",
order = 72
},
addSpellInput = {
type = "input",
name = "Add Spell ID",
desc = "Enter a spell ID to track (you can find spell IDs on Wowhead)",
get = "GetAddSpellInput",
set = "SetAddSpellInput",
width = "normal",
order = 73
},
addSpellButton = {
type = "execute",
name = "Add Spell",
desc = "Add the entered spell ID to tracking",
func = "AddSpellFromInput",
width = "normal",
order = 74
},
removeSpellInput = {
type = "input",
name = "Remove Spell ID",
desc = "Enter a spell ID to remove from tracking",
get = "GetRemoveSpellInput",
set = "SetRemoveSpellInput",
width = "normal",
order = 75
},
removeSpellButton = {
type = "execute",
name = "Remove Spell",
desc = "Remove the entered spell ID from tracking",
func = "RemoveSpellFromInput",
width = "normal",
order = 76
},
resetSpellsButton = {
type = "execute",
name = "Reset to Defaults",
desc = "Reset all spell tracking to default settings (removes custom spells and restores removed defaults)",
func = "ResetSpellsToDefault",
width = "full",
order = 77
}
}
}
-- Loading Config Frame
if LibStub then
LibStub("AceConfig-3.0"):RegisterOptionsTable("Headsup", optionsFrameModel)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Headsup")
-- Store the options frame model for dynamic updates
self.optionsFrameModel = optionsFrameModel
-- Create the spell list frame
self:CreateSpellListFrame()
-- Initialize the spell list
self:RefreshSpellsList()
else
print("Headsup: AceConfig library not found. GUI configuration not available.")
end
end
-- Create the scrollable spell list frame
function Headsup:CreateSpellListFrame()
if spellListFrame then
return -- Already created
end
-- Main frame
spellListFrame = CreateFrame("Frame", "HeadsupSpellListFrame", UIParent)
spellListFrame:SetWidth(520)
spellListFrame:SetHeight(500)
spellListFrame:SetPoint("CENTER")
spellListFrame:SetFrameStrata("DIALOG")
spellListFrame:SetMovable(true)
spellListFrame:EnableMouse(true)
spellListFrame:RegisterForDrag("LeftButton")
spellListFrame:SetScript("OnDragStart", spellListFrame.StartMoving)
spellListFrame:SetScript("OnDragStop", spellListFrame.StopMovingOrSizing)
spellListFrame:Hide()
-- Background
spellListFrame.bg = spellListFrame:CreateTexture(nil, "BACKGROUND")
spellListFrame.bg:SetAllPoints()
spellListFrame.bg:SetTexture(0, 0, 0, 0.8)
-- Border
spellListFrame.border = CreateFrame("Frame", nil, spellListFrame)
spellListFrame.border:SetAllPoints()
spellListFrame.border:SetBackdrop({
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 16,
insets = {
left = 4,
right = 4,
top = 4,
bottom = 4
}
})
spellListFrame.border:SetBackdropBorderColor(1, 1, 1, 1)
-- Title
spellListFrame.title = spellListFrame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
spellListFrame.title:SetPoint("TOP", 0, -10)
spellListFrame.title:SetText("Manage Tracked Spells")
-- Close button
spellListFrame.closeButton = CreateFrame("Button", nil, spellListFrame, "UIPanelCloseButton")
spellListFrame.closeButton:SetPoint("TOPRIGHT", -5, -5)
spellListFrame.closeButton:SetScript("OnClick", function()
spellListFrame:Hide()
end)
-- Scroll frame
spellListScrollFrame = CreateFrame("ScrollFrame", "HeadsupSpellListScrollFrame", spellListFrame,
"UIPanelScrollFrameTemplate")
spellListScrollFrame:SetPoint("TOPLEFT", 10, -35)
spellListScrollFrame:SetPoint("BOTTOMRIGHT", -30, 40)
-- Content container
spellListContent = CreateFrame("Frame", "HeadsupSpellListContent", spellListScrollFrame)
spellListContent:SetWidth(spellListScrollFrame:GetWidth() - 20)
spellListContent:SetHeight(1) -- Will be updated dynamically
spellListScrollFrame:SetScrollChild(spellListContent)
-- Close button (bottom)
spellListFrame.closeButtonBottom = CreateFrame("Button", nil, spellListFrame, "UIPanelButtonTemplate")
spellListFrame.closeButtonBottom:SetWidth(100)
spellListFrame.closeButtonBottom:SetHeight(22)
spellListFrame.closeButtonBottom:SetPoint("BOTTOM", 0, 10)
spellListFrame.closeButtonBottom:SetText("Close")
spellListFrame.closeButtonBottom:SetScript("OnClick", function()
spellListFrame:Hide()
end)
end
-- Create individual spell row
function Headsup:CreateSpellRow(spellID, yOffset)
local row = CreateFrame("Frame", nil, spellListContent)
row:SetWidth(spellListContent:GetWidth())
row:SetHeight(26)
row:SetPoint("TOPLEFT", 0, yOffset)
-- Background for hover effect
row.bg = row:CreateTexture(nil, "BACKGROUND")
row.bg:SetAllPoints()
row.bg:SetTexture(0.1, 0.1, 0.1, 0.5)
row.bg:Hide()
row:EnableMouse(true)
row:SetScript("OnEnter", function()
row.bg:Show()
end)
row:SetScript("OnLeave", function()
row.bg:Hide()
end)
-- Spell icon and link with tooltip
local spellName, _, spellIcon = GetSpellInfo(spellID)
if spellName then
-- Create spell icon
row.spellIcon = row:CreateTexture(nil, "ARTWORK")
row.spellIcon:SetWidth(20)
row.spellIcon:SetHeight(20)
row.spellIcon:SetPoint("LEFT", 5, 0)
if spellIcon then
row.spellIcon:SetTexture(spellIcon)
else
-- Default icon for spells without icons
row.spellIcon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark")
end
-- Create a clickable frame for the spell link to enable tooltips
row.spellLinkFrame = CreateFrame("Frame", nil, row)
row.spellLinkFrame:SetWidth(195) -- Reduced width to account for icon
row.spellLinkFrame:SetHeight(20)
row.spellLinkFrame:SetPoint("LEFT", row.spellIcon, "RIGHT", 5, 0)
row.spellLinkFrame:EnableMouse(true)
row.spellLink = row.spellLinkFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
row.spellLink:SetAllPoints()
local spellLink = GetSpellLink(spellID)
if spellLink then
row.spellLink:SetText(spellLink)
else
row.spellLink:SetText("|cff71d5ff[" .. spellName .. "]|r")
end
row.spellLink:SetJustifyH("LEFT")
-- Add spell tooltip on hover
row.spellLinkFrame:SetScript("OnEnter", function(self)
row.bg:Show() -- Show row highlight
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
-- Try multiple methods for WotLK compatibility
local spellLink = GetSpellLink(spellID)
if spellLink then
-- Use the spell link for tooltip (most compatible)
GameTooltip:SetHyperlink(spellLink)
else
-- Fallback to spell name and ID
local spellName = GetSpellInfo(spellID)
if spellName then
GameTooltip:AddLine(spellName, 1, 1, 1)
GameTooltip:AddLine("Spell ID: " .. spellID, 0.8, 0.8, 0.8)
else
GameTooltip:AddLine("Unknown Spell", 1, 0.5, 0.5)
GameTooltip:AddLine("Spell ID: " .. spellID, 0.8, 0.8, 0.8)
end
end
GameTooltip:Show()
end)
row.spellLinkFrame:SetScript("OnLeave", function(self)
row.bg:Hide() -- Hide row highlight
GameTooltip:Hide()
end)
-- Allow clicking on the spell link (standard WoW behavior)
row.spellLinkFrame:SetScript("OnMouseUp", function(self, button)
if button == "LeftButton" and IsShiftKeyDown() then
-- Shift-click to link in chat
local spellLink = GetSpellLink(spellID)
if spellLink and ChatEdit_GetActiveWindow() then
ChatEdit_InsertLink(spellLink)
end
end
end)
else
-- Create question mark icon for unknown spells
row.spellIcon = row:CreateTexture(nil, "ARTWORK")
row.spellIcon:SetWidth(20)
row.spellIcon:SetHeight(20)
row.spellIcon:SetPoint("LEFT", 5, 0)
row.spellIcon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark")
row.spellLinkFrame = CreateFrame("Frame", nil, row)
row.spellLinkFrame:SetWidth(195)
row.spellLinkFrame:SetHeight(20)
row.spellLinkFrame:SetPoint("LEFT", row.spellIcon, "RIGHT", 5, 0)
row.spellLink = row.spellLinkFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
row.spellLink:SetAllPoints()
row.spellLink:SetText("|cffff6b6b(Unknown Spell)|r")
row.spellLink:SetJustifyH("LEFT")
-- No tooltip for unknown spells, but show helpful message
row.spellLinkFrame:EnableMouse(true)
row.spellLinkFrame:SetScript("OnEnter", function(self)
row.bg:Show()
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:AddLine("Unknown Spell", 1, 0.5, 0.5)
GameTooltip:AddLine("Spell ID: " .. spellID, 0.8, 0.8, 0.8)
GameTooltip:AddLine("This spell may not exist or may be from a different game version.", 0.6, 0.6, 0.6, true)
GameTooltip:Show()
end)
row.spellLinkFrame:SetScript("OnLeave", function(self)
row.bg:Hide()
GameTooltip:Hide()
end)
end
-- Spell ID
row.spellID = row:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
row.spellID:SetPoint("LEFT", row.spellLinkFrame, "RIGHT", 10, 0)
row.spellID:SetText("|cff888888ID: " .. spellID .. "|r")
row.spellID:SetJustifyH("LEFT")
row.spellID:SetWidth(80)
-- Spell type indicator
local typeText = ""
if HeadsupDB.customSpells and HeadsupDB.customSpells[spellID] then
typeText = "|cff00ff00(Custom)|r"
elseif TRACKED_SPELLS and TRACKED_SPELLS[spellID] then
typeText = "|cff4f9eff(Default)|r"
end
row.spellType = row:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
row.spellType:SetPoint("LEFT", row.spellID, "RIGHT", 5, 0)
row.spellType:SetText(typeText)
row.spellType:SetJustifyH("LEFT")
row.spellType:SetWidth(70)
-- Remove button
row.removeButton = CreateFrame("Button", nil, row, "UIPanelButtonTemplate")
row.removeButton:SetWidth(60)
row.removeButton:SetHeight(20)
row.removeButton:SetPoint("RIGHT", -5, 0)
row.removeButton:SetText("Remove")
row.removeButton:SetScript("OnClick", function()
if Headsup.RemoveSpell then
Headsup:RemoveSpell(spellID)
Headsup:RefreshSpellsList()
else
print("Headsup: RemoveSpell function not available")
end
end)
-- All spells use same "Remove" text since they're all actually removed from tracking
-- Default spells can be restored via "Reset to Defaults" button
return row
end
-- Show the spell list frame
function Headsup:ShowSpellListFrame()
if not spellListFrame then
self:CreateSpellListFrame()
end
self:RefreshSpellsList()
spellListFrame:Show()
end
-- Getter and setter functions for the configuration interface
function Headsup:IsHeadsupEnabled()
return HeadsupDB.enabled
end
function Headsup:ToggleEnable()
HeadsupDB.enabled = not HeadsupDB.enabled
if HeadsupDB.enabled then
if mainFrame then
mainFrame:Show()
end
print("Headsup: Enabled")
else
if mainFrame then
mainFrame:Hide()
end
print("Headsup: Disabled")
end
end
function Headsup:GetIconSize()
return HeadsupDB.iconSize
end
function Headsup:SetIconSize(info, value)
HeadsupDB.iconSize = value
-- Update frame sizes if the UpdateFrameSizes function exists
if UpdateFrameSizes then
UpdateFrameSizes()
end
end
function Headsup:GetSpacing()
return HeadsupDB.spacing
end
function Headsup:SetSpacing(info, value)
HeadsupDB.spacing = value
-- Update positions if the PositionFrames function exists
if PositionFrames then
PositionFrames()
end
end
function Headsup:GetYOffset()
return HeadsupDB.yOffset
end
function Headsup:SetYOffset(info, value)
HeadsupDB.yOffset = value
-- Update main frame position if the UpdateMainFramePosition function exists
if UpdateMainFramePosition then
UpdateMainFramePosition()
end
end
function Headsup:GetShowSpellName()
return HeadsupDB.showSpellName
end
function Headsup:SetShowSpellName(info, value)
HeadsupDB.showSpellName = value
-- Update spell name visibility if the UpdateSpellNameVisibility function exists
if UpdateSpellNameVisibility then
UpdateSpellNameVisibility()
end
print("Headsup: Spell names " .. (value and "enabled" or "disabled"))
end
function Headsup:GetTimerFontSize()
return HeadsupDB.timerFontSize
end
function Headsup:SetTimerFontSize(info, value)
HeadsupDB.timerFontSize = value
-- Update font sizes if the UpdateFontSizes function exists
if UpdateFontSizes then
UpdateFontSizes()
end
print("Headsup: Timer font size set to " .. value)
end
function Headsup:GetSpellNameFontSize()
return HeadsupDB.spellNameFontSize
end
function Headsup:SetSpellNameFontSize(info, value)
HeadsupDB.spellNameFontSize = value
-- Update font sizes if the UpdateFontSizes function exists
if UpdateFontSizes then
UpdateFontSizes()
end
print("Headsup: Spell name font size set to " .. value)
end
function Headsup:TestDisplay()
-- Test with some common spells
if ShowBuff then
ShowBuff(12536, 15) -- Arcane Concentration
ShowBuff(48108, 20) -- Hot Streak
-- Test stack count display with Maelstrom Weapon (which can stack)
local testSpellID = 53817 -- Maelstrom Weapon
local buffData = activeBuffs[testSpellID] or {}
if not buffData.frame then
buffData.frame = CreateSpellFrame(testSpellID)
end
-- Mock stack count for testing (Maelstrom Weapon can stack to 5)
buffData.stackCount = 3
buffData.expireTime = GetTime() + 30
-- Update stack count display
buffData.frame.stackCount:SetText(buffData.stackCount)
buffData.frame.stackCount:Show()
buffData.frame:Show()
activeBuffs[testSpellID] = buffData
if PositionFrames then
PositionFrames()
end
print("Headsup: Test buffs displayed (including stacked buff)")
else
print("Headsup: ShowBuff function not available")
end
end
function Headsup:ClearAllBuffs()
if activeBuffs and HideBuff then
for spellID in pairs(activeBuffs) do
HideBuff(spellID)
end
print("Headsup: All buffs cleared")
else
print("Headsup: Clear function not available")
end
end
-- Spell Management Functions
-- Variables to store input values
local addSpellInputValue = ""
local removeSpellInputValue = ""
function Headsup:GetAddSpellInput()
return addSpellInputValue
end
function Headsup:SetAddSpellInput(info, value)
addSpellInputValue = value or ""
end
function Headsup:GetRemoveSpellInput()
return removeSpellInputValue
end
function Headsup:SetRemoveSpellInput(info, value)
removeSpellInputValue = value or ""
end
function Headsup:AddSpellFromInput()
local spellID = tonumber(addSpellInputValue)
if spellID and spellID > 0 then
if self.AddSpell then
self:AddSpell(spellID)
addSpellInputValue = "" -- Clear input after adding
self:RefreshSpellsList() -- Update the list
else
print("Headsup: AddSpell function not available")
end
else
print("Headsup: Please enter a valid spell ID (number)")
end
end
function Headsup:RemoveSpellFromInput()
local spellID = tonumber(removeSpellInputValue)
if spellID and spellID > 0 then
if self.RemoveSpell then
self:RemoveSpell(spellID)
removeSpellInputValue = "" -- Clear input after removing
self:RefreshSpellsList() -- Update the list
else
print("Headsup: RemoveSpell function not available")
end
else
print("Headsup: Please enter a valid spell ID (number)")
end
end
function Headsup:RefreshSpellsList()
if not spellListContent then
return -- Frame not created yet
end
-- Clear existing buttons
for _, button in pairs(spellButtons) do
button:Hide()
button:SetParent(nil)
end
spellButtons = {}
if GetAllTrackedSpells then
local trackedSpells = GetAllTrackedSpells()
local count = 0
-- Convert to sorted array for better display
local sortedSpells = {}
for spellID in pairs(trackedSpells) do
table.insert(sortedSpells, spellID)
end
table.sort(sortedSpells)
-- Create rows for each spell
local yOffset = 0
for _, spellID in ipairs(sortedSpells) do
local row = self:CreateSpellRow(spellID, yOffset)
table.insert(spellButtons, row)
yOffset = yOffset - 28 -- 26 height + 2 spacing
count = count + 1
end
-- Update content height
local totalHeight = math.max(count * 28, 100)
spellListContent:SetHeight(totalHeight)
-- Update title with count
if spellListFrame and spellListFrame.title then
if count == 0 then
spellListFrame.title:SetText("No Spells Tracked")
else
spellListFrame.title:SetText("Manage Tracked Spells (" .. count .. ")")
end
end
print("Headsup: Spell list refreshed - " .. count .. " spells tracked")
else
print("Headsup: GetAllTrackedSpells function not available")
end
end
function Headsup:ResetSpellsToDefault()
-- Clear custom and removed spell lists
HeadsupDB.customSpells = {}
HeadsupDB.removedSpells = {}
-- Clear any currently displayed custom buffs
if activeBuffs and HideBuff then
for spellID in pairs(activeBuffs) do
if not TRACKED_SPELLS[spellID] then
HideBuff(spellID)
end
end
end
self:RefreshSpellsList()
print("Headsup: Reset to default spell tracking")
end
-- Sound setting functions
function Headsup:GetEnableSound()
return HeadsupDB.enableSound
end
function Headsup:SetEnableSound(info, value)
HeadsupDB.enableSound = value
print("Headsup: Sound " .. (value and "enabled" or "disabled"))
end
function Headsup:GetSoundChoice()
return HeadsupDB.soundChoice
end
function Headsup:SetSoundChoice(info, value)
HeadsupDB.soundChoice = value
print("Headsup: Sound changed to " .. value)
end
function Headsup:TestSound()
if HeadsupDB.soundChoice then
PlaySoundFile(HeadsupDB.soundChoice)
print("Headsup: Playing sound " .. HeadsupDB.soundChoice)
else
print("Headsup: No sound selected")
end
end
-- Visual Effects getter/setter functions