-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmage_spellmenu.lua
1065 lines (983 loc) · 37.7 KB
/
mage_spellmenu.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
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
local debugOptions = {
scrollChild = false,
header = false,
spells = false,
}
-- L for translations
local L = LibStub("AceLocale-3.0"):GetLocale("ConROC");
local ConROC_Mage, ids = ...;
local ConROC_RolesTable = {};
local wandFrame =0;
local lastFrame = 0;
local showOptions = false;
local fixOptionsWidth = false;
local frameWidth = math.ceil(ConROCSpellmenuFrame:GetWidth()*2);
local spellFrameHeight = 0;
local scrollContentWidth = frameWidth - 30;
local scrollHeight = 0;
local plvl = UnitLevel('player');
local defaults = {
["ConROC_SM_Role_Caster"] = true,
["ConROC_Caster_Armor_Ice"] = true,
["ConROC_Caster_Filler_Fireball"] = true,
["ConROC_Caster_AoE_ArcaneExplosion"] = false,
["ConROC_Caster_AoE_Flamestrike"] = false,
["ConROC_Caster_AoE_Blizzard"] = false,
["ConROC_Caster_Option_UseWand"] = false,
["ConROC_Caster_Option_AoE"] = true,
["ConROC_Caster_Rune_ArcaneBlastCount"] = 2,
["ConROC_PvP_Rune_ArcaneBlastCount"] = 2,
}
ConROCMageSpells = ConROCMageSpells or defaults;
local radioGroups = {}
function ConROC:setRole(radioBtn, roleData, radioButtons)
for _, btn in ipairs(radioButtons) do
btn:SetChecked(false)
ConROCMageSpells[btn.role] = false
end
radioBtn:SetChecked(true)
ConROCMageSpells[roleData.role] = true
end
function ConROC:checkActiveRole()
for _, roleSettings in ipairs(ConROC_RoleSettingsTable) do
local frameName = roleSettings.frameName
local role = _G[roleSettings.role]
if role:GetChecked() then
local checkboxName = "ConROC_"..frameName.."_"
-- The frame with matching name is checked, perform actions here
return role, checkboxName, frameName
end
end
end
function ConROC:setRoleChecked(_spellData, _oItem)
local activeRole, checkboxName, _ = ConROC:checkActiveRole()
if ConROC:CheckBox(activeRole) then
local spellCheck = checkboxName .. _spellData.spellCheckbox
if _spellData.type == "textfield" then
_oItem:SetNumber(ConROCMageSpells[spellCheck]);
else
_oItem:SetChecked(ConROCMageSpells[spellCheck]);
end
end
end
function ConROC:setRoleSpellClicked(_spellData, _oItem)
local activeRole, checkboxName, _ = ConROC:checkActiveRole()
if ConROC:CheckBox(activeRole) then
local spellCheck = checkboxName .. _spellData.spellCheckbox
if _spellData.type == "textfield" then
ConROCMageSpells[spellCheck] = _G["ConROC_SM_".._spellData.spellCheckbox]:GetNumber();
else
ConROCMageSpells[spellCheck] = _oItem:GetChecked();
end
end
end
local function CheckScrollbarVisibility()
local scrollChildHeight = math.ceil(ConROCScrollChild:GetHeight())
local containerHeight = math.ceil(ConROCScrollFrame:GetHeight())
if scrollChildHeight <= containerHeight then
ConROCScrollbar:Hide()
ConROCScrollContainer:SetHeight(math.ceil(ConROCScrollChild:GetHeight())+16)
ConROCSpellmenuFrame:SetHeight(math.ceil(ConROCScrollContainer:GetHeight())+68)
ConROCScrollFrame:SetPoint("TOPLEFT", 8, -8)
ConROCScrollFrame:SetPoint("BOTTOMRIGHT", -28, 8)
ConROCScrollChild:SetWidth(ConROCScrollFrame:GetWidth())
else
ConROCScrollbar:Show()
ConROCSpellmenuFrame:SetHeight(300)
ConROCScrollContainer:SetHeight(237)
ConROCScrollFrame:SetPoint("TOPLEFT", 8, -8)
ConROCScrollFrame:SetPoint("BOTTOMRIGHT", -28, 8)
ConROCScrollChild:SetWidth(ConROCScrollFrame:GetWidth())
end
end
function ConROC:RotationChoices()
ConROC:UpdateSpellID();
ConROC_RoleSettingsTable = {
{
frameName = "Caster",
activeTexture = ConROC.Textures.Caster,
disabledTexture = ConROC.Textures.Caster_disabled,
role = "ConROC_SM_Role_Caster",
},
{
frameName = "PvP",
activeTexture = ConROC.Textures.PvP,
disabledTexture = ConROC.Textures.PvP_disabled,
role = "ConROC_SM_Role_PvP",
},
}
ConROC_RotationSettingsTable = {
{
frameName = "Runes",
spells = {
{spellID = ids.Runes.ArcaneBlast, spellCheckbox = "Rune_ArcaneBlast", reqLevel = 1, type = "spell"},
{spellID = ids.Runes.ArcaneBlast, spellCheckbox = "Rune_ArcaneBlastCount", reqLevel = 1, type = "textfield", icon = 230237, customName = "Number of Arcane Blast"},
--{spellID = ids.Runes.ArcaneSurge, spellCheckbox = "Rune_ArcaneSurge", reqLevel = 1, type = "spell"},
{spellID = ids.Runes.IceLance, spellCheckbox = "Rune_IceLance", reqLevel = 1, type = "spell"},
{spellID = ids.Runes.IcyVeins, spellCheckbox = "Rune_IcyVeins", reqLevel = 1, type = "spell"},
{spellID = ids.Runes.LivingBomb, spellCheckbox = "Rune_LivingBomb", reqLevel = 1, type = "spell"},
{spellID = ids.Runes.LivingFlame, spellCheckbox = "Rune_LivingFlame", reqLevel = 1, type = "spell"},
{spellID = ids.Runes.MassRegeneration, spellCheckbox = "Rune_MassRegeneration", reqLevel = 1, type = "spell"},
{spellID = ids.Runes.Regeneration, spellCheckbox = "Rune_Regeneration", reqLevel = 1, type = "spell"},
{spellID = ids.Runes.RewindTime, spellCheckbox = "Rune_RewindTime", reqLevel = 1, type = "spell"},
},
groupType = "checkBoxes"
},
{
frameName = "Armors",
spells = {
{spellID = ids.Ability.IceArmor, spellCheckbox = "Armor_Ice", reqLevel = 1, type="spell"},
{spellID = ids.Runes.MoltenArmor, spellCheckbox = "Armor_MoltenArmor", reqLevel = 1, type="spell"},
{spellID = ids.Ability.MageArmor, spellCheckbox = "Armor_Mage", reqLevel = 34, type="spell"},
},
groupType = "radioButtons"
},
{
frameName = "Filler",
spells = {
{spellID = ids.Ability.Fireball, spellCheckbox = "Filler_Fireball", reqLevel = 1, type="spell"},
{spellID = ids.Runes.FrostfireBolt, spellCheckbox = "Filler_FrostfireBolt", reqLevel = 1, type="spell"},
{spellID = ids.Ability.Frostbolt, spellCheckbox = "Filler_Frostbolt", reqLevel = 4, type="spell"},
{spellID = ids.Ability.ArcaneMissiles, spellCheckbox = "Filler_ArcaneMissiles", reqLevel = 8, type="spell"}
},
groupType = "radioButtons"
},
{
frameName = "Cooldowns",
spells = {
{spellID = ids.Ability.Evocation, spellCheckbox = "CD_Evocation", reqLevel = 20, type="spell"},
{spellID = ids.Ability.ArcanePower, spellCheckbox = "CD_ArcanePower", reqLevel = 40, type="spell"},
{spellID = ids.Ability.Combustion, spellCheckbox = "CD_Combustion", reqLevel = 40, type="spell"},
},
groupType = "checkBoxes"
},
{
frameName = "AoEs",
spells = {
{spellID = ids.Ability.ArcaneExplosion, spellCheckbox = "AoE_ArcaneExplosion", reqLevel = 14, type="spell"},
{spellID = ids.Ability.Flamestrike, spellCheckbox = "AoE_Flamestrike", reqLevel = 16, type="spell"},
{spellID = ids.Ability.Blizzard, spellCheckbox = "AoE_Blizzard", reqLevel = 20, type="spell"}
},
groupType = "checkBoxes"
},
{
frameName = "Options",
spells = {
--{spellID = "Hide rotation window out of combat", spellCheckbox = "Option_HideRotation", reqLevel = 1, type="custom", customName="Hide Out of Combat"},
{spellID = "AoE Toggle Button", spellCheckbox = "Option_AoE", reqLevel = 14, type="aoetoggler"},
{spellID = "Use Wand", spellCheckbox = "Option_UseWand", reqLevel = 5, type="wand"},
}
}
}
end
function ConROC:SpellmenuClass()
ConROC:RotationChoices();
local _, Class, classId = UnitClass("player")
local Color = RAID_CLASS_COLORS[Class]
local frame = CreateFrame("Frame", "ConROCSpellmenuClass", ConROCSpellmenuFrame)
frame:SetFrameStrata('MEDIUM');
frame:SetFrameLevel('5')
frame:SetSize(frameWidth, 30)
frame:SetAlpha(1)
frame:SetPoint("TOP", "ConROCSpellmenuFrame_Title", "BOTTOM", 0, 0)
frame:SetMovable(false)
frame:EnableMouse(true)
frame:SetClampedToScreen(true)
ConROC_roles(frame)
frame:Hide();
lastFrame = frame;
-- create the frame and set its properties
ConROCScrollContainer = CreateFrame("Frame", "ConROC_ScrollContainer", ConROCSpellmenuClass, "BackdropTemplate")
ConROCScrollContainer:SetSize(frameWidth - 6, 237)
ConROCScrollContainer:SetPoint("TOP", ConROCSpellmenuClass, "CENTER", 0, -20)
ConROCScrollContainer:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
nil,
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
})
if debugOptions.scrollChild then
ConROCScrollContainer:SetBackdropColor(0,1,0,0.2)
else
ConROCScrollContainer:SetBackdropColor(0,0,0,0.0)
end
ConROCScrollContainer:Show()
-- create the scroll frame and set its properties
ConROCScrollFrame = CreateFrame("ScrollFrame", "ConROC_ScrollFrame", ConROCScrollContainer, "UIPanelScrollFrameTemplate BackdropTemplate")
ConROCScrollFrame:SetPoint("TOPLEFT", 8, -8)
ConROCScrollFrame:SetPoint("BOTTOMRIGHT", -28, 8)
ConROCScrollFrame:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
nil,
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
})
if debugOptions.scrollChild then
ConROCScrollFrame:SetBackdropColor(0,0,1,0.2)
else
ConROCScrollFrame:SetBackdropColor(0,0,0,0.0)
end
ConROCScrollFrame:Show()
scrollContentWidth = ConROCScrollFrame:GetWidth()
-- create the child frame and set its properties
ConROCScrollChild = CreateFrame("Frame", "ConROC_ScrollChild", ConROCScrollFrame, "BackdropTemplate")
ConROCScrollChild:SetSize(ConROCScrollFrame:GetWidth(), ConROCScrollFrame:GetHeight())
ConROCScrollFrame:SetScrollChild(ConROCScrollChild)
ConROCScrollChild:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
nil,
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
})
if debugOptions.scrollChild then
ConROCScrollChild:SetBackdropColor(1,0,0,0.2)
else
ConROCScrollChild:SetBackdropColor(0,0,0,0.0)
end
ConROCScrollChild:Show()
-- create the scrollbar and set its properties
ConROCScrollbar = _G[ConROCScrollFrame:GetName() .. "ScrollBar"]
ConROCScrollbar:SetValueStep(10)
ConROCScrollbar.scrollStep = 10
ConROCScrollbar:SetPoint("TOPLEFT", ConROCScrollFrame, "TOPRIGHT", 4, -16)
ConROCScrollbar:SetPoint("BOTTOMLEFT", ConROCScrollFrame, "BOTTOMRIGHT", 4, 16)
ConROCScrollbar:SetWidth(16)
lastFrame = ConROCScrollChild;
ConROCScrollContainer:Show();
ConROCScrollFrame:Show();
ConROCScrollChild:Show();
ConROC_OptionsWindow(ConROC_RotationSettingsTable, ConROC_RoleSettingsTable)
showOptions = true;
fixOptionsWidth = true;
-- Register for events to check scrollbar visibility
ConROCScrollChild:SetScript("OnSizeChanged", CheckScrollbarVisibility)
ConROCScrollContainer:SetScript("OnShow", CheckScrollbarVisibility)
end
local function ConROC_NoOptionsFrame()
if ConROCNoOptions then
return
end
if not ConROCScrollChild then
return
end
-- Create ConROCNoOptions frame inside ConROCScrollChild
ConROCNoOptions = CreateFrame("Frame", "ConROC_NoOptions", ConROCScrollFrame)
ConROCNoOptions:SetSize(ConROCScrollFrame:GetWidth(), 80) -- Start with a minimum height, will be adjusted dynamically
ConROCNoOptions:SetPoint("TOPLEFT", ConROCScrollFrame, "TOPLEFT", 0, 0)
ConROCNoOptions.text = ConROCNoOptions:CreateFontString(nil, "ARTWORK", "GameFontNormal")
ConROCNoOptions.text:SetPoint("TOPLEFT", ConROCNoOptions, "TOPLEFT", 0, 0)
ConROCNoOptions.text:SetWidth(ConROCNoOptions:GetWidth()) -- Set the width to match the frame width
ConROCNoOptions.text:SetText(L["NO_SPELLS_TO_LIST"])
ConROCNoOptions.text:SetJustifyH("LEFT")
ConROCNoOptions.text:SetSpacing(2)
ConROCNoOptions.text:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
ConROCNoOptions.text:SetTextColor(1, 1, 1) -- White color
ConROCNoOptions:SetHeight(ConROCNoOptions.text:GetHeight())
ConROCNoOptions:Show()
end
function ConROC_roles(frame)
local radioButtons = {}
local roleIconSize = 32;
local sizeCheck = (math.ceil(frame:GetWidth()-20)/#ConROC_RoleSettingsTable)
if(sizeCheck <= 34) then
roleIconSize = 28;
elseif (sizeCheck <= 28) then
roleIconSize = 24
end
local roleSpaceValue = (math.ceil(frame:GetWidth())-20-roleIconSize) / (#ConROC_RoleSettingsTable-1)
for i, roleData in ipairs(ConROC_RoleSettingsTable) do
local radioBtn = CreateFrame("CheckButton", roleData.role, frame, "UIRadioButtonTemplate")
radioBtn:SetSize(roleIconSize, roleIconSize)
local radioNormalTexture = radioBtn:GetNormalTexture()
radioNormalTexture:SetTexture(nil)
radioNormalTexture:SetAlpha(0)
local radioHighlightTexture = radioBtn:GetHighlightTexture()
radioHighlightTexture:SetTexture(nil)
radioHighlightTexture:SetAlpha(0)
local radioCheckedTexture = radioBtn:GetCheckedTexture()
radioCheckedTexture:SetTexture(nil)
radioCheckedTexture:SetAlpha(0)
radioBtn:SetPoint("TOPLEFT", frame, "TOPLEFT", (10 + (i - 1) * roleSpaceValue), -2)
radioBtn:SetChecked(ConROCMageSpells[roleData.role])
local checkedTexture = radioBtn:CreateTexture(nil, "ARTWORK")
checkedTexture:SetTexture(roleData.activeTexture)
checkedTexture:SetBlendMode("BLEND")
checkedTexture:SetSize(roleIconSize, roleIconSize)
checkedTexture:SetPoint("CENTER", radioBtn, "CENTER", 0, 0)
radioBtn:SetCheckedTexture(checkedTexture)
local uncheckedTexture = radioBtn:CreateTexture(nil, "ARTWORK")
uncheckedTexture:SetTexture(roleData.disabledTexture)
uncheckedTexture:SetBlendMode("BLEND")
uncheckedTexture:SetSize(roleIconSize, roleIconSize)
uncheckedTexture:SetPoint("CENTER", radioBtn, "CENTER", 0, 0)
radioBtn:SetNormalTexture(uncheckedTexture)
radioBtn:SetScript("OnClick", function(self)
ConROC:setRole(self, roleData, radioButtons)
ConROC:RoleProfile()
end)
local radioText = radioBtn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
radioText:SetText(roleData.frameName)
radioText:SetPoint("BOTTOM", radioBtn, "TOP", 0, -5)
radioBtn.role = roleData.role
table.insert(radioButtons, radioBtn)
end
end
function ConROC_OptionsWindow(_table, _roles)
local _, Class, classId = UnitClass("player")
local Color = RAID_CLASS_COLORS[Class]
-- create the child frames and add text to them
for i = 1, #_table do
local radioButtonsTable = {}
local frame = CreateFrame("Frame", "ConROC_CheckHeader"..i, ConROCScrollChild, "BackdropTemplate")
frame:SetSize(scrollContentWidth, 20)
if i == 1 then
frame:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0)
else
frame:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, -10)
end
if debugOptions.header then
frame:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
nil,
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
})
local r, g, b = math.random(), math.random(), math.random()
frame:SetBackdropColor(r, g, b, 0.5)
end
scrollHeight = scrollHeight + math.ceil(frame:GetHeight());
frame:Show()
local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
text:SetPoint("CENTER", frame, "CENTER")
text:SetText(_table[i].frameName)
frame.text = text -- store the text object in the frame for later use
spellFrameHeight = 0;
local _spellFrame = CreateFrame("Frame", "ConROC_CheckFrame"..i, frame, "BackdropTemplate");
_spellFrame:SetSize(scrollContentWidth, 5)
_spellFrame:SetPoint("TOPLEFT", "ConROC_CheckHeader"..i, "BOTTOMLEFT", 0, 0)
if debugOptions.spells then
_spellFrame:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
nil,
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
})
local r, g, b = math.random(), math.random(), math.random()
_spellFrame:SetBackdropColor(r, g, b, 0.5)
end
lastFrame = _spellFrame;
scrollHeight = scrollHeight + 5;
local _spells = _table[i].spells
for j = 1, #_spells do
local _spellData = _spells[j]
if _spellData.type == "spell" or _spellData.type == "poison" then
if _table[i].groupType == "radioButtons" then
ConROC:OptionRadioButtonSpell(_spellData, i, j, _spellFrame, radioButtonsTable);
else
ConROC:OptionCheckboxSpell(_spellData, i, j, _spellFrame);
end
elseif _spellData.type == "wand" then
ConROC:OptionWand(_spellData, i, j, _spellFrame);
elseif _spellData.type == "custom" then
ConROC:CustomOption(_spellData, i, j, _spellFrame);
elseif _spellData.type == "textfield" then
ConROC:OptionTextfield(_spellData, i, j, _spellFrame);
elseif _spellData.type == "aoetoggler" then
ConROC:OptionAoE(_spellData, i, j, _spellFrame);
elseif _spellData.type == "none" then
if _table[i].groupType == "radioButtons" then
ConROC:OptionNone(_spellData, i, j, _spellFrame, _table[i].groupType, radioButtonsTable);
else
ConROC:OptionNone(_spellData, i, j, _spellFrame);
end
end
_spellFrame:SetHeight(spellFrameHeight);
frame:Show();
end
end
ConROCScrollChild:SetHeight(scrollHeight);
end
function ConROC:wandEquipmentChanged(slotID)
local newTexture = 0;
if plvl >= 5 then
if GetInventoryItemTexture("player", 18) == nil then
newTexture = GetItemIcon(44214) -- Default Wand texture
else
newTexture = GetInventoryItemTexture("player", 18);
end
wandFrame.texture:SetTexture(newTexture);
end
ConROC:SpellMenuUpdate();
end
function ConROC:OptionCheckboxSpell(_spellData, i, j, _spellFrame)
--spell start
local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID)
local oItem = CreateFrame("CheckButton", "ConROC_SM_".._spellData.spellCheckbox, _spellFrame, "UICheckButtonTemplate");
local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall");
if j == 1 then
oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0);
end
lastFrame = oItem;
oItem:SetSize(20,20)
ConROC:setRoleChecked(_spellData, oItem)
oItem:SetScript("OnClick",
function(self)
ConROC:setRoleSpellClicked(_spellData, self)
end);
-- static
oItemtext:SetText(spellName);
local c1t = oItem.texture;
if not c1t then
c1t = oItem:CreateTexture('CheckFrame'..j..'_check'..j..'_Texture', 'ARTWORK');
c1t:SetTexture(spellTexture);
c1t:SetBlendMode('BLEND');
oItem.texture = c1t;
end
c1t:SetSize(20,20)
c1t:SetPoint("LEFT", oItem, "RIGHT", 2, 0);
oItemtext:SetPoint('LEFT', c1t, 'RIGHT', 4, 0);
scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight());
lastFrame:Show();
--spell end
end
function ConROC:OptionRadioButtonSpell(_spellData, i, j, _spellFrame, _radioButtonsTable)
--spell start
local spellName, _, spellTexture;
if type(_spellData.spellID) == "number" then
spellName, _, spellTexture = GetSpellInfo(_spellData.spellID)
else
spellName, spellTexture = _spellData.spellID, nil;
end
local myFrame = "ConROC_SM_".._spellData.spellCheckbox
local oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UIRadioButtonTemplate");
local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall");
if j == 1 then
oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0);
end
lastFrame = oItem;
oItem:SetSize(20,20)
ConROC:setRoleChecked(_spellData, oItem)
oItem.spellCheckbox = _spellData.spellCheckbox
_radioButtonsTable[j] = oItem;
oItem:SetScript("OnClick",
function(self)
local role, checkboxName, frameName = ConROC:checkActiveRole()
for _, radioButton in ipairs(_radioButtonsTable) do
if radioButton ~= self then
radioButton:SetChecked(false)
ConROCMageSpells[checkboxName .. radioButton.spellCheckbox] = radioButton:GetChecked()
else
-- Perform any additional logic based on the selected button
self:SetChecked(true)
ConROCMageSpells[checkboxName .. radioButton.spellCheckbox] = self:GetChecked()
end
end
end);
oItemtext:SetText(spellName);
local c1t = oItem.texture;
if not c1t then
c1t = oItem:CreateTexture('CheckFrame'..j..'_check'..j..'_Texture', 'ARTWORK');
c1t:SetTexture(spellTexture);
c1t:SetBlendMode('BLEND');
oItem.texture = c1t;
end
c1t:SetSize(20,20)
c1t:SetPoint("LEFT", oItem, "RIGHT", 2, 0);
if type(_spellData.spellID) == "number" then
oItemtext:SetPoint('LEFT', c1t, 'RIGHT', 4, 0);
else
oItemtext:SetPoint('LEFT', oItem, 'RIGHT', 26, 0);
end
_G[myFrame] = oItem
scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight());
lastFrame:Show();
--spell end
end
function ConROC:OptionWand(_spellData, i, j, _spellFrame)
local myFrame = "ConROC_SM_".._spellData.spellCheckbox
local oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UICheckButtonTemplate");
local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall");
if j == 1 then
oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0);
end
lastFrame = oItem;
oItem:SetSize(20,20)
ConROC:setRoleChecked(_spellData, oItem)
oItem:SetScript("OnClick",
function(self)
ConROC:setRoleSpellClicked(_spellData, self)
if self:GetChecked() then
if (not HasWandEquipped()) then
flashMessage()
end
end
end);
oItemtext:SetText(_spellData.spellID);
local texture = 0;
if GetInventoryItemTexture("player", 18) == nil then
texture = GetItemIcon(44214) -- Default Wand texture
else
texture = GetInventoryItemTexture("player", 18);
end
local c1t = oItem.texture;
if not c1t then
c1t = oItem:CreateTexture('CheckFrame'..j..'_check'..j..'_Texture', 'ARTWORK');
c1t:SetTexture(texture);
c1t:SetBlendMode('BLEND');
oItem.texture = c1t;
end
c1t:SetSize(20,20)
c1t:SetPoint("LEFT", oItem, "RIGHT", 2, 0);
oItemtext:SetPoint('LEFT', c1t, 'RIGHT', 4, 0);
_G[myFrame] = oItem
wandFrame = oItem;
ConROC:wandEquipmentChanged(18);
spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight());
scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight());
lastFrame:Show();
end
function ConROC:OptionTextfield(_spellData, i, j, _spellFrame)
local oItem = CreateFrame("Frame", "ConROC_SM_".._spellData.spellCheckbox.."Frame", _spellFrame,"BackdropTemplate");
oItem:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0},});
oItem:SetBackdropColor(0, 0, 0);
if j == 1 then
oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0);
end
lastFrame = oItem;
oItem:SetSize(20, 20);
local box1 = CreateFrame("EditBox", "ConROC_SM_".._spellData.spellCheckbox, oItem);
box1:SetPoint("TOP", 0, 0);
box1:SetPoint("BOTTOM", 0, 0);
box1:SetMultiLine(false);
box1:SetFontObject(GameFontNormalSmall);
box1:SetNumeric(true);
box1:SetAutoFocus(false);
box1:SetMaxLetters("2");
box1:SetWidth(20);
box1:SetTextInsets(3, 0, 0, 0);
ConROC:setRoleChecked(_spellData, box1)
box1:SetScript("OnEditFocusLost",
function()
ConROC:setRoleSpellClicked(_spellData, box1)
box1:ClearFocus()
end);
box1:SetScript("OnEnterPressed",
function()
ConROC:setRoleSpellClicked(_spellData, box1)
box1:ClearFocus()
end);
box1:SetScript("OnEscapePressed",
function()
ConROC:setRoleSpellClicked(_spellData, box1)
box1:ClearFocus()
end);
local e1t = oItem:CreateTexture('CheckFrame2_oItem_Texture', 'ARTWORK');
e1t:SetTexture(GetItemIcon(_spellData.icon));
e1t:SetBlendMode('BLEND');
e1t:SetSize(20,20);
e1t:SetPoint("LEFT", oItem, "LEFT", 20, 0);
local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall");
if(_spellData.customName) then
oItemtext:SetText(_spellData.customName);
else
oItemtext:SetText(_spellData.spellID);
end
oItemtext:SetPoint('LEFT', e1t, 'RIGHT', 5, 0);
spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight());
scrollHeight = scrollHeight + lastFrame:GetHeight();
lastFrame:Show();
end
function ConROC:CustomOption(_spellData, i, j, _spellFrame)
local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID)
local oItem = CreateFrame("CheckButton", "ConROC_SM_".._spellData.spellCheckbox, _spellFrame, "UICheckButtonTemplate");
local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall");
if j == 1 then
oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0);
end
lastFrame = oItem;
oItem:SetSize(20,20)
ConROC:setRoleChecked(_spellData, oItem)
oItem:SetScript("OnClick",
function(self)
ConROC:setRoleSpellClicked(_spellData, self)
end);
-- static
oItemtext:SetText(_spellData.customName);
local c1t = oItem.texture;
if not c1t then
c1t = oItem:CreateTexture('CheckFrame'..j..'_check'..j..'_Texture', 'ARTWORK');
c1t:SetTexture(spellTexture);
c1t:SetBlendMode('BLEND');
oItem.texture = c1t;
end
c1t:SetSize(20,20)
c1t:SetPoint("LEFT", oItem, "RIGHT", 2, 0);
oItemtext:SetPoint('LEFT', c1t, 'RIGHT', 4, 0);
scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight());
lastFrame:Show();
end
function ConROC:OptionAoE(_spellData, i, j, _spellFrame)
local myFrame = "ConROC_SM_".._spellData.spellCheckbox
local oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UICheckButtonTemplate");
local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall");
if j == 1 then
oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0);
end
lastFrame = oItem;
oItem:SetSize(20,20)
ConROC:setRoleChecked(_spellData, oItem)
if ConROC:CheckBox(ConROC_SM_Option_AoE) then
ConROCButtonFrame:Show();
if ConROC.db.profile.unlockWindow then
ConROCToggleMover:Show();
else
ConROCToggleMover:Hide();
end
else
ConROCButtonFrame:Hide();
ConROCToggleMover:Hide();
end
oItem:SetScript("OnClick",
function(self)
ConROC:setRoleSpellClicked(_spellData, self)
if ConROC:CheckBox(ConROC_SM_Option_AoE) then
ConROCButtonFrame:Show();
if ConROC.db.profile.unlockWindow then
ConROCToggleMover:Show();
else
ConROCToggleMover:Hide();
end
else
ConROCButtonFrame:Hide();
ConROCToggleMover:Hide();
end
end);
oItemtext:SetText(_spellData.spellID);
oItemtext:SetPoint('LEFT', oItem, 'RIGHT', 26, 0);
_G[myFrame] = oItem;
scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight());
lastFrame:Show();
end
function ConROC:OptionNone(_spellData, i, j, _spellFrame, _checkType, _radioButtonsTable)
_checkType = _checkType or nil
_radioButtonsTable = _radioButtonsTable or nil
local myFrame = "ConROC_SM_".._spellData.spellCheckbox
local oItem;
if _checkType == "radioButtons" then
oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UIRadioButtonTemplate");
else
oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UICheckButtonTemplate");
end
local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall");
if j == 1 then
oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0);
end
lastFrame = oItem;
oItem:SetSize(20,20)
ConROC:setRoleChecked(_spellData, oItem)
if _checkType == "radioButtons" then
oItem.spellCheckbox = _spellData.spellCheckbox
_radioButtonsTable[j] = oItem;
oItem:SetScript("OnClick",
function(self)
local role, checkboxName, frameName = ConROC:checkActiveRole()
for _, radioButton in ipairs(_radioButtonsTable) do
if radioButton ~= self then
radioButton:SetChecked(false)
ConROCMageSpells[checkboxName .. radioButton.spellCheckbox] = radioButton:GetChecked()
else
-- Perform any additional logic based on the selected button
self:SetChecked(true)
ConROCMageSpells[checkboxName .. radioButton.spellCheckbox] = self:GetChecked()
end
end
end);
else
oItem:SetScript("OnClick",
function(self)
ConROC:setRoleSpellClicked(_spellData, self)
end);
end
oItemtext:SetText(_spellData.spellID);
oItemtext:SetPoint('LEFT', oItem, 'RIGHT', 26, 0);
_G[myFrame] = oItem;
scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight());
lastFrame:Show();
end
function ConROC:SpellMenuUpdate(newSpell)
ConROC:RotationChoices();
lastFrame = ConROCScrollChild;
local anyHLVisible = false;
scrollHeight = 0;
local _table = ConROC_RotationSettingsTable;
local firstHeadline = 1;
for i = 1, #_table do
local anyChildVisible = false;
local frame = _G["ConROC_CheckHeader"..i]
if i == firstHeadline then
frame:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0)
else
frame:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, -10)
--scrollHeight = scrollHeight + 10;
end
--scrollHeight = scrollHeight + math.ceil(frame:GetHeight());
frame:Show()
local spellFrameHeight = 0;
local _spellFrame = _G["ConROC_CheckFrame"..i];
_spellFrame:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, 0);
local lFrame = _spellFrame;
local _spells = _table[i].spells
local firstItem = 1;
for j = 1, #_spells do
local _spellData = _spells[j]
if _spellData.type == "spell" then
local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID)
local oItem = _G["ConROC_SM_".._spellData.spellCheckbox]
if j == firstItem then
oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0);
end
if type(_spellData.spellID) == "number" then
if plvl >= _spellData.reqLevel and (IsSpellKnown(_spellData.spellID) or IsSpellKnownOrOverridesKnown(_spellData.spellID)) then
lFrame = oItem;
lFrame:Show();
if oItem:IsShown() then
anyChildVisible = true;
scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight());
end
else
if j == firstItem then
if j == #_spells then
--print("all section spells hidden")
else
firstItem = j + 1;
end
end
oItem:Hide()
--print("Hide spell", spellName)
end
end
--spell end
elseif _spellData.type == "wand" then
--Use Wand
local oItem = _G["ConROC_SM_".._spellData.spellCheckbox]
if j == firstItem then
oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0);
end
if plvl >= _spellData.reqLevel then
lFrame = oItem;
lFrame:Show();
if oItem:IsShown() then
anyChildVisible = true;
scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight());
end
local role, checkboxName, frameName = ConROC:checkActiveRole()
local spellName = "ConROC_" .. frameName .. "_" .. _spellData.spellCheckbox
else
if j == firstItem then
if j == #_spells then
--print("all section spells hidden")
else
firstItem = j + 1;
end
end
oItem:Hide();
end
elseif _spellData.type == "aoetoggler" then
local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID)
local oItem = _G["ConROC_SM_".._spellData.spellCheckbox]
if j == firstItem then
oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0);
end
if plvl >= _spellData.reqLevel then
lFrame = oItem;
lFrame:Show();
if oItem:IsShown() then
anyChildVisible = true;
scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight());
end
else
if j == firstItem then
if j == #_spells then
--print("all section spells hidden")
else
firstItem = j + 1;
end
end
oItem:Hide()
end
elseif _spellData.type == "textfield" then
local oItem = _G["ConROC_SM_".._spellData.spellCheckbox.."Frame"]
if j == firstItem then
oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0);
end
if plvl >= _spellData.reqLevel and (IsSpellKnown(_spellData.spellID) or IsSpellKnownOrOverridesKnown(_spellData.spellID)) then
lFrame = oItem;
lFrame:Show();
if oItem:IsShown() then
anyChildVisible = true;
scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight());
end
else
if j == firstItem then
if j == #_spells then
--print("all section spells hidden")
else
firstItem = j + 1;
end
end
oItem:Hide()
end
elseif _spellData.type == "custom" then
--local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID)
local oItem = _G["ConROC_SM_".._spellData.spellCheckbox]
if j == firstItem then
oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0);
end
if plvl >= _spellData.reqLevel then
lFrame = oItem;
scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight());
lFrame:Show();
anyChildVisible = true;
else
if j == firstItem then
if j == #_spells then
--print("all section spells hidden")
else
firstItem = j + 1;
end
end
--print("Hiding", spellName)
oItem:Hide()
end
elseif _spellData.type == "none" then
local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID)
local oItem = _G["ConROC_SM_".._spellData.spellCheckbox]
if j == firstItem then
oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0);
else
oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0);
end
if plvl >= _spellData.reqLevel and anyChildVisible then
lFrame = oItem;
oItem:Show();
else
oItem:Hide();
end
if oItem:IsShown() then
--anyChildVisible = true;
scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight());
spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight());
end
end
if anyChildVisible then
lastFrame = _spellFrame;
_spellFrame:SetHeight(spellFrameHeight);
end
end
if anyChildVisible then
--print("-- FRAME to show", frame:GetName())
if i > firstHeadline then scrollHeight = scrollHeight + 10; end
scrollHeight = scrollHeight + math.ceil(frame:GetHeight());
frame:Show();
anyHLVisible = true;
else
--print("-- FRAME to hide", frame:GetName())
frame:Hide();
if i == firstHeadline then
firstHeadline = i +1;
end
end
end
if not anyHLVisible then