Files
ShaguTweaks-ClassicAPI/mods/actionbar-range-color.lua
T

32 lines
1.3 KiB
Lua

local _G = ShaguTweaks.GetGlobalEnv()
local T = ShaguTweaks.T
local hooksecurefunc = ShaguTweaks.hooksecurefunc
local module = ShaguTweaks:register({
title = T["Range Color"],
description = T["Action buttons will be colored red when out of range."],
expansions = { ["vanilla"] = true },
category = T["Action Bar"],
enabled = nil,
})
module.enable = function(self)
hooksecurefunc("ActionButton_OnUpdate", function(elapsed)
-- Button color based on range
if ( this.rangeTimer ) then
this.rangeTimer = this.rangeTimer - elapsed
if ( this.rangeTimer <= 0.2 ) then -- 0.1
if ( IsActionInRange( ActionButton_GetPagedID(this)) == 0 ) then
if not this.a then
this.r,this.g,this.b,this.a = 0.85, 0.18, 0.18, 1 -- out of range colour
end
_G[this:GetName() .. 'Icon']:SetVertexColor(this.r, this.g, this.b, this.a)
elseif IsUsableAction(ActionButton_GetPagedID(this)) then
_G[this:GetName() .. 'Icon']:SetVertexColor(1, 1, 1, 1)
end
this.rangeTimer = TOOLTIP_UPDATE_TIME
end
end
end, true)
end