-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMapCoords.lua
More file actions
100 lines (85 loc) · 2.95 KB
/
Copy pathMapCoords.lua
File metadata and controls
100 lines (85 loc) · 2.95 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
--[[
Adds player's coordinates to the WorldMap and Minimap
]] --
local updater = CreateFrame("Frame", "AutoTurnIn_CoordOverlay_Updater", UIParent)
local coordOverlay = CreateFrame("Frame", "AutoTurnIn_CoordOverlay", WorldMapFrame)
coordOverlay:SetPoint("LEFT", WorldMapFrame.BorderFrame, "BOTTOMLEFT", 2, 10)
coordOverlay:SetSize(260, 16)
coordOverlay:SetFrameStrata("FULLSCREEN_DIALOG")
local coordMouse = coordOverlay:CreateFontString(nil, "OVERLAY", "GameFontNormal")
coordMouse:SetPoint("LEFT", coordOverlay, "LEFT", 0, 0)
coordMouse:SetJustifyH("LEFT")
local coordPlayer = coordOverlay:CreateFontString(nil, "OVERLAY", "GameFontNormal")
coordPlayer:SetPoint("RIGHT", coordOverlay, "RIGHT", 0, 0)
coordPlayer:SetJustifyH("RIGHT")
local coordMiniMap
if Minimap then
coordMiniMap = Minimap:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
coordMiniMap:SetPoint("TOP", Minimap, "BOTTOM", 0, -5)
coordMiniMap:SetJustifyH("CENTER")
end
local function GetMouseCoord()
local adjustedX, adjustedY = WorldMapFrame:GetNormalizedCursorPosition()
if adjustedX and adjustedY and adjustedX >= 0 and adjustedY >= 0 and adjustedX <= 1 and adjustedY <= 1 then
adjustedX = adjustedX * 100
adjustedY = adjustedY * 100
else
adjustedX = 0
adjustedY = 0
end
return adjustedX, adjustedY
end
local elapsedSinceLast = 0
updater:SetScript("OnUpdate", function(_, elapsed)
elapsedSinceLast = elapsedSinceLast + elapsed
if elapsedSinceLast < 0.1 then
return
end
elapsedSinceLast = 0
if not AutoTurnIn.db or not AutoTurnIn.db.profile then
return
end
if WorldMapFrame:IsShown() and AutoTurnIn.db.profile.map_coords then
local mx, my = GetMouseCoord()
coordMouse:SetText(string.format("cursor = %04.1f / %04.1f", mx, my))
local map = C_Map.GetBestMapForUnit("player")
if map then
local pos = C_Map.GetPlayerMapPosition(map, "player")
if pos then
local px, py = pos:GetXY()
coordPlayer:SetText(string.format("you = %04.1f / %04.1f", px * 100, py * 100))
end
end
end
if coordMiniMap and AutoTurnIn.db.profile.minimap_coords then
local map = C_Map.GetBestMapForUnit("player")
if map then
local pos = C_Map.GetPlayerMapPosition(map, "player")
if pos then
local px, py = pos:GetXY()
coordMiniMap:SetText(string.format("%04.1f / %04.1f", px * 100, py * 100))
end
end
end
end)
function AutoTurnIn:SwitchMapCoords(flag)
if flag then
coordOverlay:Show()
coordMouse:Show()
coordPlayer:Show()
else
coordOverlay:Hide()
coordMouse:Hide()
coordPlayer:Hide()
end
end
function AutoTurnIn:SwitchMiniMapCoords(flag)
if not coordMiniMap then
return
end
if flag then
coordMiniMap:Show()
else
coordMiniMap:Hide()
end
end