Buff Timers

Buff Timers

1M Downloads

Some enhancement suggestion on bufftime colors

uthersh opened this issue · 4 comments

commented

Hello, I am a player who just used your addon. It helped me a lot as I could not use my old bufftime addon due to DF prepatch. There are some good features from the old addon so I would like to introduce it to you. And I really hope you could add them in your bufftimer! I am new to github so spare me for the mistakes I might make below.

The old addon I used was called Icebuff, which worked for years without update until now. It showed the timeless buffs as N/A, and other buffs with detailed times in format of hh:mm:ss.

The colors were also applied. For buffs more than 10mins, they are green, 1min to 10min yellow, less than 1min red.

I have attached the original file of Icebuff and a screenshot of mine to display how it worked. I really hope you could add them as I am just not capable of editing codes.
WoWScrnShot_060622_051822

Here are the codes of Icebuff, as I cannot drag the lua file.

--[[
-- Author: yaroot at no fucking spam gmail dot com
-- Copyright owner: Wowshell, All Rights Reserved
--]]

local AceLocale = LibStub('AceLocale-3.0')
do
local L = AceLocale:NewLocale('IceBuff', 'enUS', true)
L['Buff timer'] = true
L['Buff timer text'] = true
L['Enable'] = true
end
do
local L = AceLocale:NewLocale('IceBuff', 'zhCN')
if(L) then
L['Buff timer'] = 'Buff计时增强'
L['Buff timer text'] = '增强Buff计时文字'
L['Enable'] = '启用'
end
end
do
local L = AceLocale:NewLocale('IceBuff', 'zhTW')
if(L) then
L['Buff timer'] = 'Buff計時增強'
L['Buff timer text'] = '增強Buff計時文字'
L['Enable'] = '啟用'
end
end

local icebuff = LibStub('AceAddon-3.0'):NewAddon('IceBuff', 'AceHook-3.0')
local L = AceLocale:GetLocale('IceBuff')

function icebuff:OnInitialize()
local defaults = {
char = {
enabled = true,
}
}
self.acedb = LibStub('AceDB-3.0'):New('WS_BUFF', defaults)
self.db = self.acedb.char

--self:SetupOptions()
if(not self.db.enabled) then
    self:Disable()
end

end

function icebuff:OnEnable()
-- hooksecurefunc('AuraButton_Update', function(...) icebuff:AuraButton_Update(...) end)
-- hooksecurefunc('AuraButton_UpdateDuration', function(...) icebuff:AuraButton_UpdateDuration(...) end)

self:SecureHook('AuraButton_Update', 'AuraButton_Update')
self:SecureHook('AuraButton_UpdateDuration', 'AuraButton_UpdateDuration')

end

function icebuff:OnDisable()
self:UnhookAll()
end

--function onUpdate(self, elapsed)
--end

function icebuff:AuraButton_Update(buttonName, index, filter)
local unit = PlayerFrame.unit
local name, rank, texture, count, debuffType, duration, expirationTime = UnitAura(unit, index, filter)
if(not name) then return end

local button = _G[buttonName .. index]
if(not button) then return end

if(duration > 0) and expirationTime then
    -- pass
else
    if(SHOW_BUFF_DURATIONS == '1') then
        --button.duration:SetText('|cff00ff00N/A|r')
        button.duration:SetText('N/A')
        icebuff:SetColor(button.duration, GREEN_FONT_COLOR)
        button.duration:Show()
    end
end

end

do
local HOUR = 60*60
local MINUTE = 60
local SEC = 1
local TEN_MIN = 10 * 60

local F_HOUR = '%dh'
local F_MINUTE = '%dm'
local F_SEC = '%ds'
local F_TEN_MIN = '%d:%02d'
local F_HOUR = '%d:%02d:%02d'

function icebuff:GetFormattedTime(t)
    --if(s >= HOUR) then
    --    return F_HOUR:format(s / HOUR), GREEN_FONT_COLOR
    --elseif(s >= TEN_MIN) then
    --    return F_MINUTE:format(s / MINUTE), GREEN_FONT_COLOR

    if(t >= HOUR) then
        local h, m, s
        h = floor(t / HOUR)
        m = floor( (t%HOUR) / MINUTE )
        s = floor(t % MINUTE)
        return F_HOUR:format(h, m, s), GREEN_FONT_COLOR
    elseif(t >= MINUTE) then
        return F_TEN_MIN:format(t / MINUTE, t % MINUTE), t>=TEN_MIN and GREEN_FONT_COLOR or NORMAL_FONT_COLOR
    else
        local remain = floor(t+1)
        if(remain >= 1) then
            return F_SEC:format(remain), RED_FONT_COLOR
        else
            return nil
        end
    end
end

end

function icebuff:SetColor(t, c)
if(c) then
t:SetVertexColor(c.r, c.g, c.b)
end
end

function icebuff:AuraButton_UpdateDuration(auraButton, timeLeft)
local duration = auraButton.duration
if(SHOW_BUFF_DURATIONS == '1' and timeLeft) then
local t, c = icebuff:GetFormattedTime(timeLeft)
duration:SetText(t)
icebuff:SetColor(duration, c)
end
end

--function icebuff:SetupOptions()
-- local __order = 0
-- local getOrder = function()
-- __order = __order + 1
-- return __order
-- end

-- wsRegisterOption(
-- 'Interface',
-- 'wsBuffTimer',
-- L['Buff timer'],
-- L['Buff timer text'],
-- [[Interface\icons\inv_jewelry_necklace_22]],
-- {
-- type = 'group',
-- args = {
-- enable = {
-- type = 'toggle',
-- order = getOrder(),
-- name = L['Enable'],
-- get = function() return self.db.enabled end,
-- set = function(_,v)
-- self.db.enabled = v
-- if(v) then
-- self:Enable()
-- else
-- self:Disable()
-- end
-- end
-- }
-- }
-- }
-- )
--end

commented

@uthersh Thanks for the suggestions! No promises, but I will see what I can do.

commented

@sandervspl Thanks for the reply! I would look forward to it!

Actually the codes in the third and fourth blocks are those control the colors. I guess they would be helpful.

commented

what would be interesting is:

  • cache the duration of the buff on application
  • no text if permanent buff (e.g. mounting)
  • if above 66%, green
  • if above 33% yellow
  • if below 33% red

don't really need a N/A text since that clutters unnecessarily and its always going to be green

  • an option that toggles this feature altogether since I personally don't look at buffs that often
commented

Added the option for colors in 609baea. It will work like this:

  • If the buff duration is more than 10 minutes or longer, it will be green
  • If the buff duration is between 1 minute and 10 minutes, it will be yellow
  • If the buff duration is shorter than 1 minute, it will be red

Colors are disabled by default. You'll need to enable it in the interface options.

For now there are no plans to add the N/A text.

Sorry it took so long!