forked from srhinos/Mappy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMappy.lua
executable file
·2785 lines (2178 loc) · 84.4 KB
/
Mappy.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local _
_, Mappy = ...
local gAddonName = select(1, ...)
gMappy_Settings = nil
Mappy.enableBlips = true
Mappy.StackingInfo = {}
Mappy.BlizzardButtonNames = {
"GameTimeFrame",
"MiniMapMailFrame",
"MiniMapTracking",
"MiniMapWorldMapButton",
"MiniMapBattlefieldFrame",
"MiniMapMeetingStoneFrame",
"MiniMapVoiceChatFrame",
"MinimapZoomIn",
"MinimapZoomOut",
"FeedbackUIButton",
"MiniMapInstanceDifficulty",
"MiniMapLFGFrame",
"GuildInstanceDifficulty",
"GarrisonLandingPageMinimapButton"
}
Mappy.MinimapAttachedFrames = {
"VehicleSeatIndicator",
"WorldStateCaptureBar1",
"WorldStateCaptureBar2",
"WorldStateCaptureBar3",
"WorldStateCaptureBar4",
--"Boss1TargetFrame",
--"Boss2TargetFrame",
--"Boss3TargetFrame",
--"Boss4TargetFrame",
"DurabilityFrame",
"ArenaEnemyFrames",
"ObjectiveTrackerFrame",
}
Mappy.OtherAddonButtonNames = {
"CT_RASets_Button",
}
Mappy.IgnoreFrames = {
Minimap = true,
MinimapBackdrop = true,
MiniMapPing = true,
MinimapToggleButton = true,
MinimapZoneTextButton = true,
CT_RASetsFrame = true,
}
Mappy.StartingCorner = "TOPRIGHT"
Mappy.CornerInfo = {
TOPRIGHT = {
NextCorner = "BOTTOMRIGHT",
AnchorPoint = "TOP",
RelativePoint = "BOTTOM",
ButtonGap = 1,
HorizGap = 0,
VertGap = -1,
HorizInsetDir = -1,
VertInsetDir = -1,
IsVert = true,
},
BOTTOMRIGHT = {
NextCorner = "BOTTOMLEFT",
AnchorPoint = "RIGHT",
RelativePoint = "LEFT",
ButtonGap = 1,
HorizGap = -1,
VertGap = 0,
HorizInsetDir = -1,
VertInsetDir = 1,
IsVert = false,
},
BOTTOMLEFT = {
NextCorner = "TOPLEFT",
AnchorPoint = "BOTTOM",
RelativePoint = "TOP",
ButtonGap = 1,
HorizGap = 0,
VertGap = 1,
HorizInsetDir = 1,
VertInsetDir = 1,
IsVert = true,
},
TOPLEFT = {
NextCorner = "TOPRIGHT",
AnchorPoint = "LEFT",
RelativePoint = "RIGHT",
ButtonGap = 1,
HorizGap = 1,
VertGap = 0,
HorizInsetDir = 1,
VertInsetDir = -1,
IsVert = false,
},
}
Mappy.CornerInfoCCW = {
TOPRIGHT = {
NextCorner = "TOPLEFT",
AnchorPoint = "RIGHT",
RelativePoint = "LEFT",
ButtonGap = 1,
HorizGap = -1,
VertGap = 0,
HorizInsetDir = -1,
VertInsetDir = -1,
IsVert = false,
},
BOTTOMRIGHT = {
NextCorner = "TOPRIGHT",
AnchorPoint = "BOTTOM",
RelativePoint = "TOP",
ButtonGap = 1,
HorizGap = 0,
VertGap = 1,
HorizInsetDir = -1,
VertInsetDir = 1,
IsVert = true,
},
BOTTOMLEFT = {
NextCorner = "BOTTOMRIGHT",
AnchorPoint = "LEFT",
RelativePoint = "RIGHT",
ButtonGap = 1,
HorizGap = 1,
VertGap = 0,
HorizInsetDir = 1,
VertInsetDir = 1,
IsVert = false,
},
TOPLEFT = {
NextCorner = "BOTTOMLEFT",
AnchorPoint = "TOP",
RelativePoint = "BOTTOM",
ButtonGap = 1,
HorizGap = 0,
VertGap = -1,
HorizInsetDir = 1,
VertInsetDir = -1,
IsVert = true,
},
}
Mappy.ProfileNameMap = {
DEFAULT = "Normal",
gather = "Gather",
NONE = "Don't change"
}
Mappy.ObjectIconsNormalSmallPath = "Interface\\MINIMAP\\ObjectIconsAtlas"
Mappy.ObjectIconsHighlightSmallPath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_On"
Mappy.ObjectIconsNormalLargePath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_Large"
Mappy.ObjectIconsHighlightLargePath = "Interface\\Addons\\Mappy\\Textures\\ObjectIconsAtlas_On_Large"
Mappy.ObjectIconsNormalPath = ""
Mappy.ObjectIconsHighlightPath = ""
Mappy.LandmarkArrows = {}
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
-- Hook Minimap_UpdateRotationSetting to enforce the visibility of the 'N' arrow
hooksecurefunc("Minimap_UpdateRotationSetting", function (...) Mappy:Minimap_UpdateRotationSetting(...) 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"
end
function Mappy:HookMinimapClusterGetBottom()
MinimapCluster.Mappy_OriginalGetBottom = MinimapCluster.GetBottom
MinimapCluster.GetBottom = MinimapCluster.GetTop
end
function Mappy:UnhookMinimapClusterGetBottom()
MinimapCluster.GetBottom = MinimapCluster.Mappy_OriginalGetBottom
MinimapCluster.Mappy_OriginalGetBottom = nil
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,
HideZoom = false,
HideWorldMap = false,
HideZoneName = false,
GhostMinimap = false,
AutoArrangeButtons = true,
StackToScreen = false,
RotateMinimap = GetCVar("rotateMinimap") == "1",
HideNorthLabel = false,
HideBorder = false,
HideTracking = false,
HideTimeManagerClock = false,
FlashGatherNodes = false,
UseNormalIcons = false, -- use large icons
DetachManagedFrames = false
},
gather =
{
MinimapSize = 1000,
MinimapAlpha = 0,
MinimapCombatAlpha = 0,
MinimapMovingAlpha = 0,
Point = "CENTER",
RelativePoint = "CENTER",
OffsetX = 0,
OffsetY = 0,
HideTimeOfDay = false,
HideZoom = false,
HideWorldMap = false,
HideZoneName = false,
GhostMinimap = true,
AutoArrangeButtons = true,
StackToScreen = true,
RotateMinimap = true,
HideNorthLabel = false,
HideBorder = true,
HideTracking = false,
HideTimeManagerClock = false,
FlashGatherNodes = true,
UseNormalIcons = false, -- use large icons
DetachManagedFrames = true,
AttachmentPosition = {
Point = "TOPRIGHT",
RelativeTo = UIParent,
RelativePoint = "TOPRIGHT",
OffsetX = -80,
OffsetY = -50
},
LockManagedFrames = true,
},
},
}
end
function Mappy:InitializeMinimap()
-- Locate the addon buttons around the minimap
self:FindMinimapButtons()
self:InitializeDragging()
self:InitializeSquareShape()
-- Get rid of the hide/show button
if MinimapToggleButton then -- Not in patch 3.3
MinimapToggleButton:Hide()
end
MinimapBorderTop:Hide()
-- Add scroll wheel support
Minimap:SetScript("OnMouseWheel", function (pMinimap, pDirection) self:MinimapMouseWheel(pDirection) end)
Minimap:EnableMouseWheel(true)
-- Add the coordinates display
self.CoordString = Minimap:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
self.CoordString:SetHeight(12)
self.CoordString:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", 15, 15)
self.SchedulerLib:ScheduleRepeatingTask(0.2, self.Update, self)
-- Adjust the objective tracker so it lines up nicely with the map
ObjectiveTrackerFrame:SetPoint("TOPRIGHT", MinimapCluster, "BOTTOMRIGHT", 10, -30)
self:InitializeAttachedFrames()
-- 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:RegenEnabled()
-- Schedule the configuration
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
function Mappy:InitializeAttachedFrames()
local attachmenFrame = CreateFrame("Frame", "MappyAttachmentFrame", UIParent, "SecureFrameTemplate", BackdropTemplateMixin and "BackdropTemplate")
self.AttachmentFrame = attachmenFrame
-- Give it an initial position
self.AttachmentFrame:SetPoint("BOTTOMRIGHT", MinimapCluster, "BOTTOMRIGHT", 0, 0)
self.AttachmentFrame:SetWidth(16)
self.AttachmentFrame:SetHeight(8)
self.AttachmentFrame:SetFrameStrata("DIALOG")
self.AttachmentFrame.Texture = self.AttachmentFrame:CreateTexture(nil, "OVERLAY")
self.AttachmentFrame.Texture:SetAllPoints()
self.AttachmentFrame.Texture:SetTexture(1, 1, 0)
self:ActivateAttachmentFrame()
end
function Mappy:DeactivateAttachmentFrame()
self.AttachmentFrame:RegisterForDrag()
self.AttachmentFrame:EnableMouse(false)
self.AttachmentFrame:SetMovable(false)
self.AttachmentFrame:SetScript("OnDragStart", nil)
self.AttachmentFrame:SetScript("OnDragStop", nil)
end
function Mappy:ActivateAttachmentFrame()
self.AttachmentFrame:RegisterForDrag("LeftButton")
self.AttachmentFrame:EnableMouse(true)
self.AttachmentFrame:SetMovable(true)
self.AttachmentFrame:SetScript("OnDragStart", function (frame)
frame:StartMoving()
end)
self.AttachmentFrame:SetScript("OnDragStop", function (frame)
frame:StopMovingOrSizing()
self.CurrentProfile.AttachmentPosition = self:GetFramePosition(frame)
end)
end
function Mappy:RecordSetPointData(frame)
-- Wipe the anchor memory on ClearAllPoints
hooksecurefunc(frame, "ClearAllPoints", function (frame)
frame.Mappy_Anchors = nil
end)
-- Record the anchor points
hooksecurefunc(frame, "SetPoint", function (frame, anchorPoint, relativeTo, relativePoint, offsetX, offsetY)
local anchors = frame.Mappy_Anchors
if not anchors then
anchors = {}
frame.Mappy_Anchors = anchors
end
local anchor = anchors[anchorPoint]
if not anchor then
anchor = {}
anchors[anchorPoint] = anchor
end
assert(relativeTo ~= self.AttachmentFrame)
anchor.relativeTo = relativeTo
anchor.relativePoint = relativePoint
anchor.offsetX = offsetX
anchor.offsetY = offsetY
-- Call the original SetPoint if not in combat lockdown
if not InCombatLockdown() then
local relativeTo = relativeTo
if self.CurrentProfile.DetachManagedFrames and (relativeTo == "MinimapCluster" or relativeTo == MinimapCluster) then
relativeTo = self.AttachmentFrame
end
frame:Mappy_SetPoint(anchorPoint, relativeTo, relativePoint, offsetX, offsetY)
end
end)
end
function Mappy:HookAttachedFrames()
if not self.AttachmentFrame
or not self.CurrentProfile.DetachManagedFrames then
return
end
for _, frameName in pairs(self.MinimapAttachedFrames) do
local frame = _G[frameName]
if frame and frame.SetPoint and not frame.Mappy_DidHook then
frame.Mappy_DidHook = true
-- Save the existing SetPoint function
frame.Mappy_SetPoint = frame.SetPoint
-- Point the original SetPoint at IsVisible instead. IsVisible is a secure function
-- which takes no parameters and affects no state, making it a good choice for this purpose
frame.SetPoint = frame.IsVisible
-- Hook the existing SetPoint so the parameters can be recorded
self:RecordSetPointData(frame)
-- Save the hooked SetPoint for re-use later
frame.Mappy_HookedSetPoint = frame.SetPoint
end
if frame then
-- Capture the existing anchors
local numPoints = frame:GetNumPoints()
frame.Mappy_Anchors = {}
for pointIndex = 1, numPoints do
local point, relativeTo, relativePoint, offsetX, offsetY = frame:GetPoint(pointIndex)
if relativeTo == self.AttachmentFrame then
relativeTo = MinimapCluster
end
frame.Mappy_Anchors[point] = {
relativeTo = relativeTo,
relativePoint = relativePoint,
offsetX = offsetX,
offsetY = offsetY
}
end
-- Use the hooked SetPoint
frame.SetPoint = frame.Mappy_HookedSetPoint
end
end
-- Refresh the anchors
self:ReanchorDetachedFrames()
end
function Mappy:UnhookAttachedFrames()
assert(not self.CurrentProfile.DetachManagedFrames, "unhooking but detach is still set")
-- Refresh the anchors
self:ReanchorDetachedFrames()
-- Restore each frame to use the original SetPoint function
for _, frameName in pairs(self.MinimapAttachedFrames) do
local frame = _G[frameName]
if frame then
frame.SetPoint = frame.Mappy_SetPoint
end
end
end
function Mappy:ReanchorDetachedFrames()
-- Don't allow in combat
if InCombatLockdown() then
Mappy:TestMessage("ReanchorDetachedFrames: In lockdown")
return
end
--
local detachManagedFrames = self.CurrentProfile.DetachManagedFrames
for _, frameName in pairs(self.MinimapAttachedFrames) do
local frame = _G[frameName]
if frame and frame.Mappy_Anchors then
for anchorPoint, anchor in pairs(frame.Mappy_Anchors) do
local relativeTo = anchor.relativeTo
local relativeToName = tostring(relativeTo)
if type(relativeTo) == "table" and relativeTo.GetName then
relativeToName = relativeTo:GetName()
end
assert(relativeTo ~= self.AttachmentFrame)
if detachManagedFrames and (relativeTo == "MinimapCluster" or relativeTo == MinimapCluster) then
relativeTo = self.AttachmentFrame
relativeToName = "AttachmentFrame"
end
-- Call the real SetPoint
frame:Mappy_SetPoint(anchorPoint, relativeTo, anchor.relativePoint, anchor.offsetX, anchor.offsetY)
end
end
end
end
function Mappy:UpdateAttachmentFrame()
if InCombatLockdown() then
self:ErrorMessage("InCombatLockdown during UpdateAttachmentFrame")
return
end
self.AttachmentFrame:ClearAllPoints()
if self.CurrentProfile.DetachManagedFrames then
if self.CurrentProfile.AttachmentPosition then
self:SetFramePosition(self.AttachmentFrame, self.CurrentProfile.AttachmentPosition)
else
self.AttachmentFrame:SetPoint("BOTTOMRIGHT", MinimapCluster, "BOTTOMRIGHT", 0, 0)
end
if self.CurrentProfile.LockManagedFrames then
self.AttachmentFrame:Hide()
else
self.AttachmentFrame:Show()
end
self:HookAttachedFrames()
else
self.AttachmentFrame:Hide()
self:UnhookAttachedFrames()
end
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 = _G[vButtonName]
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
-- self:ShowFrameTree(Minimap)
self:FindAddonButtons(MinimapCluster)
self:FindAddonButtons(MinimapBackdrop)
self:FindAddonButtons(Minimap)
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()
if self.CurrentProfile.AutoArrangeButtons then
self:EnableButtonStacking()
else
self:DisableButtonStacking()
end
if self.CurrentProfile.HideTimeOfDay then
GameTimeFrame:Hide()
else
GameTimeFrame:Show()
end
if self.CurrentProfile.HideZoom then
MinimapZoomIn:Hide()
MinimapZoomOut:Hide()
else
MinimapZoomIn:Show()
MinimapZoomOut:Show()
end
if self.CurrentProfile.HideWorldMap then
MiniMapWorldMapButton:Hide()
else
MiniMapWorldMapButton:Show()
end
if self.CurrentProfile.HideZoneName then
MinimapZoneTextButton:Hide()
else
MinimapZoneTextButton:Show()
end
if self.CurrentProfile.HideTracking then
MiniMapTracking:Hide()
else
MiniMapTracking:Show()
end
if self.CurrentProfile.HideTimeManagerClock then
TimeManagerClockButton:Hide()
else
TimeManagerClockButton:Show()
end
if self.CurrentProfile.FlashGatherNodes then
self:StartGatherFlash()
else
self:StopGatherFlash()
end
if self.CurrentProfile.GhostMinimap then
self:GhostMinimap()
else
self:UnghostMinimap()
end
if self.CurrentProfile.NormalGatherNodes then
self.ObjectIconsNormalPath = self.ObjectIconsNormalSmallPath
self.ObjectIconsHighlightPath = self.ObjectIconsHighlightSmallPath
else
self.ObjectIconsNormalPath = self.ObjectIconsNormalLargePath
self.ObjectIconsHighlightPath = self.ObjectIconsHighlightLargePath
end
if Mappy.enableBlips then
if self.GatherFlashState then
Minimap:SetBlipTexture(self.ObjectIconsHighlightPath)
else
Minimap:SetBlipTexture(self.ObjectIconsNormalPath)
end
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
function Mappy:InitializeDragging()
MinimapCluster:SetMovable(true)
MinimapCluster:SetUserPlaced(true)
Minimap:RegisterForDrag("LeftButton")
Minimap:SetScript("OnDragStart", function() Mappy:StartMovingMinimap() end)
Minimap:SetScript("OnDragStop", function() Mappy:StopMovingMinimap() end)
MinimapCluster.Mappy_SetPoint = MinimapCluster.SetPoint
MinimapCluster.Mappy_ClearAllPoints = MinimapCluster.ClearAllPoints
MinimapCluster.SetPoint = function () end
MinimapCluster.ClearAllPoints = function () end
Minimap.Mappy_SetPoint = Minimap.SetPoint
Minimap.Mappy_ClearAllPoints = Minimap.ClearAllPoints
Minimap.SetPoint = function () end
Minimap.ClearAllPoints = function () end
Minimap:Mappy_ClearAllPoints()
Minimap:Mappy_SetPoint("TOPLEFT", MinimapCluster, "TOPLEFT", 0, 0)
end
function Mappy:AdjustBackgroundStyle()
if not MinimapBackdrop.SetBackdrop then
Mixin(MinimapBackdrop, BackdropTemplateMixin)
end
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
function Mappy:InitializeSquareShape()
Minimap:SetMaskTexture("Interface\\Addons\\Mappy\\Textures\\MinimapMask")
MinimapBorder:SetTexture(nil)
if not MinimapBackdrop.SetBackdrop then
Mixin(MinimapBackdrop, BackdropTemplateMixin)
end
MinimapBackdrop:SetBackdrop({
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:SetBackdropBorderColor(0.75, 0.75, 0.75)
MinimapBackdrop:SetBackdropColor(0.15, 0.15, 0.15, 0.0)
MinimapBackdrop:SetAlpha(1.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
MinimapZoneTextButton:ClearAllPoints()
MinimapZoneTextButton:SetPoint("BOTTOM", Minimap, "TOP", 0, 4)
end
function Mappy:SetCounterClockwise(pCCW)
self.CurrentProfile.CCW = pCCW
self:LoadProfile(self.CurrentProfile)
end
function Mappy:SetDetachManagedFrames(pDetach)
self.CurrentProfile.DetachManagedFrames = pDetach
self:LoadProfile(self.CurrentProfile)
end
function Mappy:SetLockManagedFrames(pLock)
self.CurrentProfile.LockManagedFrames = pLock
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
Minimap:RegisterForDrag()
Minimap:EnableMouse(false)
MinimapCluster:RegisterForDrag()
MinimapCluster:EnableMouse(false)
Minimap:EnableMouseWheel(false)
end
function Mappy:UnghostMinimap()
self.CurrentProfile.GhostMinimap = false
Minimap:RegisterForDrag("LeftButton")
Minimap:EnableMouse(true)
Minimap:SetScript("OnMouseWheel", function (self, direction) Mappy:MinimapMouseWheel(direction) end)
Minimap:EnableMouseWheel(true)
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
self:help()
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 normal"..NORMAL_FONT_COLOR_CODE..": Alias for /mappy default")
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")
end
function Mappy:ghost(pParameter)
self:GhostMinimap()
end
function Mappy:unghost(pParameter)
self:UnghostMinimap()
end
function Mappy:save(pParameter)
self:SaveProfile(pParameter)
end
function Mappy:load(pParameter)
self:LoadProfileName(pParameter)
end
function Mappy:normal(pParameter)
self:LoadDefaultProfile()
end
Mappy.default = Mappy.normal -- Alias the 'normal' command as 'default'
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
self.StackingInfo.StackingParent = Minimap
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