option show seconds or milliseconds added

This commit is contained in:
Sumsebrum 2021-07-26 11:27:32 +02:00
parent 17a983fad6
commit d9f0c1491a
7 changed files with 76 additions and 75 deletions

View File

@ -106,7 +106,7 @@ function Auras:CreateFrame(unit)
Auras:AURA_FADE(self.unit, self.track)
else
self.timeLeft = self.timeLeft - elapsed
self.text:SetFormattedText("%.1f", self.timeLeft >= 0.0 and self.timeLeft or 0.0)
Gladdy:FormatTimer(self.text, self.timeLeft, self.timeLeft < 10)
end
else
self:SetAlpha(0.01)
@ -170,11 +170,11 @@ function Auras:CreateInterrupt(unit)
self.active = false
self.priority = nil
self.spellSchool = nil
self.cooldown:SetCooldown(GetTime(), 0)
self.cooldown:Clear()
self:SetAlpha(0.01)
else
self.timeLeft = self.timeLeft - elapsed
self.text:SetFormattedText("%.1f", self.timeLeft >= 0.0 and self.timeLeft or 0.0)
Gladdy:FormatTimer(self.text, self.timeLeft, self.timeLeft < 10)
end
else
self:SetAlpha(0.01)
@ -282,12 +282,12 @@ function Auras:Test(unit)
self:AURA_GAIN(unit,AURA_TYPE_DEBUFF, 27010, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
self:SPELL_INTERRUPT(unit,19244, select(1, GetSpellInfo(19244)), "physical", 25396, select(1, GetSpellInfo(25396)), 64)
elseif (unit == "arena3") then
spellName, _, icon = GetSpellInfo(31224)
spellName, _, icon = GetSpellInfo(34709)
self:AURA_FADE(unit, AURA_TYPE_BUFF)
self:AURA_GAIN(unit,AURA_TYPE_BUFF, 31224, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
self:AURA_GAIN(unit,AURA_TYPE_BUFF, 34709, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
spellName, _, icon = GetSpellInfo(18425)
self:AURA_FADE(unit, AURA_TYPE_DEBUFF)
self:AURA_GAIN(unit,AURA_TYPE_DEBUFF, 18425, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
--self:AURA_FADE(unit, AURA_TYPE_DEBUFF)
--self:AURA_GAIN(unit,AURA_TYPE_DEBUFF, 18425, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
end
end
@ -348,7 +348,7 @@ function Auras:AURA_FADE(unit, auraType)
return
end
if auraFrame.active then
auraFrame.cooldown:SetCooldown(GetTime(), 0)
auraFrame.cooldown:Clear()
end
--auraFrame.cooldown:Hide()
auraFrame.active = false

View File

@ -153,6 +153,7 @@ function BuffsDebuffs:Test(unit)
BuffsDebuffs:AddOrRefreshAura(unit, 1, AURA_TYPE_BUFF, 12, 12, 1, "poison", select(3, GetSpellInfo(1943)), 1)
BuffsDebuffs:AddOrRefreshAura(unit, 1, AURA_TYPE_BUFF, 10, 10, 2, "magic", select(3, GetSpellInfo(1)), 2)
BuffsDebuffs:AURA_GAIN(unit, AURA_TYPE_BUFF, 28093, select(1, GetSpellInfo(28093)), select(3, GetSpellInfo(28093)), 10, GetTime() + 10, 1, "physical")
BuffsDebuffs:AddOrRefreshAura(unit, 5, AURA_TYPE_DEBUFF, 12, 12, 3, "physical", select(3, GetSpellInfo(27009)), 1)
BuffsDebuffs:AddOrRefreshAura(unit, 5, AURA_TYPE_DEBUFF, 11, 11, 4, "disease", select(3, GetSpellInfo(11426)), 2)
end
@ -469,28 +470,23 @@ local function iconTimer(auraFrame, elapsed)
local timeLeftMilliSec = auraFrame.endtime - GetTime()
local timeLeftSec = ceil(timeLeftMilliSec)
auraFrame.timeLeft = timeLeftMilliSec
--auraFrame.cooldowncircle:SetCooldown(auraFrame.startTime, auraFrame.endtime)
if Gladdy.db.buffsDynamicColor then
if timeLeftSec >= 60 then
if Gladdy.db.buffsDynamicColor then auraFrame.cooldown:SetTextColor(0.7, 1, 0) end
auraFrame.cooldown:SetFormattedText("%dm", ceil(timeLeftSec / 60))
auraFrame.cooldown:SetTextColor(0.7, 1, 0)
elseif timeLeftSec < 60 and timeLeftSec >= 11 then
--if it's less than 60s
if Gladdy.db.buffsDynamicColor then auraFrame.cooldown:SetTextColor(0.7, 1, 0) end
auraFrame.cooldown:SetFormattedText("%d", timeLeftSec)
auraFrame.cooldown:SetTextColor(0.7, 1, 0)
elseif timeLeftSec <= 10 and timeLeftSec >= 5 then
if Gladdy.db.buffsDynamicColor then auraFrame.cooldown:SetTextColor(1, 0.7, 0) end
auraFrame.cooldown:SetFormattedText("%d", timeLeftSec)
auraFrame.cooldown:SetTextColor(1, 0.7, 0)
elseif timeLeftSec <= 4 and timeLeftSec >= 3 then
if Gladdy.db.buffsDynamicColor then auraFrame.cooldown:SetTextColor(1, 0, 0) end
auraFrame.cooldown:SetFormattedText("%d", timeLeftSec)
auraFrame.cooldown:SetTextColor(1, 0, 0)
elseif timeLeftMilliSec <= 3 and timeLeftMilliSec > 0 then
if Gladdy.db.buffsDynamicColor then auraFrame.cooldown:SetTextColor(1, 0, 0) end
auraFrame.cooldown:SetFormattedText("%.1f", timeLeftMilliSec >= 0.0 and timeLeftMilliSec or 0.0)
elseif timeLeftMilliSec <= 0 and timeLeftMilliSec > -0.05 then -- 50ms ping max wait for SPELL_AURA_REMOVED event
auraFrame.cooldown:SetText("")
else -- fallback in case SPELL_AURA_REMOVED is not fired
auraFrame.cooldown:SetTextColor(1, 0, 0)
end
end
if timeLeftMilliSec < 0 then
auraFrame:Hide()
end
Gladdy:FormatTimer(auraFrame.cooldown, timeLeftMilliSec, timeLeftMilliSec <= 3)
else
auraFrame.cooldown:SetText("")
end

View File

@ -295,19 +295,13 @@ function Cooldowns:CooldownStart(button, spellId, duration)
self.timeLeft = self.timeLeft - elapsed
local timeLeft = ceil(self.timeLeft)
if timeLeft >= 540 then
self.cooldownFont:SetText(ceil(timeLeft / 60) .. "m")
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.cooldownFont), Gladdy.db.cooldownSize / 3.1 * Gladdy.db.cooldownFontScale, "OUTLINE")
elseif timeLeft < 540 and timeLeft >= 60 then
-- more than 1 minute
self.cooldownFont:SetText(ceil(timeLeft / 60) .. "m")
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.cooldownFont), Gladdy.db.cooldownSize / 2.15 * Gladdy.db.cooldownFontScale, "OUTLINE")
elseif timeLeft < 60 and timeLeft > 0 then
-- between 60s and 21s (green)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.cooldownFont), Gladdy.db.cooldownSize / 2.15 * Gladdy.db.cooldownFontScale, "OUTLINE")
self.cooldownFont:SetText(timeLeft)
else
self.cooldownFont:SetText("")
end
Gladdy:FormatTimer(self.cooldownFont, self.timeLeft, self.timeLeft < 0)
if (self.timeLeft <= 0) then
Cooldowns:CooldownReady(button, spellId, frame)
end

