-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPointer.lua
More file actions
1461 lines (1199 loc) · 40.2 KB
/
Pointer.lua
File metadata and controls
1461 lines (1199 loc) · 40.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
assert (ZygorGuidesViewer,"Zygor Guides Viewer not loaded properly!")
local ZGV=ZygorGuidesViewer
local Pointer = {}
ZGV.Pointer = Pointer
local _G,assert,table,string,tinsert,tonumber,tostring,type,ipairs,pairs,setmetatable,math,wipe = _G,assert,table,string,tinsert,tonumber,tostring,type,ipairs,pairs,setmetatable,math,wipe
local L=ZGV.L
Pointer.Debug = ZGV.Debug
Pointer.waypoints = {}
local scarlet_cont = 5
local scarlet_zone = 1
local Astrolabe = DongleStub("Astrolabe-0.4-Zygor")
local unusedMarkers = {}
local last_distance=0
local speed=0
local last_speed=0
local initialdist=nil
local lastminimapdist=99999
local minimapcontrol_suspension=0
local minimap_lastset = 0
local cuedinged=nil
local profile={}
function Pointer:Startup()
self:CreateArrowFrame()
profile = ZGV.db.profile
profile.arrowsmooth = true
--[[
self.EventFrame = CreateFrame("FRAME")
self.EventFrame:Show()
self.EventFrame:SetScript("OnEvent",PointerEventFrame_OnEvent)
self.EventFrame:RegisterEvent("WORLD_MAP_UPDATE")
--]]
local overlay = CreateFrame("FRAME","ZygorGuidesViewerPointerOverlay",WorldMapButton)
self.OverlayFrame = overlay
overlay:SetAllPoints(true)
overlay:SetWidth(1002)
overlay:SetHeight(668)
--overlay:SetFrameStrata("DIALOG")
--overlay:SetFrameLevel(WorldMapButton:GetFrameLevel()+1)
overlay:SetScript("OnEvent",self.Overlay_OnEvent)
overlay:RegisterEvent("PLAYER_ENTERING_WORLD")
overlay:RegisterEvent("PLAYER_ALIVE")
overlay:RegisterEvent("PLAYER_UNGHOST")
overlay:RegisterEvent("ZONE_CHANGED_NEW_AREA")
overlay:RegisterEvent("WORLD_MAP_UPDATE")
--overlay:EnableMouse(true)
--overlay:SetScript("OnMouseUp",self.Overlay_OnClick)
overlay:SetScript("OnUpdate",self.Overlay_OnUpdate)
--hooksecurefunc("WorldMapButton_OnClick",ZGV.Pointer.hook_WorldMapButton_OnClick)
local texture = overlay:CreateTexture("ZygorGuidesViewerPointerOverlayTexture","OVERLAY")
texture:SetAllPoints(true)
--texture:SetTexture(ZGV.DIR .. "\\Maps\\deadmines")
texture:SetTexCoord(0,0.975,0,0.65)
texture:Hide()
overlay.texture = texture
local youarehere = overlay:CreateTexture("ZygorGuidesViewerPointerOverlayYouarehere","OVERLAY")
youarehere:SetTexture(ZGV.DIR .. "\\Skin\\minimaparrow-green-dot")
overlay.youarehere = youarehere
--hooksecurefunc("WorldMapFrame_OnShow",ZGV.Pointer.hook_WorldMapFrame_OnShow)
--WorldMapFrame.PlayerCoord = WorldMapFrame:CreateFontString(nil,"ARTWORK","GameFontHighlightSmall")
--WorldMapFrame.CursorCoord = WorldMapFrame:CreateFontString(nil,"ARTWORK","GameFontHighlightSmall")
--WorldMapFrame.PlayerCoord:SetText("Player")
--WorldMapFrame.CursorCoord:SetText("Cursor")
--ZGV.ScheduleRepeatingTimer(self,"FixMapLevel", 1.0)
Pointer.ready = true
self:HandleCamRegistration()
end
local is_moving=false
function Pointer:HandleCamRegistration()
local LibCamera = LibStub.libs["LibCamera-1.0"]
if not LibCamera then profile.arrowcam = false return end
if profile.arrowcam then
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
if not CallbackHandler then profile.arrowcam = false end
if not self.callbacks then
self.callbacks = CallbackHandler:New(self)
end
LibCamera.RegisterCallback(self,"LibCamera_Update")
--[[
hooksecurefunc("TurnOrActionStart",function() is_moving=true print("toastart") end)
hooksecurefunc("TurnOrActionStop",function() is_moving=false print("toastop") end)
hooksecurefunc("CameraOrSelectOrMoveStart",function() is_moving=true print("cosomstart") end)
hooksecurefunc("CameraOrSelectOrMoveStop",function() is_moving=false print("cosomstop") end)
hooksecurefunc("MoveForwardStart",function() is_moving=true print("mfstart") end)
hooksecurefunc("MoveForwardStop",function() is_moving=false print("mfstop") end)
hooksecurefunc("MoveAndSteerStart",function() is_moving=true print("masstart") end)
hooksecurefunc("MoveAndSteerStop",function() is_moving=false print("masstop") end)
--]]
else
LibCamera.UnregisterCallback(self,"LibCamera_Update")
end
end
local cam_yaw=0
function Pointer:LibCamera_Update(target,p,y,d)
cam_yaw=y
--print (p.." "..y.." "..d)
end
--[[
local numlevels=0
local oldlevel=1
function Pointer.FixMapLevel()
local x,y = GetPlayerMapPosition("player")
if x<=0 and y<=0 then
-- perhaps wrong floor indeed.
numlevels = GetNumDungeonMapLevels()
if numlevels>1 then
oldlevel = GetCurrentMapDungeonLevel()
for lev=1,numlevels do
if lev~=oldlevel and GetPlayerMapPosition("player")>0 then
GetCurrentMapDungeonLevel()
end
end
end
--]]
--[[
data elements:
title - guess
type - 'way' 'poi' 'manual' 'corpse'
icon - texture path
onminimap - 'always' 'zone'
overworld - show on world map
persistent - don't hide when arrived at
--]]
function Pointer:SetWaypoint (c,z,x,y,data)
if not data then data={} end
if not data.title then data.title="Waypoint" end
if not data.type then data.type="way" end
if not data.icon then data.icon=ZGV.DIR .. "\\Skin\\minimaparrow-green-dot" end
if not data.edgeicon then data.edgeicon=ZGV.DIR .. "\\Skin\\minimaparrow-green-edge" end
local waypoint = self:CreateMapMarker (c,z,x,y,data)
--ZGV:Debug("Adding waypoint type "..data.type.." in "..c..","..z..","..x..","..y)
if not waypoint then return end
waypoint.t=data.title
waypoint.type=data.type
waypoint.minimapFrame.icon:SetTexture(data.icon)
waypoint.worldmapFrame.icon:SetTexture(data.icon)
waypoint.minimapFrame.arrow:SetTexture(data.edgeicon)
Pointer.MinimapButton_OnUpdate(waypoint.minimapFrame,1000)
if waypoint.type~="poi" then
self:ShowArrow(waypoint)
end
self.waypoints[waypoint]=1
return waypoint
end
function Pointer:CreateMapMarker (c,z,x,y,data)
--ZGV:Debug("Internal CreateMapMarker: "..tostring(c).." "..tostring(z).." "..tostring(x).." "..tostring(y).." "..tostring(title))
if not c and type(z)=="string" then
c,z = ZGV:GetMapZoneNumbers(z)
end
if not c and not z then
c,z = GetCurrentMapContinentAndZone()
end
--ZGV:Debug("Internal CreateMapMarker nums: "..tostring(c).." "..tostring(z).." "..tostring(x).." "..tostring(y).." "..tostring(title))
--[[
if c==-1 and z==0 and GetMapInfo()=="ScarletEnclave" then
c,z = scarlet_cont,scarlet_zone
end
--]]
if not c or not z or not x or x<0 or not y or y<0 then
--ZGV:Print("Invalid zone, or what?")
return
end
if x>1 or y>1 then
x=x/100
y=y/100
end
local waypoint = self:GetMarker()
table.zygor_join(waypoint,{ c=c,z=z,x=x,y=y })
table.zygor_join(waypoint,data)
-- TODO: add callbacks for distance detection
waypoint.minimapFrame.waypoint = waypoint
waypoint.worldmapFrame.waypoint = waypoint
waypoint.minimapFrame:EnableMouse(true)
waypoint.worldmapFrame:EnableMouse(true)
local lc,lz = GetCurrentMapContinentAndZone()
waypoint:UpdateWorldMapIcon(lc,lz)
waypoint:UpdateMiniMapIcon(lc,lz)
--if lc==c and lz==z then Astrolabe:PlaceIconOnMinimap(waypoint.minimapFrame, c, z, x, y) end
return waypoint
end
function Pointer:ClearWaypoints (waytype)
local n=0
for way,w in pairs(self.waypoints) do
if not waytype or way.type==waytype then
n=n+1
self:RemoveWaypoint(way)
end
end
return n
end
function Pointer:RemoveWaypoint(waypoint)
Astrolabe:RemoveIconFromMinimap(waypoint.minimapFrame)
waypoint.minimapFrame:Hide()
waypoint.minimapFrame.waypoint=nil
waypoint.worldmapFrame:Hide()
waypoint.worldmapFrame.waypoint=nil
if self.ArrowFrame.waypoint==waypoint then self:HideArrow() end
table.insert(unusedMarkers, waypoint)
self.waypoints[waypoint]=nil
end
function Pointer:HideArrow()
self.ArrowFrame.waypoint = nil
self:ResetMinimapZoom() -- to perhaps reset the zoom
--self.ArrowFrame:Hide()
end
function Pointer:ShowArrow(waypoint)
if waypoint.type~="manual" then self:ClearWaypoints("manual") end
Astrolabe:PlaceIconOnMinimap(waypoint.minimapFrame, waypoint.c, waypoint.z, waypoint.x, waypoint.y) -- if it's not already there, place it
self.ArrowFrame.waypoint = waypoint
last_distance=0
speed=0
lastbeeptime=GetTime()+3
cuedinged=nil
initialdist = nil
lastminimapdist=99999
--self.ArrowFrame.temporarilyhidden = true
--self.ArrowFrame:Show()
end
--[[
function Pointer:GetWaypointBearings(way)
--local dx,dy =
if type(way)==number then way=self.waypoints[way] end
end
--]]
local markerproto = {}
local markermeta = {__index=markerproto}
local nummarkers=0
function Pointer:GetMarker()
local marker = table.remove(unusedMarkers)
if marker then return marker end
-- create a new marker
marker = {visible=true}
setmetatable(marker,markermeta)
nummarkers=nummarkers+1
marker.minimapFrame = CreateFrame("Button", "ZGVMarker"..nummarkers.."Mini", Minimap, "ZygorGuidesViewerPointerMinimapMarker")
marker.worldmapFrame = CreateFrame("Button", "ZGVMarker"..nummarkers.."World", self.OverlayFrame, "ZygorGuidesViewerPointerWorldMapMarker")
return marker
end
function markerproto:Hide(c,z)
self.minimapFrame:Hide()
self.worldmapFrame:Hide()
self.visible = false
end
function markerproto:Show()
self.minimapFrame:Show()
self.worldmapFrame:Show()
self.visible = true
end
function markerproto:UpdateWorldMapIcon(c,z)
local show=true
if not ZGV.Pointer.OverlayFrame:IsShown() or self.hidden then show=false end
if show and not self.overworld then
if not c then c,z=GetCurrentMapContinentAndZone() end
if self.c~=c or self.z~=z then show=false end
end
if show then
local x,y = Astrolabe:PlaceIconOnWorldMap(ZGV.Pointer.OverlayFrame, self.worldmapFrame, self.c, self.z, self.x, self.y)
if not x or not y or x<0 or y<0 or x>1 or y>1 then
show=false
end
end
if show then
self.worldmapFrame:Show()
self.worldmapFrame.icon:ClearAllPoints()
self.worldmapFrame.icon:SetAllPoints()
--ZGV:Print("Showing "..way.title)
else
self.worldmapFrame:Hide()
end
end
function markerproto:UpdateMiniMapIcon(c,z)
if not c then c,z=GetCurrentMapContinentAndZone() end
if profile.minicons and not self.hidden and
(
self.onminimap=="always" or
ZGV.Pointer.ArrowFrame.waypoint==self or
((self.onminimap=="zone" or self.onminimap=="zonedistance") and c==self.c and z==self.z)
) then
Astrolabe:PlaceIconOnMinimap(self.minimapFrame, self.c, self.z, self.x, self.y)
else
Astrolabe:RemoveIconFromMinimap(self.minimapFrame)
end
end
-----------------------------------------------------------------------
--[[
do
local lastx,lasty
local x,y,zone
function Pointer:GetPlayerPosition()
local x,y = GetPlayerMapPosition("player")
end
end
function Pointer:GetDistFromPlayer(c,z,x,y)
local pc,pz,px,py
local px, py = GetPlayerMapPosition("player")
px, py, pzone = self:GetCurrentPlayerPosition()
if pzone then
pzone = BZL[pzone]
end
if px == 0 or py == 0 or not px or not py then
return nil
end
if pzone and BZH[pzone] then
pzone = BZL[pzone]
end
if zone and BZH[zone] then
zone = BZL[zone]
end
if not zone then
zone = GetRealZoneText()
end
if not pzone then
pzone = zone
end
local dist = Tourist:GetYardDistance(zone, x, y, pzone, px, py)
return dist
end
--]]
-- Code taken from HandyNotes, thanks Xinhuan
---------------------------------------------------------
-- Public functions for plugins to convert between MapFile <-> C,Z
--
--[[
local continentMapFile = {
[WORLDMAP_COSMIC_ID] = "Cosmic", -- That constant is -1
[0] = "World",
[1] = "Kalimdor",
[2] = "Azeroth",
[3] = "Expansion01",
[scarlet_cont] = "ScarletEnclave",
}
local reverseMapFileC = {}
local reverseMapFileZ = {}
for C in pairs(Astrolabe.ContinentList) do
for Z = 1, #Astrolabe.ContinentList[C] do
local mapFile = Astrolabe.ContinentList[C][Z]
reverseMapFileC[mapFile] = C
reverseMapFileZ[mapFile] = Z
end
end
for C = -1, 3 do
local mapFile = continentMapFile[C]
reverseMapFileC[mapFile] = C
reverseMapFileZ[mapFile] = 0
end
--]]
--[[
function Pointer:GetMapFile(C, Z)
if type(C)=="string" then return end
if not C or not Z then return end
if Z == 0 then
return continentMapFile[C]
elseif C > 0 then
return Astrolabe.ContinentList[C][Z]
end
end
function Pointer:GetCZ(mapFile)
return reverseMapFileC[mapFile], reverseMapFileZ[mapFile]
end
--]]
local function FormatDistance(dist)
if profile.arrowmeters then
local mdist = dist * 0.9144
if mdist>1000 then
return ("%.1f km"):format(mdist/1000)
else
return ("%d m"):format(mdist)
end
else
if dist>1760 then
return ("%.1f mil"):format(dist/1760)
else
return ("%d yd"):format(dist)
end
end
end
ZGV.FormatDistance=FormatDistance
---------------
function Pointer:CreateArrowFrame()
self.ArrowFrame = CreateFrame("Frame","ZygorGuidesViewerPointerArrowFrame",UIParent,"ZygorGuidesViewerFloatingArrow")
local tex = self.ArrowFrame.arrow:GetTexture()
self.ArrowFrame.arrow:SetTexture(true)
self.ArrowFrame.arrow:SetTexture(tex,false)
self.ArrowFrame:Hide()
self.ArrowFrameCtrl = CreateFrame("Frame",nil,UIParent,nil)
self.ArrowFrameCtrl:SetScript("OnUpdate",self.ArrowFrameControl_OnUpdate)
self.ArrowFrameCtrl:Show()
self:SetupArrowFreeze()
self:SetScale(profile.arrowscale)
end
function Pointer:SetupArrowFreeze()
self.ArrowFrame:EnableMouse(not profile.arrowfreeze)
self.ArrowFrame:RegisterForDrag(not profile.arrowfreeze and "LeftButton")
end
function Pointer:UpdateWaypoints()
-- worldmap updates only, so far
for way,w in pairs(self.waypoints) do
Astrolabe:PlaceIconOnWorldMap(WorldMapFrame, way.worldmapFrame, way.c, way.z, way.x, way.y )
end
end
function Pointer:SetScale(scale)
if not scale then return end
self.ArrowFrame:SetScale(scale)
self.ArrowFrame:SetScale(scale)
self.ArrowFrame:SetScale(scale)
self.ArrowFrame:SetScale(scale)
end
function Pointer:SetFontSize(size)
local f=self.ArrowFrame.title:GetFont()
self.ArrowFrame.title:SetFont(f,size)
--[[
self.ArrowFrame.dist:SetFont(f,size)
self.ArrowFrame.eta:SetFont(f,size)
self.ArrowFrame.title:SetHeight(size)
self.ArrowFrame.dist:SetHeight(size)
self.ArrowFrame.eta:SetHeight(size)
--]]
end
function GetCurrentMapContinentAndZone()
local c,z = GetCurrentMapContinent(), GetCurrentMapZone()
if c==-1 and z==0 and GetMapInfo()=="ScarletEnclave" then c,z=5,1 end
return c,z
end
function Pointer:MinimapZoomChanged()
if profile.minimapzoom then
--minimapcontrolled = true
else
--minimapcontrolled = false
Minimap:SetZoom(0)
MinimapZoomOut:Disable()
MinimapZoomIn:Enable()
end
end
function Pointer:ResetMinimapZoom()
if profile.minimapzoom then
Minimap:SetZoom(0)
MinimapZoomOut:Disable()
MinimapZoomIn:Enable()
end
--minimap_lastset = 0
end
local function ShowTooltip(button,tooltip)
if not button.waypoint or not button.waypoint.t then return end
tooltip:SetOwner(button,"ANCHOR_BOTTOM")
tooltip:ClearLines()
tooltip:SetText(button.waypoint.t)
if button.waypoint.OnEnter then
local r = button.waypoint:OnEnter(tooltip)
if r==false then return end
end
--GameTooltip:SetFrameStrata("TOOLTIP")
tooltip:Show()
end
function Pointer.MinimapButton_OnEnter(self,arg)
if self.waypoint and (self.icon:IsVisible() or self.arrow:IsVisible()) then
ShowTooltip(self,GameTooltip)
GameTooltip:AddLine(("Distance: %s"):format(FormatDistance(self.dist)))
GameTooltip:Show()
self.hastooltip=true
end
end
function Pointer.WorldmapButton_OnEnter(self,arg)
if self.waypoint and (self.icon:IsVisible() or self.arrow:IsVisible()) then
WorldMapPOIFrame.old_allowBlobTooltip = WorldMapPOIFrame.allowBlobTooltip
WorldMapPOIFrame.allowBlobTooltip = false
ShowTooltip(self,WorldMapTooltip)
end
end
function Pointer.MinimapButton_OnLeave(self)
GameTooltip:Hide()
self.hastooltip=false
end
function Pointer.WorldmapButton_OnLeave(self)
WorldMapTooltip:Hide()
WorldMapPOIFrame.allowBlobTooltip = WorldMapPOIFrame.old_allowBlobTooltip
WorldMapPOIFrame.old_allowBlobTooltip = nil
end
function Pointer.MinimapButton_OnUpdate(self,elapsed)
local c = self.minimap_count
if not c then c=0 end
c = c + elapsed
if c < 0.1 then
self.minimap_count = c
return
end
elapsed = c
self.minimap_count = 0
if not profile.minicons then self.icon:Hide() self.arrow:Hide() return end
local dist,x,y = Astrolabe:GetDistanceToIcon(self)
if not dist or IsInInstance() then self.icon:Hide() self.arrow:Hide() return end
self.lastdist=self.dist
self.dist = dist
if self.waypoint.OnUpdate then self.waypoint:OnUpdate() end
if self.waypoint.hidden or self.waypoint.hideminimap then
self.icon:Hide()
self.arrow:Hide()
return
end
local edge = Astrolabe:IsIconOnEdge(self)
if edge then
self.icon:Hide()
self.arrow:Show()
local angle = Astrolabe:GetDirectionToIcon(self)
angle = angle + 2.356194 -- rad(135)
if GetCVar("rotateMinimap") == "1" then
angle = angle - GetPlayerFacing()
end
local sin,cos = math.sin(angle)*0.71, math.cos(angle) * 0.71
self.arrow:SetTexCoord(0.5-sin, 0.5+cos, 0.5+cos, 0.5+sin, 0.5-cos, 0.5-sin, 0.5+sin, 0.5-cos)
else
self.icon:Show()
self.arrow:Hide()
end
-- handle tooltip distance updates
if self.lastdist~=self.dist and self.hastooltip then
ZGV.Pointer.MinimapButton_OnEnter(self)
end
-- minimap autozoom
if profile.minimapzoom then
local Minimap = Minimap
local getzoom = Minimap:GetZoom()
if getzoom~=minimap_lastset then
-- user playing with minimap; suspend our activities for a while
minimapcontrol_suspension = 5.0
minimap_lastset = getzoom
end
-- are we pointed to?
if Pointer.ArrowFrame.waypoint==self.waypoint then
if minimapcontrol_suspension>0 then
minimapcontrol_suspension = minimapcontrol_suspension - elapsed
else
local old_minimap_lastset=minimap_lastset
local dist = dist*2
if dist~=lastminimapdist then
local mapsizes = MinimapSize[Astrolabe.minimapOutside and 'outdoor' or 'indoor']
minimap_lastset=0
for i=1,Minimap:GetZoomLevels()-1 do
if dist<mapsizes[i]*0.7 then minimap_lastset=i end
end
if old_minimap_lastset~=minimap_lastset then
-- sanitise buttons
if(minimap_lastset == (Minimap:GetZoomLevels() - 1)) then MinimapZoomIn:Disable() else MinimapZoomIn:Enable() end
if(minimap_lastset == 0) then MinimapZoomOut:Disable() else MinimapZoomOut:Enable() end
Minimap:SetZoom(minimap_lastset)
end
end
lastminimapdist=dist
end
end
end
end
function Pointer.MinimapButton_OnClick(self,button)
if button=="RightButton" then
if ZGV.Pointer.ArrowFrame.waypoint==self.waypoint then ZGV.Pointer:HideArrow() end
if self.waypoint.type=="manual" then ZGV.Pointer:RemoveWaypoint(self.waypoint) end
ZGV:SetWaypoint()
else
ZGV.Pointer:ShowArrow(self.waypoint)
end
end
function Pointer.MinimapButton_OnEvent(self,event,...)
-- temporarily unused
ZGV:Print("MINIMAP ONEVENT "..event)
if not self.waypoint then self:Hide() return end
if event == "PLAYER_ENTERING_WORLD" then
local way = self.waypoint
if way then
way:UpdateMiniMapIcon()
end
end
end
function Pointer.WorldMapButton_OnEvent(self,event,...)
local way = self.waypoint
--ZGV:Print("WORLDMAP ONEVENT "..event)
if event == "WORLD_MAP_UPDATE" then
--[[
local show=true
if not way.showinallzones then
local c,z = GetCurrentMapContinentAndZone()
if way.c~=c or way.z~=z then show=false end
end
if way and way.OnEvent then way:OnEvent(event,...) end
if not way or way.hidden then self:Hide() return end
local x,y = Astrolabe:PlaceIconOnWorldMap(ZGV.Pointer.OverlayFrame, self, self.waypoint.c, self.waypoint.z, self.waypoint.x, self.waypoint.y)
if (x and y and (0 < x and x <= 1) and (0 < y and y <= 1)) then
self:Show()
else
self:Hide()
end
self.icon:ClearAllPoints()
self.icon:SetAllPoints()
--]]
--[[
if GetCurrentMapZone()==0 then
self:SetWidth(10)
self:SetHeight(10)
else
end
--]]
--[[
self:SetWidth(25)
self:SetHeight(25)
--]]
elseif event == "PLAYER_ENTERING_WORLD" or event=="ZONE_CHANGED_NEW_AREA" then
if way then way:UpdateMiniMapIcon() end
end
end
local instancemaps = {
["Deadmines"] = {
map="deadmines"
},
["Sethekk Halls"] = {
map="sethekkhalls"
},
["Mana-Tombs"] = {
map="manatombs",
rooms={
["Ravaged Crypt"] = {x=459/1000,y=214/667},
["Crescent Hall"] = {x=581/1000,y=421/667},
["Hall of Twilight"] = {x=381/1000,y=444/667},
}
},
}
if not ZGV_DEV then instancemaps={} end
-- DUNGEON MAPS
function after_WorldMapFrame_LoadZones(...)
local info = UIDropDownMenu_CreateInfo();
info.text = "dupa"
info.func = WorldMapZygorDungeonButton_OnClick
info.checked = nil
UIDropDownMenu_AddButton(info)
end
hooksecurefunc("WorldMapFrame_LoadZones",after_WorldMapFrame_LoadZones)
local dungeons = {
[1] = {
['Blackfathom Deeps']={
l1=21,l2=24,type='D',
floors={
{
map='blackfathomdeeps',
rooms={
}
}
}
},
['Dire Maul']={
l1=55,l2=65,type='D',floors={
{map='diremaul',rooms={}} }},
['Maraudon']={
l1=45,l2=48,type='D',floors={{map='maraudon',rooms={}}} },
['Ragefire Chasm']={
l1=15,l2=16,type='D',floors={{map='ragefirechasm',rooms={}}} },
['Razorfen Downs']={
l1=34,l2=37,type='D',floors={{map='razorfendowns',rooms={}}} },
['Razorfen Kraul']={
l1=24,l2=27,type='D',floors={{map='razorfenkraul',rooms={}}} },
['Wailing Caverns']={
l1=17,l2=20,type='D',floors={{map='wailingcaverns',rooms={}}} },
['Zul\'Farrak']={
l1=43,l2=46,type='D',floors={{map='zulfarrak',rooms={}}} },
['Ahn\'Qiraj']={
l1=60,l2=63,type='R',floors={{map='ahnqiraj',rooms={}}} },
['Ruins of Ahn\'Qiraj']={
l1=60,l2=63,type='R',floors={{map='ruinsofahnqiraj',rooms={}}} },
['Onyxia\'s Lair']={
l1=80,l2=83,type='R',floors={{map='onyxiaslair',rooms={}}} },
},
[2] = {
['Blackrock Depths']={
l1=53,l2=56,type='D',floors={{map='blackrockdepths',rooms={}}} },
['Blackrock Spire']={
l1=57,l2=63,type='D',floors={{map='blackrockspire',rooms={}}} },
['Gnomeregan']={
l1=25,l2=28,type='D',floors={{map='gnomeregan',rooms={}}} },
['Scarlet Monastery']={
l1=32,l2=35,type='D',floors={{map='scarletmonastery',rooms={}}} },
['Scholomance']={
l1=55,l2=65,type='D',floors={{map='scholomance',rooms={}}} },
['Shadowfang Keep']={
l1=18,l2=21,type='D',floors={{map='shadowfangkeep',rooms={}}} },
['Stratholme']={
l1=55,l2=65,type='D',floors={{map='stratholme',rooms={}}} },
['Sunken Temple']={
l1=55,l2=65,type='D',floors={{map='sunkentemple',rooms={}}} },
['The Deadmines']={
l1=17,l2=20,type='D',floors={{map='deadmines',rooms={}}} },
['The Stockade']={
l1=22,l2=25,type='D',floors={{map='stockade',rooms={}}} },
['Uldaman']={
l1=37,l2=40,type='D',floors={{map='uldaman',rooms={}}} },
['Blackwing Lair']={
l1=60,l2=63,type='R',floors={{map='blackwinglair',rooms={}}} },
['Molten Core']={
l1=60,l2=63,type='R',floors={{map='moltencore',rooms={}}} },
['Zul\'Gurub']={
l1=57,l2=63,type='R',floors={{map='zulgurub',rooms={}}} },
['Zul\'Aman']={
l1=70,l2=73,type='R',floors={{map='zulaman',rooms={}}} },
},
[3] = {
['Auchindoun: Auchenai Crypts']={
l1=65,l2=67,type='D',floors={{map='auchenaicrypts',rooms={}}} },
['Auchindoun: Mana-Tombs']={
l1=64,l2=66,type='D',floors={{map='manatombs',rooms={}}} },
['Auchindoun: Sethekk Halls']={
l1=67,l2=68,type='D',floors={{map='sethekkhalls',rooms={}}} },
['Auchindoun: Shadow Labyrinth']={
l1=67,l2=75,type='D',floors={{map='shadowlabyrinth',rooms={}}} },
['Caverns of Time: Old Hillsbrad Foothills']={
l1=66,l2=68,type='D',floors={{map='oldhillsbrad',rooms={}}} },
['Caverns of Time: The Black Morass']={
l1=68,l2=75,type='D',floors={{map='blackmorass',rooms={}}} },
['Coilfang Reservoir: The Slave Pens']={
l1=62,l2=64,type='D',floors={{map='slavepens',rooms={}}} },
['Coilfang Reservoir: The Steamvault']={
l1=67,l2=75,type='D',floors={{map='steamvault',rooms={}}} },
['Coilfang Reservoir: The Underbog']={
l1=63,l2=65,type='D',floors={{map='underbog',rooms={}}} },
['Hellfire Citadel: Hellfire Ramparts']={
l1=59,l2=62,type='D',floors={{map='hellfireramparts',rooms={}}} },
['Hellfire Citadel: The Blood Furnace']={
l1=61,l2=63,type='D',floors={{map='bloodfurnace',rooms={}}} },
['Hellfire Citadel: The Shattered Halls']={
l1=67,l2=75,type='D',floors={{map='shatteredhalls',rooms={}}} },
['Magisters\' Terrace']={
l1=68,l2=75,type='D',floors={{map='magistersterrace',rooms={}}} },
['The Eye: The Arcatraz']={
l1=68,l2=75,type='D',floors={{map='arcatraz',rooms={}}} },
['The Eye: The Botanica']={
l1=67,l2=75,type='D',floors={{map='botanica',rooms={}}} },
['The Eye: The Mechanar']={
l1=67,l2=75,type='D',floors={{map='mechanar',rooms={}}} },
['Black Temple']={
l1=70,l2=73,type='R',floors={{map='blacktemple',rooms={}}} },
['Coilfang Reservoir: Serpentshrine Cavern']={
l1=70,l2=73,type='R',floors={{map='serpentshrinecavern',rooms={}}} },
['Hellfire Citadel: Magtheridon\'s Lair']={
l1=70,l2=73,type='R',floors={{map='magtheridonslair',rooms={}}} },
['Karazhan']={
l1=70,l2=73,type='R',floors={{map='karazhan',rooms={}}} },
['Sunwell Plateau']={
l1=70,l2=73,type='R',floors={{map='sunwellplateau',rooms={}}} },
['Tempest Keep: Tempest Keep']={
l1=70,l2=73,type='R',floors={{map='tempestkeep',rooms={}}} },
},
[4] = {
['Ahn\'kahet: The Old Kingdom']={ l1=73,l2=75,type='D',builtin=true},
['Azjol-Nerub']={ l1=72,l2=74,type='D',builtin=true},
['The Culling of Stratholme']={ l1=79,l2=80,type='D',builtin=true},
['Trial of the Champion']={ l1=79,l2=80,type='D',builtin=true},
['Trial of the Crusader']={ l1=80,l2=83,type='R',builtin=true},
['Drak\'Tharon Keep']={ l1=74,l2=76,type='D',builtin=true},
['Gundrak']={ l1=76,l2=78,type='D',builtin=true},
['Icecrown Citadel: Halls of Reflection']={ l1=79,l2=80,type='D',builtin=true},
['Icecrown Citadel: Pit of Saron']={ l1=79,l2=80,type='D',builtin=true},
['Icecrown Citadel: The Forge of Souls']={ l1=79,l2=80,type='D',builtin=true},
['The Nexus']={ l1=71,l2=73,type='D',builtin=true},
['The Oculus']={ l1=79,l2=80,type='D',builtin=true},
['The Violet Hold']={ l1=75,l2=77,type='D',builtin=true},
['Ulduar: Halls of Lightning']={ l1=79,l2=80,type='D',builtin=true},
['Ulduar: Halls of Stone']={ l1=77,l2=79,type='D',builtin=true},
['Utgarde Keep: Utgarde Keep']={ l1=69,l2=72,type='D',builtin=true},
['Utgarde Keep: Utgarde Pinnacle']={ l1=79,l2=80,type='D',builtin=true},
['Icecrown Citadel']={ l1=80,l2=83,type='R',builtin=true},
['Naxxramas']={ l1=80,l2=83,type='R',builtin=true},
['The Nexus: The Eye of Eternity']={ l1=80,l2=83,type='R',builtin=true},
['Ulduar']={ l1=80,l2=83,type='R',builtin=true},
['Vault of Archavon']={ l1=80,l2=83,type='R',builtin=true},
['Wyrmrest Temple: The Obsidian Sanctum']={ l1=80,l2=83,type='R',builtin=true},
['Wyrmrest Temple: The Ruby Sanctum']={ l1=80,l2=83,type='R',builtin=true}
},
}
function WorldMapZygorDungeonButton_OnClick(self)
UIDropDownMenu_SetSelectedID(WorldMapZoneDropDown, self:GetID())
ZGV:Print("dupa mapa")
end
function Pointer.Overlay_OnEvent(self,event,...)
if event == "WORLD_MAP_UPDATE" then
if not WorldMapFrame:IsVisible() then
return
elseif IsInInstance() and GetPlayerMapPosition("player")==0 then
--magic!
local inst = instancemaps[GetZoneText()]
if inst then
ZGV.Pointer.OverlayFrame.texture:SetTexture(ZGV.DIR .. "\\Maps\\" ..inst.map)
ZGV.Pointer.OverlayFrame.texture:Show()
ZGV.Pointer.OverlayFrame:EnableMouse(true)
local room = inst.rooms and inst.rooms[GetMinimapZoneText()]
if room then
--ZGV:Print("room")
self.youarehere:SetPoint("CENTER",self,"TOPLEFT",room.x*self:GetWidth(),-room.y*self:GetHeight())
self.youarehere:Show()
else
self.youarehere:Hide()
end
WorldMapFrameTitle:SetText(GetZoneText())
WorldMapFrameAreaLabel:SetAlpha(0)
end
for way,w in pairs(ZGV.Pointer.waypoints) do
way:Hide()
end
else
--magic!
-- hide instance overlay
ZGV.Pointer.OverlayFrame.texture:Hide()
ZGV.Pointer.OverlayFrame:EnableMouse(false)
WorldMapFrameAreaLabel:SetAlpha(1)
--ZGV:Print("showing...")
local c,z = GetCurrentMapContinentAndZone()
local count=0
for way,w in pairs(ZGV.Pointer.waypoints) do
way:UpdateWorldMapIcon(c,z)
if way.worldmapFrame:IsShown() and way.OnEvent then way:OnEvent(event,...) end
end
end
elseif event=="PLAYER_ALIVE" or event=="PLAYER_ENTERING_WORLD" or event=="ZONE_CHANGED_NEW_AREA" then
ZGV:Debug(event.." (dead?)")
if UnitIsDeadOrGhost("player") and select(2, IsInInstance()) ~= "pvp" and not IsActiveBattlefieldArena() then
ZGV:Debug("Player dead!")
-- corpse arrow
ZGV.Pointer:SetCorpseArrow()
else
ZGV.Pointer.corpsearrow = nil
local n=ZGV.Pointer:ClearWaypoints("corpse")
if n>0 then ZGV:SetWaypoint() end
end
--[[
for way,w in pairs(ZGV.Pointer.waypoints) do
way:UpdateMinimapIcon()
end
--]]
elseif event=="PLAYER_UNGHOST" then
ZGV:Debug("Player unghosted!")
ZGV.Pointer:ClearWaypoints("corpse")
ZGV.Pointer.corpsearrow = nil
ZGV:SetWaypoint()
end
end
------------------------------------------- ARROW -----------------
--[[
function Pointer.ArrowFrame_OnEvent(self,event,...)