mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 14:50:13 -05:00
- Even more configuration options
- SpellStatus lib for spell casting (shows rank now too)
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
local AceOO = AceLibrary("AceOO-2.0")
|
||||
local SpellCache = AceLibrary("SpellCache-1.0")
|
||||
|
||||
local CastBar = AceOO.Class(IceBarElement)
|
||||
|
||||
@ -6,8 +7,10 @@ CastBar.prototype.casting = nil
|
||||
CastBar.prototype.channeling = nil
|
||||
CastBar.prototype.failing = nil
|
||||
CastBar.prototype.succeeding = nil
|
||||
CastBar.prototype.instanting = nil
|
||||
|
||||
CastBar.prototype.spellName = nil
|
||||
CastBar.prototype.spellRank = nil
|
||||
|
||||
CastBar.prototype.startTime = nil
|
||||
CastBar.prototype.castTime = nil
|
||||
@ -35,7 +38,7 @@ function CastBar.prototype:GetDefaultSettings()
|
||||
local settings = CastBar.super.prototype.GetDefaultSettings(self)
|
||||
settings["side"] = IceCore.Side.Left
|
||||
settings["offset"] = 0
|
||||
settings["alwaysShowText"] = true
|
||||
settings["showInstants"] = true
|
||||
return settings
|
||||
end
|
||||
|
||||
@ -43,20 +46,21 @@ end
|
||||
-- OVERRIDE
|
||||
function CastBar.prototype:GetOptions()
|
||||
local opts = CastBar.super.prototype.GetOptions(self)
|
||||
opts["alwaysShowText"] =
|
||||
|
||||
opts["showInstants"] =
|
||||
{
|
||||
type = 'toggle',
|
||||
name = 'Always Show Text',
|
||||
desc = 'Overrides possible text hiding option',
|
||||
name = 'Show Instant Casts',
|
||||
desc = 'Toggles showing instant spell names',
|
||||
get = function()
|
||||
return self.moduleSettings.alwaysShowText
|
||||
return self.moduleSettings.showInstants
|
||||
end,
|
||||
set = function(value)
|
||||
self.moduleSettings.alwaysShowText = value
|
||||
self:Redraw()
|
||||
self.moduleSettings.showInstants = value
|
||||
end,
|
||||
order = 50
|
||||
}
|
||||
|
||||
return opts
|
||||
end
|
||||
|
||||
@ -64,17 +68,17 @@ end
|
||||
function CastBar.prototype:Enable()
|
||||
CastBar.super.prototype.Enable(self)
|
||||
|
||||
self:RegisterEvent("SPELLCAST_START", "CastStart")
|
||||
self:RegisterEvent("SPELLCAST_STOP", "CastStop")
|
||||
self:RegisterEvent("SPELLCAST_FAILED", "CastFailed")
|
||||
self:RegisterEvent("SPELLCAST_INTERRUPTED", "CastInterrupted")
|
||||
|
||||
self:RegisterEvent("SPELLCAST_DELAYED", "CastDelayed")
|
||||
|
||||
self:RegisterEvent("SPELLCAST_CHANNEL_START", "ChannelingStart")
|
||||
self:RegisterEvent("SPELLCAST_CHANNEL_STOP", "ChannelingStop")
|
||||
self:RegisterEvent("SPELLCAST_CHANNEL_UPDATE", "ChannelingUpdate")
|
||||
self:RegisterEvent("SpellStatus_SpellCastInstant")
|
||||
self:RegisterEvent("SpellStatus_SpellCastCastingStart")
|
||||
self:RegisterEvent("SpellStatus_SpellCastCastingChange")
|
||||
self:RegisterEvent("SpellStatus_SpellCastCastingFinish")
|
||||
self:RegisterEvent("SpellStatus_SpellCastFailure")
|
||||
|
||||
self:RegisterEvent("SpellStatus_SpellCastChannelingStart")
|
||||
self:RegisterEvent("SpellStatus_SpellCastChannelingChange")
|
||||
self:RegisterEvent("SpellStatus_SpellCastChannelingFinish")
|
||||
|
||||
|
||||
self.frame:Hide()
|
||||
|
||||
-- remove blizz cast bar
|
||||
@ -99,17 +103,13 @@ end
|
||||
-- OVERRIDE
|
||||
function CastBar.prototype:Redraw()
|
||||
CastBar.super.prototype.Redraw(self)
|
||||
|
||||
if (self.moduleSettings.alwaysShowText) then
|
||||
self.frame.bottomUpperText:Show()
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 'Protected' methods --------------------------------------------------------
|
||||
|
||||
|
||||
-- OVERRIDE
|
||||
function CastBar.prototype:CreateFrame()
|
||||
CastBar.super.prototype.CreateFrame(self)
|
||||
@ -140,7 +140,9 @@ function CastBar.prototype:OnUpdate()
|
||||
end
|
||||
|
||||
self:UpdateBar(scale, "castCasting")
|
||||
self:SetBottomText1(remaining .. "s " .. self.spellName)
|
||||
|
||||
self.spellName = self.spellName or ''
|
||||
self:SetBottomText1(remaining .. "s " .. self.spellName .. self:FormatRank(self.spellRank))
|
||||
|
||||
elseif (self.failing) then
|
||||
self.alpha = 0.7
|
||||
@ -165,6 +167,22 @@ function CastBar.prototype:OnUpdate()
|
||||
self.frame:Hide()
|
||||
self.frame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
elseif (self.instanting) then
|
||||
self:UpdateBar(1, "castSuccess", 1-scale)
|
||||
self.frame.bg:Hide()
|
||||
self.barFrame:Hide()
|
||||
|
||||
self.spellName = self.spellName or ''
|
||||
self:SetBottomText1(self.spellName .. self:FormatRank(self.spellRank))
|
||||
|
||||
if (scale >= 1) then
|
||||
self.frame.bg:Show()
|
||||
self.barFrame:Show()
|
||||
|
||||
self:CleanUp()
|
||||
self.frame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
else -- shouldn't be needed
|
||||
self:CleanUp()
|
||||
@ -175,26 +193,83 @@ end
|
||||
|
||||
|
||||
|
||||
function CastBar.prototype:CastStart(name, castTime)
|
||||
self.spellName = name
|
||||
self.castTime = castTime / 1000
|
||||
self.startTime = GetTime()
|
||||
function CastBar.prototype:CleanUp()
|
||||
self.spellName = nil
|
||||
self.spellRank = nil
|
||||
self.castTime = nil
|
||||
self.startTime = nil
|
||||
self.delay = 0
|
||||
self.casting = true
|
||||
self.casting = false
|
||||
self.channeling = false
|
||||
self.failing = false
|
||||
self.succeeding = false
|
||||
self.instanting = false
|
||||
self:SetBottomText1()
|
||||
self.alpha = self.settings.alphaooc
|
||||
end
|
||||
|
||||
|
||||
function CastBar.prototype:FormatRank(rank)
|
||||
if (rank) then
|
||||
return " (" .. rank .. ")"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- INSTANT SPELLS --
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
function CastBar.prototype:SpellStatus_SpellCastInstant(sId, sName, sRank, sFullName, sCastTime)
|
||||
IceHUD:Debug("SpellStatus_SpellCastInstant", sId, sName, sRank, sFullName, sCastTime)
|
||||
|
||||
if not (self.moduleSettings.showInstants) then
|
||||
return
|
||||
end
|
||||
|
||||
self:CleanUp()
|
||||
|
||||
self.spellName = sName
|
||||
self.spellRank = SpellCache:GetRankNumber(sRank or '')
|
||||
self.castTime = 1
|
||||
self.startTime = GetTime()
|
||||
self.instanting = true
|
||||
|
||||
self.frame:Show()
|
||||
|
||||
self.frame:SetScript("OnUpdate", function() self:OnUpdate() end)
|
||||
end
|
||||
|
||||
|
||||
function CastBar.prototype:CastStop()
|
||||
if not (self.casting) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- NORMAL SPELLS --
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
function CastBar.prototype:SpellStatus_SpellCastCastingStart(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration)
|
||||
IceHUD:Debug("SpellStatus_SpellCastCastingStart", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration)
|
||||
|
||||
self.spellName = sName
|
||||
self.spellRank = SpellCache:GetRankNumber(sRank or '')
|
||||
|
||||
self.castTime = sCastDuration / 1000
|
||||
self.startTime = sCastStartTime
|
||||
self.delay = 0
|
||||
self.casting = true
|
||||
|
||||
self.frame:Show()
|
||||
self.frame:SetScript("OnUpdate", function() self:OnUpdate() end)
|
||||
end
|
||||
|
||||
|
||||
function CastBar.prototype:SpellStatus_SpellCastCastingFinish (sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sCastDelayTotal)
|
||||
IceHUD:Debug("SpellStatus_SpellCastCastingFinish ", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sCastDelayTotal)
|
||||
|
||||
self:CleanUp()
|
||||
|
||||
self.spellName = nil
|
||||
self.castTime = 1
|
||||
self.startTime = GetTime()
|
||||
self.succeeding = true
|
||||
@ -203,23 +278,22 @@ function CastBar.prototype:CastStop()
|
||||
end
|
||||
|
||||
|
||||
function CastBar.prototype:CastFailed()
|
||||
self:CastTerminated("Failed")
|
||||
function CastBar.prototype:SpellStatus_SpellCastCastingChange(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sCastDelay, sCastDelayTotal)
|
||||
IceHUD:Debug("SpellStatus_SpellCastCastingChange", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sCastDelay, sCastDelayTotal)
|
||||
self.delay = sCastDelayTotal
|
||||
end
|
||||
|
||||
|
||||
function CastBar.prototype:CastInterrupted()
|
||||
self:CastTerminated("Interrupted")
|
||||
end
|
||||
|
||||
|
||||
function CastBar.prototype:CastTerminated(reason)
|
||||
if not (self.casting or self.channeling or self.succeeding) then
|
||||
function CastBar.prototype:SpellStatus_SpellCastFailure(sId, sName, sRank, sFullName, isActiveSpell, UIEM_Message, CMSFLP_SpellName, CMSFLP_Message)
|
||||
IceHUD:Debug("SpellStatus_SpellCastFailure", sId, sName, sRank, sFullName, isActiveSpell, UIEM_Message, CMSFLP_SpellName, CMSFLP_Message)
|
||||
|
||||
if (not (isActiveSpell) or not (self.casting or self.channeling)) then
|
||||
return
|
||||
end
|
||||
|
||||
self:CleanUp()
|
||||
|
||||
self.spellName = reason
|
||||
self.spellName = UIEM_Message
|
||||
self.castTime = 1
|
||||
self.startTime = GetTime()
|
||||
self.failing = true
|
||||
@ -228,17 +302,22 @@ function CastBar.prototype:CastTerminated(reason)
|
||||
end
|
||||
|
||||
|
||||
function CastBar.prototype:CastDelayed(delay)
|
||||
self.delay = self.delay + (delay / 1000)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function CastBar.prototype:ChannelingStart(duration, spell)
|
||||
self.spellName = spell
|
||||
self.castTime = duration / 1000
|
||||
self.startTime = GetTime()
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- CHANNELING SPELLS --
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
function CastBar.prototype:SpellStatus_SpellCastChannelingStart(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction)
|
||||
IceHUD:Debug("SpellStatus_SpellCastChannelingStart", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction)
|
||||
|
||||
self.spellName = sName
|
||||
self.spellRank = SpellCache:GetRankNumber(sRank or '')
|
||||
self.castTime = sCastDuration
|
||||
self.startTime = sCastStartTime
|
||||
self.delay = 0
|
||||
self.channeling = true
|
||||
|
||||
@ -248,30 +327,27 @@ function CastBar.prototype:ChannelingStart(duration, spell)
|
||||
end
|
||||
|
||||
|
||||
function CastBar.prototype:ChannelingStop()
|
||||
function CastBar.prototype:SpellStatus_SpellCastChannelingFinish(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction, sCastDisruptionTotal)
|
||||
IceHUD:Debug("SpellStatus_SpellCastChannelingFinish", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction, sCastDisruptionTotal)
|
||||
|
||||
self:CleanUp()
|
||||
self.frame:Hide()
|
||||
end
|
||||
|
||||
|
||||
function CastBar.prototype:ChannelingUpdate(duration)
|
||||
self.castTime = duration / 1000
|
||||
function CastBar.prototype:SpellStatus_SpellCastChannelingChange(sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction, sCastDisruption, sCastDisruptionTotal)
|
||||
IceHUD:Debug("SpellStatus_SpellCastChannelingChange", sId, sName, sRank, sFullName, sCastStartTime, sCastStopTime, sCastDuration, sAction, sCastDisruption, sCastDisruptionTotal)
|
||||
self.castTime = sCastDuration / 1000
|
||||
end
|
||||
|
||||
|
||||
|
||||
function CastBar.prototype:CleanUp()
|
||||
self.spellName = nil
|
||||
self.castTime = nil
|
||||
self.startTime = nil
|
||||
self.delay = 0
|
||||
self.casting = false
|
||||
self.channeling = false
|
||||
self.failing = false
|
||||
self.succeeding = false
|
||||
self:SetBottomText1()
|
||||
self.alpha = self.settings.alphaooc
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- Load us up
|
||||
|
Reference in New Issue
Block a user