-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinimapButtonFrame.lua
More file actions
2536 lines (2316 loc) · 75.6 KB
/
Copy pathMinimapButtonFrame.lua
File metadata and controls
2536 lines (2316 loc) · 75.6 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
MBFversion = GetAddOnMetadata("MinimapButtonFrame", "Version");
MBF_DRAGTITLE = "MBF " .. MBFversion;
local LibStub = LibStub
MBF = LibStub("AceAddon-3.0"):NewAddon("Minimap Button Frame", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Minimap Button Frame")
local libdbicon = LibStub("LibDBIcon-1.0", true)
-- Internal Variables
local scanned = false;
local MBF_ButtonInfoStorage = {};
local MBF_ChildEventStorage = {};
local tBackdrop = {};
local tBorder = {};
local tList = {};
local tSize = {};
local currentProfile;
local numButtons = 2;
local oldParentName;
local oldPoint;
local oldRelativeTo;
local oldRelativePoint;
local oldXofs;
local oldYofs;
local oldOnEvent;
local oldOnDragStart;
local oldOnDragStop;
local oldName;
local oldFrameLevel;
local oldWidth;
local oldHeight;
local oldScale;
local oldLevel;
local oldStrata;
-- Recursion guard to prevent stack overflow when iterating Minimap children
-- (prevents MinimapButtonFrame and FarmHud from triggering each other)
local isIteratingMinimapChildren = false
local BlizzButtons = { "MiniMapTracking", "MiniMapVoiceChatFrame", "MiniMapWorldMapButton", "MiniMapLFGFrame",
"MinimapZoomIn", "MinimapZoomOut", "MiniMapMailFrame", "MiniMapBattlefieldFrame", "GameTimeFrame", "FeedbackUIButton" };
local BlizzUI = { "ActionBar", "BonusActionButton", "MainMenu", "ShapeshiftButton", "MultiBar", "KeyRingButton",
"PlayerFrame", "TargetFrame", "PartyMemberFrame", "ChatFrame", "ExhaustionTick", "TargetofTargetFrame", "WorldFrame",
"ActionButton", "CharacterMicroButton", "SpellbookMicroButton", "TalentMicroButton", "QuestLogMicroButton",
"SocialsMicroButton", "LFGMicroButton", "HelpMicroButton", "CharacterBag", "PetFrame", "MinimapCluster",
"MinimapBackdrop", "UIParent", "WorldFrame", "Minimap", "BuffButton", "BuffFrame", "TimeManagerClockButton",
"CharacterFrame", "MMHolder", "MinimapMover", "ElvConfigToggle", "ElvUI_MinimapButtonGrabber", "LeftMiniPanel",
"RightMiniPanel", "TopMiniPanel", "BottomMiniPanel", "TopLeftMiniPanel", "TopRightMiniPanel", "BottomLeftMiniPanel",
"BottomRightMiniPanel" };
local BlizzParentStop = { "WorldFrame", "Minimap", "MinimapBackdrop", "UIParent", "MinimapCluster" }
local SkinProtect = { "MinimapButtonFrameDragButton", "MBFRestoreButton", "GameTimeFrame" }
-- Configuration Screens
local hidewhenlocked_options = {
["Nothing"] = L["Nothing"],
["Border"] = L["Border"],
["Background"] = L["Background"],
["All"] = L["All"],
}
local sortorder_options = {
["Alphabetical"] = L["Alphabetical"],
["Blizzard First"] = L["Blizzard First"],
["Blizzard Last"] = L["Blizzard Last"],
["Custom"] = L["Custom"],
}
local frameanchor_options = {
["TOPLEFT"] = L["Top Left"],
["TOPRIGHT"] = L["Top Right"],
["BOTTOMRIGHT"] = L["Bottom Right"],
["BOTTOMLEFT"] = L["Bottom Left"],
}
local minimapIconList = {};
local buttonOverrideList = {};
local childList = {};
-- Helper function: Check if ElvUI's Button Grabber is in control (MBF should be disabled)
local function IsMBFDisabledByElvUI()
if ElvUI then
local E = unpack(ElvUI)
if E and E.db then
local mbfControlEnabled = E.db.general and E.db.general.minimap and E.db.general.minimap.mbfControlEnabled
-- If mbfControlEnabled is explicitly true, MBF is in control
if mbfControlEnabled == true then
return false -- MBF is explicitly enabled to control buttons
end
-- If mbfControlEnabled is explicitly false, user chose "Let ElvUI Control Buttons" in MBF
-- In this case, MBF should ALWAYS be disabled
if mbfControlEnabled == false then
return true -- User explicitly chose ElvUI control
end
-- If mbfControlEnabled is nil (not set), check if ElvUI's Button Grabber is enabled
local buttonGrabberEnabled = false
-- Check Enhanced private path (this is what the Enable checkbox actually uses)
if E.private and E.private.enhanced then
buttonGrabberEnabled = E.private.enhanced.minimapButtonGrabber
end
-- MBF should be disabled only when ElvUI's Button Grabber is actually enabled
return buttonGrabberEnabled == true
end
end
return false
end
local display = {
order = 1,
type = "group",
name = L["Display"],
desc = L["Display Settings"],
handler = MBF,
args = {
elvuiWarning = {
order = 0,
type = "description",
name =
"|cffff0000ElvUI is controlling minimap buttons.|r\n\nMBF options are disabled. To use MBF, disable ElvUI's Button Grabber or enable 'Let MBF Control Buttons' in ElvUI settings.\n",
hidden = function() return not IsMBFDisabledByElvUI() end,
},
hidewhenlocked = {
order = 1,
type = "select",
name = L["Hide when Locked"],
desc = L["HIDELOCKED_DESC"],
get = function() return MBF.db.profile.colorLocked end,
set = function(info, name)
MBF.db.profile.colorLocked = name
MBFC_ColorLocked()
end,
values = hidewhenlocked_options,
disabled = IsMBFDisabledByElvUI,
},
locked = {
order = 2,
type = "toggle",
name = L["Locked"],
desc = L["LOCKED_DESC"],
get = function() return MBF.db.profile.locked end,
set = function()
MBF.db.profile.locked = not MBF.db.profile.locked
if not MBF.db.profile.locked and not MBF.db.profile.mbfHidden then
MinimapButtonFrameDragButton:Show()
MBFRestoreButtonFrame:Show()
else
MinimapButtonFrameDragButton:Hide()
MBFRestoreButtonFrame:Hide()
end
MBFC_ColorLocked()
end,
disabled = IsMBFDisabledByElvUI,
},
altTitle = {
order = 3,
type = "toggle",
name = L["ALTTITLE_DESC"],
desc = L["ALTTITLEDESC_DESC"],
get = function() return MBF.db.profile.altTitle end,
set = function()
MBF.db.profile.altTitle = not MBF.db.profile.altTitle
MBF:SwapTitleLocation()
end,
disabled = IsMBFDisabledByElvUI,
},
space = {
order = 4,
name = "\n",
type = "description",
},
backgroundcolor = {
order = 10,
type = 'color',
name = L['Background Color'],
desc = L['COLOR_DESC'],
hasAlpha = true,
get = function()
local t = MBF.db.profile.MBFBackdropColor
return t.Red, t.Green, t.Blue, t.Alpha
end,
set = function(info, r, g, b, a)
local t = MBF.db.profile.MBFBackdropColor
t.Red = r
t.Green = g
t.Blue = b
t.Alpha = a
MBFC_ColorLocked()
end,
disabled = IsMBFDisabledByElvUI,
},
space1 = {
order = 11,
name = "",
type = "description",
},
opacity = {
order = 20,
type = "range",
name = L["Opacity"],
desc = L["OPACITY_DESC"],
min = 0,
max = 1,
step = .1,
get = function() return MBF.db.profile.opacity end,
set = function(info, v)
MBF.db.profile.opacity = v
MinimapButtonFrame:SetAlpha(MBF.db.profile.opacity)
MBFRestoreButtonFrame:SetAlpha(MBF.db.profile.opacity)
end,
disabled = IsMBFDisabledByElvUI,
},
space2 = {
order = 21,
name = "",
type = "description",
},
columnsorrows = {
order = 30,
type = "range",
name = L["Columns or Rows"],
desc = L["CLR_DESC"],
min = 1,
max = 50,
step = 1,
get = function() return MBF.db.profile.columns_or_rows end,
set = function(info, v)
MBF.db.profile.columns_or_rows = v
MBF:Scan()
end,
disabled = IsMBFDisabledByElvUI,
},
mbfanchor = {
order = 31,
type = "select",
name = L["MBF Anchor"],
desc = L["MBFANCHOR_DESC"],
get = function() return MBF.db.profile.mbfAnchor end,
set = function(info, name)
MBF.db.profile.mbfAnchor = name
MBF:SavePosition();
end,
values = frameanchor_options,
disabled = IsMBFDisabledByElvUI,
},
space3 = {
order = 32,
name = "",
type = "description",
},
padding = {
order = 40,
type = "range",
name = L["Padding"],
desc = L["PADDING_DESC"],
min = 0,
max = 20,
step = .5,
get = function() return MBF.db.profile.padding end,
set = function(info, v)
MBF.db.profile.padding = v
MBF:Scan()
end,
disabled = IsMBFDisabledByElvUI,
},
space4 = {
order = 41,
name = "",
type = "description",
},
scale = {
order = 50,
type = "range",
name = L["Scale"],
desc = L["SCALE_DESC"],
min = .5,
max = 2,
step = .1,
get = function() return MBF.db.profile.addonScale end,
set = function(info, v)
MBF.db.profile.addonScale = v
MinimapButtonFrame:SetScale(MBF.db.profile.addonScale)
MBFRestoreButtonFrame:SetScale(MBF.db.profile.addonScale)
end,
disabled = IsMBFDisabledByElvUI,
},
space5 = {
order = 51,
name = "",
type = "description",
},
buttonskin = {
order = 60,
type = "select",
name = L["Buttonskin"],
desc = L["BUTTONSKIN_DESC"],
get = function() return MBF.db.profile.currentTexture end,
set = function(info, name)
MBF.db.profile.currentTexture = name
textureFrame(MinimapButtonFrame)
MBF:Scan()
end,
values = tList,
disabled = IsMBFDisabledByElvUI,
},
},
}
local gathering = {
order = 2,
type = "group",
name = L["Gathering"],
desc = L["Gathering Settings"],
handler = MBF,
disabled = IsMBFDisabledByElvUI,
args = {
elvuiWarning = {
order = 0,
type = "description",
name = "|cffff0000ElvUI is controlling minimap buttons.|r\n\nMBF options are disabled.\n",
hidden = function() return not IsMBFDisabledByElvUI() end,
},
header1 = {
order = 1,
type = "header",
name = L["GATHERHEAD1_DESC"],
},
desc1 = {
order = 2,
type = "description",
name = L["GATHERDESC1_DESC"] .. "\n",
},
ShowMinimapButton = {
order = 3,
type = "toggle",
name = L["Show Minimap Button"],
desc = L["SHOWBUTTON_DESC"],
get = function() return not MBF.db.profile.minimapButton.hide end,
set = function(_, v)
MBF.db.profile.minimapButton.hide = not (v)
if MBF.db.profile.minimapButton.hide then
libdbicon:Hide("MBF")
else
libdbicon:Show("MBF")
end
MBF:Scan()
end,
disabled = function()
if IsMBFDisabledByElvUI() then return true end
if libdbicon then return false end
return true
end,
},
GatherMBFButton = {
order = 4,
type = "toggle",
name = L["Collect Button"],
desc = L["COLLECT1_DESC"],
get = function() return MBF.db.profile.grabMBFButton end,
set = function(info, value)
MBF.db.profile.grabMBFButton = not MBF.db.profile.grabMBFButton
if (MBF.db.profile.grabMBFButton) then
MinimapButtonFrame:Show();
MBF.db.profile.mbfHidden = false;
else
removeButton(LibDBIcon10_MBF, 0);
end
MBF:Scan()
end,
disabled = function()
if IsMBFDisabledByElvUI() then return true end
if MBF.db.profile.minimapButton.hide then return true end
return false
end,
},
spacer0 = {
order = 5,
name = "\n",
type = "description",
},
header2 = {
order = 10,
type = "header",
name = L["GATHERHEAD2_DESC"],
},
desc2 = {
order = 11,
type = "description",
name = L["GATHERDESC2_DESC"] .. "\n",
},
GatherBlizz = {
order = 12,
type = "toggle",
name = L["Collect Buttons"],
desc = L["COLLECT2_DESC"],
get = function() return MBF.db.profile.grabBlizzButtons end,
set = function(info, value)
MBF.db.profile.grabBlizzButtons = not MBF.db.profile.grabBlizzButtons
if not (MBF.db.profile.grabBlizzButtons) then
removeBlizzButtons()
MBF.db.profile.disabledMail = false
end
MBF:Scan()
end,
disabled = IsMBFDisabledByElvUI,
},
spacer1 = {
order = 13,
name = "",
type = "description",
},
HideBlizzMail = {
order = 14,
type = "toggle",
name = L["Hide Mail"],
desc = L["HIDEMAIL_DESC"],
get = function() return MBF.db.profile.MBFHideMiniMapMailFrame end,
set = function(info, value)
MBF.db.profile.MBFHideMiniMapMailFrame = not MBF.db.profile.MBFHideMiniMapMailFrame
if MBF.db.profile.MBFHideMiniMapMailFrame then
MiniMapMailFrame:Hide()
MBF.db.profile.disabledMail = false
else
if (HasNewMail() == 1) then
MiniMapMailFrame:Show()
end
end
MBF:Scan()
end,
disabled = IsMBFDisabledByElvUI,
},
ShowNoMail = {
order = 15,
type = "toggle",
name = L["Show No Mail Icon"],
desc = L["NOMAIL_DESC"],
get = function() return MBF.db.profile.disabledMail end,
set = function(info, value)
MBF.db.profile.disabledMail = not MBF.db.profile.disabledMail
MBF:Scan()
end,
disabled = function()
if IsMBFDisabledByElvUI() then return true end
if MBF.db.profile.MBFHideMiniMapMailFrame or (MBF.db.profile.grabBlizzButtons == false) then return true end
return false
end,
},
spacer2 = {
order = 16,
name = "",
type = "description",
},
HideTracking = {
order = 17,
type = "toggle",
name = L["Hide Tracking"],
desc = L["TRACKING_DESC"],
get = function() return MBF.db.profile.MBFHideMiniMapTracking end,
set = function(info, value)
MBF.db.profile.MBFHideMiniMapTracking = not MBF.db.profile.MBFHideMiniMapTracking
if MBF.db.profile.MBFHideMiniMapTracking then
MiniMapTracking:Hide()
else
MiniMapTracking:Show()
end
MBF:Scan()
end,
disabled = IsMBFDisabledByElvUI,
},
spacer4 = {
order = 18,
name = "",
type = "description",
},
HideVoiceChat = {
order = 19,
type = "toggle",
name = L["Hide Voice Chat"],
desc = L["VOICECHAT_DESC"],
get = function() return MBF.db.profile.MBFHideMiniMapVoiceChatFrame end,
set = function(info, value)
MBF.db.profile.MBFHideMiniMapVoiceChatFrame = not MBF.db.profile.MBFHideMiniMapVoiceChatFrame
if MBF.db.profile.MBFHideMiniMapVoiceChatFrame then
MiniMapVoiceChatFrame:Hide()
else
MiniMapVoiceChatFrame:Show()
end
MBF:Scan()
end,
disabled = IsMBFDisabledByElvUI,
},
spacer5 = {
order = 20,
name = "",
type = "description",
},
HideGameTime = {
order = 21,
type = "toggle",
name = L["Hide Calendar"],
desc = L["CALENDAR_DESC"],
get = function() return MBF.db.profile.MBFHideGameTimeFrame end,
set = function(info, value)
MBF.db.profile.MBFHideGameTimeFrame = not MBF.db.profile.MBFHideGameTimeFrame
if MBF.db.profile.MBFHideGameTimeFrame then
GameTimeFrame:Hide()
else
GameTimeFrame:Show()
end
MBF:Scan()
end,
disabled = IsMBFDisabledByElvUI,
},
spacer6 = {
order = 22,
name = "",
type = "description",
},
HideMinimapZoom = {
order = 23,
type = "toggle",
name = L["Hide Zoom Buttons"],
desc = L["ZOOM_DESC"],
get = function() return MBF.db.profile.MBFHideMinimapZoomIn end,
set = function(info, value)
MBF.db.profile.MBFHideMinimapZoomIn = not MBF.db.profile.MBFHideMinimapZoomIn
if MBF.db.profile.MBFHideMinimapZoomIn then
MinimapZoomIn:Hide()
MinimapZoomOut:Hide()
else
MinimapZoomIn:Show()
MinimapZoomOut:Show()
end
MBF:Scan()
end,
disabled = IsMBFDisabledByElvUI,
},
spacer7 = {
order = 24,
name = "",
type = "description",
},
HideWorldMap = {
order = 25,
type = "toggle",
name = L["Hide World Map"],
desc = L["WORLDMAP_DESC"],
get = function() return MBF.db.profile.MBFHideMiniMapWorldMapButton end,
set = function(info, value)
MBF.db.profile.MBFHideMiniMapWorldMapButton = not MBF.db.profile.MBFHideMiniMapWorldMapButton
if MBF.db.profile.MBFHideMiniMapWorldMapButton then
MiniMapWorldMapButton:Hide()
else
MiniMapWorldMapButton:Show()
end
MBF:Scan()
end,
disabled = IsMBFDisabledByElvUI,
},
},
}
local exceptions = {
order = 1,
type = "group",
name = L["Exceptions"],
desc = L["Exceptions Settings"],
handler = MBF,
disabled = IsMBFDisabledByElvUI,
args = {
header1 = {
order = 1,
type = "header",
name = L["Protected Items"],
},
desc1 = {
order = 2,
type = "description",
name = L["ICONSDESC_DESC"] .. "\n",
},
minimapIcons = {
order = 3,
type = "select",
name = L["Protected Items"],
desc = L["CURRENTEXCEPTIONS_DESC"],
get = function() return MBF.db.profile.currentMinimapIcon end,
set = function(info, name) MBF.db.profile.currentMinimapIcon = name end,
values = minimapIconList,
},
removeIcon = {
order = 4,
type = "execute",
name = L["Remove"],
desc = L["ICONREMOVE_DESC"],
func = function()
local miniButton = MBF.db.profile.currentMinimapIcon
removeFromTable(MBF.db.profile.MinimapIcons, miniButton)
minimapIconList[miniButton] = nil;
for i, name in pairs(MBF.db.profile.MinimapIcons) do
minimapIconList[name] = name
if i == 1 then
MBF.db.profile.currentMinimapIcon = name
end
end
MBF:Scan()
end,
},
spacer1 = {
order = 5,
name = "\n",
type = "description",
},
iconInput = {
order = 6,
type = "input",
name = L["ICONADDTITLE_DESC"],
desc = L["ICONADD_DESC"],
set = function(info, newValue)
local liveButton
tinsert(MBF.db.profile.MinimapIcons, newValue)
minimapIconList[newValue] = newValue
for i, liveButton in ipairs({ MinimapButtonFrame:GetChildren() }) do
if (isMinimapIcon(liveButton:GetName())) then
removeButton(liveButton, 1)
end
end
MBF:Scan()
end,
},
header2 = {
order = 10,
type = "header",
name = L["Button Override"],
},
desc2 = {
order = 11,
type = "description",
name = L["OVERRIDEDESC_DESC"] .. "\n",
},
buttonOverride = {
order = 12,
type = "select",
name = L["Button Override"],
desc = L["Current Button Overrides"],
get = function() return MBF.db.profile.currentButtonOverride end,
set = function(info, name) MBF.db.profile.currentButtonOverride = name end,
values = buttonOverrideList,
},
removeOverride = {
order = 13,
type = "execute",
name = L["Remove"],
desc = L["OVERRIDEREMOVE_DESC"],
func = function()
local liveButton
local miniButton = MBF.db.profile.currentButtonOverride
if isInTable(MBF.db.profile.ButtonOverride, miniButton) then
removeFromTable(MBF.db.profile.ButtonOverride, miniButton)
liveButton = _G[miniButton]
if ((liveButton ~= nil) and (MBF_ButtonInfoStorage[miniButton] ~= nil)) then
removeButton(liveButton, 0)
end
for i, name in pairs(MBF.db.profile.ButtonOverride) do
buttonOverrideList[name] = name
if i == 1 then
MBF.db.profile.currentButtonOverride = name
end
end
buttonOverrideList[miniButton] = nil;
MBF:Scan()
end
end,
},
spacer2 = {
order = 14,
name = "\n",
type = "description",
},
overrideInput = {
order = 15,
type = "input",
name = L["Add Button Override"],
desc = L["OVERRIDEADD_DESC"],
set = function(info, newValue)
tinsert(MBF.db.profile.ButtonOverride, newValue)
buttonOverrideList[newValue] = newValue
MBF:Scan()
end,
},
},
}
local sorting = {
order = 1,
type = "group",
name = L["Sorting"],
desc = L["Sorting Settings"],
handler = MBF,
disabled = IsMBFDisabledByElvUI,
args = {
sortOrder = {
order = 1,
type = "select",
name = L["Sort Order"],
desc = L["SORTORDER_DESC"],
get = function() return MBF.db.profile.sortOrder end,
set = function(info, name)
MBF.db.profile.sortOrder = name
MBF:Scan()
end,
values = sortorder_options,
},
growUp = {
order = 2,
type = "toggle",
name = L["Grow Buttons Up"],
desc = L["GROWUP_DESC"],
get = function() return MBF.db.profile.GrowUp end,
set = function(info, value)
MBF.db.profile.GrowUp = not MBF.db.profile.GrowUp
MBF:Scan()
end,
},
sortByRows = {
order = 3,
type = "toggle",
name = L["Sort By Rows"],
desc = L["SBR_DESC"],
get = function() return MBF.db.profile.sort_by_rows end,
set = function(info, value)
MBF.db.profile.sort_by_rows = not MBF.db.profile.sort_by_rows
MBF:Scan()
end,
},
space = {
order = 9,
name = "\n",
type = "description",
},
mbfKids = {
order = 10,
type = "select",
name = L["Children"],
desc = L["Children"],
get = function() return MBF.db.profile.currentChild end,
set = function(info, name) MBF.db.profile.currentChild = name end,
values = childList,
},
moveUp = {
order = 11,
type = "execute",
name = L["UP"],
image = "Interface/Buttons/UI-ScrollBar-ScrollUpButton-Up",
imageWidth = 50,
imageHeight = 50,
desc = L["UP_DESC"],
func = function() MBF:moveButton(1) end,
},
moveDown = {
order = 12,
type = "execute",
name = L["DOWN"],
image = "Interface/Buttons/UI-ScrollBar-ScrollDownButton-Up",
imageWidth = 50,
imageHeight = 50,
desc = L["DOWN_DESC"],
func = function() MBF:moveButton(2) end,
},
}
}
-- ElvUI Integration options
local plugins = {
order = 1,
type = "group",
name = "Plugins",
desc = "Plugin Integration Settings",
handler = MBF,
args = {
elvuiHeader = {
order = 1,
type = "header",
name = "ElvUI Integration",
},
elvuiDesc = {
order = 2,
type = "description",
name =
"\n|cff00ffffElvUI Integration|r\n\nWhen ElvUI is installed, you can control which addon manages minimap buttons.\n\nIf you want ElvUI to manage buttons instead of MBF, enable the toggle below. This will disable MBF's button control and you may want to disable this addon.\n",
},
relinquishToElvUI = {
order = 3,
type = "toggle",
name = "Let ElvUI Control Buttons",
desc =
"When enabled, MBF will relinquish control of minimap buttons to ElvUI. You should then disable MBF addon.",
width = "full",
hidden = function() return not IsAddOnLoaded("ElvUI") end,
get = function()
-- Check ElvUI's setting
if ElvUI then
local E = unpack(ElvUI)
if E and E.db and E.db.general and E.db.general.minimap then
return not E.db.general.minimap.mbfControlEnabled
end
end
return false
end,
set = function(_, value)
if ElvUI then
local E = unpack(ElvUI)
if E and E.db then
-- Ensure table structure exists
E.db.general = E.db.general or {}
E.db.general.minimap = E.db.general.minimap or {}
E.db.general.minimap.mbfControlEnabled = not value
-- If relinquishing to ElvUI (value = true), auto-enable ElvUI's button grabber
if value then
-- Enable ElvUI's minimap button grabber so user doesn't have to do it manually
-- The Enable checkbox uses E.private.enhanced.minimapButtonGrabber
E.private = E.private or {}
E.private.enhanced = E.private.enhanced or {}
E.private.enhanced.minimapButtonGrabber = true
StaticPopupDialogs["MBF_DISABLE_ADDON"] = {
text =
"ElvUI will now control minimap buttons.\n\nElvUI's Minimap Button Grabber has been auto-enabled.\n\nYou must disable MinimapButtonFrame and reload your UI for changes to take effect.",
button1 = "Disable & Reload",
button2 = "Cancel",
OnAccept = function()
DisableAddOn("MinimapButtonFrame")
DisableAddOn("MinimapButtonFrame_SkinPack")
ReloadUI()
end,
OnCancel = function()
-- Cancel - revert the setting since user didn't proceed
if ElvUI then
local E = unpack(ElvUI)
if E and E.db and E.db.general and E.db.general.minimap then
E.db.general.minimap.mbfControlEnabled = true -- Revert to MBF control
end
end
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
}
StaticPopup_Show("MBF_DISABLE_ADDON")
else
-- Enabling MBF control, just reload
StaticPopupDialogs["MBF_RELOAD_UI"] = {
text = "MBF will now control minimap buttons.\n\nReload your UI to apply this change?",
button1 = "Reload",
button2 = "Later",
OnAccept = function()
ReloadUI()
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
}
StaticPopup_Show("MBF_RELOAD_UI")
end
end
end
end,
},
elvuiNotInstalled = {
order = 4,
type = "description",
name =
"\n|cffff0000ElvUI is not installed.|r\n\nThis integration option is only available when ElvUI is installed.",
hidden = function() return IsAddOnLoaded("ElvUI") end,
},
}
}
local defaults = {
profile = {
version = MBFVersion,
-- Display Vars
locked = false,
colorLocked = "Nothing",
altTitle = false,
mbfAnchor = "TOPRIGHT",
currentTexture = "Blizzard",
MBFBackdropColor = { Red = 0, Green = 0, Blue = 0, Alpha = 1 },
columns_or_rows = 3,
sort_by_rows = false,
padding = 5,
opacity = 1,
addonScale = .8,
MBF_FrameLocation = { "TOPRIGHT", "TOPRIGHT", 0, 0 },
mbfHidden = false,
rollUp = false,
-- Gathering Vars
minimapButton = { hide = true },
grabMBFButton = false,
grabBlizzButtons = false,
disabledMail = true,
MBFHideMiniMapMailFrame = false,
MBFHideMiniMapTracking = false,
MBFHideMiniMapVoiceChatFrame = false,
MBFHideGameTimeFrame = false,
MBFHideMinimapZoomIn = false,
MBFHideMiniMapWorldMapButton = false,
MBFHideMiniMapLFGFrame = false,
MBFHideMiniMapBattlefieldFrame = false,
-- Exception Vars
currentMinimapIcon = "Note",
MinimapIcons = { "Note", "JQuest", "NauticusMiniIcon", "MinimapIcon", "GatherMatePin", "WestPointer", "Chinchilla_", "SmartMinimapZoom", "pMinimap", "GuildMap3Mini", "MiniButton", "DropCount", "pfQuest", "pfMiniMapPin", "pfQuestContinentPin", "QuestieFrame", "QuestPOI", "HandyNotes" },
currentButtonOverride = "notesiconframe",
ButtonOverride = { "notesiconframe", "duckiebank_minimapicon", "cta_minimapicon", "BejeweledMinimapIcon", "EMPMINIMAPBUTTON", "MobMapMinimapButtonFrame", "Karma_MinimapIconFrame", "FuBarPluginCraftNotesFrameMinimapButton", "PeggledMinimapIcon", "DropCount_MinimapIcon" },
UserUIProtected = { "TitanPanel", "AutoBarButton", "FuBarFrame", "RicoMinimap_CoordinatesFrame", "MinimapZoom", "MinimapButtonFrame", "Xparky", "MBFRestoreButton", "BasicMiniMap", "CT_RASetsFrame", "SMM", "GuildOrg_Toggle" },
ParentStop = { "CECBMiniMapButtonFrame", "CT_RASetsFrame", "GuildOrg_Toggle", "PoisonerStateHeader" },
MBF_Ignore = { "MetamapButton" },
MBF_Include = {},
-- Sorting Vars
sortOrder = "Alphabetical",
growUp = false,
currentChild = "",
customChildren = {},
}
}
-- Init and Event Handler Functions
function MBF:OnInitialize()
-- Called when the addon is loaded
self.db = LibStub("AceDB-3.0"):New("MBFDB", defaults, true)
-- Migrate existing profiles: ensure pfQuest pins are in MinimapIcons
if self.db.profile.MinimapIcons then
if not isInTable(self.db.profile.MinimapIcons, "pfMiniMapPin") then
tinsert(self.db.profile.MinimapIcons, "pfMiniMapPin")
end
if not isInTable(self.db.profile.MinimapIcons, "pfQuestContinentPin") then
tinsert(self.db.profile.MinimapIcons, "pfQuestContinentPin")
end
end
if LibStub:GetLibrary("LibAboutPanel", true) then
self.optionsFrame = LibStub:GetLibrary("LibAboutPanel").new(nil, "Minimap Button Frame")
else
self:Print("Lib AboutPanel not loaded.")
end
LibStub("AceConfig-3.0"):RegisterOptionsTable("MBF Display", display)
LibStub("AceConfig-3.0"):RegisterOptionsTable("MBF Gathering", gathering)
LibStub("AceConfig-3.0"):RegisterOptionsTable("MBF Exceptions", exceptions)
LibStub("AceConfig-3.0"):RegisterOptionsTable("MBF Sorting", sorting)
LibStub("AceConfig-3.0"):RegisterOptionsTable("MBF Plugins", plugins)
LibStub("AceConfig-3.0"):RegisterOptionsTable("MBF Profiles", LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db))
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MBF Display", L["Display"], "MinimapButtonFrame")
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MBF Gathering", L["Gathering"], "MinimapButtonFrame")
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MBF Exceptions", L["Exceptions"], "MinimapButtonFrame")
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MBF Sorting", L["Sorting"], "MinimapButtonFrame")
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MBF Plugins", "Plugins", "MinimapButtonFrame")
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MBF Profiles", L["Profiles"], "MinimapButtonFrame")
self:RegisterChatCommand(L["MBF"], "ChatCommand")
self:fillDropdowns();
MBFC_LoadStandardSkins();
MBF.obj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("MinimapButtonFrame", {
type = "launcher",
text = "MBF",
OnClick = function(_, msg, down)
if (IsShiftKeyDown()) then
MBFC_Toggle();
elseif (msg == "LeftButton") then
MBFC_Visible(2, MinimapButtonFrame:GetParent():GetName());
end
end,
icon = "Interface\\Icons\\INV_Misc_Coin_11",
OnTooltipShow = function(tooltip)
if not tooltip or not tooltip.AddLine then return end
tooltip:AddLine(L["ADDON"]);
tooltip:AddLine(L["MBF_LDB_TOOLTIP"])
end,
})
-- register MBF with LibDBicon and show minimap icon
if libdbicon then
libdbicon:Register("MBF", MBF.obj, MBF.db.profile.minimapButton)
end
self:Init();
MinimapButtonFrame:RegisterForDrag("LeftButton");
MinimapButtonFrameDragButton:RegisterForClicks("RightButtonUp");