annotate TimeManager/TimeManager.lua @ 59:07ef62fe201f

Re-write of BuffFrame module: - uses secure hooks on blizzard BuffFrame.lua functions to determine needed action - make use of built-in table behavior to reduce unnecessary frame updates
author Nenue
date Thu, 28 Jul 2016 18:27:56 -0400
parents dd9b5f59632c
children
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:SetScript('OnUpdate', clock.OnUpdate)
Nenue@54 60 self:Show()
Nenue@54 61 self.time:SetText('Clock stuff')
Nenue@55 62 end
Nenue@55 63
Nenue@55 64 clock.Open = function(self)
Nenue@55 65 end
Nenue@55 66 clock.Close = function(self)
Nenue@47 67 end