-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinimap.lua
More file actions
859 lines (738 loc) · 28.9 KB
/
Copy pathMinimap.lua
File metadata and controls
859 lines (738 loc) · 28.9 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
-- Minimap Module
local minimapSettings = {
enabled = true,
size = 230,
borderSize = 2,
anchorPoint = "TOPRIGHT",
relativeTo = "UIParent",
relativePoint = "TOPRIGHT",
offsetX = -10,
offsetY = -10,
scale = 1,
autoZoom = true,
mouseWheelZoom = true,
hideBlizzardButtons = true,
hideZoomButtons = true,
hideTrackingButton = true,
hideDifficultyIcon = false,
difficultyIcon = {
anchor = "Top Right",
offsetX = -5,
offsetY = -5,
},
hideMailButton = false,
mailIcon = {
anchor = "Top Left",
offsetX = 3,
offsetY = -3,
},
hideCalendarButton = true,
hideMissionsButton = true,
hideAddonCompartment = true,
zoneText = {
enabled = true,
fontSize = 14,
anchor = "Top",
offsetX = 0,
offsetY = -5,
useCustomColor = false,
color = {1, 0.82, 0, 1},
colorNormal = {1, 0.82, 0, 1},
colorSanctuary = {0.41, 0.8, 0.94, 1},
colorArena = {1.0, 0.1, 0.1, 1},
colorFriendly = {0.1, 1.0, 0.1, 1},
colorHostile = {1.0, 0.1, 0.1, 1},
colorContested = {1.0, 0.7, 0.0, 1},
},
clock = {
enabled = true,
fontSize = 12,
anchor = "Bottom Left",
color = {1, 1, 1, 1},
offsetX = 4,
offsetY = 4,
},
fps = {
enabled = true,
fontSize = 12,
anchor = "Bottom Right",
color = {1, 1, 1, 1},
updateFrequency = 2,
offsetX = -4,
offsetY = 4,
},
}
local Minimap = _G.Minimap
local backdropFrame
local clockDisplay
local clockTimer
local fpsDisplay
local fpsTimer
local zoneTextFrame
local mailFrameRef
local trackingFrameHooked = false
-- Helper function to convert anchor position to SetPoint format
local function GetAnchorPoint(anchor)
local anchorMap = {
["Top"] = "TOP",
["Top Right"] = "TOPRIGHT",
["Top Left"] = "TOPLEFT",
["Right"] = "RIGHT",
["Left"] = "LEFT",
["Center"] = "CENTER",
["Bottom Right"] = "BOTTOMRIGHT",
["Bottom"] = "BOTTOM",
["Bottom Left"] = "BOTTOMLEFT",
}
return anchorMap[anchor] or "BOTTOM"
end
-- Create backdrop frame for minimap border
local function CreateBackdrop()
if backdropFrame then return end
backdropFrame = CreateFrame("Frame", nil, UIParent)
backdropFrame:SetFrameStrata("BACKGROUND")
backdropFrame:SetFrameLevel(1)
backdropFrame:SetFixedFrameStrata(true)
backdropFrame:SetFixedFrameLevel(true)
local backdrop = backdropFrame:CreateTexture(nil, "BACKGROUND")
backdrop:SetPoint("CENTER", Minimap, "CENTER")
backdropFrame.backdrop = backdrop
end
-- Update backdrop size and appearance
local function UpdateBackdrop()
if not backdropFrame or not Minimap then return end
if not minimapSettings or not minimapSettings.enabled then return end
local fullSize = minimapSettings.size + minimapSettings.borderSize
local backdrop = backdropFrame.backdrop
if backdrop then
backdrop:SetSize(fullSize, fullSize)
backdrop:SetColorTexture(0, 0, 0, 1)
-- Create mask for shape
if not backdropFrame.mask then
backdropFrame.mask = backdropFrame:CreateMaskTexture()
backdropFrame.mask:SetAllPoints(backdrop)
backdropFrame.mask:SetParent(backdropFrame)
backdrop:AddMaskTexture(backdropFrame.mask)
end
local maskTexture = "Interface\\BUTTONS\\WHITE8X8"
backdropFrame.mask:SetTexture(maskTexture)
end
end
-- Preserve Layout methods to prevent errors when Blizzard code calls them
local function PreserveLayoutMethods()
-- Preserve Layout method on Minimap frame itself
if Minimap then
if type(Minimap.Layout) ~= "function" then
-- Create a stub Layout method to prevent errors
Minimap.Layout = function() end
end
end
if MinimapCluster then
-- Preserve Layout method if it exists to prevent errors when Blizzard code calls it
if type(MinimapCluster.Layout) ~= "function" then
-- Create a stub Layout method to prevent errors
MinimapCluster.Layout = function() end
end
-- Also ensure IndicatorFrame has a Layout method if it exists
if MinimapCluster.IndicatorFrame then
if type(MinimapCluster.IndicatorFrame.Layout) ~= "function" then
MinimapCluster.IndicatorFrame.Layout = function() end
end
end
end
end
-- Hide Blizzard minimap elements
local function HideBlizzardElements()
if MinimapBackdrop then
MinimapBackdrop:SetParent(UIParent)
MinimapBackdrop:Hide()
hooksecurefunc(MinimapBackdrop, "SetParent", function(self)
if self:GetParent() ~= UIParent then
self:SetParent(UIParent)
self:Hide()
end
end)
end
if MinimapBorder then
MinimapBorder:SetParent(UIParent)
MinimapBorder:Hide()
hooksecurefunc(MinimapBorder, "SetParent", function(self)
if self:GetParent() ~= UIParent then
self:SetParent(UIParent)
self:Hide()
end
end)
end
if MinimapCluster then
-- Extract mail frame reference before hiding MinimapCluster
if MinimapCluster.IndicatorFrame and MinimapCluster.IndicatorFrame.MailFrame then
mailFrameRef = MinimapCluster.IndicatorFrame.MailFrame
elseif MiniMapMailFrame then
mailFrameRef = MiniMapMailFrame
elseif MinimapCluster.MailFrame then
mailFrameRef = MinimapCluster.MailFrame
end
-- Preserve Layout methods before hiding to prevent errors
PreserveLayoutMethods()
MinimapCluster:SetParent(UIParent)
MinimapCluster:Hide()
hooksecurefunc(MinimapCluster, "SetParent", function(self)
if self:GetParent() ~= UIParent then
self:SetParent(UIParent)
self:Hide()
end
-- Re-preserve Layout methods after reparenting
PreserveLayoutMethods()
end)
hooksecurefunc(MinimapCluster, "Show", function(self)
self:Hide()
end)
end
if MinimapNorthTag then
MinimapNorthTag:SetParent(UIParent)
MinimapNorthTag:Hide()
end
if MinimapBorderTop then
MinimapBorderTop:SetParent(UIParent)
MinimapBorderTop:Hide()
end
end
-- Setup minimap shape
local function ApplyMinimapShape()
if not minimapSettings or not minimapSettings.enabled then return end
local maskTexture = "Interface\\BUTTONS\\WHITE8X8"
Minimap:SetMaskTexture(maskTexture)
if HybridMinimap then
HybridMinimap.MapCanvas:SetUseMaskTexture(false)
if HybridMinimap.CircleMask then
HybridMinimap.CircleMask:SetTexture(maskTexture)
end
HybridMinimap.MapCanvas:SetUseMaskTexture(true)
end
end
-- Hide blob rings (archaeology/quest rings)
local function HideBlobRings()
Minimap:SetArchBlobRingScalar(0)
Minimap:SetArchBlobRingAlpha(0)
Minimap:SetQuestBlobRingScalar(0)
Minimap:SetQuestBlobRingAlpha(0)
end
-- Create clock display
local function CreateClock()
if not minimapSettings or not minimapSettings.enabled or not minimapSettings.clock or not minimapSettings.clock.enabled then
if clockDisplay then
clockDisplay:SetParent(UIParent)
clockDisplay:Hide()
end
return
end
if not clockDisplay then
clockDisplay = Minimap:CreateFontString(nil, "OVERLAY")
clockDisplay:SetJustifyH("CENTER")
end
-- Update font size
clockDisplay:SetFont("Fonts\\FRIZQT__.TTF", minimapSettings.clock.fontSize or 12, "OUTLINE")
-- Set color
local color = minimapSettings.clock.color or {1, 1, 1, 1}
clockDisplay:SetTextColor(color[1], color[2], color[3], color[4] or 1)
clockDisplay:SetParent(Minimap)
clockDisplay:ClearAllPoints()
local anchor = GetAnchorPoint(minimapSettings.clock.anchor or "Bottom")
local relativePoint = GetAnchorPoint(minimapSettings.clock.anchor or "Bottom")
clockDisplay:SetPoint(anchor, backdropFrame and backdropFrame.backdrop or Minimap, relativePoint, minimapSettings.clock.offsetX or 0, minimapSettings.clock.offsetY or -4)
clockDisplay:Show()
-- Cancel existing timer if any
if clockTimer then
clockTimer:Cancel()
clockTimer = nil
end
-- Update clock
local function UpdateClock()
if not clockDisplay or not clockDisplay:IsShown() then return end
local hour, minute
if GetCVarBool("timeMgrUseLocalTime") then
hour, minute = tonumber(date("%H")), tonumber(date("%M"))
else
hour, minute = GetGameTime()
end
if GetCVarBool("timeMgrUseMilitaryTime") then
clockDisplay:SetFormattedText(TIMEMANAGER_TICKER_24HOUR, hour, minute)
else
if hour == 0 then
hour = 12
elseif hour > 12 then
hour = hour - 12
end
clockDisplay:SetFormattedText(TIMEMANAGER_TICKER_12HOUR, hour, minute)
end
-- Update every minute (60 seconds)
clockTimer = C_Timer.NewTimer(60, UpdateClock)
end
UpdateClock()
end
-- Create FPS display
local function CreateFPS()
if not minimapSettings or not minimapSettings.enabled or not minimapSettings.fps or not minimapSettings.fps.enabled then
if fpsDisplay then
fpsDisplay:SetParent(UIParent)
fpsDisplay:Hide()
end
return
end
if not fpsDisplay then
fpsDisplay = Minimap:CreateFontString(nil, "OVERLAY")
fpsDisplay:SetJustifyH("CENTER")
end
-- Update font size
fpsDisplay:SetFont("Fonts\\FRIZQT__.TTF", minimapSettings.fps.fontSize or 12, "OUTLINE")
-- Set color
local color = minimapSettings.fps.color or {1, 1, 1, 1}
fpsDisplay:SetTextColor(color[1], color[2], color[3], color[4] or 1)
fpsDisplay:SetParent(Minimap)
fpsDisplay:ClearAllPoints()
local anchor = GetAnchorPoint(minimapSettings.fps.anchor or "Bottom")
local relativePoint = GetAnchorPoint(minimapSettings.fps.anchor or "Bottom")
fpsDisplay:SetPoint(anchor, backdropFrame and backdropFrame.backdrop or Minimap, relativePoint, minimapSettings.fps.offsetX or 0, minimapSettings.fps.offsetY or -20)
fpsDisplay:Show()
-- Cancel existing timer if any
if fpsTimer then
fpsTimer:Cancel()
fpsTimer = nil
end
-- Update FPS
local function UpdateFPS()
if not fpsDisplay or not fpsDisplay:IsShown() then return end
local fps = math.floor(GetFramerate())
fpsDisplay:SetText(string.format("%d FPS", fps))
-- Update at configured frequency
local updateFrequency = minimapSettings.fps.updateFrequency or 2.0
fpsTimer = C_Timer.NewTimer(updateFrequency, UpdateFPS)
end
UpdateFPS()
end
-- Create custom zone text with PVP colors
local function CreateZoneText()
if not minimapSettings or not minimapSettings.enabled or not minimapSettings.zoneText or not minimapSettings.zoneText.enabled then
if MinimapZoneTextButton then
MinimapZoneTextButton:Hide()
end
if zoneTextFrame then
zoneTextFrame:Hide()
end
return
end
-- Hide default zone text button
if MinimapZoneTextButton then
MinimapZoneTextButton:Hide()
end
-- Update zone text function (defined outside if block so it's always accessible)
local function UpdateZoneText()
if not zoneTextFrame or not zoneTextFrame.font then return end
local text = GetMinimapZoneText()
zoneTextFrame.font:SetText(text)
local color
if minimapSettings.zoneText.useCustomColor and minimapSettings.zoneText.color then
color = minimapSettings.zoneText.color
else
local pvpType = C_PvP and C_PvP.GetZonePVPInfo() or GetZonePVPInfo()
if pvpType == "sanctuary" then
color = minimapSettings.zoneText.colorSanctuary or {0.41, 0.8, 0.94, 1}
elseif pvpType == "arena" then
color = minimapSettings.zoneText.colorArena or {1, 0.1, 0.1, 1}
elseif pvpType == "friendly" then
color = minimapSettings.zoneText.colorFriendly or {0.1, 1, 0.1, 1}
elseif pvpType == "hostile" then
color = minimapSettings.zoneText.colorHostile or {1, 0.1, 0.1, 1}
elseif pvpType == "contested" then
color = minimapSettings.zoneText.colorContested or {1, 0.7, 0, 1}
else
color = minimapSettings.zoneText.colorNormal or {1, 0.82, 0, 1}
end
end
zoneTextFrame.font:SetTextColor(unpack(color))
end
-- Create our own zone text frame
if not zoneTextFrame then
zoneTextFrame = CreateFrame("Button", nil, Minimap)
local zoneTextFont = zoneTextFrame:CreateFontString(nil, "OVERLAY")
zoneTextFont:SetAllPoints(zoneTextFrame)
zoneTextFont:SetJustifyH("CENTER")
zoneTextFrame.font = zoneTextFont
zoneTextFrame:EnableMouse(true)
zoneTextFrame:RegisterForClicks("AnyUp")
-- Tooltip on enter
zoneTextFrame:SetScript("OnEnter", function(self)
local tooltip = GameTooltip
tooltip:SetOwner(self, "ANCHOR_LEFT")
local pvpType, _, factionName = C_PvP and C_PvP.GetZonePVPInfo() or GetZonePVPInfo()
local zoneName = GetZoneText()
local subzoneName = GetSubZoneText()
if subzoneName == zoneName then
subzoneName = ""
end
tooltip:AddLine(zoneName, 1, 1, 1)
if pvpType == "sanctuary" then
local c = minimapSettings.zoneText.colorSanctuary or {0.41, 0.8, 0.94, 1}
if subzoneName ~= "" then tooltip:AddLine(subzoneName, unpack(c)) end
tooltip:AddLine(SANCTUARY_TERRITORY, unpack(c))
elseif pvpType == "arena" then
local c = minimapSettings.zoneText.colorArena or {1, 0.1, 0.1, 1}
if subzoneName ~= "" then tooltip:AddLine(subzoneName, unpack(c)) end
tooltip:AddLine(FREE_FOR_ALL_TERRITORY, unpack(c))
elseif pvpType == "friendly" then
local c = minimapSettings.zoneText.colorFriendly or {0.1, 1, 0.1, 1}
if subzoneName ~= "" then tooltip:AddLine(subzoneName, unpack(c)) end
if factionName and factionName ~= "" then
tooltip:AddLine((FACTION_CONTROLLED_TERRITORY):format(factionName), unpack(c))
end
elseif pvpType == "hostile" then
local c = minimapSettings.zoneText.colorHostile or {1, 0.1, 0.1, 1}
if subzoneName ~= "" then tooltip:AddLine(subzoneName, unpack(c)) end
if factionName and factionName ~= "" then
tooltip:AddLine((FACTION_CONTROLLED_TERRITORY):format(factionName), unpack(c))
end
elseif pvpType == "contested" then
local c = minimapSettings.zoneText.colorContested or {1, 0.7, 0, 1}
if subzoneName ~= "" then tooltip:AddLine(subzoneName, unpack(c)) end
tooltip:AddLine(CONTESTED_TERRITORY, unpack(c))
else
local c = minimapSettings.zoneText.colorNormal or {1, 0.82, 0, 1}
if subzoneName ~= "" then tooltip:AddLine(subzoneName, unpack(c)) end
end
tooltip:Show()
end)
zoneTextFrame:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
zoneTextFrame:RegisterEvent("ZONE_CHANGED")
zoneTextFrame:RegisterEvent("ZONE_CHANGED_INDOORS")
zoneTextFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
zoneTextFrame:SetScript("OnEvent", UpdateZoneText)
end
-- Update font size and frame height
local fontSize = minimapSettings.zoneText.fontSize or 14
zoneTextFrame:SetHeight(fontSize + 1)
if zoneTextFrame.font then
zoneTextFrame.font:SetFont("Fonts\\FRIZQT__.TTF", fontSize, "OUTLINE")
end
zoneTextFrame:Show()
zoneTextFrame:ClearAllPoints()
local minimapWidth = Minimap:GetWidth()
zoneTextFrame:SetWidth(minimapWidth and minimapWidth > 0 and (minimapWidth - 10) or 200)
-- Position using anchor
local anchor = GetAnchorPoint(minimapSettings.zoneText.anchor or "Top")
local relativePoint = GetAnchorPoint(minimapSettings.zoneText.anchor or "Top")
zoneTextFrame:SetPoint(anchor, Minimap, relativePoint, minimapSettings.zoneText.offsetX or 0, minimapSettings.zoneText.offsetY or -5)
-- Update zone text color immediately
UpdateZoneText()
end
-- Manage Blizzard buttons
local function ManageBlizzardButtons()
if not minimapSettings or not minimapSettings.enabled then return end
-- Zoom buttons
if Minimap.ZoomIn and Minimap.ZoomOut then
if minimapSettings.hideZoomButtons then
Minimap.ZoomIn:Hide()
Minimap.ZoomOut:Hide()
else
Minimap.ZoomIn:Show()
Minimap.ZoomOut:Show()
-- Prevent auto-hide
local fakeMouseOver = function() return true end
Minimap.ZoomIn.IsMouseOver = fakeMouseOver
Minimap.ZoomOut.IsMouseOver = fakeMouseOver
end
end
-- Tracking button
local trackingFrame = MinimapCluster and MinimapCluster.Tracking
if trackingFrame then
trackingFrame:SetParent(Minimap)
-- Hook Show only once to maintain alpha control
if not trackingFrameHooked then
hooksecurefunc(trackingFrame, "Show", function(self)
if minimapSettings and minimapSettings.hideTrackingButton then
self:SetAlpha(0)
else
self:SetAlpha(1)
end
end)
trackingFrameHooked = true
end
-- Always keep frame shown, control visibility with alpha
-- Only call Show() if it's not already shown to avoid triggering hooks unnecessarily
if not trackingFrame:IsShown() then
trackingFrame:Show()
end
-- Set alpha based on setting
if minimapSettings.hideTrackingButton then
trackingFrame:SetAlpha(0)
else
trackingFrame:SetAlpha(1)
end
end
local mailFrame = mailFrameRef
if not mailFrame then
if MinimapCluster and MinimapCluster.IndicatorFrame and MinimapCluster.IndicatorFrame.MailFrame then
mailFrame = MinimapCluster.IndicatorFrame.MailFrame
elseif _G.MiniMapMailFrame then
mailFrame = _G.MiniMapMailFrame
end
end
-- Update stored reference if we found it
if mailFrame and not mailFrameRef then
mailFrameRef = mailFrame
end
if mailFrame then
if minimapSettings.hideMailButton then
mailFrame:SetParent(UIParent)
mailFrame:Hide()
hooksecurefunc(mailFrame, "Show", function(self)
self:Hide()
end)
else
mailFrame:SetParent(Minimap)
-- Ensure it's above the minimap
mailFrame:SetFrameStrata("MEDIUM")
mailFrame:SetFrameLevel(Minimap:GetFrameLevel() + 10)
-- Ensure alpha is visible
mailFrame:SetAlpha(1)
-- Ensure child elements are visible (like MailIcon)
if mailFrame.MailIcon then
mailFrame.MailIcon:SetAlpha(1)
mailFrame.MailIcon:Show()
end
-- Position the mail icon using configured settings
mailFrame:ClearAllPoints()
local mailAnchor = GetAnchorPoint((minimapSettings.mailIcon and minimapSettings.mailIcon.anchor) or "Top Left")
local offsetX = (minimapSettings.mailIcon and minimapSettings.mailIcon.offsetX) or 3
local offsetY = (minimapSettings.mailIcon and minimapSettings.mailIcon.offsetY) or -3
mailFrame:SetPoint(mailAnchor, Minimap, mailAnchor, offsetX, offsetY)
-- Let the mail frame manage its own visibility based on mail status
mailFrame:Show()
end
end
-- Calendar button
if GameTimeFrame then
GameTimeFrame:SetParent(Minimap)
if minimapSettings.hideCalendarButton then
GameTimeFrame:Hide()
hooksecurefunc(GameTimeFrame, "Show", function(self)
self:Hide()
end)
else
GameTimeFrame:Show()
end
end
-- Difficulty icon - reparent to Minimap since MinimapCluster is hidden
local difficultyFrame = MinimapCluster and MinimapCluster.InstanceDifficulty
if difficultyFrame then
difficultyFrame:SetParent(Minimap)
if minimapSettings.hideDifficultyIcon then
difficultyFrame:Hide()
else
difficultyFrame:Show()
-- Position the difficulty icon
difficultyFrame:ClearAllPoints()
local iconAnchor = GetAnchorPoint((minimapSettings.difficultyIcon and minimapSettings.difficultyIcon.anchor) or "Top Right")
local offsetX = (minimapSettings.difficultyIcon and minimapSettings.difficultyIcon.offsetX) or -5
local offsetY = (minimapSettings.difficultyIcon and minimapSettings.difficultyIcon.offsetY) or -5
difficultyFrame:SetPoint(iconAnchor, Minimap, iconAnchor, offsetX, offsetY)
end
end
-- Missions/garrison buttons - handle both expansion and garrison buttons
if ExpansionLandingPageMinimapButton then
-- Keep it visible by default; only hide when the user explicitly requests it
ExpansionLandingPageMinimapButton:SetParent(Minimap)
ExpansionLandingPageMinimapButton:SetFrameStrata("MEDIUM")
ExpansionLandingPageMinimapButton:SetFrameLevel(Minimap:GetFrameLevel() + 10)
if minimapSettings.hideMissionsButton then
ExpansionLandingPageMinimapButton:Hide()
else
ExpansionLandingPageMinimapButton:Show()
local offsetX = (minimapSettings.missionsButton and minimapSettings.missionsButton.offsetX) or 0
local offsetY = (minimapSettings.missionsButton and minimapSettings.missionsButton.offsetY) or 0
ExpansionLandingPageMinimapButton:ClearAllPoints()
ExpansionLandingPageMinimapButton:SetPoint("TOPLEFT", Minimap, "TOPLEFT", offsetX, offsetY)
end
end
-- Handle GarrisonLandingPageMinimapButton if it exists
if GarrisonLandingPageMinimapButton then
if minimapSettings.hideMissionsButton then
GarrisonLandingPageMinimapButton:Hide()
else
GarrisonLandingPageMinimapButton:Show()
end
end
-- Addon compartment
if AddonCompartmentFrame then
AddonCompartmentFrame:SetParent(Minimap)
if minimapSettings.hideAddonCompartment then
AddonCompartmentFrame:Hide()
hooksecurefunc(AddonCompartmentFrame, "Show", function(self)
self:Hide()
end)
else
AddonCompartmentFrame:Show()
end
end
end
-- Setup minimap position (fixed)
local function SetupPosition()
if not minimapSettings or not minimapSettings.enabled then return end
Minimap:ClearAllPoints()
Minimap:SetPoint(
minimapSettings.anchorPoint,
_G[minimapSettings.relativeTo],
minimapSettings.relativePoint,
minimapSettings.offsetX,
minimapSettings.offsetY
)
-- Ensure minimap is not movable
Minimap:SetMovable(false)
Minimap:RegisterForDrag()
end
-- Setup mouse wheel zoom
local function SetupMouseWheelZoom()
if not minimapSettings or not minimapSettings.enabled or not minimapSettings.mouseWheelZoom then return end
Minimap:EnableMouseWheel(true)
Minimap:SetScript("OnMouseWheel", function(_, delta)
if delta > 0 then
if Minimap.ZoomIn then
Minimap.ZoomIn:Click()
end
elseif delta < 0 then
if Minimap.ZoomOut then
Minimap.ZoomOut:Click()
end
end
end)
end
-- Setup minimap click handlers for tracker and calendar
local function SetupMinimapClicks()
if not minimapSettings or not minimapSettings.enabled then return end
-- Get the original OnMouseUp script if it exists
local originalOnMouseUp = Minimap:GetScript("OnMouseUp")
Minimap:SetScript("OnMouseUp", function(self, button)
-- Right-click opens tracker menu
if button == "RightButton" then
local trackingButton = MinimapCluster and MinimapCluster.Tracking and MinimapCluster.Tracking.Button
if trackingButton and trackingButton.OpenMenu then
trackingButton:OpenMenu()
end
return
end
-- Middle-click opens calendar
if button == "MiddleButton" then
if GameTimeFrame then
GameTimeFrame:Click()
end
return
end
-- Call original handler for other buttons (like LeftButton)
if originalOnMouseUp then
originalOnMouseUp(self, button)
end
end)
end
-- Setup auto zoom
local function SetupAutoZoom()
if not minimapSettings or not minimapSettings.enabled or not minimapSettings.autoZoom then return end
local zoomTimer
local function AutoZoomOut()
if zoomTimer then
zoomTimer:Cancel()
end
zoomTimer = C_Timer.NewTimer(10, function()
Minimap:SetZoom(0)
if Minimap.ZoomIn then Minimap.ZoomIn:Enable() end
if Minimap.ZoomOut then Minimap.ZoomOut:Disable() end
end)
end
if Minimap.ZoomIn then
Minimap.ZoomIn:HookScript("OnClick", AutoZoomOut)
end
if Minimap.ZoomOut then
Minimap.ZoomOut:HookScript("OnClick", AutoZoomOut)
end
end
-- Set minimap shape function for other addons
local function SetMinimapShapeFunction()
if not minimapSettings or not minimapSettings.enabled then return end
if GetMinimapShape then
GetMinimapShape = function()
return "SQUARE"
end
end
end
-- Initialize minimap
local function InitializeMinimap()
if not Minimap then return end
-- Preserve Layout methods early to prevent errors
PreserveLayoutMethods()
if not minimapSettings or not minimapSettings.enabled then return end
-- Setup minimap frame
Minimap:SetFixedFrameStrata(true)
Minimap:SetFixedFrameLevel(true)
Minimap:SetParent(UIParent)
if Minimap:GetFrameStrata() ~= "LOW" then
Minimap:SetFrameStrata("LOW")
end
if Minimap:GetFrameLevel() ~= 2 then
Minimap:SetFrameLevel(2)
end
Minimap:SetSize(minimapSettings.size or 200, minimapSettings.size or 200)
if minimapSettings.scale and minimapSettings.scale ~= 1 then
Minimap:SetScale(minimapSettings.scale)
end
-- Create backdrop
CreateBackdrop()
-- Hide blizzard elements
HideBlizzardElements()
-- Apply shape
ApplyMinimapShape()
-- Hide blob rings
HideBlobRings()
-- Setup position
SetupPosition()
-- Setup mouse wheel zoom
SetupMouseWheelZoom()
-- Setup auto zoom
SetupAutoZoom()
-- Setup minimap clicks for tracker and calendar
SetupMinimapClicks()
-- Set minimap shape function
SetMinimapShapeFunction()
-- Update backdrop
C_Timer.After(0.1, function()
UpdateBackdrop()
CreateZoneText()
CreateClock()
CreateFPS()
ManageBlizzardButtons()
end)
-- Hook size changes
hooksecurefunc(Minimap, "SetSize", function()
UpdateBackdrop()
if zoneTextFrame then
local minimapWidth = Minimap:GetWidth()
zoneTextFrame:SetWidth(minimapWidth and minimapWidth > 0 and (minimapWidth - 10) or 200)
end
end)
end
-- Handle HybridMinimap when it loads
local minimapEventFrame = CreateFrame("Frame")
minimapEventFrame:RegisterEvent("ADDON_LOADED")
minimapEventFrame:RegisterEvent("PLAYER_LOGIN")
minimapEventFrame:RegisterEvent("UPDATE_PENDING_MAIL")
minimapEventFrame:SetScript("OnEvent", function(self, event, addonName)
if event == "ADDON_LOADED" and addonName == "Blizzard_HybridMinimap" then
ApplyMinimapShape()
InitializeMinimap()
elseif event == "PLAYER_LOGIN" then
InitializeMinimap()
self:UnregisterEvent("PLAYER_LOGIN")
elseif event == "UPDATE_PENDING_MAIL" then
-- Ensure Layout methods are preserved when mail updates occur
PreserveLayoutMethods()
end
end)