-- TODO trade skill bar updates as well, check Quartz modules/Tradeskill.lua
local function onUpdate(bar)
-- TODO trade skill bar updates as well, check Quartz modules/Tradeskill.lua
local function onUpdate(bar)
local width = bar.icon:IsShown() and bar.cast.width or bar.cast.width; -- TODO fullwidth
local startTime, endTime = bar.startTime, bar.endTime;
local currentClamped = min(GetTime(), endTime);
local width = bar.icon:IsShown() and bar.cast.width or bar.cast.width; -- TODO fullwidth
local startTime, endTime = bar.startTime, bar.endTime;
local currentClamped = min(GetTime(), endTime);
+local function showBar(bar)
+ bar:Show();
+ bar:SetScript("OnUpdate", onUpdate);
+end
+
+local function hideBar(bar)
+ bar:Hide();
+ bar:SetScript("OnUpdate", nil);
+end
+
local function toggleInterruptible(bar, nointr)
if bar.unit == "player" then return end
if nointr then
local function toggleInterruptible(bar, nointr)
if bar.unit == "player" then return end
if nointr then
local name, icon, startTime, endTime, noInterrupt, id;
if channeling then
name, _, _, icon, startTime, endTime, _, noInterrupt = UnitChannelInfo(unit);
local name, icon, startTime, endTime, noInterrupt, id;
if channeling then
name, _, _, icon, startTime, endTime, _, noInterrupt = UnitChannelInfo(unit);
bar.channeling = true;
bar.cast.color = channelingColor;
else
_, _, name, icon, startTime, endTime, _, _, noInterrupt, id = UnitCastingInfo(unit);
bar.channeling = true;
bar.cast.color = channelingColor;
else
_, _, name, icon, startTime, endTime, _, _, noInterrupt, id = UnitCastingInfo(unit);
bar.startTime = startTime / 1000;
bar.endTime = endTime / 1000;
-- don't show samwise for non-existent icons
bar.startTime = startTime / 1000;
bar.endTime = endTime / 1000;
-- don't show samwise for non-existent icons
bar.spell:SetText(ssub(name, 1, bar.spell.count));
bar.time:SetFormattedText("%.1f", (endTime - startTime)/1000);
bar.cast:SetVertexColor(unpack(bar.cast.color));
bar.spell:SetText(ssub(name, 1, bar.spell.count));
bar.time:SetFormattedText("%.1f", (endTime - startTime)/1000);
bar.cast:SetVertexColor(unpack(bar.cast.color));
else
_, _, _, _, startTime, endTime = UnitCastingInfo(unit);
end
else
_, _, _, _, startTime, endTime = UnitCastingInfo(unit);
end
+ ["PLAYER_TARGET_CHANGED"] = function(bar)
+ hideBar(bar);
+ if not startCast(bar, bar.unit) then
+ startCast(bar, bar.unit, true);
+ end
+ end,
["UNIT_SPELLCAST_CHANNEL_START"] = function(bar, unit)
startCast(bar, unit, true);
end,
["UNIT_SPELLCAST_CHANNEL_START"] = function(bar, unit)
startCast(bar, unit, true);
end,
local function onEvent(bar, event, unit)
if unit == bar.unit or (bar.unit == "player" and unit == "vehicle") then
local function onEvent(bar, event, unit)
if unit == bar.unit or (bar.unit == "player" and unit == "vehicle") then
bar:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE");
bar:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE");
bar:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE");
bar:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE");
bar:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE");
bar:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE");
-- trigger initial check
if not startCast(bar, bar.unit) then
startCast(bar, bar.unit, true);
-- trigger initial check
if not startCast(bar, bar.unit) then
startCast(bar, bar.unit, true);