annotate TimeManager/TimeManager.lua @ 55:dd9b5f59632c v1.0a-release

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 Fri, 10 Jun 2016 20:52:27 -0400
parents ed74c5cabe98
children 07ef62fe201f
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@55 17 local months = {'JA', 'FB', 'MR', 'AP', 'MY', 'JN', 'JL', 'AG', 'SP', 'OC', 'NV', 'DC'}
Nenue@47 18
Nenue@54 19 -- runs when visible
Nenue@47 20 clock.OnUpdate = function(self)
Nenue@54 21 local weekday, month, day, year = _G.CalendarGetDate()
Nenue@54 22 local hour, min = _G.GetGameTime()
Nenue@47 23 if hour > 12 then
Nenue@47 24 hour = hour - 12
Nenue@47 25 end
Nenue@54 26 local posFunc, posF = _G.GetPlayerMapPosition, 100
Nenue@54 27 local posFormat = "|cFF00FFFF%0.1f %0.1f|r"
Nenue@54 28 if self:IsMouseOver() then
Nenue@54 29 posFunc = _G.UnitPosition
Nenue@55 30 posFormat = "yds |cFFFFFF00%d %d|r"
Nenue@54 31 posF = 1
Nenue@54 32 end
Nenue@55 33
Nenue@54 34 local posX, posY = posFunc('player')
Nenue@55 35 self.coords:SetFormattedText(posFormat, posX * posF, posY * posF)
Nenue@55 36 self.time:SetFormattedText("%s |cFF44FFFF%s|r|c88FFFFFF%s|r %d:%02d", weekDays[weekday], day, months[month], hour, min)
Nenue@47 37 end
Nenue@47 38
Nenue@54 39 -- hide/show toggler
Nenue@47 40 clock.OnMouseUp = function(self, button)
Nenue@47 41 if button == 'RightButton' then
Nenue@47 42 if self:IsVisible() then
Nenue@47 43 self:Hide()
Nenue@47 44 else
Nenue@47 45 self:Show()
Nenue@47 46 end
Nenue@47 47 end
Nenue@47 48 end
Nenue@47 49
Nenue@54 50 -- runs once per login
Nenue@47 51 function clock:OnInitialize()
Nenue@47 52 print('clock thing')
Nenue@47 53 self:Show()
Nenue@54 54 end
Nenue@54 55
Nenue@54 56 -- runs once per ui load
Nenue@54 57 clock.OnEnable = function(self)
Nenue@54 58 self:SetParent(_G.UIParent)
Nenue@54 59 self:SetPoint('TOPRIGHT', _G.UIParent, 'TOPRIGHT', -100, -2)
Nenue@54 60 self:SetScript('OnUpdate', clock.OnUpdate)
Nenue@54 61 self:Show()
Nenue@54 62 self.time:SetText('Clock stuff')
Nenue@55 63 end
Nenue@55 64
Nenue@55 65 clock.Open = function(self)
Nenue@55 66 end
Nenue@55 67 clock.Close = function(self)
Nenue@47 68 end