start castbar. not finished

This commit is contained in:
Bunny67
2018-06-02 20:37:32 +03:00
parent 8edcbda164
commit a38ad77063
6 changed files with 355 additions and 238 deletions
+62 -234
View File
@@ -11,9 +11,7 @@ Castbar - A `StatusBar` to represent spell cast/channel progress.
## Sub-Widgets ## Sub-Widgets
.Text - A `FontString` to represent spell name. .Text - A `FontString` to represent spell name.
.Icon - A `Texture` to represent spell icon.
.Time - A `FontString` to represent spell duration. .Time - A `FontString` to represent spell duration.
.SafeZone - A `Texture` to represent latency.
## Notes ## Notes
@@ -51,21 +49,11 @@ A default texture will be applied to the StatusBar and Texture widgets if they d
local Text = Castbar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") local Text = Castbar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
Text:SetPoint("LEFT", Castbar) Text:SetPoint("LEFT", Castbar)
-- Add spell icon
local Icon = Castbar:CreateTexture(nil, "OVERLAY")
Icon:SetSize(20, 20)
Icon:SetPoint("TOPLEFT", Castbar, "TOPLEFT")
-- Add safezone
local SafeZone = Castbar:CreateTexture(nil, "OVERLAY")
-- Register it with oUF -- Register it with oUF
Castbar.bg = Background Castbar.bg = Background
Castbar.Spark = Spark Castbar.Spark = Spark
Castbar.Time = Time Castbar.Time = Time
Castbar.Text = Text Castbar.Text = Text
Castbar.Icon = Icon
Castbar.SafeZone = SafeZone
self.Castbar = Castbar self.Castbar = Castbar
--]] --]]
local ns = oUF local ns = oUF
@@ -73,117 +61,44 @@ local oUF = ns.oUF
local match = string.match local match = string.match
local GetNetStats = GetNetStats
local GetTime = GetTime local GetTime = GetTime
local UnitCastingInfo = UnitCastingInfo
local UnitChannelInfo = UnitChannelInfo
local UnitIsUnit = UnitIsUnit
local tradeskillCastTime, tradeskillCastDuration, tradeskillCurrent, tradeskillTotal, mergeTradeskill = 0, 0, 0, 0, false local function SPELLCAST_START(self, event, name, endTime)
local function updateSafeZone(self)
local safeZone = self.SafeZone
local width = self:GetWidth()
local _, _, ms = GetNetStats()
-- Guard against GetNetStats returning latencies of 0.
if(ms ~= 0) then
local safeZoneRatio = (ms / 1e3) / self.max
if(safeZoneRatio > 1) then
safeZoneRatio = 1
end
safeZone:SetWidth(width * safeZoneRatio)
safeZone:Show()
else
safeZone:Hide()
end
end
local function UNIT_SPELLCAST_SENT(self, event, unit, spell, rank, target)
local element = self.Castbar local element = self.Castbar
element.curTarget = (target and target ~= "") and target or nil
if element.isTradeSkill then
element.tradeSkillCastName = spell
end
end
local function UNIT_SPELLCAST_START(self, event, unit)
if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar
local name, _, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(unit)
if(not name) then if(not name) then
return element:Hide() return element:Hide()
end end
endTime = endTime / 1e3 endTime = endTime / 1000
startTime = startTime / 1e3 element.startTime = GetTime()
local max = endTime - startTime element.duration = element.startTime
element.max = endTime
element.castName = name
element.duration = GetTime() - startTime
element.max = max
element.delay = 0 element.delay = 0
element.casting = true element.casting = true
element.holdTime = 0 element.holdTime = 0
element.isTradeSkill = isTradeSkill
if(mergeTradeskill and isTradeSkill and UnitIsUnit(unit, "player")) then
element.duration = element.duration + (element.max * tradeskillCurrent)
element.max = max * tradeskillTotal
if(unit == "player") then
tradeskillCurrent = tradeskillCurrent + 1
tradeskillCastDuration = element.duration
tradeskillCastTime = max
end
element:SetValue(element.duration)
else
element:SetValue(0)
end
element:SetMinMaxValues(0, element.max) element:SetMinMaxValues(0, element.max)
element:SetValue(0)
if(element.Text) then element.Text:SetText(text) end if(element.Text) then element.Text:SetText(name) end
if(element.Icon) then element.Icon:SetTexture(texture) end
if(element.Time) then element.Time:SetText() end if(element.Time) then element.Time:SetText() end
local sf = element.SafeZone
if(sf) then
sf:ClearAllPoints()
sf:SetPoint("RIGHT")
sf:SetPoint("TOP")
sf:SetPoint("BOTTOM")
updateSafeZone(element)
end
--[[ Callback: Castbar:PostCastStart(unit, name) --[[ Callback: Castbar:PostCastStart(unit, name)
Called after the element has been updated upon a spell cast start. Called after the element has been updated upon a spell cast start.
* self - the Castbar widget * self - the Castbar widget
* unit - unit for which the update has been triggered (string)
* name - name of the spell being cast (string) * name - name of the spell being cast (string)
--]] --]]
if(element.PostCastStart) then if(element.PostCastStart) then
element:PostCastStart(unit, name) element:PostCastStart(name)
end end
element:Show() element:Show()
end end
local function UNIT_SPELLCAST_FAILED(self, event, unit, spellname) local function SPELLCAST_FAILED(self, event)
if(not self.casting) then return end if(not self.casting) then return end
if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar local element = self.Castbar
if(spellname and (element.castName ~= spellname and element.tradeSkillCastName ~= spellname)) then
return
end
if(mergeTradeskill and UnitIsUnit(unit, "player")) then
mergeTradeskill = false
element.tradeSkillCastName = nil
end
local text = element.Text local text = element.Text
if(text) then if(text) then
@@ -197,40 +112,14 @@ local function UNIT_SPELLCAST_FAILED(self, event, unit, spellname)
Called after the element has been updated upon a failed spell cast. Called after the element has been updated upon a failed spell cast.
* self - the Castbar widget * self - the Castbar widget
* unit - unit for which the update has been triggered (string)
* name - name of the failed spell (string)
--]] --]]
if(element.PostCastFailed) then if(element.PostCastFailed) then
return element:PostCastFailed(unit, spellname) return element:PostCastFailed()
end end
end end
local function UNIT_SPELLCAST_FAILED_QUIET(self, event, unit, spellname) local function SPELLCAST_INTERRUPTED(self, event)
if(not self.casting) then return end
if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar local element = self.Castbar
if(spellname and (element.castName ~= spellname and element.tradeSkillCastName ~= spellname)) then
return
end
if(mergeTradeskill and UnitIsUnit(unit, "player")) then
mergeTradeskill = false
element.tradeSkillCastName = nil
end
element.casting = nil
element:SetValue(0)
element:Hide()
end
local function UNIT_SPELLCAST_INTERRUPTED(self, event, unit, spellname)
if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar
if(spellname and element.castName ~= spellname) then
return
end
local text = element.Text local text = element.Text
if(text) then if(text) then
@@ -245,22 +134,18 @@ local function UNIT_SPELLCAST_INTERRUPTED(self, event, unit, spellname)
Called after the element has been updated upon an interrupted spell cast. Called after the element has been updated upon an interrupted spell cast.
* self - the Castbar widget * self - the Castbar widget
* unit - unit for which the update has been triggered (string)
* name - name of the interrupted spell (string)
--]] --]]
if(element.PostCastInterrupted) then if(element.PostCastInterrupted) then
return element:PostCastInterrupted(unit, spellname) return element:PostCastInterrupted()
end end
end end
local function UNIT_SPELLCAST_DELAYED(self, event, unit) local function SPELLCAST_DELAYED(self, event, delay)
if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar local element = self.Castbar
local name, _, _, _, startTime = UnitCastingInfo(unit) local name, _, _, _, startTime = UnitCastingInfo(unit)
if(not startTime or not element:IsShown()) then return end if(not startTime or not element:IsShown()) then return end
local duration = GetTime() - (startTime / 1000) local duration = GetTime() - (self.startTime / 1000)
if(duration < 0) then duration = 0 end if(duration < 0) then duration = 0 end
element.delay = element.delay + element.duration - duration element.delay = element.delay + element.duration - duration
@@ -272,62 +157,41 @@ local function UNIT_SPELLCAST_DELAYED(self, event, unit)
Called after the element has been updated when a spell cast has been delayed. Called after the element has been updated when a spell cast has been delayed.
* self - the Castbar widget * self - the Castbar widget
* unit - unit that the update has been triggered (string)
* name - name of the delayed spell (string)
--]] --]]
if(element.PostCastDelayed) then if(element.PostCastDelayed) then
return element:PostCastDelayed(unit, name) return element:PostCastDelayed()
end end
end end
local function UNIT_SPELLCAST_STOP(self, event, unit, spellname) local function SPELLCAST_STOP(self, event)
if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar local element = self.Castbar
if(spellname and (element.castName ~= spellname)) then if(spellname and (element.castName ~= spellname)) then
return return
end end
if(mergeTradeskill and UnitIsUnit(unit, "player")) then
if(tradeskillCurrent == tradeskillTotal) then
mergeTradeskill = false
end
else
element.casting = nil element.casting = nil
end
--[[ Callback: Castbar:PostCastStop(unit, name) --[[ Callback: Castbar:PostCastStop(unit, name)
Called after the element has been updated when a spell cast has finished. Called after the element has been updated when a spell cast has finished.
* self - the Castbar widget * self - the Castbar widget
* unit - unit for which the update has been triggered (string)
* name - name of the spell (string)
--]] --]]
if(element.PostCastStop) then if(element.PostCastStop) then
return element:PostCastStop(unit, spellname) return element:PostCastStop()
end end
end end
local function UNIT_SPELLCAST_CHANNEL_START(self, event, unit) local function SPELLCAST_CHANNEL_START(self, event, endTime, name)
if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar local element = self.Castbar
local name, _, _, texture, startTime, endTime = UnitChannelInfo(unit)
if(not name) then if(not name) then
return return
end end
endTime = endTime / 1e3 endTime = endTime / 1000
startTime = startTime / 1e3 element.startTime = GetTime()
local max = (endTime - startTime) element.duration = element.startTime + endTime
local duration = endTime - GetTime() element.max = endTime
element.duration = duration
element.max = max
element.delay = 0 element.delay = 0
element.startTime = startTime
element.endTime = endTime
element.extraTickRatio = 0
element.channeling = true element.channeling = true
element.holdTime = 0 element.holdTime = 0
@@ -335,38 +199,26 @@ local function UNIT_SPELLCAST_CHANNEL_START(self, event, unit)
-- executed or be fully completed by the OnUpdate handler before CHANNEL_START -- executed or be fully completed by the OnUpdate handler before CHANNEL_START
-- is called. -- is called.
element.casting = nil element.casting = nil
element.castName = nil
element:SetMinMaxValues(0, max) element:SetMinMaxValues(0, endTime)
element:SetValue(duration) element:SetValue(endTime)
if(element.Text) then element.Text:SetText(name) end if(element.Text) then element.Text:SetText(name) end
if(element.Icon) then element.Icon:SetTexture(texture) end
if(element.Time) then element.Time:SetText() end if(element.Time) then element.Time:SetText() end
local sf = element.SafeZone
if(sf) then
sf:ClearAllPoints()
sf:SetPoint("LEFT")
sf:SetPoint("TOP")
sf:SetPoint("BOTTOM")
updateSafeZone(element)
end
--[[ Callback: Castbar:PostChannelStart(unit, name) --[[ Callback: Castbar:PostChannelStart(unit, name)
Called after the element has been updated upon a spell channel start. Called after the element has been updated upon a spell channel start.
* self - the Castbar widget * self - the Castbar widget
* unit - unit for which the update has been triggered (string)
* name - name of the channeled spell (string) * name - name of the channeled spell (string)
--]] --]]
if(element.PostChannelStart) then if(element.PostChannelStart) then
element:PostChannelStart(unit, name) element:PostChannelStart(name)
end end
element:Show() element:Show()
end end
local function UNIT_SPELLCAST_CHANNEL_UPDATE(self, event, unit) local function SPELLCAST_CHANNEL_UPDATE(self, event, unit)
if(self.unit ~= unit and self.realUnit ~= unit) then return end if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar local element = self.Castbar
@@ -389,17 +241,13 @@ local function UNIT_SPELLCAST_CHANNEL_UPDATE(self, event, unit)
Called after the element has been updated after a channeled spell has been delayed or interrupted. Called after the element has been updated after a channeled spell has been delayed or interrupted.
* self - the Castbar widget * self - the Castbar widget
* unit - unit for which the update has been triggered (string)
* name - name of the channeled spell (string)
--]] --]]
if(element.PostChannelUpdate) then if(element.PostChannelUpdate) then
return element:PostChannelUpdate(unit, name) return element:PostChannelUpdate()
end end
end end
local function UNIT_SPELLCAST_CHANNEL_STOP(self, event, unit, spellname) local function SPELLCAST_CHANNEL_STOP(self, event)
if(self.unit ~= unit and self.realUnit ~= unit) then return end
local element = self.Castbar local element = self.Castbar
if(element:IsShown()) then if(element:IsShown()) then
element.channeling = nil element.channeling = nil
@@ -408,22 +256,20 @@ local function UNIT_SPELLCAST_CHANNEL_STOP(self, event, unit, spellname)
Called after the element has been updated after a channeled spell has been completed. Called after the element has been updated after a channeled spell has been completed.
* self - the Castbar widget * self - the Castbar widget
* unit - unit for which the update has been triggered (string)
* name - name of the channeled spell (string)
--]] --]]
if(element.PostChannelStop) then if(element.PostChannelStop) then
return element:PostChannelStop(unit, spellname) return element:PostChannelStop()
end end
end end
end end
local function onUpdate(self, elapsed) local function onUpdate(self, elapsed)
if(self.casting) then if(self.casting) then
local duration = self.duration + elapsed local duration = GetTime() - self.startTime
if(duration >= self.max or (tradeskillTotal > 1 and duration >= (tradeskillCastDuration + tradeskillCastTime * 1.25))) then
if(duration >= self.max) then
self.casting = nil self.casting = nil
self:Hide() self:Hide()
tradeskillTotal = 0
if(self.PostCastStop) then self:PostCastStop(self.__owner.unit) end if(self.PostCastStop) then self:PostCastStop(self.__owner.unit) end
return return
@@ -449,10 +295,10 @@ local function onUpdate(self, elapsed)
self:SetValue(duration) self:SetValue(duration)
if(self.Spark) then if(self.Spark) then
self.Spark:SetPoint("CENTER", self, "LEFT", (duration / self.max) * self:GetWidth(), 0) self.Spark:SetPoint("CENTER", self, "LEFT", (duration / ((self.startTime + self.max) - self.startTime)) * self:GetWidth(), 0)
end end
elseif(self.channeling) then elseif(self.channeling) then
local duration = self.duration - elapsed local duration = (self.max + self.startTime) - GetTime()
if(duration <= 0) then if(duration <= 0) then
self.channeling = nil self.channeling = nil
@@ -489,15 +335,14 @@ local function onUpdate(self, elapsed)
self.casting = nil self.casting = nil
self.castName = nil self.castName = nil
self.channeling = nil self.channeling = nil
tradeskillTotal = 0
self:Hide() self:Hide()
end end
end end
local function Update(self, ...) local function Update(self, ...)
UNIT_SPELLCAST_START(self, ...) SPELLCAST_START(self, unpack(arg))
return UNIT_SPELLCAST_CHANNEL_START(self, ...) return SPELLCAST_CHANNEL_START(self, unpack(arg))
end end
local function ForceUpdate(element) local function ForceUpdate(element)
@@ -510,30 +355,28 @@ local function Enable(self, unit)
element.__owner = self element.__owner = self
element.ForceUpdate = ForceUpdate element.ForceUpdate = ForceUpdate
if(not (unit and match(unit, "%wtarget$"))) then
self:RegisterEvent("UNIT_SPELLCAST_START", UNIT_SPELLCAST_START)
self:RegisterEvent("UNIT_SPELLCAST_FAILED", UNIT_SPELLCAST_FAILED)
self:RegisterEvent("UNIT_SPELLCAST_STOP", UNIT_SPELLCAST_STOP)
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED)
self:RegisterEvent("UNIT_SPELLCAST_DELAYED", UNIT_SPELLCAST_DELAYED)
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START", UNIT_SPELLCAST_CHANNEL_START)
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", UNIT_SPELLCAST_CHANNEL_UPDATE)
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", UNIT_SPELLCAST_CHANNEL_STOP)
self:RegisterEvent("UNIT_SPELLCAST_SENT", UNIT_SPELLCAST_SENT, true)
self:RegisterEvent("UNIT_SPELLCAST_FAILED_QUIET", UNIT_SPELLCAST_FAILED_QUIET)
end
element.holdTime = 0 element.holdTime = 0
element:SetScript("OnUpdate", element.OnUpdate or onUpdate) element:SetScript("OnUpdate", function()
if element.OnUpdate then
else
onUpdate(this, arg1)
end
end)
if(unit == "player") then
self:RegisterEvent("SPELLCAST_START", SPELLCAST_START)
self:RegisterEvent("SPELLCAST_STOP", SPELLCAST_STOP)
self:RegisterEvent("SPELLCAST_FAILED", SPELLCAST_FAILED)
self:RegisterEvent("SPELLCAST_INTERRUPTED", SPELLCAST_INTERRUPTED)
self:RegisterEvent("SPELLCAST_DELAYED", SPELLCAST_DELAYED)
self:RegisterEvent("SPELLCAST_CHANNEL_START", SPELLCAST_CHANNEL_START)
self:RegisterEvent("SPELLCAST_CHANNEL_UPDATE", SPELLCAST_CHANNEL_UPDATE)
self:RegisterEvent("SPELLCAST_CHANNEL_STOP", SPELLCAST_CHANNEL_STOP)
if(self.unit == "player") then
CastingBarFrame:UnregisterAllEvents() CastingBarFrame:UnregisterAllEvents()
CastingBarFrame.Show = CastingBarFrame.Hide CastingBarFrame.Show = CastingBarFrame.Hide
CastingBarFrame:Hide() CastingBarFrame:Hide()
PetCastingBarFrame:UnregisterAllEvents()
PetCastingBarFrame.Show = PetCastingBarFrame.Hide
PetCastingBarFrame:Hide()
end end
if(element:IsObjectType("StatusBar") and not element:GetStatusBarTexture()) then if(element:IsObjectType("StatusBar") and not element:GetStatusBarTexture()) then
@@ -545,11 +388,6 @@ local function Enable(self, unit)
spark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]]) spark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]])
end end
local safeZone = element.SafeZone
if(safeZone and safeZone:IsObjectType("Texture") and not safeZone:GetTexture()) then
safeZone:SetTexture(1, 0, 0)
end
element:Hide() element:Hide()
return true return true
@@ -561,27 +399,17 @@ local function Disable(self)
if(element) then if(element) then
element:Hide() element:Hide()
self:UnregisterEvent("UNIT_SPELLCAST_START", UNIT_SPELLCAST_START) self:UnregisterEvent("SPELLCAST_START", SPELLCAST_START)
self:UnregisterEvent("UNIT_SPELLCAST_FAILED", UNIT_SPELLCAST_FAILED) self:UnregisterEvent("SPELLCAST_FAILED", SPELLCAST_FAILED)
self:UnregisterEvent("UNIT_SPELLCAST_STOP", UNIT_SPELLCAST_STOP) self:UnregisterEvent("SPELLCAST_STOP", SPELLCAST_STOP)
self:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED) self:UnregisterEvent("SPELLCAST_INTERRUPTED", SPELLCAST_INTERRUPTED)
self:UnregisterEvent("UNIT_SPELLCAST_DELAYED", UNIT_SPELLCAST_DELAYED) self:UnregisterEvent("SPELLCAST_DELAYED", SPELLCAST_DELAYED)
self:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_START", UNIT_SPELLCAST_CHANNEL_START) self:UnregisterEvent("SPELLCAST_CHANNEL_START", SPELLCAST_CHANNEL_START)
self:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", UNIT_SPELLCAST_CHANNEL_UPDATE) self:UnregisterEvent("SPELLCAST_CHANNEL_UPDATE", SPELLCAST_CHANNEL_UPDATE)
self:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", UNIT_SPELLCAST_CHANNEL_STOP) self:UnregisterEvent("SPELLCAST_CHANNEL_STOP", SPELLCAST_CHANNEL_STOP)
self:UnregisterEvent("UNIT_SPELLCAST_SENT", UNIT_SPELLCAST_SENT)
self:UnregisterEvent("UNIT_SPELLCAST_FAILED_QUIET", UNIT_SPELLCAST_FAILED_QUIET)
element:SetScript("OnUpdate", nil) element:SetScript("OnUpdate", nil)
end end
end end
hooksecurefunc("DoTradeSkill", function(_, num) oUF:AddElement("Castbar", function() end, Enable, Disable)
tradeskillCastTime = 0
tradeskillCastDuration = 0
tradeskillCurrent = 0
tradeskillTotal = num or 1
mergeTradeskill = true
end)
oUF:AddElement("Castbar", Update, Enable, Disable)
+2 -2
View File
@@ -9,8 +9,8 @@
<!--<Script file="pvpindicator.lua"/>--> <!--<Script file="pvpindicator.lua"/>-->
<Script file="portrait.lua"/> <Script file="portrait.lua"/>
<!-- <!--
<Script file="range.lua"/> <Script file="range.lua"/>-->
<Script file="castbar.lua"/>--> <Script file="castbar.lua"/>
<Script file="tags.lua"/> <Script file="tags.lua"/>
<Script file="masterlooterindicator.lua"/> <Script file="masterlooterindicator.lua"/>
<Script file="assistantindicator.lua"/> <Script file="assistantindicator.lua"/>
@@ -0,0 +1,277 @@
local E, L, V, P, G = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local UF = E:GetModule("UnitFrames");
--Cache global variables
--Lua functions
local unpack, tonumber = unpack, tonumber
local abs, min = abs, math.min
--WoW API / Variables
local CreateFrame = CreateFrame
local UnitSpellHaste = UnitSpellHaste
local UnitBuff = UnitBuff
local UnitIsPlayer = UnitIsPlayer
local UnitClass = UnitClass
local UnitReaction = UnitReaction
local UnitCanAttack = UnitCanAttack
local ns = oUF
local ElvUF = ns.oUF
local INVERT_ANCHORPOINT = {
TOPLEFT = "BOTTOMRIGHT",
LEFT = "RIGHT",
BOTTOMLEFT = "TOPRIGHT",
RIGHT = "LEFT",
TOPRIGHT = "BOTTOMLEFT",
BOTTOMRIGHT = "TOPLEFT",
CENTER = "CENTER",
TOP = "BOTTOM",
BOTTOM = "TOP",
}
local ticks = {}
function UF:Construct_Castbar(frame, moverName)
local castbar = CreateFrame("StatusBar", nil, frame)
castbar:SetFrameLevel(frame.RaisedElementParent:GetFrameLevel() + 30) --Make it appear above everything else
self["statusbars"][castbar] = true
castbar.CustomDelayText = self.CustomCastDelayText
castbar.CustomTimeText = self.CustomTimeText
castbar.PostCastStart = self.PostCastStart
castbar.PostChannelStart = self.PostCastStart
castbar.PostCastInterruptible = self.PostCastInterruptible
castbar.PostCastNotInterruptible = self.PostCastNotInterruptible
castbar:SetClampedToScreen(true)
E:CreateBackdrop(castbar, "Default", nil, nil, self.thinBorders, true)
castbar.Time = castbar:CreateFontString(nil, "OVERLAY")
self:Configure_FontString(castbar.Time)
castbar.Time:SetPoint("RIGHT", castbar, "RIGHT", -4, 0)
castbar.Time:SetTextColor(0.84, 0.75, 0.65)
castbar.Time:SetJustifyH("RIGHT")
castbar.Text = castbar:CreateFontString(nil, "OVERLAY")
self:Configure_FontString(castbar.Text)
castbar.Text:SetPoint("LEFT", castbar, "LEFT", 4, 0)
castbar.Text:SetTextColor(0.84, 0.75, 0.65)
castbar.Text:SetJustifyH("LEFT")
--castbar.Text:SetWordWrap(false)
castbar.Spark = castbar:CreateTexture(nil, "OVERLAY")
castbar.Spark:SetBlendMode("ADD")
castbar.Spark:SetVertexColor(1, 1, 1)
castbar.bg = castbar:CreateTexture(nil, "BORDER")
castbar.bg:Hide()
local button = CreateFrame("Frame", nil, castbar)
local holder = CreateFrame("Frame", nil, castbar)
E:SetTemplate(button, "Default", nil, nil, self.thinBorders, true)
castbar.Holder = holder
--these are placeholder so the mover can be created.. it will be changed.
castbar.Holder:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, -(frame.BORDER - frame.SPACING))
castbar:SetPoint("BOTTOMLEFT", castbar.Holder, "BOTTOMLEFT", frame.BORDER, frame.BORDER)
button:SetPoint("RIGHT", castbar, "LEFT", -E.Spacing*3, 0)
if moverName then
E:CreateMover(castbar.Holder, frame:GetName().."CastbarMover", moverName, nil, -6, nil, "ALL,SOLO")
end
return castbar
end
function UF:Configure_Castbar(frame)
if not frame.VARIABLES_SET then return end
local castbar = frame.Castbar
local db = frame.db
castbar:SetWidth(db.castbar.width - ((frame.BORDER+frame.SPACING)*2))
castbar:SetHeight(db.castbar.height - ((frame.BORDER+frame.SPACING)*2))
castbar.Holder:SetWidth(db.castbar.width)
castbar.Holder:SetHeight(db.castbar.height)
if castbar.Holder:GetScript("OnSizeChanged") then
castbar.Holder:GetScript("OnSizeChanged")(castbar.Holder)
end
if db.castbar.spark then
castbar.Spark:Show()
else
castbar.Spark:Hide()
end
castbar:ClearAllPoints()
if db.castbar.insideInfoPanel and frame.USE_INFO_PANEL then
E:SetInside(castbar, frame.InfoPanel, 0, 0)
if castbar.Holder.mover then
E:DisableMover(castbar.Holder.mover:GetName())
end
else
local isMoved = E:HasMoverBeenMoved(frame:GetName().."CastbarMover") or not castbar.Holder.mover
if not isMoved then
castbar.Holder.mover:ClearAllPoints()
end
castbar:ClearAllPoints()
if frame.ORIENTATION ~= "RIGHT" then
castbar:SetPoint("BOTTOMRIGHT", castbar.Holder, "BOTTOMRIGHT", -(frame.BORDER+frame.SPACING), frame.BORDER+frame.SPACING)
if not isMoved then
castbar.Holder.mover:SetPoint("TOPRIGHT", frame, "BOTTOMRIGHT", 0, -(frame.BORDER - frame.SPACING))
end
else
castbar:SetPoint("BOTTOMLEFT", castbar.Holder, "BOTTOMLEFT", frame.BORDER+frame.SPACING, frame.BORDER+frame.SPACING)
if not isMoved then
castbar.Holder.mover:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, -(frame.BORDER - frame.SPACING))
end
end
if castbar.Holder.mover then
E:EnableMover(castbar.Holder.mover:GetName())
end
end
if db.castbar.enable and not frame:IsElementEnabled("Castbar") then
frame:EnableElement("Castbar")
elseif not db.castbar.enable and frame:IsElementEnabled("Castbar") then
frame:DisableElement("Castbar")
if(castbar.Holder.mover) then
E:DisableMover(castbar.Holder.mover:GetName())
end
end
end
function UF:CustomCastDelayText(duration)
local db = self:GetParent().db
if not db then return end
if self.channeling then
if db.castbar.format == "CURRENT" then
self.Time:SetText(format("%.1f |cffaf5050%.1f|r", abs(duration - self.max), self.delay))
elseif db.castbar.format == "CURRENTMAX" then
self.Time:SetText(format("%.1f / %.1f |cffaf5050%.1f|r", duration, self.max, self.delay))
elseif db.castbar.format == "REMAINING" then
self.Time:SetText(format("%.1f |cffaf5050%.1f|r", duration, self.delay))
end
else
if db.castbar.format == "CURRENT" then
self.Time:SetText(format("%.1f |cffaf5050%s %.1f|r", duration, "+", self.delay))
elseif db.castbar.format == "CURRENTMAX" then
self.Time:SetText(format("%.1f / %.1f |cffaf5050%s %.1f|r", duration, self.max, "+", self.delay))
elseif db.castbar.format == "REMAINING" then
self.Time:SetText(format("%.1f |cffaf5050%s %.1f|r", abs(duration - self.max), "+", self.delay))
end
end
end
function UF:CustomTimeText(duration)
local db = self:GetParent().db
if not db then return end
if self.channeling then
if db.castbar.format == "CURRENT" then
self.Time:SetText(format("%.1f", abs(duration - self.max)))
elseif db.castbar.format == "CURRENTMAX" then
self.Time:SetText(format("%.1f / %.1f", duration, self.max))
self.Time:SetText(format("%.1f / %.1f", abs(duration - self.max), self.max))
elseif db.castbar.format == "REMAINING" then
self.Time:SetText(format("%.1f", duration))
end
else
if db.castbar.format == "CURRENT" then
self.Time:SetText(format("%.1f", duration))
elseif db.castbar.format == "CURRENTMAX" then
self.Time:SetText(format("%.1f / %.1f", duration, self.max))
elseif db.castbar.format == "REMAINING" then
self.Time:SetText(format("%.1f", abs(duration - self.max)))
end
end
end
function UF:PostCastStart(name)
local db = self:GetParent().db
if not db or not db.castbar then return; end
self.Text:SetText(name)
-- Get length of Time, then calculate available length for Text
local timeWidth = self.Time:GetStringWidth()
local textWidth = self:GetWidth() - timeWidth - 10
local textStringWidth = self.Text:GetStringWidth()
if timeWidth == 0 or textStringWidth == 0 then
E:Delay(0.05, function() -- Delay may need tweaking
textWidth = self:GetWidth() - self.Time:GetStringWidth() - 10
textStringWidth = self.Text:GetStringWidth()
if textWidth > 0 then self.Text:SetWidth(min(textWidth, textStringWidth)) end
end)
else
self.Text:SetWidth(min(textWidth, textStringWidth))
end
self.Spark:SetHeight(self:GetHeight() * 2)
local colors = ElvUF.colors
local r, g, b = colors.castColor[1], colors.castColor[2], colors.castColor[3]
local t
if UF.db.colors.castClassColor and UnitIsPlayer("player") then
local _, class = UnitClass("player")
t = ElvUF.colors.class[class]
elseif UF.db.colors.castReactionColor and UnitReaction("player", "player") then
t = ElvUF.colors.reaction[UnitReaction("player", "player")]
end
if t then
r, g, b = t[1], t[2], t[3]
end
--[[
if self.notInterruptible and unit ~= "player" and UnitCanAttack("player", unit) then
r, g, b = colors.castNoInterrupt[1], colors.castNoInterrupt[2], colors.castNoInterrupt[3]
end
]]
self:SetStatusBarColor(r, g, b)
UF:ToggleTransparentStatusBar(UF.db.colors.transparentCastbar, self, self.bg, nil, true)
if self.bg:IsShown() then
self.bg:SetColorTexture(r * 0.25, g * 0.25, b * 0.25)
local _, _, _, alpha = self.backdrop:GetBackdropColor()
self.backdrop:SetBackdropColor(r * 0.58, g * 0.58, b * 0.58, alpha)
end
end
function UF:PostCastInterruptible()
local colors = ElvUF.colors
local r, g, b = colors.castColor[1], colors.castColor[2], colors.castColor[3]
local t
if UF.db.colors.castClassColor and UnitIsPlayer("player") then
local _, class = UnitClass("player")
t = ElvUF.colors.class[class]
elseif UF.db.colors.castReactionColor and UnitReaction("player", "player") then
t = ElvUF.colors.reaction[UnitReaction("player", "player")]
end
if t then
r, g, b = t[1], t[2], t[3]
end
--[[
if self.notInterruptible and UnitCanAttack("player", unit) then
r, g, b = colors.castNoInterrupt[1], colors.castNoInterrupt[2], colors.castNoInterrupt[3]
end
]]
self:SetStatusBarColor(r, g, b)
UF:ToggleTransparentStatusBar(UF.db.colors.transparentCastbar, self, self.bg, nil, true)
if self.bg:IsShown() then
self.bg:SetColorTexture(r * 0.25, g * 0.25, b * 0.25)
local _, _, _, alpha = self.backdrop:GetBackdropColor()
self.backdrop:SetBackdropColor(r * 0.58, g * 0.58, b * 0.58, alpha)
end
end
function UF:PostCastNotInterruptible()
local colors = ElvUF.colors
self:SetStatusBarColor(colors.castNoInterrupt[1], colors.castNoInterrupt[2], colors.castNoInterrupt[3])
end
@@ -1,6 +1,7 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="AuraBars.lua"/> <Script file="AuraBars.lua"/>
<Script file="Auras.lua"/> <Script file="Auras.lua"/>
<Script file="Castbar.lua"/>
<Script file="CombatIndicator.lua"/> <Script file="CombatIndicator.lua"/>
<Script file="GPS.lua"/> <Script file="GPS.lua"/>
<Script file="Health.lua"/> <Script file="Health.lua"/>
+3 -1
View File
@@ -24,7 +24,7 @@ function UF:Construct_PlayerFrame(frame)
frame.Portrait2D = self:Construct_Portrait(frame, "texture") frame.Portrait2D = self:Construct_Portrait(frame, "texture")
frame.Buffs = self:Construct_Buffs(frame) frame.Buffs = self:Construct_Buffs(frame)
frame.Debuffs = self:Construct_Debuffs(frame) frame.Debuffs = self:Construct_Debuffs(frame)
-- frame.Castbar = self:Construct_Castbar(frame, L["Player Castbar"]) frame.Castbar = self:Construct_Castbar(frame, L["Player Castbar"])
frame.RaidTargetIndicator = UF:Construct_RaidIcon(frame) frame.RaidTargetIndicator = UF:Construct_RaidIcon(frame)
frame.RestingIndicator = self:Construct_RestingIndicator(frame) frame.RestingIndicator = self:Construct_RestingIndicator(frame)
frame.CombatIndicator = self:Construct_CombatIndicator(frame) frame.CombatIndicator = self:Construct_CombatIndicator(frame)
@@ -102,6 +102,8 @@ function UF:Update_PlayerFrame(frame, db)
UF:Configure_Auras(frame, "Buffs") UF:Configure_Auras(frame, "Buffs")
UF:Configure_Auras(frame, "Debuffs") UF:Configure_Auras(frame, "Debuffs")
UF:Configure_Castbar(frame)
UF:Configure_RaidIcon(frame) UF:Configure_RaidIcon(frame)
E:SetMoverSnapOffset(frame:GetName().."Mover", -(12 + db.castbar.height)) E:SetMoverSnapOffset(frame:GetName().."Mover", -(12 + db.castbar.height))
+9
View File
@@ -174,6 +174,15 @@ P["nameplates"] = {
["channelTimeFormat"] = "CURRENT", ["channelTimeFormat"] = "CURRENT",
["timeToHold"] = 0 ["timeToHold"] = 0
}, },
["castbar"] = {
["enable"] = true,
["height"] = 8,
["hideTime"] = false,
["castTimeFormat"] = "CURRENT",
["channelTimeFormat"] = "CURRENT",
["timeToHold"] = 0,
["iconPosition"] = "RIGHT",
},
["buffs"] = { ["buffs"] = {
["enable"] = true, ["enable"] = true,
["numAuras"] = 4, ["numAuras"] = 4,