forked from Mundocani/Mappy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMappy.lua
More file actions
executable file
·3025 lines (2412 loc) · 93.6 KB
/
Mappy.lua
File metadata and controls
executable file
·3025 lines (2412 loc) · 93.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
-- 10/14/2020 - Updated to support new Backdrop requirments in Shadowlands - LynchburgJack
local _
_, Mappy = ...
local gAddonName = select(1, ...)
gMappy_Settings = nil
-- MBB compatibility
Mappy.MBBenabled = nil
-- FarmHud compatibility
Mappy.FarmHudEnabled = nil
Mappy.enableBlips = true
Mappy.StackingInfo = {}
Mappy.CoordAnchorInfo = {}
Mappy.BlizzardButtonNames = {
"GameTimeFrame",
MinimapCluster.IndicatorFrame.MailFrame,
MinimapCluster.IndicatorFrame.CraftingOrderFrame,
MinimapCluster.Tracking,
"MiniMapBattlefieldFrame",
"MiniMapMeetingStoneFrame",
"MiniMapVoiceChatFrame",
"FeedbackUIButton",
MinimapCluster.InstanceDifficulty,
"MiniMapLFGFrame",
"GuildInstanceDifficulty",
"ExpansionLandingPageMinimapButton",
"AddonCompartmentFrame",
}
Mappy.BlizzardMinimalistButtons = {
[GameTimeFrame] = true,
[MinimapCluster.IndicatorFrame.MailFrame] = true,
[MinimapCluster.IndicatorFrame.CraftingOrderFrame] = true,
[MinimapCluster.Tracking] = true,
[MinimapCluster.InstanceDifficulty] = true,
[AddonCompartmentFrame] = true,
}
Mappy.OtherAddonButtonNames = {
"CT_RASets_Button",
"MBB_MinimapButtonFrame",
}
Mappy.IgnoreFrames = {
Minimap = true,
MinimapBackdrop = true,
MiniMapPing = true,
MinimapToggleButton = true,
MinimapZoneTextButton = true,
CT_RASetsFrame = true,
}
Mappy.CoordAnchor = "BOTTOMLEFT"
-- placeholder for coord anchor
Mappy.CoordInfo = {
BOTTOMLEFT = {
CoordOffsetX = 5,
CoordOffsetY = 4,
},
BOTTOM = {
CoordOffsetX = 0,
CoordOffsetY = 10,
},
BOTTOMRIGHT = {
CoordOffsetX = -5,
CoordOffsetY = 4,
},
}
Mappy.StartingCorner = "TOPRIGHT"
Mappy.CornerInfo = {
TOPRIGHT = {
NextCorner = "BOTTOMRIGHT",
AnchorPoint = "TOP",
RelativePoint = "BOTTOM",
ButtonGap = 1,
HorizGap = 0,
VertGap = -1,
HorizInsetDir = -1,
VertInsetDir = -1,
IsVert = true,
OffsetPositive = false,
},
BOTTOMRIGHT = {
NextCorner = "BOTTOMLEFT",
AnchorPoint = "RIGHT",
RelativePoint = "LEFT",
ButtonGap = 1,
HorizGap = -1,
VertGap = 0,
HorizInsetDir = -1,
VertInsetDir = 1,
IsVert = false,
OffsetPositive = false,
},
BOTTOMLEFT = {
NextCorner = "TOPLEFT",
AnchorPoint = "BOTTOM",
RelativePoint = "TOP",
ButtonGap = 1,
HorizGap = 0,
VertGap = 1,
HorizInsetDir = 1,
VertInsetDir = 1,
IsVert = true,
OffsetPositive = true,
},
TOPLEFT = {
NextCorner = "TOPRIGHT",
AnchorPoint = "LEFT",
RelativePoint = "RIGHT",
ButtonGap = 1,
HorizGap = 1,
VertGap = 0,
HorizInsetDir = 1,
VertInsetDir = -1,
IsVert = false,
OffsetPositive = true,
},
}
Mappy.CornerInfoCCW = {
TOPRIGHT = {
NextCorner = "TOPLEFT",
AnchorPoint = "RIGHT",
RelativePoint = "LEFT",
ButtonGap = 1,
HorizGap = -1,
VertGap = 0,
HorizInsetDir = -1,
VertInsetDir = -1,
IsVert = false,
OffsetPositive = false,
},
BOTTOMRIGHT = {
NextCorner = "TOPRIGHT",
AnchorPoint = "BOTTOM",
RelativePoint = "TOP",
ButtonGap = 1,
HorizGap = 0,
VertGap = 1,
HorizInsetDir = -1,
VertInsetDir = 1,
IsVert = true,
OffsetPositive = true,
},
BOTTOMLEFT = {
NextCorner = "BOTTOMRIGHT",
AnchorPoint = "LEFT",
RelativePoint = "RIGHT",
ButtonGap = 1,
HorizGap = 1,
VertGap = 0,
HorizInsetDir = 1,
VertInsetDir = 1,
IsVert = false,
OffsetPositive = true,
},
TOPLEFT = {
NextCorner = "BOTTOMLEFT",
AnchorPoint = "TOP",
RelativePoint = "BOTTOM",
ButtonGap = 1,
HorizGap = 0,
VertGap = -1,
HorizInsetDir = 1,
VertInsetDir = -1,
IsVert = true,
OffsetPositive = false,
},
}
Mappy.ProfileNameMap = {
DEFAULT = "Normal",
gather = "Gather",
NONE = "Don't change"
}
Mappy.ObjectIconsNormalLargePath = "Interface\\MINIMAP\\ObjectIconsAtlas"
Mappy.ObjectIconsHighlightLargePath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_On"
Mappy.ObjectIconsNormalSmallPath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_Small"
Mappy.ObjectIconsHighlightSmallPath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_On_Small"
Mappy.ObjectIconsNormalOldPath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_Old"
Mappy.ObjectIconsHighlightOldPath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_On_Old"
Mappy.ObjectIconsNormalSmallOldPath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_Small_Old"
Mappy.ObjectIconsHighlightSmallOldPath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_On_Small_Old"
Mappy.ObjectIconsNormalPath = ""
Mappy.ObjectIconsHighlightPath = ""
Mappy.LandmarkArrows = {}
-- local functions
local function tableContains(table, key)
return table[key] ~= nil
end
--
function Mappy:AddonLoaded(pEventID, pAddonName)
if pAddonName ~= gAddonName then
return
end
if not gMappy_Settings then
self:InitializeSettings()
end
--
self.CurrentProfile = gMappy_Settings.Profiles[gMappy_Settings.CurrentProfileName]
if not self.CurrentProfile then
self.CurrentProfile = gMappy_Settings.Profiles.DEFAULT
end
self.SchedulerLib:ScheduleUniqueTask(0.5, self.InitializeMinimap, self)
self.OptionsPanel = self:New(self._OptionsPanel, UIParent)
self.ButtonOptionsPanel = self:New(self._ButtonOptionsPanel, UIParent)
self.ProfilesPanel = self:New(self._ProfilesPanel, UIParent)
-- Commands
SlashCmdList.MAPPY = function (...) Mappy:ExecuteCommand(...) end
SLASH_MAPPY1 = "/mappy"
-- Unregister to avoid firing for every load-on-demand addon
self.EventLib:UnregisterEvent("ADDON_LOADED", self.AddonLoaded, self)
end
function Mappy:InitializeSettings()
gMappy_Settings =
{
Profiles =
{
DEFAULT =
{
MinimapSize = 140,
MinimapAlpha = 1,
MinimapCombatAlpha = 0.2,
MinimapMovingAlpha = 0.2,
Point = "TOPRIGHT",
RelativePoint = "TOPRIGHT",
OffsetX = -32,
OffsetY = -32,
HideTimeOfDay = false,
HideZoneName = false,
GhostMinimap = false,
AutoArrangeButtons = true,
StackToScreen = false,
HideBorder = false,
HideTracking = false,
HideAddonCompartment = false,
HideTimeManagerClock = false,
FlashGatherNodes = false,
NormalGatherNodes = true, -- use large icons
UseAddonPosition = false,
CoordSize = 1,
CoordAnchor = "BOTTOMLEFT",
},
gather =
{
MinimapSize = 1000,
MinimapAlpha = 0,
MinimapCombatAlpha = 0,
MinimapMovingAlpha = 0,
Point = "CENTER",
RelativePoint = "CENTER",
OffsetX = 0,
OffsetY = 0,
HideTimeOfDay = false,
HideZoneName = false,
GhostMinimap = true,
AutoArrangeButtons = true,
StackToScreen = true,
HideBorder = true,
HideTracking = false,
HideAddonCompartment = false,
HideTimeManagerClock = false,
FlashGatherNodes = true,
NormalGatherNodes = false, -- use large icons
AttachmentPosition = {
Point = "TOPRIGHT",
RelativeTo = UIParent,
RelativePoint = "TOPRIGHT",
OffsetX = -80,
OffsetY = -50
},
UseAddonPosition = false,
CoordSize = 1,
CoordAnchor = "BOTTOMLEFT",
},
},
}
end
function Mappy:InitializeMinimap()
-- Enlarge and add borders to minimalist buttons
self:EnlargeMinimalistButtons()
-- Locate the addon buttons around the minimap
self:FindMinimapButtons()
-- Save method references for dragging
MinimapCluster.Mappy_SetPoint = MinimapCluster.SetPoint
MinimapCluster.Mappy_ClearAllPoints = MinimapCluster.ClearAllPoints
Minimap.Mappy_SetPoint = Minimap.SetPoint
Minimap.Mappy_ClearAllPoints = Minimap.ClearAllPoints
self:InitializeSquareShape()
-- Visually hide elements immediately via SetAlpha
-- The real Hide() calls happen in ApplyProtectedInitState when out of combat
MinimapCluster.BorderTop:SetAlpha(0)
Minimap.ZoomHitArea:SetAlpha(0)
-- Workaround for self:GetParent():Layout() errors after 10.0.5
-- Minimap.lua:376
MinimapCluster.Layout = function() end
-- Add scroll wheel support
Minimap:SetScript("OnMouseWheel", function (pMinimap, pDirection) self:MinimapMouseWheel(pDirection) end)
Minimap:EnableMouseWheel(true)
-- Set up drag scripts (RegisterForDrag is deferred)
Minimap:SetScript("OnDragStart", function() Mappy:StartMovingMinimap() end)
Minimap:SetScript("OnDragStop", function() Mappy:StopMovingMinimap() end)
-- Add the coordinates display
self.CoordString = Minimap:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
self.CoordString:SetHeight(12)
self.SchedulerLib:ScheduleRepeatingTask(0.2, self.Update, self)
-- Register for events
self.EventLib:RegisterEvent("ZONE_CHANGED", self.ZoneChanged, self)
self.EventLib:RegisterEvent("ZONE_CHANGED_INDOORS", self.ZoneChanged, self)
self.EventLib:RegisterEvent("PLAYER_ENTERING_WORLD", self.RegenEnabled, self)
self.EventLib:RegisterEvent("PLAYER_REGEN_ENABLED", self.RegenEnabled, self)
self.EventLib:RegisterEvent("PLAYER_REGEN_DISABLED", self.RegenDisabled, self)
self.EventLib:RegisterEvent("PLAYER_STARTED_MOVING", self.StartedMoving, self)
self.EventLib:RegisterEvent("PLAYER_STOPPED_MOVING", self.StoppedMoving, self)
self.EventLib:RegisterEvent("ACTIVE_PLAYER_SPECIALIZATION_CHANGED", self.TalentChanged, self)
-- Reapply addon positioning after Edit Mode exit
hooksecurefunc(EditModeManagerFrame, "ExitEditMode", self.EditModeExit)
-- Apply Edit Mode positioning on enter to avoid positioning issues
hooksecurefunc(EditModeManagerFrame, "EnterEditMode", self.EditModeEnter)
self:RegenEnabled()
-- Schedule the configuration (includes deferred protected-state init)
self.SchedulerLib:ScheduleUniqueTask(0.5, self.ConfigureMinimap, self)
-- Monitor the mounted state so we can determine which opacity setting to use
self.SchedulerLib:ScheduleUniqueRepeatingTask(0.5, self.UpdateMountedState, self)
end
-- Apply one-time protected operations that require out-of-combat state
-- Called from ConfigureMinimap on first successful (non-combat) run
function Mappy:ApplyProtectedInitState()
if self.ProtectedInitApplied then
return
end
self.ProtectedInitApplied = true
-- Hide elements
MinimapCluster.BorderTop:Hide()
Minimap.ZoomHitArea:Hide()
-- Enable dragging
Minimap:RegisterForDrag("LeftButton")
-- Reposition Minimap within MinimapCluster
Minimap:Mappy_ClearAllPoints()
Minimap:Mappy_SetPoint("TOPLEFT", MinimapCluster, "TOPLEFT", 0, 0)
-- Change the backdrop to size with the map
MinimapBackdrop:ClearAllPoints()
MinimapBackdrop:SetPoint("TOPLEFT", Minimap, "TOPLEFT", -4, 4)
MinimapBackdrop:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", 4, -4)
-- Move the zone text to the top and make it wider
MinimapCluster.ZoneTextButton:ClearAllPoints()
MinimapCluster.ZoneTextButton:SetPoint("BOTTOM", Minimap, "TOP", 0, 4)
MinimapCluster.ZoneTextButton:SetSize(180, 12)
-- Move zoom buttons to the corner and raise strata above the backdrop
Minimap.ZoomIn:SetPoint("TOPLEFT", 22, -2)
Minimap.ZoomOut:SetPoint("TOPLEFT", 2, -24)
Minimap.ZoomIn:SetFrameLevel(MinimapBackdrop:GetFrameLevel() + 1)
Minimap.ZoomOut:SetFrameLevel(MinimapBackdrop:GetFrameLevel() + 1)
end
function Mappy:ReparentLandmarks()
for vFrameIndex, vFrame in ipairs({Minimap:GetChildren()}) do
-- self:DebugMessage("Frame %s: Width: %s Height: %s Type: %s", vFrame:GetName() or "anonymous", vFrame:GetWidth() or "nil", vFrame:GetHeight() or "nil", vFrame:GetObjectType() or "nil")
if vFrame:GetName() ~= "MinimapBackdrop" then -- Don't reparent the backdrop since we want it to fade with the map
vFrame:SetParent(MinimapCluster)
end
end
end
function Mappy:FindMinimapButtons()
self.MinimapButtons = {}
self.MinimapButtonsByFrame = {}
for _, vButtonName in ipairs(self.BlizzardButtonNames) do
self.IgnoreFrames[vButtonName] = true
local vButton
-- filter frame names from frame globals
if type(vButtonName) == "string" then
vButton = _G[vButtonName]
else
vButton = vButtonName
end
if vButton then
self:RegisterMinimapButton(vButton, true)
end
end
for _, vButtonName in ipairs(self.OtherAddonButtonNames) do
self.IgnoreFrames[vButtonName] = true
local vButton = _G[vButtonName]
if vButton then
self:RegisterMinimapButton(vButton)
end
end
-- MBB compatibility
if not Mappy.MBBenabled then
self:FindAddonButtons(MinimapCluster)
self:FindAddonButtons(MinimapBackdrop)
self:FindAddonButtons(Minimap)
end
end
function Mappy:RegisterMinimapButton(pButton, pAlwaysStack)
if self.MinimapButtonsByFrame[pButton] then
return
end
table.insert(self.MinimapButtons, pButton)
self.MinimapButtonsByFrame[pButton] = true
for vName, vFunction in pairs(self._MinimapButton) do
pButton[vName] = vFunction
end
pButton.Mappy_AlwaysStack = pAlwaysStack
if pAlwaysStack then
pButton:Mappy_SetStackingEnabled(true)
end
end
function Mappy:ConfigureMinimapOptions()
-- Show/Hide calls are protected - defer if in combat
if InCombatLockdown() then
self.SchedulerLib:ScheduleUniqueTask(0, self.ConfigureMinimap, self)
return
end
if self.CurrentProfile.AutoArrangeButtons then
self:EnableButtonStacking()
else
self:DisableButtonStacking()
end
if self.CurrentProfile.HideTimeOfDay then
GameTimeFrame:Hide()
else
GameTimeFrame:SetAlpha(1)
GameTimeFrame:Show()
end
if self.CurrentProfile.HideZoneName then
MinimapCluster.ZoneTextButton:Hide()
else
MinimapCluster.ZoneTextButton:SetAlpha(1)
MinimapCluster.ZoneTextButton:Show()
end
if self.CurrentProfile.HideTracking then
MinimapCluster.Tracking:Hide()
else
MinimapCluster.Tracking:SetAlpha(1)
MinimapCluster.Tracking:Show()
end
if self.CurrentProfile.HideAddonCompartment then
AddonCompartmentFrame:Hide()
else
AddonCompartmentFrame:SetAlpha(1)
AddonCompartmentFrame:Show()
end
if self.CurrentProfile.HideTimeManagerClock then
if TimeManagerClockButton then
TimeManagerClockButton:Hide()
end
else
if TimeManagerClockButton then
TimeManagerClockButton:SetAlpha(1)
TimeManagerClockButton:Show()
end
end
if self.CurrentProfile.GhostMinimap then
self:GhostMinimap()
else
self:UnghostMinimap()
end
if self.CurrentProfile.NormalGatherNodes then
if self.CurrentProfile.OldGatherNodes then
self.ObjectIconsNormalPath = self.ObjectIconsNormalOldPath
self.ObjectIconsHighlightPath = self.ObjectIconsHighlightOldPath
else
self.ObjectIconsNormalPath = self.ObjectIconsNormalLargePath
self.ObjectIconsHighlightPath = self.ObjectIconsHighlightLargePath
end
else
if self.CurrentProfile.OldGatherNodes then
self.ObjectIconsNormalPath = self.ObjectIconsNormalSmallOldPath
self.ObjectIconsHighlightPath = self.ObjectIconsHighlightSmallOldPath
else
self.ObjectIconsNormalPath = self.ObjectIconsNormalSmallPath
self.ObjectIconsHighlightPath = self.ObjectIconsHighlightSmallPath
end
end
if Mappy.enableBlips then
if self.GatherFlashState then
Minimap:SetBlipTexture(self.ObjectIconsHighlightPath)
else
Minimap:SetBlipTexture(self.ObjectIconsNormalPath)
end
end
if self.CurrentProfile.FlashGatherNodes then
self:StartGatherFlash()
else
self:StopGatherFlash()
end
self:AdjustBackgroundStyle()
end
function Mappy:EnableButtonStacking()
self.StackingEnabled = true
for _, vButton in ipairs(self.MinimapButtons) do
vButton:Mappy_SetStackingEnabled(true)
end
end
function Mappy:DisableButtonStacking()
self.StackingEnabled = false
for _, vButton in ipairs(self.MinimapButtons) do
vButton:Mappy_SetStackingEnabled(false)
end
end
-- create borders and enlarge these new mini buttons
function Mappy:EnlargeMinimalistButtons()
-- calendar
local GameTime = GameTimeFrame:CreateTexture(nil, "OVERLAY")
-- Interface\\Minimap\\MiniMap-TrackingBorder
GameTime:SetTexture(136430)
GameTime:SetPoint("CENTER", GameTimeFrame, "CENTER", 10, -10)
GameTime:SetSize(60,60)
local GameTimeBG = GameTimeFrame:CreateTexture(nil, "BACKGROUND")
-- Interface\\Minimap\\UI-Minimap-Background
GameTimeBG:SetTexture(136467)
GameTimeBG:SetPoint("CENTER", GameTimeFrame, "CENTER")
GameTimeBG:SetSize(30,30)
-- mail
local MailFrame = MinimapCluster.IndicatorFrame.MailFrame:CreateTexture(nil, "OVERLAY")
MailFrame:SetTexture(136430)
MailFrame:SetPoint("CENTER", MiniMapMailIcon, "CENTER", 10, -10)
MailFrame:SetSize(53,53)
local MailFrameBG = MinimapCluster.IndicatorFrame.MailFrame:CreateTexture(nil, "BACKGROUND")
MailFrameBG:SetTexture(136467)
MailFrameBG:SetPoint("CENTER", MiniMapMailIcon, "CENTER")
MailFrameBG:SetSize(25,25)
-- crafting orders
local CraftingOrderFrame = MinimapCluster.IndicatorFrame.CraftingOrderFrame:CreateTexture(nil, "OVERLAY")
CraftingOrderFrame:SetTexture(136430)
CraftingOrderFrame:SetPoint("CENTER", MiniMapCraftingOrderIcon, "CENTER", 10, -10)
CraftingOrderFrame:SetSize(53,53)
local CraftingOrderFrameBG = MinimapCluster.IndicatorFrame.CraftingOrderFrame:CreateTexture(nil, "BACKGROUND")
CraftingOrderFrameBG:SetTexture(136467)
CraftingOrderFrameBG:SetPoint("CENTER", MiniMapCraftingOrderIcon, "CENTER")
CraftingOrderFrameBG:SetSize(25,25)
-- tracking
local Tracking = MinimapCluster.Tracking:CreateTexture(nil, "OVERLAY")
Tracking:SetTexture(136430)
Tracking:SetPoint("CENTER", MinimapCluster.Tracking.Button, "CENTER", 10, -10)
Tracking:SetSize(53,53)
local TrackingBG = MinimapCluster.Tracking:CreateTexture(nil, "BACKGROUND")
TrackingBG:SetTexture(136467)
TrackingBG:SetPoint("CENTER", MinimapCluster.Tracking.Button, "CENTER")
TrackingBG:SetSize(25,25)
-- addon compartment
local AddonCompartment = AddonCompartmentFrame:CreateTexture(nil, "OVERLAY")
AddonCompartment:SetTexture(136430)
AddonCompartment:SetPoint("CENTER", AddonCompartmentFrame.Text, "CENTER", 10, -10)
AddonCompartment:SetSize(53,53)
local AddonCompartmentBG = AddonCompartmentFrame:CreateTexture(nil, "BACKGROUND")
AddonCompartmentBG:SetTexture(136467)
AddonCompartmentBG:SetPoint("CENTER", AddonCompartmentFrame.Text, "CENTER")
AddonCompartmentBG:SetSize(25,25)
end
function Mappy:AdjustBackgroundStyle()
if self.CurrentProfile.HideBorder then
MinimapBackdrop:SetBackdropBorderColor(0.75, 0.75, 0.75, 0.0)
MinimapBackdrop:SetBackdropColor(0.15, 0.15, 0.15, 0.0, 0.0)
else
MinimapBackdrop:SetBackdropBorderColor(0.75, 0.75, 0.75)
MinimapBackdrop:SetBackdropColor(0.15, 0.15, 0.15, 0.0)
end
end
-- Combat-safe portion only
-- Protected positioning ops are in ApplyProtectedInitState()
function Mappy:InitializeSquareShape()
Minimap:SetMaskTexture("Interface\\Addons\\Mappy\\Textures\\MinimapMask")
MinimapCompassTexture:SetTexture(nil)
-- 10/14/2020 - Updated code to use the new Backdrop templates -LynchburgJack
MinimapBackdrop = CreateFrame("Frame", "Backdrop", MinimapBackdrop, BackdropTemplateMixin and "BackdropTemplate")
-- Transfer StaticOverlayTexture from the original MinimapBackdrop
-- Use custom square texture instead of Blizzard's circular one
local vStaticOverlay = MinimapBackdrop:GetParent().StaticOverlayTexture
if vStaticOverlay then
vStaticOverlay:SetParent(MinimapBackdrop)
vStaticOverlay:ClearAllPoints()
vStaticOverlay:SetAllPoints(Minimap)
vStaticOverlay:SetDrawLayer("BACKGROUND")
vStaticOverlay:SetTexture("Interface\\Addons\\Mappy\\Textures\\UIHudMinimapHousingIndoorStaticBg")
-- Prevent overwriting with atlas area
vStaticOverlay.SetAtlas = function() end
MinimapBackdrop.StaticOverlayTexture = vStaticOverlay
end
MinimapBackdrop.backdropInfo = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = {left = 3, right = 3, top = 3, bottom = 3},
}
MinimapBackdrop:SetBackdrop(MinimapBackdrop.backdropInfo)
MinimapBackdrop:SetBackdropBorderColor(0.75, 0.75, 0.75, 1.0)
MinimapBackdrop:SetBackdropColor(0.15, 0.15, 0.15, 1.0)
MinimapZoneText:SetAllPoints(MinimapCluster.ZoneTextButton)
MinimapZoneText:SetJustifyH("CENTER")
MinimapBackdrop:ApplyBackdrop()
end
function Mappy:SetCounterClockwise(pCCW)
self.CurrentProfile.CCW = pCCW
self:LoadProfile(self.CurrentProfile)
end
function Mappy:SetGhost(pGhost)
if pGhost then
self:GhostMinimap()
else
self:UnghostMinimap()
end
end
function Mappy:GhostMinimap()
self.CurrentProfile.GhostMinimap = true
-- Protected ops (EnableMouse, RegisterForDrag) - defer if in combat
if InCombatLockdown() then
self.SchedulerLib:ScheduleUniqueTask(0, self.ConfigureMinimap, self)
return
end
if not (Mappy.FarmHudEnabled and FarmHud:IsVisible()) then
Minimap:RegisterForDrag()
Minimap:EnableMouse(false)
MinimapCluster:RegisterForDrag()
MinimapCluster:EnableMouse(false)
Minimap:EnableMouseWheel(false)
end
end
function Mappy:UnghostMinimap()
self.CurrentProfile.GhostMinimap = false
-- Protected ops (EnableMouse, RegisterForDrag) - defer if in combat
if InCombatLockdown() then
self.SchedulerLib:ScheduleUniqueTask(0, self.ConfigureMinimap, self)
return
end
if not (Mappy.FarmHudEnabled and FarmHud:IsVisible()) then
Minimap:RegisterForDrag("LeftButton")
Minimap:EnableMouse(true)
Minimap:SetScript("OnMouseWheel", function (self, direction) Mappy:MinimapMouseWheel(direction) end)
Minimap:EnableMouseWheel(true)
end
end
function Mappy:SaveProfile(pName)
if not pName or pName == "" then
Mappy:ErrorMessage("You must specify a name for the profile")
return
end
local vName = string.lower(pName)
-- Clone the current profile
local vProfile = {}
for vKey, vValue in pairs(self.CurrentProfile) do
vProfile[vKey] = vValue
end
gMappy_Settings.Profiles[vName] = vProfile
gMappy_Settings.CurrentProfileName = vName
self.CurrentProfile = vProfile
end
function Mappy:LoadProfileName(pName)
if not pName or pName == "" then
self:ErrorMessage("You must specify a name for the profile")
return
end
local vName = pName:lower()
if not gMappy_Settings.Profiles[vName] then
self:ErrorMessage("Couldn't find a saved profile with the name %s", pName)
return
end
gMappy_Settings.CurrentProfileName = vName
self:LoadProfile(gMappy_Settings.Profiles[vName])
end
function Mappy:LoadDefaultProfile()
gMappy_Settings.CurrentProfileName = "DEFAULT"
self:LoadProfile(gMappy_Settings.Profiles.DEFAULT)
end
function Mappy:LoadProfile(pProfile)
local vProfileChanged = self.CurrentProfile ~= pProfile
self.CurrentProfile = pProfile
if vProfileChanged then
if self.OptionsPanel:IsVisible() then
self.OptionsPanel:OnShow()
end
if self.ButtonOptionsPanel:IsVisible() then
self.ButtonOptionsPanel:OnShow()
end
if self.ProfilesPanel:IsVisible() then
self.ProfilesPanel:OnShow()
end
end
self.SchedulerLib:ScheduleUniqueTask(0, self.ConfigureMinimap, self)
end
function Mappy:ExecuteCommand(pCommand)
local vStartIndex, vEndIndex, vCommand, vParameter = string.find(pCommand, "(%w+) ?(.*)")
if not vCommand then
Settings.OpenToCategory(self.name)
return
end
vCommand = vCommand:lower()
if self[vCommand] then
self[vCommand](self, vParameter)
-- See if there's a profile with the name and load it if there is
elseif gMappy_Settings.Profiles[vCommand] then
gMappy_Settings.CurrentProfileName = vCommand
self:LoadProfile(gMappy_Settings.Profiles[vCommand])
else
self:ErrorMessage("Expected command")
end
end
function Mappy:help()
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy help"..NORMAL_FONT_COLOR_CODE..": Shows this list")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy default"..NORMAL_FONT_COLOR_CODE..": Loads the default profile")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy save settingsname"..NORMAL_FONT_COLOR_CODE..": Saves the settings under the name settingsname")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy load settingsname"..NORMAL_FONT_COLOR_CODE..": Loads the settings")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy settingsname"..NORMAL_FONT_COLOR_CODE..": Shorthand version of /mappy load")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy ghost"..NORMAL_FONT_COLOR_CODE..": Mouse clicks in the minimap will be passed through to the background")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy unghost"..NORMAL_FONT_COLOR_CODE..": Mouse clicks work as usual")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy corner TOPLEFT|TOPRIGHT|BOTTOMLEFT|BOTTOMRIGHT"..NORMAL_FONT_COLOR_CODE..": Sets the starting corner for button stacking")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy reset"..NORMAL_FONT_COLOR_CODE..": Resets all settings and profiles")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy unlock"..NORMAL_FONT_COLOR_CODE..": Unlocks the minimap for dragging")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy lock"..NORMAL_FONT_COLOR_CODE..": Locks the minimap, preventing its movement")
self:NoteMessage(HIGHLIGHT_FONT_COLOR_CODE.."/mappy reload"..NORMAL_FONT_COLOR_CODE..": Reload Mappy if something doesn't look right")
end
function Mappy:ghost(pParameter)
self:GhostMinimap()
end
function Mappy:unghost(pParameter)
self:UnghostMinimap()
end
function Mappy:unlock(pParameter)
self.CurrentProfile.LockPosition = nil
end
function Mappy:lock(pParameter)
self.CurrentProfile.LockPosition = true
end
function Mappy:save(pParameter)
self:SaveProfile(pParameter)
end
function Mappy:load(pParameter)
self:LoadProfileName(pParameter)
end
function Mappy:reload(pParameter)
self:LoadProfile(self.CurrentProfile)
end
function Mappy:default(pParameter)
self:LoadDefaultProfile()
end
function Mappy:corner(pParameter)
local vCorner = pParameter:upper()
if vCorner == "TOPLEFT"
or vCorner == "TOPRIGHT"
or vCorner == "BOTTOMLEFT"
or vCorner == "BOTTOMRIGHT" then
self.CurrentProfile.StartingCorner = vCorner
self:LoadProfile(self.CurrentProfile)
else
self:ErrorMessage("Corner must be TOPLEFT, TOPRIGHT, BOTTOMLEFT, or BOTTOMRIGHT")
end
end
function Mappy:cw(pParameter)
self:SetCCW(false)
end
function Mappy:ccw(pParameter)
self:SetCCW(true)
end
function Mappy:reset(pParameter)
self:InitializeSettings()
self:LoadProfile(gMappy_Settings.Profiles.DEFAULT)
end
function Mappy:gcompact()
self:CompactGatherer()
end
function Mappy:BeginStackingButtons()
if self.CurrentProfile.StackToScreen then
self.StackingInfo.StackingParent = UIParent
if self.CurrentProfile.HideTimeOfDay then
self.StackingInfo.StackingInsetX = 18
self.StackingInfo.StackingInsetY = 18
else
self.StackingInfo.StackingInsetX = 24
self.StackingInfo.StackingInsetY = 24
end
else
if Mappy.FarmHudEnabled and FarmHud:IsVisible() then
self.StackingInfo.StackingParent = FarmHudMinimapDummy
else
self.StackingInfo.StackingParent = Minimap
end
self.StackingInfo.StackingInsetX = 0
self.StackingInfo.StackingInsetY = 0
end
self.StackingInfo.Corner = self.StartingCorner
self.StackingInfo.CornerInfo = (self.CurrentProfile.CCW and self.CornerInfoCCW or self.CornerInfo)[self.StackingInfo.Corner]
self.StackingInfo.PreviousButton = nil
if self.StackingInfo.CornerInfo.IsVert then
self.StackingInfo.SpaceRemaining = self.StackingInfo.StackingParent:GetHeight() - (2 * self.StackingInfo.StackingInsetY)
else
self.StackingInfo.SpaceRemaining = self.StackingInfo.StackingParent:GetWidth() - (2 * self.StackingInfo.StackingInsetX)
end
self.StackingInfo.ButtonFrameLevel = Minimap:GetFrameLevel() + 5
end
function Mappy:StackButton(pButton, pNextButton)
-- Calculate the space used by the button
local vSpaceUsed
local vButtonSize = pButton:GetHeight()
local MiniOffsetH = 0
local MiniOffsetV = 0
-- Check if mini button and add more space for border if yes
if tableContains(self.BlizzardMinimalistButtons, pButton) then
vButtonSize = vButtonSize + 16
MiniOffsetH = -16
MiniOffsetV = -16
elseif tableContains(self.BlizzardMinimalistButtons, self.StackingInfo.PreviousButton) then
-- Correct offset if previous button was mini, but current button is not
if self.StackingInfo.PreviousButton == MinimapCluster.InstanceDifficulty then
-- ...unless it's the dungeon difficulty icon, it's badly formatted
MiniOffsetH = MiniOffsetH - 2
MiniOffsetV = MiniOffsetV - 2
else
MiniOffsetH = MiniOffsetH - 7
MiniOffsetV = MiniOffsetV - 7
end
end
if not self.StackingInfo.PreviousButton then
vSpaceUsed = vButtonSize / 2 -- Corner, so use half the size
else
vSpaceUsed = vButtonSize + self.StackingInfo.CornerInfo.ButtonGap
end
-- See if there's going to be room for the next button
if pNextButton then
local vNextButtonSize = pNextButton:GetHeight()