-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBroker.lua
71 lines (61 loc) · 1.8 KB
/
Broker.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
local NAME, S = ...
local KIT = KethoInstanceTimer
local ACD = LibStub("AceConfigDialog-3.0")
local L = S.L
local GetBattlefieldInstanceRunTime = GetBattlefieldInstanceRunTime
---------------------
--- LibDataBroker ---
---------------------
local dataobject = {
type = "data source",
icon = "Interface\\Icons\\Spell_Holy_BorrowedTime",
OnClick = function(clickedframe, button)
if button == "RightButton" then
ACD[ACD.OpenFrames[NAME] and "Close" or "Open"](ACD, NAME)
elseif button == "LeftButton" and not IsModifierKeyDown() then
if KethoInstanceTimerData then
if KethoInstanceTimerData:IsShown() then
KethoInstanceTimerData:Hide()
else
KethoInstanceTimerData:Show()
end
else
KethoInstanceTimer:DataFrame()
end
elseif button == "LeftButton" and IsModifierKeyDown() then
KIT:SlashCommand(KIT:IsEnabled() and "0" or "1")
end
end,
OnTooltipShow = function(tt)
tt:AddLine("|cffADFF2F"..NAME.."|r")
tt:AddLine(L.BROKER_LCLICK)
tt:AddLine(L.BROKER_RCLICK)
tt:AddLine(L.BROKER_SHIFT_CLICK)
end,
}
------------
--- Time ---
------------
local function MilitaryTime(v)
local sec = floor(v) % 60
local minute = floor(v/60) % 60
local hour = floor(v/3600)
if v >= 3600 then
return format("%02.f:%02.f:%02.f", hour, minute, sec)
else
return format("%02.f:%02.f", minute, sec)
end
end
-------------
--- Timer ---
-------------
C_Timer.NewTicker(1, function()
if S.pvp[S.instance] then -- no idea about arena
local bgTime = GetBattlefieldInstanceRunTime() or 0
dataobject.text = MilitaryTime(bgTime / 1000)
else
local timeInstance = KIT.db.char.timeInstance
dataobject.text = MilitaryTime(S.LastInst and S.LastInst or (timeInstance > 0 and GetServerTime() - timeInstance or 0))
end
end)
LibStub("LibDataBroker-1.1"):NewDataObject(NAME, dataobject)