08251f8 - Fix OmaCD UNIT_SPELLCAST_SUCCEEDED
[wowui.git] / OmaCoords / Coords.lua
1 -- Coords.lua
2 local _;
3 local CTimerAfter = C_Timer.After;
4
5 local updating = false;
6 local zoneChanged = true;
7
8 local frame = CreateFrame("Frame", "OmaCoords", UIParent);
9 frame:SetPoint("CENTER", UIParent, "CENTER", 0, 60);
10 frame:SetWidth(1);
11 frame:SetHeight(1);
12 frame.text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
13 frame.text:SetPoint("CENTER");
14 frame:SetScript("OnEvent", function() zoneChanged = true end);
15 frame:RegisterEvent("ZONE_CHANGED_NEW_AREA");
16 frame:Hide();
17
18 local function update()
19     if updating then
20         if zoneChanged then
21             SetMapToCurrentZone();
22             zoneChanged = false;
23         end
24         local x, y = GetPlayerMapPosition("player");
25         frame.text:SetFormattedText("%.1f, %.1f", (x or 0)*100, (y or 0)*100);
26         CTimerAfter(0.2, update);
27     end
28 end
29
30 SLASH_OMACOORDS1 = "/coords";
31 function SlashCmdList.OMACOORDS()
32     if frame:IsShown() then
33         updating = false;
34         frame:Hide();
35     else
36         updating = true;
37         update();
38         frame:Show();
39     end
40 end