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