View File

@ -93,11 +93,7 @@ function Diminishings:CreateFrame(unit)
Diminishings:Positionate(unit)
else
self.timeLeft = self.timeLeft - elapsed
if self.timeLeft >=5 then
self.timeText:SetFormattedText("%d", self.timeLeft)
else
self.timeText:SetFormattedText("%.1f", self.timeLeft >= 0.0 and self.timeLeft or 0.0)
end
Gladdy:FormatTimer(self.text, self.timeLeft, self.timeLeft < 5)
end
end
end)

View File

@ -45,33 +45,22 @@ local function iconTimer(self,elapsed)
local timeLeft = ceil(self.timeLeft)
if timeLeft >= 60 then
-- more than 1 minute
self.cooldownFont:SetTextColor(1, 1, 0)
self.cooldownFont:SetText(floor(timeLeft / 60) .. ":" .. string_format("%02.f", floor(timeLeft - floor(timeLeft / 60) * 60)))
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.racialFont), (self:GetWidth()/2 - 0.15* self:GetWidth()) * Gladdy.db.racialFontScale, "OUTLINE")
elseif timeLeft < 60 and timeLeft >= 21 then
-- between 60s and 21s (green)
self.cooldownFont:SetTextColor(0.7, 1, 0)
self.cooldownFont:SetText(timeLeft)
elseif timeLeft < 60 and timeLeft >= 30 then
self.cooldownFont:SetTextColor(1, 1, 0)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.racialFont), (self:GetWidth()/2 - 1) * Gladdy.db.racialFontScale, "OUTLINE")
elseif timeLeft < 20.9 and timeLeft >= 11 then
-- between 20s and 11s (green)
self.cooldownFont:SetTextColor(0, 1, 0)
self.cooldownFont:SetText(timeLeft)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.racialFont), (self:GetWidth()/2 - 1) * Gladdy.db.racialFontScale, "OUTLINE")
elseif timeLeft <= 10 and timeLeft >= 5 then
-- between 10s and 5s (orange)
elseif timeLeft < 30 and timeLeft >= 11 then
self.cooldownFont:SetTextColor(1, 0.7, 0)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.racialFont), (self:GetWidth()/2 - 1) * Gladdy.db.racialFontScale, "OUTLINE")
elseif timeLeft < 10 and timeLeft >= 5 then
self.cooldownFont:SetTextColor(1, 0.7, 0)
self.cooldownFont:SetFormattedText("%.1f", self.timeLeft)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.racialFont), (self:GetWidth()/2 - 1) * Gladdy.db.racialFontScale, "OUTLINE")
elseif timeLeft < 5 and timeLeft > 0 then
-- between 5s and 1s (red)
self.cooldownFont:SetTextColor(1, 0, 0)
self.cooldownFont:SetFormattedText("%.1f", self.timeLeft >= 0.0 and self.timeLeft or 0.0)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.racialFont), (self:GetWidth()/2 - 1) * Gladdy.db.racialFontScale, "OUTLINE")
else
self.cooldownFont:SetText("")
end
Gladdy:FormatTimer(self.cooldownFont, self.timeLeft, self.timeLeft < 10, true)
end
end

