-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoordinates.lua
More file actions
67 lines (56 loc) · 2.7 KB
/
Copy pathcoordinates.lua
File metadata and controls
67 lines (56 loc) · 2.7 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
local addon = ForgedMapNotes
if not addon then
return
end
function addon:SetupCoordinateDisplay()
if not WorldMapFrame or not WorldMapButton then
return
end
local frame = self.coordinatesFrame
if not frame then
frame = CreateFrame("Frame", "ForgedMapNotesCoordinates", WorldMapButton)
frame.cursorCoords = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
frame.playerCoords = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
frame:SetScript("OnUpdate", function()
local x, y = GetCursorPosition()
local left = WorldMapDetailFrame and WorldMapDetailFrame:GetLeft()
local top = WorldMapDetailFrame and WorldMapDetailFrame:GetTop()
local width = WorldMapDetailFrame and WorldMapDetailFrame:GetWidth()
local height = WorldMapDetailFrame and WorldMapDetailFrame:GetHeight()
local scale = WorldMapDetailFrame and WorldMapDetailFrame:GetEffectiveScale()
if not left or not top or not width or not height or not scale or width == 0 or height == 0 then
this.cursorCoords:SetText("Cursor: --, --")
else
local cx = (x / scale - left) / width
local cy = (top - y / scale) / height
this.cursorCoords:SetText(string.format("Cursor: %.1f, %.1f", 100 * cx, 100 * cy))
end
local px, py = GetPlayerMapPosition("player")
if not px or not py or px == 0 or py == 0 or IsInInstance() then
this.playerCoords:SetText("")
else
this.playerCoords:SetText(string.format("Player: %.1f, %.1f", 100 * px, 100 * py))
end
end)
self.coordinatesFrame = frame
end
frame:SetParent(WorldMapButton)
frame:ClearAllPoints()
frame:SetAllPoints(WorldMapButton)
frame:SetFrameStrata("TOOLTIP")
frame:SetFrameLevel(WorldMapButton:GetFrameLevel() + 30)
frame.cursorCoords:ClearAllPoints()
frame.cursorCoords:SetPoint("BOTTOMLEFT", WorldMapButton, "BOTTOMLEFT", 8, 8)
frame.cursorCoords:SetText("Cursor: --, --")
frame.playerCoords:ClearAllPoints()
frame.playerCoords:SetPoint("BOTTOMRIGHT", WorldMapButton, "BOTTOMRIGHT", -8, 8)
frame.playerCoords:SetText("")
if not frame.helpText then
frame.helpText = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
frame.helpText:SetJustifyH("LEFT")
frame.helpText:SetPoint("TOPLEFT", WorldMapButton, "TOPLEFT", 66, -48)
frame.helpText:SetTextColor(1, 1, 1)
frame.helpText:SetText("Ctrl+Right Click On Map To Add Note\nLeft Click on Note to Edit\nRight Click On Note To Delete")
end
frame:Show()
end