f92b14e - Add a coordinate frame
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Fri, 4 May 2018 15:10:19 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Fri, 4 May 2018 15:10:19 +0000
OmaCoords/Coords.lua [new file with mode: 0644]
OmaCoords/OmaCoords.toc [new file with mode: 0644]

diff --git a/OmaCoords/Coords.lua b/OmaCoords/Coords.lua
new file mode 100644 (file)
index 0000000..7a50559
--- /dev/null
@@ -0,0 +1,40 @@
+-- Coords.lua
+local _;
+local CTimerAfter = C_Timer.After;
+
+local updating = false;
+local zoneChanged = true;
+
+local frame = CreateFrame("Frame", "OmaCoords", UIParent);
+frame:SetPoint("CENTER", UIParent, "CENTER", 0, 60);
+frame:SetWidth(1);
+frame:SetHeight(1);
+frame.text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
+frame.text:SetPoint("CENTER");
+frame:SetScript("OnEvent", function() zoneChanged = true end);
+frame:RegisterEvent("ZONE_CHANGED_NEW_AREA");
+frame:Hide();
+
+local function update()
+    if updating then
+        if zoneChanged then
+            SetMapToCurrentZone();
+            zoneChanged = false;
+        end
+        local x, y = GetPlayerMapPosition("player");
+        frame.text:SetFormattedText("%.1f, %.1f", (x or 0)*100, (y or 0)*100);
+        CTimerAfter(0.2, update);
+    end
+end
+
+SLASH_OMACOORDS1 = "/coords";
+function SlashCmdList.OMACOORDS()
+    if frame:IsShown() then
+        updating = false;
+        frame:Hide();
+    else
+        updating = true;
+        update();
+        frame:Show();
+    end
+end
diff --git a/OmaCoords/OmaCoords.toc b/OmaCoords/OmaCoords.toc
new file mode 100644 (file)
index 0000000..64d8142
--- /dev/null
@@ -0,0 +1,7 @@
+## Interface: 70300
+## Title: Oma Coords
+## Version: 1.0
+## Author: schyrio
+## Notes: My coordinate frame
+
+Coords.lua