annotate 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
rev   line source
Nenue@47 1 --------------------------------------------
Nenue@47 2 -- Veneer
Nenue@54 3 -- Clock/Coordinate multi-tool
Nenue@54 4 -- mouseover reveals coordinates by map yards, right-click toggles display
Nenue@47 5 -- Krakyn
Nenue@47 6 -- @project-revision@ @project-hash@
Nenue@47 7 -- @file-revision@ @file-hash@
Nenue@47 8 -- Created: 4/27/2016 1:02 AM
Nenue@47 9 --------------------------------------------
Nenue@47 10
Nenue@54 11 local B = select(2,...).frame
Nenue@54 12 local _G = _G
Nenue@54 13 local clock = B:RegisterModule("Clock", _G.VeneerClock)
Nenue@54 14 local print = B.print('XML') -- debug hook
Nenue@54 15 -- weekday abbreviations used in display
Nenue@47 16 local weekDays = {'Su', 'M', 'T', 'W', 'R' ,'F', 'Sa' }
Nenue@47 17
Nenue@54 18 -- runs when visible
Nenue@47 19 clock.OnUpdate = function(self)
Nenue@54 20 local weekday, month, day, year = _G.CalendarGetDate()
Nenue@54 21 local hour, min = _G.GetGameTime()
Nenue@47 22 if hour > 12 then
Nenue@47 23 hour = hour - 12
Nenue@47 24 end
Nenue@54 25 local posFunc, posF = _G.GetPlayerMapPosition, 100
Nenue@54 26 local posFormat = "|cFF00FFFF%0.1f %0.1f|r"
Nenue@54 27 if self:IsMouseOver() then
Nenue@54 28 posFunc = _G.UnitPosition
Nenue@54 29 posFormat = "|cFFFFFF00%d %d|r"
Nenue@54 30 posF = 1
Nenue@54 31 end
Nenue@54 32 local posX, posY = posFunc('player')
Nenue@54 33 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)
Nenue@47 34 end
Nenue@47 35
Nenue@54 36 -- hide/show toggler
Nenue@47 37 clock.OnMouseUp = function(self, button)
Nenue@47 38 if button == 'RightButton' then
Nenue@47 39 if self:IsVisible() then
Nenue@47 40 self:Hide()
Nenue@47 41 else
Nenue@47 42 self:Show()
Nenue@47 43 end
Nenue@47 44 end
Nenue@47 45 end
Nenue@47 46
Nenue@54 47 -- runs once per login
Nenue@47 48 function clock:OnInitialize()
Nenue@47 49 print('clock thing')
Nenue@47 50 self:Show()
Nenue@54 51 end
Nenue@54 52
Nenue@54 53 -- runs once per ui load
Nenue@54 54 clock.OnEnable = function(self)
Nenue@54 55 self:SetParent(_G.UIParent)
Nenue@54 56 self:SetPoint('TOPRIGHT', _G.UIParent, 'TOPRIGHT', -100, -2)
Nenue@54 57 self:SetScript('OnUpdate', clock.OnUpdate)
Nenue@54 58 self:Show()
Nenue@54 59 self.time:SetText('Clock stuff')
Nenue@47 60 end