-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.lua
More file actions
1546 lines (1374 loc) · 49.2 KB
/
Copy pathOptions.lua
File metadata and controls
1546 lines (1374 loc) · 49.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
-------------------------------------------------------------------------------
-- SmartBuff Options
-------------------------------------------------------------------------------
local SG = SMARTBUFF_GLOBALS;
local GetNumSpecGroups = _G.GetNumTalentGroups or function() return 1; end
local GetActiveTalentGroup = _G.GetActiveTalentGroup or function() return 1 end
function SMARTBUFF_IsActiveBattlefield(zone)
local i, status, map, instanceId, teamSize;
for i = 1, GetMaxBattlefieldID() do
status, map, instanceId, _, _, teamSize = GetBattlefieldStatus(i);
if (status and status ~= "none") then
SMARTBUFF_AddMsgD("Battlefield status = "..SG.ChkS(status)..", Id = "..SG.ChkS(instanceId)..", TS = "..SG.ChkS(teamSize)..", Map = "..SG.ChkS(map)..", Zone = "..SG.ChkS(zone));
else
SMARTBUFF_AddMsgD("Battlefield status = none");
end
if (status and status == "active" and map) then
if (teamSize and type(teamSize) == "number" and teamSize > 0) then
return 2;
end
return 1;
end
end
return 0;
end
-- END IsActiveBattlefield
-- Helper functions ---------------------------------------------------------------------------------------
function SMARTBUFF_toggleBool(b, msg)
if (not b or b == nil) then
b = true;
SMARTBUFF_AddMsg(SMARTBUFF_TITLE .. ": " .. msg .. SG.GR .. "On", true);
else
b = false
SMARTBUFF_AddMsg(SMARTBUFF_TITLE .. ": " .. msg .. SG.RD .."Off", true);
end
return b;
end
function SMARTBUFF_BoolState(b, msg)
if (b) then
SMARTBUFF_AddMsg(SMARTBUFF_TITLE .. ": " .. msg .. SG.GR .. "On", true);
else
SMARTBUFF_AddMsg(SMARTBUFF_TITLE .. ": " .. msg .. SG.RD .."Off", true);
end
end
function SMARTBUFF_Split(msg, char)
local arr = { };
while (string.find(msg, char)) do
local iStart, iEnd = string.find(msg, char);
tinsert(arr, strsub(msg, 1, iStart - 1));
msg = strsub(msg, iEnd + 1, strlen(msg));
end
if (strlen(msg) > 0) then
tinsert(arr, msg);
end
return arr;
end
-- END Bool helper functions
-- Init the SmartBuff variables ---------------------------------------------------------------------------------------
SG.smVerWarn = true;
function SMARTBUFF_Options_Init(self)
if (SG.isInit) then return; end
-- test if this is the intended client
if SMARTBUFF_CLIENTVER > 100000 then
if SG.smVerWarn then
DEFAULT_CHAT_FRAME:AddMessage("|cff00e0ffSmartbuff Build "..SMARTBUFF_VERSION.." (Client: "..SMARTBUFF_CLIENTVER..")|cffffffff "..SMARTBUFF_NOTINTENDEDCLIENT)
end
SG.smVerWarn = false;
return
end
self:UnregisterEvent("CHAT_MSG_CHANNEL");
self:UnregisterEvent("UPDATE_MOUSEOVER_UNIT");
_, SG.sPlayerClass = UnitClass("player");
SG.sRealmName = GetRealmName();
SG.sPlayerName = UnitName("player");
SG.sID = SG.sRealmName .. ":" .. SG.sPlayerName;
SMARTBUFF_PLAYERCLASS = SG.sPlayerClass;
if (not SMARTBUFF_Buffs) then SMARTBUFF_Buffs = { }; end
SG.B = SMARTBUFF_Buffs;
if (not SMARTBUFF_Options) then SMARTBUFF_Options = { }; end
SG.O = SMARTBUFF_Options;
SMARTBUFF_BROKER_SetIcon();
if (SG.O.Toggle == nil) then SG.O.Toggle = true; end
if (SG.O.ToggleAuto == nil) then SG.O.ToggleAuto = true; end
if (SG.O.AutoTimer == nil) then SG.O.AutoTimer = 5; end
if (SG.O.BlacklistTimer == nil) then SG.O.BlacklistTimer = 5; end
if (SG.O.ToggleAutoCombat == nil) then SG.O.ToggleAutoCombat = false; end
if (SG.O.ToggleAutoChat == nil) then SG.O.ToggleAutoChat = false; end
if (SG.O.ToggleAutoSplash == nil) then SG.O.ToggleAutoSplash = true; end
if (SG.O.ToggleAutoSound == nil) then SG.O.ToggleAutoSound = true; end
if (SG.O.ToggleMountedPrompt == nil) then SG.O.ToggleMountedPrompt = false; end
if (SG.O.AutoSoundSelection == nil) then SG.O.AutoSoundSelection = 4; end
SG.InitSharedMediaSounds();
SG.SetSoundSelection(SG.ResolveSoundIndex());
if (SG.O.CheckCharges == nil) then SG.O.CheckCharges = true; end
if (SG.O.RebuffTimer == nil) then SG.O.RebuffTimer = 20; end
if (SG.O.SkipOverBuffing == nil) then SG.O.SkipOverBuffing = false; end
if (SG.O.SkipSplashLimit == nil) then SG.O.SkipSplashLimit = 3; end
if (SG.O.SkipSplashCounts == nil) then SG.O.SkipSplashCounts = { }; end
if (SG.O.SplashDuration == nil) then SG.O.SplashDuration = 2; end
if (SG.O.SplashIconSize == nil) then SG.O.SplashIconSize = 16; end
if (SG.O.BuffTarget == nil) then SG.O.BuffTarget = true; end
if (SG.O.BuffPvP == nil) then SG.O.BuffPvP = false; end
if (SG.O.BuffInCities == nil) then SG.O.BuffInCities = true; end
if (SG.O.LinkSelfBuffCheck == nil) then SG.O.LinkSelfBuffCheck = true; end
if (SG.O.LinkGrpBuffCheck == nil) then SG.O.LinkGrpBuffCheck = true; end
if (SG.O.AntiDaze == nil) then SG.O.AntiDaze = true; end
if (SG.O.WarnCombatFishingRod == nil) then SG.O.WarnCombatFishingRod = true; end
if (SG.O.WarnGroupFishingRod == nil) then SG.O.WarnGroupFishingRod = true; end
if (SG.O.ScrollWheel ~= nil and SG.O.ScrollWheelUp == nil) then SG.O.ScrollWheelUp = SG.O.ScrollWheel; end
if (SG.O.ScrollWheel ~= nil and SG.O.ScrollWheelDown == nil) then SG.O.ScrollWheelDown = SG.O.ScrollWheel; end
if (SG.O.ScrollWheelUp == nil) then SG.O.ScrollWheelUp = true; end
if (SG.O.ScrollWheelDown == nil) then SG.O.ScrollWheelDown = true; end
if (SG.O.ScrollWheelZooming == nil) then SG.O.ScrollWheelZooming = false; end
if (SG.O.FixCasting == nil) then SG.O.FixCasting = true; end
if (SG.O.InCombat == nil) then SG.O.InCombat = true; end
if (SG.O.AutoSwitchTemplate == nil) then SG.O.AutoSwitchTemplate = true; end
if (SG.O.AutoSwitchTemplateInst == nil) then SG.O.AutoSwitchTemplateInst = true; end
if (SG.O.RetainTemplate == nil) then SG.O.RetainTemplate = false; end
if (SG.O.InShapeshift == nil) then SG.O.InShapeshift = true; end
if (SG.O.UseSingleForOneMissing == nil) then SG.O.UseSingleForOneMissing = true; end
if (SG.O.UseSingleThreshold == nil) then SG.O.UseSingleThreshold = 1; end
SG.O.ToggleGrp = {true, true, true, true, true, true, true, true};
if (SG.O.ToggleMsgNormal == nil) then SG.O.ToggleMsgNormal = true; end
if (SG.O.ToggleMsgWarning == nil) then SG.O.ToggleMsgWarning = false; end
if (SG.O.ToggleMsgError == nil) then SG.O.ToggleMsgError = false; end
if (SG.O.HideMmButton == nil) then SG.O.HideMmButton = false; end
if (SG.O.HideSAButton == nil) then SG.O.HideSAButton = true; end
if (SG.O.HideSAButtonNoAction == nil) then SG.O.HideSAButtonNoAction = true; end
if (SG.O.MinCharges == nil) then
if (SG.sPlayerClass == "SHAMAN" or SG.sPlayerClass == "PRIEST") then
SG.O.MinCharges = 1;
else
SG.O.MinCharges = 3;
end
end
if (not SG.O.AddList) then SG.O.AddList = { }; end
if (not SG.O.IgnoreList) then SG.O.IgnoreList = { }; end
SG.RebuildTemplateList();
if (SG.O.LastTemplate == nil) then SG.O.LastTemplate = SMARTBUFF_TEMPLATES[1]; end
local b = false;
local i = 1;
while (SMARTBUFF_TEMPLATES[i] ~= nil) do
if (SMARTBUFF_TEMPLATES[i] == SG.O.LastTemplate) then
b = true;
break;
end
i = i + 1;
end
if (not b) then
SG.O.LastTemplate = SMARTBUFF_TEMPLATES[1];
end
SG.currentTemplate = SG.O.LastTemplate;
SG.currentSpec = GetActiveTalentGroup()
if (SG.O.OldWheelUp == nil) then SG.O.OldWheelUp = ""; end
if (SG.O.OldWheelDown == nil) then SG.O.OldWheelDown = ""; end
SMARTBUFF_InitActionButtonPos();
if (SG.O.SplashX == nil) then SG.O.SplashX = 100; end
if (SG.O.SplashY == nil) then SG.O.SplashY = -100; end
if (SG.O.CurrentFont == nil) then SG.O.CurrentFont = 6; end
if (SG.O.ColSplashFont == nil) then
SG.O.ColSplashFont = { };
SG.O.ColSplashFont.r = 1.0;
SG.O.ColSplashFont.g = 1.0;
SG.O.ColSplashFont.b = 1.0;
end
SG.iCurrentFont = SG.O.CurrentFont;
if (SG.O.Debug == nil) then SG.O.Debug = false; end
-- Cosmos support
if(EarthFeature_AddButton) then
EarthFeature_AddButton(
{ id = SMARTBUFF_TITLE;
name = SMARTBUFF_TITLE;
subtext = SMARTBUFF_TITLE;
tooltip = "";
icon = SG.imgSB;
callback = SMARTBUFF_OptionsFrame_Toggle;
test = nil;
} )
elseif (Cosmos_RegisterButton) then
Cosmos_RegisterButton(SMARTBUFF_TITLE, SMARTBUFF_TITLE, SMARTBUFF_TITLE, SG.imgSB, SMARTBUFF_OptionsFrame_Toggle);
end
if (C_AddOns.IsAddOnLoaded("Parrot")) then
SG.isParrot = true;
end
SMARTBUFF_RebuildBagIndex();
DEFAULT_CHAT_FRAME:AddMessage("|cff00e0ffSmartbuff Build "..SMARTBUFF_VERSION.." (Client: "..SMARTBUFF_CLIENTVER..")|cffffffff "..SMARTBUFF_MSG_LOADED)
SG.isInit = true;
SMARTBUFF_CheckMiniMapButton();
SMARTBUFF_MinimapButton_OnUpdate(SmartBuff_MiniMapButton);
SMARTBUFF_ShowSAButton();
SMARTBUFF_Splash_Hide();
if (SG.O.UpgradeToDualSpec == nil) then
for n = 1, GetNumSpecGroups(), 1 do
if (SG.B[n] == nil) then
SG.B[n] = { };
end
for k, v in pairs(SMARTBUFF_TEMPLATES) do
SMARTBUFF_AddMsgD(v);
if (SG.B[v] ~= nil) then
SG.B[n][v] = SG.B[v];
end
end
end
for k, v in pairs(SMARTBUFF_TEMPLATES) do
if (SG.B[v] ~= nil) then
wipe(SG.B[v]);
SG.B[v] = nil;
end
end
SG.O.UpgradeToDualSpec = true;
end
for k, v in pairs(SG.cClasses) do
if (SMARTBUFF_CLASSES[k] == nil) then
SMARTBUFF_CLASSES[k] = v;
end
end
-- major version changes are backwards incompatible by definition, so trigger a RESET ALL
SG.O.VersionNr = SG.O.VersionNr or SMARTBUFF_VERSIONNR -- don't reset if SG.O.VersionNr == nil
if SG.O.VersionNr < SMARTBUFF_VERSIONNR then
SG.O.VersionNr = SMARTBUFF_VERSIONNR;
StaticPopup_Show("SMARTBUFF_DATA_PURGE");
SMARTBUFF_SetTemplate();
SMARTBUFF_SetBuffs();
SG.InitBuffOrder(true);
end
if (SMARTBUFF_OptionsGlobal == nil) then
SMARTBUFF_OptionsGlobal = { };
SMARTBUFF_BuffOrderReset();
end
SG.OG = SMARTBUFF_OptionsGlobal;
if (SG.OG.SplashIcon == nil) then SG.OG.SplashIcon = true; end
if (SG.OG.SplashMsgShort == nil) then SG.OG.SplashMsgShort = false; end
if (SG.OG.FirstStart == nil) then SG.OG.FirstStart = "V0"; end
SMARTBUFF_Splash_ChangeFont(0);
if (SG.OG.FirstStart ~= SMARTBUFF_VERSION) then
SG.OG.FirstStart = SMARTBUFF_VERSION;
end
SMARTBUFF_SetBuffs();
if (not SG.IsVisibleToPlayer(SmartBuff_KeyButton)) then
SmartBuff_KeyButton:ClearAllPoints();
SmartBuff_KeyButton:SetPoint("CENTER", UIParent, "CENTER", 0, 100);
end
SMARTBUFF_SetTemplate(true);
SMARTBUFF_RebindKeys();
-- Re-run after a delay so we pick up the key if it was set in a previous session (bindings load async)
if (C_Timer and C_Timer.After) then
C_Timer.After(2, function() if not InCombatLockdown() then SMARTBUFF_RebindKeys(); end end);
end
-- When the keybindings UI is closed, re-apply so a newly assigned SmartBuff Action key works immediately
if (KeyBindingFrame and KeyBindingFrame.Hide and not KeyBindingFrame.SmartBuffRebindHook) then
KeyBindingFrame.SmartBuffRebindHook = true;
hooksecurefunc(KeyBindingFrame, "Hide", function() if SG.isInit and not InCombatLockdown() then SMARTBUFF_RebindKeys(); end end);
end
SG.isSyncReq = true;
end
-- END SMARTBUFF_Options_Init
function SMARTBUFF_ShowChangelog()
if (not SG.isInit) then return; end
SMARTBUFF_OptionsFrame_Open(true);
SmartBuffWNF_lblText:SetText(SMARTBUFF_WHATSNEW);
SmartBuffWNF:Show();
end
function SMARTBUFF_ToggleChangelog()
if (not SG.isInit) then return; end
SMARTBUFF_OptionsFrame_Open(true);
SMARTBUFF_ToggleWhatsNewWindow();
end
function SMARTBUFF_ToggleWhatsNewWindow()
SmartBuffWNF_lblText:SetText(SMARTBUFF_WHATSNEW);
if SmartBuffWNF:IsShown() then
SmartBuffWNF:Hide();
else
SmartBuffWNF:Show();
end
end
function SMARTBUFF_command(msg)
if (not SG.isInit) then
SMARTBUFF_AddMsgWarn(SMARTBUFF_VERS_TITLE.." not initialized correctly!", true);
return;
end
if(msg == "toggle" or msg == "t") then
SMARTBUFF_OToggle();
SMARTBUFF_SetTemplate();
elseif (msg == "menu") then
SMARTBUFF_OptionsFrame_Toggle();
elseif (msg == "rbt") then
SMARTBUFF_ResetBuffTimers();
elseif (msg == "sbt") then
SMARTBUFF_ShowBuffTimers();
elseif (msg == "target") then
if (SMARTBUFF_PreCheck(0)) then
SMARTBUFF_checkBlacklist();
SMARTBUFF_BuffUnit("target", 0, 0);
end
elseif (msg == "debug") then
SG.O.Debug = SMARTBUFF_toggleBool(SG.O.Debug, "Debug active = ");
elseif (msg == "open") then
SMARTBUFF_OptionsFrame_Open(true);
elseif (msg == "sync") then
SMARTBUFF_SyncBuffTimers();
elseif (msg == "rb") then
SMARTBUFF_ResetBindings();
SMARTBUFF_AddMsg("SmartBuff key and mouse bindings reset.", true);
elseif (msg == "rafp") then
SmartBuffSplashFrame:ClearAllPoints();
SmartBuffSplashFrame:SetPoint("CENTER", UIParent, "CENTER");
SmartBuff_MiniMapButton:ClearAllPoints();
SmartBuff_MiniMapButton:SetPoint("TOPLEFT", Minimap, "TOPLEFT");
SmartBuff_KeyButton:ClearAllPoints();
SmartBuff_KeyButton:SetPoint("CENTER", UIParent, "CENTER");
SmartBuffOptionsFrame:ClearAllPoints();
SmartBuffOptionsFrame:SetPoint("CENTER", UIParent, "CENTER");
elseif (msg == "changes") then
SMARTBUFF_ShowChangelog();
elseif (msg == "reload") then
SMARTBUFF_BuffOrderReset();
SMARTBUFF_OptionsFrame_Open(true);
else
SMARTBUFF_AddMsg(SMARTBUFF_VERS_TITLE, true);
SMARTBUFF_AddMsg("Syntax: /sbo [command] or /sbuff [command] or /smartbuff [command]", true);
SMARTBUFF_AddMsg("toggle - " .. SMARTBUFF_OFT, true);
SMARTBUFF_AddMsg("menu - " .. SMARTBUFF_OFT_MENU, true);
SMARTBUFF_AddMsg("target - " .. SMARTBUFF_OFT_TARGET, true);
SMARTBUFF_AddMsg("rbt - " .. "Reset buff timers", true);
SMARTBUFF_AddMsg("sbt - " .. "Show buff timers", true);
SMARTBUFF_AddMsg("rafp - " .. "Reset all frame positions", true);
SMARTBUFF_AddMsg("sync - " .. "Sync buff timers with UI", true);
SMARTBUFF_AddMsg("rb - " .. "Reset key/mouse bindings", true);
SMARTBUFF_AddMsg("changes - " .. "Display changelog", true);
SMARTBUFF_AddMsg("reload - " .. "Reset buff list", true)
end
end
-- END SMARTBUFF_command
-- SmartBuff options toggle ---------------------------------------------------------------------------------------
function SMARTBUFF_OToggle()
if (not SG.isInit) then return; end
SG.O.Toggle = SMARTBUFF_toggleBool(SG.O.Toggle, "Active = ");
SMARTBUFF_CheckMiniMapButton();
if (SG.O.Toggle) then
SMARTBUFF_SetTemplate();
end
end
function SMARTBUFF_OToggleAuto()
SG.O.ToggleAuto = not SG.O.ToggleAuto;
end
function SMARTBUFF_OToggleAutoCombat()
SG.O.ToggleAutoCombat = not SG.O.ToggleAutoCombat;
end
function SMARTBUFF_OToggleAutoChat()
SG.O.ToggleAutoChat = not SG.O.ToggleAutoChat;
end
function SMARTBUFF_OToggleAutoSplash()
SG.O.ToggleAutoSplash = not SG.O.ToggleAutoSplash;
end
function SMARTBUFF_OToggleAutoSound()
SG.O.ToggleAutoSound = not SG.O.ToggleAutoSound;
SMARTBUFF_UpdateSoundDropdownState();
end
function SMARTBUFF_OSkipOverBuffing()
SG.O.SkipOverBuffing = not SG.O.SkipOverBuffing;
if (not SG.O.SkipOverBuffing and SG.O.SkipSplashCounts) then
wipe(SG.O.SkipSplashCounts);
end
SMARTBUFF_UpdateSkipSplashLimitState();
end
function SMARTBUFF_UpdateSkipSplashLimitState()
local enabled = SG.O and SG.O.SkipOverBuffing;
local sld = SmartBuffOptionsFrame_sldSkipSplashLimit;
if (sld) then
if (enabled) then
sld:Enable();
else
sld:Disable();
end
sld:SetAlpha(enabled and 1 or 0.5);
end
end
function SMARTBUFF_OToggleMountedPrompt()
SG.O.ToggleMountedPrompt = not SG.O.ToggleMountedPrompt;
end
function SMARTBUFF_OAutoSwitchTmp()
SG.O.AutoSwitchTemplate = not SG.O.AutoSwitchTemplate;
end
function SMARTBUFF_OAutoSwitchTmpInst()
SG.O.AutoSwitchTemplateInst = not SG.O.AutoSwitchTemplateInst;
end
function SMARTBUFF_ORetainTemplate()
SG.O.RetainTemplate = not SG.O.RetainTemplate;
end
function SMARTBUFF_OBuffTarget()
SG.O.BuffTarget = not SG.O.BuffTarget;
end
function SMARTBUFF_OBuffPvP()
SG.O.BuffPvP = not SG.O.BuffPvP;
end
function SMARTBUFF_OBuffInCities()
SG.O.BuffInCities = not SG.O.BuffInCities;
end
function SMARTBUFF_OLinkSelfBuffCheck()
SG.O.LinkSelfBuffCheck = not SG.O.LinkSelfBuffCheck;
end
function SMARTBUFF_OLinkGrpBuffCheck()
SG.O.LinkGrpBuffCheck = not SG.O.LinkGrpBuffCheck;
end
function SMARTBUFF_OUseSingleForOneMissing()
SG.O.UseSingleForOneMissing = not SG.O.UseSingleForOneMissing;
end
function SMARTBUFF_OAntiDaze()
SG.O.AntiDaze = not SG.O.AntiDaze;
end
function SMARTBUFF_OScrollWheelUp()
SG.O.ScrollWheelUp = not SG.O.ScrollWheelUp;
SG.isKeyUpChanged = true;
end
function SMARTBUFF_OScrollWheelDown()
SG.O.ScrollWheelDown = not SG.O.ScrollWheelDown;
SG.isKeyDownChanged = true;
end
function SMARTBUFF_OScrollWheelZoom()
SG.O.ScrollWheelZooming = not SG.O.ScrollWheelZooming;
end
function SMARTBUFF_OFixCasting()
SG.O.FixCasting = not SG.O.FixCasting;
end
function SMARTBUFF_OInShapeshift()
SG.O.InShapeshift = not SG.O.InShapeshift;
end
function SMARTBUFF_OInCombat()
SG.O.InCombat = not SG.O.InCombat;
end
function SMARTBUFF_OToggleMsgNormal()
SG.O.ToggleMsgNormal = not SG.O.ToggleMsgNormal;
end
function SMARTBUFF_OToggleMsgWarning()
SG.O.ToggleMsgWarning = not SG.O.ToggleMsgWarning;
end
function SMARTBUFF_OToggleMsgError()
SG.O.ToggleMsgError = not SG.O.ToggleMsgError;
end
function SMARTBUFF_OHideMmButton()
SG.O.HideMmButton = not SG.O.HideMmButton;
SMARTBUFF_CheckMiniMapButton();
end
function SMARTBUFF_OHideSAButton()
SG.O.HideSAButton = not SG.O.HideSAButton;
SMARTBUFF_ShowSAButton();
end
function SMARTBUFF_OSelfFirst()
SG.B[SG.CS()][SG.currentTemplate].SelfFirst = not SG.B[SG.CS()][SG.currentTemplate].SelfFirst;
end
function SMARTBUFF_OHideSAButtonNoAction()
SG.O.HideSAButtonNoAction = not SG.O.HideSAButtonNoAction;
if not SG.O.HideSAButtonNoAction and not SG.O.HideSAButtonNoAction then
SMARTBUFF_ShowSAButton();
end
end
function SMARTBUFF_OToggleBuff(s, i)
local bs = SG.GetBuffSettings(SG.cBuffs[i].BuffS);
if (bs == nil) then
return;
end
if (s == "S") then
bs.EnableS = not bs.EnableS;
if (bs.EnableS) then
SmartBuff_BuffSetup_Show(i);
else
SmartBuff_BuffSetup:Hide();
SG.iLastBuffSetup = -1;
SmartBuff_PlayerSetup:Hide();
end
elseif (s == "G") then
bs.EnableG = not bs.EnableG;
end
end
function SMARTBUFF_OToggleDebug()
SG.O.Debug = not SG.O.Debug;
end
function SMARTBUFF_OptionsFrame_Toggle()
if (not SG.isInit) then return; end
if(SmartBuffOptionsFrame:IsVisible()) then
if(SG.iLastBuffSetup > 0) then
SmartBuff_BuffSetup:Hide();
SG.iLastBuffSetup = -1;
SmartBuff_PlayerSetup:Hide();
end
SmartBuffOptionsFrame:Hide();
-- if we were a new build then request a reloadui.
if (SG.OG.FirstStart ~= SMARTBUFF_VERSION) then
SG.OG.FirstStart = SMARTBUFF_VERSION;
StaticPopup_Show("SMARTBUFF_GUI_RELOAD");
end
else
SmartBuffOptionsCredits_lblText:SetText(SMARTBUFF_CREDITS);
SmartBuffOptionsFrame:Show();
SmartBuff_PlayerSetup:Hide();
end
SMARTBUFF_MinimapButton_CheckPos();
end
function SMARTBUFF_OptionsFrame_Open(force)
if (not SG.isInit) then return; end
if(not SmartBuffOptionsFrame:IsVisible() or force) then
SmartBuffOptionsFrame:Show();
end
end
function SmartBuff_BuffSetup_Show(i)
local icon1 = SG.cBuffs[i].IconS;
local icon2 = SG.cBuffs[i].IconG;
local name = SG.cBuffs[i].BuffS;
local btype = SG.cBuffs[i].Type;
local hidden = true;
local n = 0;
local bs = SG.GetBuffSettings(name);
if (name == nil or btype == SMARTBUFF_CONST_TRACK) then
SmartBuff_BuffSetup:Hide();
SG.iLastBuffSetup = -1;
SmartBuff_PlayerSetup:Hide();
return;
end
if(SmartBuff_BuffSetup:IsVisible() and i == SG.iLastBuffSetup) then
SmartBuff_BuffSetup:Hide();
SG.iLastBuffSetup = -1;
SmartBuff_PlayerSetup:Hide();
return;
else
if (btype == SMARTBUFF_CONST_GROUP or btype == SMARTBUFF_CONST_ITEMGROUP) then
hidden = false;
end
if (icon2 and bs.EnableG) then
SmartBuff_BuffSetup_BuffIcon2:SetNormalTexture(icon2);
SmartBuff_BuffSetup_BuffIcon2:Show();
else
SmartBuff_BuffSetup_BuffIcon2:Hide();
end
if (icon1) then
SmartBuff_BuffSetup_BuffIcon1:SetNormalTexture(icon1);
if (icon2 and bs.EnableG) then
SmartBuff_BuffSetup_BuffIcon1:SetPoint("TOPLEFT", 44, -30);
else
SmartBuff_BuffSetup_BuffIcon1:SetPoint("TOPLEFT", 64, -30);
end
SmartBuff_BuffSetup_BuffIcon1:Show();
else
SmartBuff_BuffSetup_BuffIcon1:SetPoint("TOPLEFT", 24, -30);
SmartBuff_BuffSetup_BuffIcon1:Hide();
end
local obj = SmartBuff_BuffSetup_BuffText;
if (name) then
obj:SetText(name);
else
obj:SetText("");
end
SmartBuff_BuffSetup_cbSelf:SetChecked(bs.SelfOnly);
SmartBuff_BuffSetup_cbSelfNot:SetChecked(bs.SelfNot);
SmartBuff_BuffSetup_cbCombatIn:SetChecked(bs.CIn);
SmartBuff_BuffSetup_cbCombatOut:SetChecked(bs.COut);
SmartBuff_BuffSetup_cbMH:SetChecked(bs.MH);
SmartBuff_BuffSetup_cbOH:SetChecked(bs.OH);
SmartBuff_BuffSetup_cbRH:SetChecked(bs.RH);
SmartBuff_BuffSetup_cbReminder:SetChecked(bs.Reminder);
SmartBuff_BuffSetup_txtManaLimit:SetNumber(bs.ManaLimit);
if (SG.cBuffs[i].DurationS > 0) then
SmartBuff_BuffSetup_RBTime:SetMinMaxValues(0, SG.cBuffs[i].DurationS);
_G[SmartBuff_BuffSetup_RBTime:GetName().."High"]:SetText(SG.cBuffs[i].DurationS);
if (SG.cBuffs[i].DurationS <= 60) then
SmartBuff_BuffSetup_RBTime:SetValueStep(1);
elseif (SG.cBuffs[i].DurationS <= 180) then
SmartBuff_BuffSetup_RBTime:SetValueStep(5);
elseif (SG.cBuffs[i].DurationS <= 600) then
SmartBuff_BuffSetup_RBTime:SetValueStep(10);
else
SmartBuff_BuffSetup_RBTime:SetValueStep(30);
end
SmartBuff_BuffSetup_RBTime:SetValue(bs.RBTime);
_G[SmartBuff_BuffSetup_RBTime:GetName().."Text"]:SetText(bs.RBTime .. "\nsec");
SmartBuff_BuffSetup_RBTime:Show();
else
SmartBuff_BuffSetup_RBTime:Hide();
end
SmartBuff_BuffSetup_txtManaLimit:Hide();
if (SG.cBuffs[i].Type == SMARTBUFF_CONST_INV or SG.cBuffs[i].Type == SMARTBUFF_CONST_WEAPON) then
SmartBuff_BuffSetup_cbMH:Show();
SmartBuff_BuffSetup_cbOH:Show();
SmartBuff_BuffSetup_cbRH:Hide();
else
SmartBuff_BuffSetup_cbMH:Hide();
SmartBuff_BuffSetup_cbOH:Hide();
SmartBuff_BuffSetup_cbRH:Hide();
if (SG.cBuffs[i].Type ~= SMARTBUFF_CONST_FOOD and SG.cBuffs[i].Type ~= SMARTBUFF_CONST_SCROLL and SG.cBuffs[i].Type ~= SMARTBUFF_CONST_POTION) then
SmartBuff_BuffSetup_txtManaLimit:Show();
end
end
if (SG.cBuffs[i].Type == SMARTBUFF_CONST_GROUP or SG.cBuffs[i].Type == SMARTBUFF_CONST_ITEMGROUP) then
SmartBuff_BuffSetup_cbSelf:Show();
SmartBuff_BuffSetup_cbSelfNot:Show();
SmartBuff_BuffSetup_btnPriorityList:Show();
SmartBuff_BuffSetup_btnIgnoreList:Show();
else
SmartBuff_BuffSetup_cbSelf:Hide();
SmartBuff_BuffSetup_cbSelfNot:Hide();
SmartBuff_BuffSetup_btnPriorityList:Hide();
SmartBuff_BuffSetup_btnIgnoreList:Hide();
SmartBuff_PlayerSetup:Hide();
end
local cb = nil;
local btn = nil;
n = 0;
for _ in pairs(SG.cClasses) do
n = n + 1;
cb = _G["SmartBuff_BuffSetup_cbClass"..n];
btn = _G["SmartBuff_BuffSetup_ClassIcon"..n];
if (hidden or SG.tcontains(cIgnoreClasses, n)) then
cb:Hide();
btn:Hide();
else
cb:SetChecked(bs[SG.cClasses[n]]);
cb:Show();
btn:Show();
end
end
SG.iLastBuffSetup = i;
SmartBuff_BuffSetup:Show();
if (SmartBuff_PlayerSetup:IsVisible()) then
SmartBuff_PS_Show(SG.iCurrentList);
end
end
end
function SmartBuff_BuffSetup_ManaLimitChanged(self)
local i = SG.iLastBuffSetup;
if (i <= 0) then
return;
end
local ct = SG.currentTemplate;
local name = SG.cBuffs[i].BuffS;
SG.B[SG.CS()][ct][name].ManaLimit = self:GetNumber();
end
function SmartBuff_BuffSetup_OnClick()
local i = SG.iLastBuffSetup;
local ct = SG.currentTemplate;
if (i <= 0) then
return;
end
local name = SG.cBuffs[i].BuffS;
local cBuff = SG.GetBuffSettings(name);
cBuff.SelfOnly = SmartBuff_BuffSetup_cbSelf:GetChecked();
cBuff.SelfNot = SmartBuff_BuffSetup_cbSelfNot:GetChecked();
cBuff.CIn = SmartBuff_BuffSetup_cbCombatIn:GetChecked();
cBuff.COut = SmartBuff_BuffSetup_cbCombatOut:GetChecked();
cBuff.MH = SmartBuff_BuffSetup_cbMH:GetChecked();
cBuff.OH = SmartBuff_BuffSetup_cbOH:GetChecked();
cBuff.RH = SmartBuff_BuffSetup_cbRH:GetChecked();
cBuff.Reminder = SmartBuff_BuffSetup_cbReminder:GetChecked();
cBuff.RBTime = SmartBuff_BuffSetup_RBTime:GetValue();
_G[SmartBuff_BuffSetup_RBTime:GetName().."Text"]:SetText(cBuff.RBTime .. "\nsec");
if (SG.cBuffs[i].Type == SMARTBUFF_CONST_GROUP or SG.cBuffs[i].Type == SMARTBUFF_CONST_ITEMGROUP) then
local n = 0;
local cb = nil;
for _ in pairs(SG.cClasses) do
n = n + 1;
cb = _G["SmartBuff_BuffSetup_cbClass"..n];
if (SG.tcontains(cIgnoreClasses, n)) then
cBuff[SG.cClasses[n]] = false;
else
cBuff[SG.cClasses[n]] = cb:GetChecked();
end
end
end
--SMARTBUFF_AddMsgD("Buff setup saved");
end
function SmartBuff_BuffSetup_ToolTip(mode)
local i = SG.iLastBuffSetup;
if (i <= 0) then
return;
end
local ids = SG.cBuffs[i].IDS;
local idg = SG.cBuffs[i].IDG;
local btype = SG.cBuffs[i].Type
GameTooltip:ClearLines();
if (SMARTBUFF_IsItem(btype)) then
local bag, slot, count, texture = SMARTBUFF_FindItem(SG.cBuffs[i].BuffS, SG.cBuffs[i].Chain);
if (bag and slot) then
if (bag == 999) then -- Toy
GameTooltip:SetToyByItemID(slot);
else
GameTooltip:SetBagItem(bag, slot);
end
end
else
if (mode == 1 and ids) then
local link = GetSpellLink(ids);
if (link) then GameTooltip:SetHyperlink(link); end
elseif (mode == 2 and idg) then
local link = GetSpellLink(idg);
if (link) then GameTooltip:SetHyperlink(link); end
end
end
GameTooltip:Show();
end
-- END SmartBuff options toggle
-- Options frame functions ---------------------------------------------------------------------------------------
function SMARTBUFF_Options_OnLoad(self)
end
function SMARTBUFF_Options_OnShow()
-- Check if the options frame is out of screen area
local top = GetScreenHeight() - math.abs(SmartBuffOptionsFrame:GetTop());
local bottom = GetScreenHeight() - math.abs(SmartBuffOptionsFrame:GetBottom());
local left = SmartBuffOptionsFrame:GetLeft();
local right = SmartBuffOptionsFrame:GetRight();
if (GetScreenWidth() < left + 20 or GetScreenHeight() < top + 20 or right < 20 or bottom < 20) then
SmartBuffOptionsFrame:SetPoint("TOPLEFT", UIParent, "CENTER", -SmartBuffOptionsFrame:GetWidth() / 2, SmartBuffOptionsFrame:GetHeight() / 2);
end
SmartBuff_ShowControls("SmartBuffOptionsFrame", true);
SmartBuffOptionsFrame_cbSB:SetChecked(SG.O.Toggle);
SmartBuffOptionsFrame_cbAuto:SetChecked(SG.O.ToggleAuto);
SmartBuffOptionsFrameAutoTimer:SetValue(SG.O.AutoTimer);
SmartBuff_SetSliderText(SmartBuffOptionsFrameAutoTimer, SMARTBUFF_OFT_AUTOTIMER, SG.O.AutoTimer, INT_SPELL_DURATION_SEC);
SmartBuffOptionsFrame_cbAutoCombat:SetChecked(SG.O.ToggleAutoCombat);
SmartBuffOptionsFrame_cbAutoChat:SetChecked(SG.O.ToggleAutoChat);
SmartBuffOptionsFrame_cbAutoSplash:SetChecked(SG.O.ToggleAutoSplash);
SmartBuffOptionsFrame_cbAutoSound:SetChecked(SG.O.ToggleAutoSound);
SMARTBUFF_UpdateSoundDropdown();
if SmartBuffOptionsFrame_cbSkipOverBuffing then
SmartBuffOptionsFrame_cbSkipOverBuffing:SetChecked(SG.O.SkipOverBuffing);
end
if SmartBuffOptionsFrame_sldSkipSplashLimit then
SmartBuffOptionsFrame_sldSkipSplashLimit:SetValue(SG.O.SkipSplashLimit or 3);
SmartBuff_SetSliderText(SmartBuffOptionsFrame_sldSkipSplashLimit, SMARTBUFF_OFT_SKIPOVERBUFFING_LIMIT, SG.O.SkipSplashLimit or 3, "%d");
SMARTBUFF_UpdateSkipSplashLimitState();
end
SmartBuffOptionsFrame_cbWarnWhenMounted:SetChecked(SG.O.ToggleMountedPrompt);
if SmartBuffOptionsFrame_cbFixCasting then
SmartBuffOptionsFrame_cbFixCasting:SetChecked(SG.O.FixCasting);
end
SmartBuffOptionsFrame_cbAutoSwitchTmp:SetChecked(SG.O.AutoSwitchTemplate);
SmartBuffOptionsFrame_cbAutoSwitchTmpInst:SetChecked(SG.O.AutoSwitchTemplateInst);
if SmartBuffOptionsFrame_cbRetainTemplate then
SmartBuffOptionsFrame_cbRetainTemplate:SetChecked(SG.O.RetainTemplate);
end
SmartBuffOptionsFrame_cbBuffPvP:SetChecked(SG.O.BuffPvP);
SmartBuffOptionsFrame_cbBuffTarget:SetChecked(SG.O.BuffTarget);
SmartBuffOptionsFrame_cbBuffInCities:SetChecked(SG.O.BuffInCities);
SmartBuffOptionsFrame_cbInShapeshift:SetChecked(SG.O.InShapeshift);
SmartBuffOptionsFrame_cbAntiDaze:SetChecked(SG.O.AntiDaze);
SmartBuffOptionsFrame_cbLinkGrpBuffCheck:SetChecked(SG.O.LinkGrpBuffCheck);
SmartBuffOptionsFrame_cbLinkSelfBuffCheck:SetChecked(SG.O.LinkSelfBuffCheck);
SmartBuffOptionsFrame_cbUseSingleForOneMissing:SetChecked(SG.O.UseSingleForOneMissing);
if SmartBuffOptionsFrameUseSingleThreshold then
SmartBuffOptionsFrameUseSingleThreshold:SetValue(SG.O.UseSingleThreshold or 1);
SmartBuff_SetSliderText(SmartBuffOptionsFrameUseSingleThreshold, SMARTBUFF_OFT_USE_SINGLEFORONE_THRESHOLD, SG.O.UseSingleThreshold or 1, "%d");
end
SmartBuffOptionsFrame_cbScrollWheelUp:SetChecked(SG.O.ScrollWheelUp);
SmartBuffOptionsFrame_cbScrollWheelDown:SetChecked(SG.O.ScrollWheelDown);
SmartBuffOptionsFrame_cbScrollWheelZoom:SetChecked(SG.O.ScrollWheelZooming);
SmartBuffOptionsFrame_cbInCombat:SetChecked(SG.O.InCombat);
SmartBuffOptionsFrame_cbMsgNormal:SetChecked(SG.O.ToggleMsgNormal);
SmartBuffOptionsFrame_cbMsgWarning:SetChecked(SG.O.ToggleMsgWarning);
SmartBuffOptionsFrame_cbMsgError:SetChecked(SG.O.ToggleMsgError);
SmartBuffOptionsFrame_cbHideMmButton:SetChecked(SG.O.HideMmButton);
SmartBuffOptionsFrame_cbHideSAButton:SetChecked(SG.O.HideSAButton);
SmartBuffOptionsFrame_cbHideSAButtonNoAction:SetChecked(SG.O.HideSAButtonNoAction);
SmartBuffOptionsFrameRebuffTimer:SetValue(SG.O.RebuffTimer);
SmartBuff_SetSliderText(SmartBuffOptionsFrameRebuffTimer, SMARTBUFF_OFT_REBUFFTIMER, SG.O.RebuffTimer, INT_SPELL_DURATION_SEC);
SmartBuffOptionsFrameBLDuration:SetValue(SG.O.BlacklistTimer);
SmartBuff_SetSliderText(SmartBuffOptionsFrameBLDuration, SMARTBUFF_OFT_BLDURATION, SG.O.BlacklistTimer, INT_SPELL_DURATION_SEC);
SMARTBUFF_SetCheckButtonBuffs(0);
SmartBuffOptionsFrame_cbSelfFirst:SetChecked(SG.B[SG.CS()][SG.currentTemplate].SelfFirst);
SMARTBUFF_Splash_Show();
SMARTBUFF_AddMsgD("Option frame updated: " .. SG.currentTemplate);
end
function SMARTBUFF_ShowSubGroups(frame, grpTable)
local i;
for i = 1, 8, 1 do
obj = _G[frame.."_cbGrp"..i];
if (obj) then
obj:SetChecked(grpTable[i]);
end
end
end
function SMARTBUFF_Options_OnHide()
if (SmartBuffWNF:IsVisible()) then
SmartBuffWNF:Hide();
end
SmartBuffOptionsFrame:SetHeight(SMARTBUFF_OPTIONSFRAME_HEIGHT);
wipe(SG.cBuffsCombat);
SMARTBUFF_SetInCombatBuffs();
SmartBuff_BuffSetup:Hide();
SmartBuff_PlayerSetup:Hide();
SMARTBUFF_Splash_Hide();
SMARTBUFF_RebindKeys();
end
function SmartBuff_ShowControls(sName, bShow)
local children = {_G[sName]:GetChildren()};
for i, child in pairs(children) do
if (i > 1 and string.find(child:GetName(), "^"..sName..".+")) then
if (bShow) then
child:Show();
else
child:Hide();
end
end
end
end
function SmartBuffOptionsFrameSlider_OnLoad(self, low, high, step, labels)
_G[self:GetName().."Text"]:SetFontObject(GameFontNormalSmall);
if (labels) then
if (self:GetOrientation() ~= "VERTICAL") then
_G[self:GetName().."Low"]:SetText(low);
else
_G[self:GetName().."Low"]:SetText("");
end
_G[self:GetName().."High"]:SetText(high);
else
_G[self:GetName().."Low"]:SetText("");
_G[self:GetName().."High"]:SetText("");
end
-- Use the default OptionsSliderTemplate behavior, but draw a slightly thicker
-- custom track underneath so it looks like the old style on all clients
if not self.SmartBuffTrack then
local track = self:CreateTexture(nil, "BACKGROUND");
track:SetColorTexture(1, 1, 1, 0.25); -- subtle light bar
if (self:GetOrientation() ~= "VERTICAL") then
track:SetHeight(8);
track:SetPoint("LEFT", self, "LEFT", 4, 0);
track:SetPoint("RIGHT", self, "RIGHT", -4, 0);
else
track:SetWidth(8);
track:SetPoint("TOP", self, "TOP", 0, -4);
track:SetPoint("BOTTOM", self, "BOTTOM", 0, 4);
end
self.SmartBuffTrack = track;
end
self:SetMinMaxValues(low, high);
self:SetValueStep(step);
self:SetStepsPerPage(step);
if (step < 1) then return; end
self.GetValueBase = self.GetValue;
self.GetValue = function()
local n = self:GetValueBase();
if (n) then
local r = SG.Round(n);
if (r ~= n) then
self:SetValue(n);
end
return r;
end
return low;
end;
end
function SMARTBUFF_DropDownSound_Toggle(self)
if (not self or not SG.O or not SG.O.ToggleAutoSound) then return; end
if (UIDropDownMenu_IsEnabled and not UIDropDownMenu_IsEnabled(self)) then return; end
ToggleDropDownMenu(1, nil, self);
end
function SMARTBUFF_DropDownSound_OnShow(self)
if (not self) then return; end
SG.InitSharedMediaSounds();
local idx = SG.ResolveSoundIndex();
SG.SetSoundSelection(idx);
local key = SG.O and SG.O.AutoSoundKey or SG.GetSoundDisplayName(idx);
UIDropDownMenu_Initialize(self, SMARTBUFF_DropDownSound_Initialize);
UIDropDownMenu_SetSelectedValue(self, key);
UIDropDownMenu_SetText(self, key or "?");
UIDropDownMenu_SetWidth(self, 222);
SMARTBUFF_UpdateSoundDropdownState();
end
function SMARTBUFF_DropDownSound_Initialize(self, level)
local info = UIDropDownMenu_CreateInfo();
for i, key in ipairs(SG.SoundList or {}) do
info.text = key;
info.value = key;
info.func = SMARTBUFF_DropDownSound_OnClick;
info.checked = (SG.O and SG.O.AutoSoundKey == key) and true or nil;
UIDropDownMenu_AddButton(info);
end
end
function SMARTBUFF_DropDownSound_OnClick(self)
local key = self.value;
if (not key or not SG.O or not SG.O.ToggleAutoSound) then return; end
SG.O.AutoSoundKey = key;
for i, k in ipairs(SG.SoundList or {}) do
if (k == key) then
SG.O.AutoSoundSelection = i;
break;
end
end
UIDropDownMenu_SetSelectedValue(SmartBuffOptionsFrame_ddSounds, key);
UIDropDownMenu_SetText(SmartBuffOptionsFrame_ddSounds, key);
CloseDropDownMenus();
SG.PlaySplashSound();
end
function SMARTBUFF_UpdateSoundDropdownState()
local enabled = SG.O and SG.O.ToggleAutoSound;
local dd = SmartBuffOptionsFrame_ddSounds;
if (dd) then
if (enabled) then
UIDropDownMenu_EnableDropDown(dd);
else
UIDropDownMenu_DisableDropDown(dd);
CloseDropDownMenus();
end
end
local lbl = SmartBuffOptionsFrame_lblSelectSound;