mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
update
This commit is contained in:
@@ -3,11 +3,8 @@ local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local next, unpack = next, unpack
|
||||
local time = time
|
||||
local format, gsub, join = string.format, string.gsub, string.join
|
||||
local abs = math.abs
|
||||
local getn, tinsert = table.getn, table.insert
|
||||
--WoW API / Variables
|
||||
local GetGameTime = GetGameTime
|
||||
local GetNumSavedInstances = GetNumSavedInstances
|
||||
@@ -15,11 +12,13 @@ local GetSavedInstanceInfo = GetSavedInstanceInfo
|
||||
local IsAddOnLoaded = IsAddOnLoaded
|
||||
local SecondsToTime = SecondsToTime
|
||||
|
||||
local europeDisplayFormat = join("", "%02d", ":|r%02d")
|
||||
local instanceFormat = "%s |cffaaaaaa(%s)"
|
||||
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 enteredFrame = false
|
||||
|
||||
local lastPanel
|
||||
|
||||
local function OnClick()
|
||||
if IsAddOnLoaded("TimeManager") then -- https://github.com/gashole/TimeManager
|
||||
@@ -33,48 +32,59 @@ end
|
||||
|
||||
local function OnLeave()
|
||||
DT.tooltip:Hide()
|
||||
|
||||
enteredFrame = false
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
RequestRaidInfo()
|
||||
if not enteredFrame then
|
||||
RequestRaidInfo()
|
||||
|
||||
local lockedInstances = {raids = {}}
|
||||
local _, name, reset
|
||||
enteredFrame = true
|
||||
end
|
||||
|
||||
local oneraid
|
||||
local name, id, reset
|
||||
for i = 1, GetNumSavedInstances() do
|
||||
name, _, reset = GetSavedInstanceInfo(i)
|
||||
name, id, reset = GetSavedInstanceInfo(i)
|
||||
if name then
|
||||
tinsert(lockedInstances["raids"], {name, reset})
|
||||
if not oneraid then
|
||||
DT.tooltip:AddLine(L["Saved Instance(s)"])
|
||||
|
||||
oneraid = true
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(format(instanceFormat, name, id), SecondsToTime(reset, true), 1, 1, 1, 0.8, 0.8, 0.8)
|
||||
end
|
||||
|
||||
if DT.tooltip:NumLines() > 0 then
|
||||
DT.tooltip:AddLine(" ")
|
||||
end
|
||||
end
|
||||
|
||||
if next(lockedInstances["raids"]) then
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(L["Saved Raid(s)"])
|
||||
DT.tooltip:AddDoubleLine(L["Realm Time:"], format(europeDisplayFormat, GetGameTime()), 1, 1, 1, 0.8, 0.8, 0.8)
|
||||
|
||||
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 function OnEvent(self, event)
|
||||
if event == "UPDATE_INSTANCE_INFO" and enteredFrame then
|
||||
OnEnter(self)
|
||||
end
|
||||
end
|
||||
|
||||
local int = 5
|
||||
local function OnUpdate(self, t)
|
||||
int = int - t
|
||||
|
||||
if int > 0 then return end
|
||||
|
||||
if enteredFrame then
|
||||
OnEnter(self)
|
||||
end
|
||||
|
||||
self.text:SetText(gsub(gsub(BetterDate(E.db.datatexts.timeFormat.." "..E.db.datatexts.dateFormat, time()), ":", timeDisplayFormat), "%s", dateDisplayFormat))
|
||||
|
||||
lastPanel = self
|
||||
@@ -91,4 +101,4 @@ local function ValueColorUpdate(hex)
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Time", nil, nil, OnUpdate, OnClick, OnEnter, OnLeave)
|
||||
DT:RegisterDatatext("Time", {"UPDATE_INSTANCE_INFO"}, OnEvent, OnUpdate, OnClick, OnEnter, OnLeave)
|
||||
|
||||
Reference in New Issue
Block a user