View File

@ -39,33 +39,22 @@ local function iconTimer(self, elapsed)
local timeLeft = ceil(self.timeLeft)
if timeLeft >= 60 then
-- more than 1 minute
self.cooldownFont:SetTextColor(1, 1, 0)
self.cooldownFont:SetText(floor(timeLeft / 60) .. ":" .. string_format("%02.f", floor(timeLeft - floor(timeLeft / 60) * 60)))
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (self:GetWidth()/2 - 0.15*self:GetWidth()) * Gladdy.db.trinketFontScale, "OUTLINE")
elseif timeLeft < 60 and timeLeft >= 21 then
-- between 60s and 21s (green)
self.cooldownFont:SetTextColor(0.7, 1, 0)
self.cooldownFont:SetText(timeLeft)
elseif timeLeft < 60 and timeLeft >= 30 then
self.cooldownFont:SetTextColor(1, 1, 0)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (self:GetWidth()/2 - 1) * Gladdy.db.trinketFontScale, "OUTLINE")
elseif timeLeft < 20.9 and timeLeft >= 11 then
-- between 20s and 11s (green)
self.cooldownFont:SetTextColor(0, 1, 0)
self.cooldownFont:SetText(timeLeft)
elseif timeLeft < 30 and timeLeft >= 11 then
self.cooldownFont:SetTextColor(1, 0.7, 0)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (self:GetWidth()/2 - 1) * Gladdy.db.trinketFontScale, "OUTLINE")
elseif timeLeft <= 10 and timeLeft >= 5 then
-- between 10s and 5s (orange)
self.cooldownFont:SetTextColor(1, 0.7, 0)
self.cooldownFont:SetFormattedText("%.1f", self.timeLeft)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (self:GetWidth()/2 - 1) * Gladdy.db.trinketFontScale, "OUTLINE")
elseif timeLeft < 5 and timeLeft > 0 then
-- between 5s and 1s (red)
self.cooldownFont:SetTextColor(1, 0, 0)
self.cooldownFont:SetFormattedText("%.1f", self.timeLeft >= 0.0 and self.timeLeft or 0.0)
self.cooldownFont:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.trinketFont), (self:GetWidth()/2 - 1) * Gladdy.db.trinketFontScale, "OUTLINE")
else
self.cooldownFont:SetText("")
end
Gladdy:FormatTimer(self.cooldownFont, self.timeLeft, self.timeLeft < 10, true)
end
end

