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
bar.cast:SetVertexColor(unpack(nointerruptColor));
bar.shield:Show();
else
local function toggleInterruptible(bar, nointr)
if bar.unit == "player" then return end
if nointr then
bar.cast:SetVertexColor(unpack(nointerruptColor));
bar.shield:Show();
else
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);
else
_, _, name, icon, startTime, endTime, _, _, noInterrupt, id = UnitCastingInfo(unit);
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
end
bar.spell:SetText(ssub(name, 1, bar.spell.count));
bar.time:SetFormattedText("%.1f", (endTime - startTime)/1000);
end
bar.spell:SetText(ssub(name, 1, bar.spell.count));
bar.time:SetFormattedText("%.1f", (endTime - startTime)/1000);
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);
bar.cast.fullwidth = bar:GetWidth() - 2; -- for casts without icon
bar.cast:SetWidth(bar.cast.width);
bar.cast:SetTexture(barTexture);
bar.cast.fullwidth = bar:GetWidth() - 2; -- for casts without icon
bar.cast:SetWidth(bar.cast.width);
bar.cast:SetTexture(barTexture);
bar.spell = bar:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
bar.spell:SetPoint("LEFT", bar.icon, "RIGHT", 2, 0);
bar.spell.count = ceil(bar.cast:GetWidth()/10);
bar.spell = bar:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
bar.spell:SetPoint("LEFT", bar.icon, "RIGHT", 2, 0);
bar.spell.count = ceil(bar.cast:GetWidth()/10);