diff TimeManager/TimeManager.lua @ 54:ed74c5cabe98

Core - updated comment notes Objectives - force hide blocks when their tracker is hidden Clock - convert clock into its own module - display zone coordinates alongside time
author Nenue
date Wed, 01 Jun 2016 20:48:14 -0400
parents 1a322b92dbfa
children dd9b5f59632c
line wrap: on
line diff
--- a/TimeManager/TimeManager.lua	Fri Apr 29 17:06:48 2016 -0400
+++ b/TimeManager/TimeManager.lua	Wed Jun 01 20:48:14 2016 -0400
@@ -1,26 +1,39 @@
 --------------------------------------------
 -- Veneer
+-- Clock/Coordinate multi-tool
+-- mouseover reveals coordinates by map yards, right-click toggles display
 -- Krakyn
 -- @project-revision@ @project-hash@
 -- @file-revision@ @file-hash@
 -- Created: 4/27/2016 1:02 AM
 --------------------------------------------
 
-local B, _G = select(2,...).frame, _G
-local clock = B:RegisterModule("Clock", VeneerClock)
+local B = select(2,...).frame
+local _G = _G
+local clock = B:RegisterModule("Clock", _G.VeneerClock)
+local print = B.print('XML') -- debug hook
+-- weekday abbreviations used in display
 local weekDays = {'Su', 'M', 'T', 'W', 'R' ,'F', 'Sa' }
 
-local print = B.print('XML')
-
+-- runs when visible
 clock.OnUpdate = function(self)
-  local weekday, month, day, year = CalendarGetDate()
-  local hour, min = GetGameTime()
+  local weekday, month, day, year = _G.CalendarGetDate()
+  local hour, min = _G.GetGameTime()
   if hour > 12 then
     hour = hour - 12
   end
-  self.time:SetFormattedText("|cAAFFFFFF%s|r |cFF44FFFF%s|r|c88FFFFFF/|r|cFF44FFFF%s|r %d:%02d", weekDays[weekday], month, day, hour, min)
+  local posFunc, posF = _G.GetPlayerMapPosition, 100
+  local posFormat = "|cFF00FFFF%0.1f %0.1f|r"
+  if self:IsMouseOver() then
+    posFunc = _G.UnitPosition
+    posFormat = "|cFFFFFF00%d %d|r"
+    posF = 1
+  end
+  local posX, posY = posFunc('player')
+  self.time:SetFormattedText(posFormat.. " |cAAFFFFFF%s|r |cFF44FFFF%s|r|c88FFFFFF/|r|cFF44FFFF%s|r %d:%02d", posX * posF, posY * posF, weekDays[weekday], month, day, hour, min)
 end
 
+-- hide/show toggler
 clock.OnMouseUp = function(self, button)
   if button == 'RightButton' then
     if self:IsVisible() then
@@ -31,7 +44,17 @@
   end
 end
 
+-- runs once per login
 function clock:OnInitialize()
   print('clock thing')
   self:Show()
+end
+
+-- runs once per ui load
+clock.OnEnable = function(self)
+  self:SetParent(_G.UIParent)
+  self:SetPoint('TOPRIGHT', _G.UIParent, 'TOPRIGHT', -100, -2)
+  self:SetScript('OnUpdate', clock.OnUpdate)
+  self:Show()
+  self.time:SetText('Clock stuff')
 end
\ No newline at end of file