View File

@ -1,4 +1,6 @@
local type, pairs, tinsert, tsort, tostring, str_match, tonumber = type, pairs, table.insert, table.sort, tostring, string.match, tonumber
local type, pairs, tinsert, tsort = type, pairs, table.insert, table.sort
local tostring, str_match, tonumber, string_format = tostring, string.match, tonumber, string.format
local ceil, floor = ceil, floor
local InterfaceOptionsFrame_OpenToFrame = InterfaceOptionsFrame_OpenToFrame
local GetSpellInfo = GetSpellInfo
@ -6,10 +8,38 @@ local LOCALIZED_CLASS_NAMES_MALE = LOCALIZED_CLASS_NAMES_MALE
local CLASS_ICON_TCOORDS = CLASS_ICON_TCOORDS
local AURA_TYPE_DEBUFF, AURA_TYPE_BUFF = AURA_TYPE_DEBUFF, AURA_TYPE_BUFF
local Gladdy = LibStub("Gladdy")
local LibClassAuras = LibStub("LibClassAuras-1.0")
local L = Gladdy.L
Gladdy.TIMER_FORMAT = { tenths = "tenths", seconds = "seconds",
values = {
["tenths"] = "xx:xx Miliseconds",
["seconds"] = "xx Seconds"
}}
function Gladdy:FormatTimer(fontString, timeLeft, milibreakpoint, showSeconds)
if timeLeft < 0 then
fontString:SetText("")
return
end
local time = timeLeft >= 0.0 and timeLeft or 0.0
if Gladdy.db.timerFormat == Gladdy.TIMER_FORMAT.tenths and milibreakpoint then
fontString:SetFormattedText("%.1f", time)
else
if time >= 60 then
if showSeconds then
fontString:SetText(floor(timeLeft / 60) .. ":" .. string_format("%02.f", floor(timeLeft - floor(timeLeft / 60) * 60)))
else
fontString:SetText(ceil(ceil(time / 60)) .. "m")
end
else
fontString:SetFormattedText("%d", ceil(time))
end
end
end
Gladdy.defaults = {
profile = {
locked = false,
@ -23,6 +53,7 @@ Gladdy.defaults = {
barWidth = 180,
bottomMargin = 2,
statusbarBorderOffset = 6,
timerFormat = Gladdy.TIMER_FORMAT.tenths
},
}
@ -343,6 +374,12 @@ function Gladdy:SetupOptions()
Gladdy:UpdateFrame()
end
},
timerFormat = Gladdy:option({
type = "select",
name = L["Timer Format"],
order = 11,
values = Gladdy.TIMER_FORMAT.values
})
},
},
fontGeneral = {