Nenue@47: -------------------------------------------- Nenue@47: -- Veneer Nenue@54: -- Clock/Coordinate multi-tool Nenue@54: -- mouseover reveals coordinates by map yards, right-click toggles display Nenue@47: -- Krakyn Nenue@47: -- @project-revision@ @project-hash@ Nenue@47: -- @file-revision@ @file-hash@ Nenue@47: -- Created: 4/27/2016 1:02 AM Nenue@47: -------------------------------------------- Nenue@47: Nenue@54: local B = select(2,...).frame Nenue@54: local _G = _G Nenue@54: local clock = B:RegisterModule("Clock", _G.VeneerClock) Nenue@54: local print = B.print('XML') -- debug hook Nenue@54: -- weekday abbreviations used in display Nenue@47: local weekDays = {'Su', 'M', 'T', 'W', 'R' ,'F', 'Sa' } Nenue@55: local months = {'JA', 'FB', 'MR', 'AP', 'MY', 'JN', 'JL', 'AG', 'SP', 'OC', 'NV', 'DC'} Nenue@47: Nenue@54: -- runs when visible Nenue@47: clock.OnUpdate = function(self) Nenue@54: local weekday, month, day, year = _G.CalendarGetDate() Nenue@54: local hour, min = _G.GetGameTime() Nenue@47: if hour > 12 then Nenue@47: hour = hour - 12 Nenue@47: end Nenue@54: local posFunc, posF = _G.GetPlayerMapPosition, 100 Nenue@54: local posFormat = "|cFF00FFFF%0.1f %0.1f|r" Nenue@54: if self:IsMouseOver() then Nenue@54: posFunc = _G.UnitPosition Nenue@55: posFormat = "yds |cFFFFFF00%d %d|r" Nenue@54: posF = 1 Nenue@54: end Nenue@55: Nenue@54: local posX, posY = posFunc('player') Nenue@55: self.coords:SetFormattedText(posFormat, posX * posF, posY * posF) Nenue@55: self.time:SetFormattedText("%s |cFF44FFFF%s|r|c88FFFFFF%s|r %d:%02d", weekDays[weekday], day, months[month], hour, min) Nenue@47: end Nenue@47: Nenue@54: -- hide/show toggler Nenue@47: clock.OnMouseUp = function(self, button) Nenue@47: if button == 'RightButton' then Nenue@47: if self:IsVisible() then Nenue@47: self:Hide() Nenue@47: else Nenue@47: self:Show() Nenue@47: end Nenue@47: end Nenue@47: end Nenue@47: Nenue@54: -- runs once per login Nenue@47: function clock:OnInitialize() Nenue@47: print('clock thing') Nenue@47: self:Show() Nenue@54: end Nenue@54: Nenue@54: -- runs once per ui load Nenue@54: clock.OnEnable = function(self) Nenue@54: self:SetParent(_G.UIParent) Nenue@54: self:SetPoint('TOPRIGHT', _G.UIParent, 'TOPRIGHT', -100, -2) Nenue@54: self:SetScript('OnUpdate', clock.OnUpdate) Nenue@54: self:Show() Nenue@54: self.time:SetText('Clock stuff') Nenue@55: end Nenue@55: Nenue@55: clock.Open = function(self) Nenue@55: end Nenue@55: clock.Close = function(self) Nenue@47: end