mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
102 lines
2.9 KiB
Lua
102 lines
2.9 KiB
Lua
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
|
local DT = E:GetModule("DataTexts");
|
|
|
|
--Cache global variables
|
|
--Lua functions
|
|
local next, unpack = next, unpack
|
|
local format, gsub, join = string.format, string.gsub, string.join
|
|
local abs = math.abs
|
|
local getn, insert = table.getn, table.insert
|
|
local time, utf8sub = time, string.utf8sub
|
|
--WoW API / Variables
|
|
local GetGameTime = GetGameTime
|
|
local GetNumSavedInstances = GetNumSavedInstances
|
|
local GetSavedInstanceInfo = GetSavedInstanceInfo
|
|
local IsAddOnLoaded = IsAddOnLoaded
|
|
local SecondsToTime = SecondsToTime
|
|
|
|
local timeDisplayFormat = ""
|
|
local dateDisplayFormat = ""
|
|
local europeDisplayFormat_nocolor = join("", "%02d", ":|r%02d")
|
|
local lockoutInfoFormat = "|cffaaaaaa(%s)"
|
|
local lockoutColorExtended, lockoutColorNormal = {r = 0.3, g = 1, b = 0.3}, {r = .8, g = .8, b = .8}
|
|
|
|
local function OnClick()
|
|
if IsAddOnLoaded("TimeManager") then -- https://github.com/gashole/TimeManager
|
|
if arg1 == "RightButton" then
|
|
TimeManagerClockButton_OnClick()
|
|
else
|
|
GameTimeFrame_OnClick()
|
|
end
|
|
end
|
|
end
|
|
|
|
local function OnLeave()
|
|
DT.tooltip:Hide()
|
|
end
|
|
|
|
local function OnEnter(self)
|
|
DT:SetupTooltip(self)
|
|
|
|
RequestRaidInfo()
|
|
|
|
local lockedInstances = {raids = {}}
|
|
local _, name, reset
|
|
|
|
for i = 1, GetNumSavedInstances() do
|
|
name, _, reset = GetSavedInstanceInfo(i)
|
|
if name then
|
|
insert(lockedInstances["raids"], {name, reset})
|
|
end
|
|
end
|
|
|
|
if next(lockedInstances["raids"]) then
|
|
DT.tooltip:AddLine(" ")
|
|
DT.tooltip:AddLine(L["Saved Raid(s)"])
|
|
|
|
for i = 1, getn(lockedInstances["raids"]) do
|
|
name, reset = unpack(lockedInstances["raids"][i])
|
|
lockoutColor = extended and lockoutColorExtended or lockoutColorNormal
|
|
DT.tooltip:AddDoubleLine(format(lockoutInfoFormat, name), SecondsToTime(abs(reset), 1, 1, false), 1, 1, 1, lockoutColor.r, lockoutColor.g, lockoutColor.b)
|
|
end
|
|
|
|
DT.tooltip:Show()
|
|
DT.tooltip:AddLine(" ")
|
|
end
|
|
|
|
DT.tooltip:AddDoubleLine(L["Realm time:"], format(europeDisplayFormat_nocolor, GetGameTime()), 1, 1, 1, lockoutColorNormal.r, lockoutColorNormal.g, lockoutColorNormal.b)
|
|
DT.tooltip:Show()
|
|
end
|
|
|
|
local lastPanel
|
|
local int = 5
|
|
local function OnUpdate(self, t)
|
|
int = int - t
|
|
|
|
if int > 0 then return end
|
|
|
|
if IsAddOnLoaded("TimeManager") then -- https://github.com/gashole/TimeManager
|
|
if TimeManagerClockButton.alarmFiring then
|
|
-- E:Flash(self)
|
|
else
|
|
-- E:StopFlash(self)
|
|
end
|
|
end
|
|
|
|
self.text:SetText(gsub(gsub(BetterDate(E.db.datatexts.timeFormat.." "..E.db.datatexts.dateFormat, time()), ":", timeDisplayFormat), "%s", dateDisplayFormat))
|
|
|
|
lastPanel = self
|
|
int = 1
|
|
end
|
|
|
|
local function ValueColorUpdate(hex)
|
|
timeDisplayFormat = join("", hex, ":|r")
|
|
dateDisplayFormat = join("", hex, " ")
|
|
|
|
if lastPanel ~= nil then
|
|
OnUpdate(lastPanel, 20000)
|
|
end
|
|
end
|
|
E["valueColorUpdateFuncs"][ValueColorUpdate] = true
|
|
|
|
DT:RegisterDatatext("Time", nil, nil, OnUpdate, OnClick, OnEnter, OnLeave) |