/
end |
return info |
end |
function addon:setOldPlayerCoords() |
local x,y = GetPlayerMapPosition("player") |
if(x) then |
if(y) then |
playerCoords = format("%.1f, %.1f", x*100, y*100) |
end |
end |
end |
function addon:GetOldPlayerCoords() |
function addon:GetPlayerCoords() |
return playerCoords |
end |
local function setPlayerCoords(mapID,x,y) |
if(not C_Map) then |
return addon:setOldPlayerCoords() |
end |
playerCoords = "-, -" |
mapID = C_Map.GetBestMapForUnit("player") |
if(mapID) then |
local adjustedY = y * 100 |
return adjustedX,adjustedY |
end |
local function update2() |
if(not addon['db']['profile'][childName]) then return end |
if(not db) then |
db = addon['db']['profile'][childName] |
end |
if(coordText) then |
addon:setOldPlayerCoords() |
local x, y = GetCursorPosition(); |
x = x / WorldMapButton:GetEffectiveScale(); |
y = y / WorldMapButton:GetEffectiveScale(); |
local centerX, centerY = WorldMapButton:GetCenter(); |
local width = WorldMapButton:GetWidth(); |
local height = WorldMapButton:GetHeight(); |
local adjustedY = addon:round((centerY + (height/2) - y) / height * 100,1); |
local adjustedX = addon:round((x - (centerX - (width/2))) / width * 100,1); |
coordText:SetText(format("Mouse: %i, %i Player: %s",adjustedX,adjustedY,addon:GetOldPlayerCoords())) |
if(not db['hideMapCoords']) then |
mapframe:SetWidth(coordText:GetStringWidth()+4) |
mapframe:SetPoint("BOTTOMLEFT", WorldMapButton, "BOTTOMLEFT", db['windowX'], db['windowY']) |
mapframe:Show() |
else |
mapframe:Hide() |
end |
end |
end |
local function update() |
if(not addon['db']['profile'][childName]) then return end |
if(not db) then |
-- Optionally override in your mixin, called when this provider is added to a map canvas |
self.owningMap = owningMap; |
if(not coordText or not mapframe) then |
mapframe = CreateFrame("Frame", "zz_CoordsMapFrame", C_Map and WorldMapFrame or WorldMapButton) |
mapframe = CreateFrame("Frame", "zz_CoordsMapFrame", WorldMapFrame) |
mapframe:SetWidth(600) |
mapframe:SetHeight(20) |
-- mapframe:SetPoint("BOTTOMLEFT", WorldMapFrame, "BOTTOMLEFT", addon['db']['windowX'], addon['db']['windowY']) |
self.elapsed = self.elapsed + elapsed |
if(self.elapsed<0.2) then return end |
self.elapsed = 0 |
if(C_Map) then |
update() |
else |
update2() |
end |
update() |
end) |
addon['mapframe'] = mapframe |
end |