Version 0.8

- 2.0 compatible
- Removed bunch of unused libs (recommended to delete your /libs folder before updating)
- Added a restriction to open configuration settings only out of combat
- TargetInfo module optimized (no longer eats your memory and babies when changing options)
- Shows up to 40 buffs/debuffs, ability to filter buffs (never/in combat/always)
- No longer uses SpellStatus lib (new events do everything worth doing)
- New module TargetCast, basically does what Blizzard target frame cast bar does
- Removed module TimerBar (it was next to useless)
- Brackets around bar texts now toggleable
- Some misc. bug fixes (eg. colors now change properly when a duel starts)
This commit is contained in:
iceroth
2006-12-04 15:58:07 +00:00
parent 17c3ddbfd8
commit 7740ef9f74
13 changed files with 677 additions and 522 deletions

View File

@ -42,6 +42,7 @@ function IceBarElement.prototype:GetDefaultSettings()
settings["barFontBold"] = true
settings["lockTextAlpha"] = true
settings["textVisible"] = {upper = true, lower = true}
settings["brackets"] = true
return settings
end
@ -181,6 +182,19 @@ function IceBarElement.prototype:GetOptions()
end,
order = 15
},
brackets = {
type = 'toggle',
name = 'Brackets around lower text',
desc = 'Toggle brackets visibility',
get = function()
return self.moduleSettings.brackets
end,
set = function(v)
self.moduleSettings.brackets = v
self:Redraw()
end,
order = 16
},
}
}
@ -469,10 +483,20 @@ end
function IceBarElement.prototype:GetFormattedText(value1, value2)
local color = "ffcccccc"
if not (value2) then
return string.format("|c%s[|r%s|c%s]|r", color, value1, color)
local bLeft = ""
local bRight = ""
if (self.moduleSettings.brackets) then
bLeft = "["
bRight = "]"
end
return string.format("|c%s[|r%s|c%s/|r%s|c%s]|r", color, value1, color, value2, color)
if not (value2) then
return string.format("|c%s%s|r%s|c%s%s|r", color, bLeft, value1, color, bRight)
end
return string.format("|c%s%s|r%s|c%s/|r%s|c%s%s|r", color, bLeft, value1, color, value2, color, bRight)
end

338
IceCastBar.lua Normal file
View File

@ -0,0 +1,338 @@
local AceOO = AceLibrary("AceOO-2.0")
IceCastBar = AceOO.Class(IceBarElement)
IceCastBar.Actions = { None = 0, Cast = 1, Channel = 2, Instant = 3, Success = 4, Failure = 5 }
IceCastBar.prototype.action = nil
IceCastBar.prototype.actionStartTime = nil
IceCastBar.prototype.actionDuration = nil
IceCastBar.prototype.actionMessage = nil
IceCastBar.prototype.unit = nil
-- Constructor --
function IceCastBar.prototype:init(name)
IceCastBar.super.prototype.init(self, name)
self:SetDefaultColor("CastCasting", 242, 242, 10)
self:SetDefaultColor("CastChanneling", 117, 113, 161)
self:SetDefaultColor("CastSuccess", 242, 242, 70)
self:SetDefaultColor("CastFail", 1, 0, 0)
self.unit = "player"
self.delay = 0
self.action = IceCastBar.Actions.None
end
-- 'Public' methods -----------------------------------------------------------
function IceCastBar.prototype:Enable(core)
IceCastBar.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_SPELLCAST_SENT", "SpellCastSent") -- "player", spell, rank, target
self:RegisterEvent("UNIT_SPELLCAST_START", "SpellCastStart") -- unit
self:RegisterEvent("UNIT_SPELLCAST_STOP", "SpellCastStop") -- unit
self:RegisterEvent("UNIT_SPELLCAST_FAILED", "SpellCastFailed") -- unit
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED", "SpellCastInterrupted") -- unit
self:RegisterEvent("UNIT_SPELLCAST_DELAYED", "SpellCastDelayed") -- unit
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED", "SpellCastSucceeded") -- "player", spell, rank
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START", "SpellCastChannelStart") -- unit
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", "SpellCastChannelUpdate") -- unit
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", "SpellCastChannelStop") -- unit
self.frame:Hide()
-- remove blizz cast bar
CastingBarFrame:UnregisterAllEvents()
end
function IceCastBar.prototype:Disable(core)
IceCastBar.super.prototype.Disable(self, core)
-- restore blizz cast bar
CastingBarFrame:RegisterEvent("SPELLCAST_START");
CastingBarFrame:RegisterEvent("SPELLCAST_STOP");
CastingBarFrame:RegisterEvent("SPELLCAST_FAILED");
CastingBarFrame:RegisterEvent("SPELLCAST_INTERRUPTED");
CastingBarFrame:RegisterEvent("SPELLCAST_DELAYED");
CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_START");
CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_UPDATE");
CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_STOP");
end
-- 'Protected' methods --------------------------------------------------------
-- OVERRIDE
function IceCastBar.prototype:CreateFrame()
IceCastBar.super.prototype.CreateFrame(self)
self.frame.bottomUpperText:SetWidth(self.settings.gap + 30)
end
-- OnUpdate handler
function IceCastBar.prototype:OnUpdate()
-- safety catch
if (self.action == IceCastBar.Actions.None) then
IceHUD:Debug("Stopping action ", self.action)
self:StopBar()
return
end
local time = GetTime()
self:Update()
-- handle casting and channeling
if (self.action == IceCastBar.Actions.Cast or self.action == IceCastBar.Actions.Channel) then
local remainingTime = self.actionStartTime + self.actionDuration - time
local scale = 1 - (remainingTime / self.actionDuration)
if (self.action == IceCastBar.Actions.Channel) then
scale = remainingTime / self.actionDuration
end
if (remainingTime < 0) then
self:StopBar()
end
-- sanity check to make sure the bar doesn't over/underfill
scale = scale > 1 and 1 or scale
scale = scale < 0 and 0 or scale
self:UpdateBar(scale, "CastCasting")
self:SetBottomText1(string.format("%.1fs %s", remainingTime , self.actionMessage))
return
end
-- stop bar if casting or channeling is done (in theory this should not be needed)
if (self.action == IceCastBar.Actions.Cast or self.action == IceCastBar.Actions.Channel) then
self:StopBar()
return
end
-- handle bar flashes
if (self.action == IceCastBar.Actions.Instant or
self.action == IceCastBar.Actions.Success or
self.action == IceCastBar.Actions.Failure)
then
local scale = time - self.actionStartTime
if (scale > 1) then
self:StopBar()
return
end
if (self.action == IceCastBar.Actions.Failure) then
self:FlashBar("CastFail", 1-scale, self.actionMessage, "CastFail")
else
self:FlashBar("CastSuccess", 1-scale, self.actionMessage)
end
return
end
-- something went wrong
IceHUD:Debug("OnUpdate error ", self.action, " -- ", self.actionStartTime, self.actionDuration, self.actionMessage)
self:StopBar()
end
function IceCastBar.prototype:FlashBar(color, alpha, text, textColor)
self.frame:SetAlpha(alpha)
local r, g, b = self.settings.backgroundColor.r, self.settings.backgroundColor.g, self.settings.backgroundColor.b
if (self.settings.backgroundToggle) then
r, g, b = self:GetColor(color)
end
self.frame:SetStatusBarColor(r, g, b, 0.3)
self.barFrame:SetStatusBarColor(self:GetColor(color, 0.8))
self:SetScale(self.barFrame.bar, 1)
self:SetBottomText1(text, textColor or "Text")
end
function IceCastBar.prototype:StartBar(action, message)
self.action = action
self.actionStartTime = GetTime()
self.actionMessage = message
local spell, rank, displayName, icon, startTime, endTime, isTradeSkill = UnitCastingInfo(self.unit)
if not (spell) then
spell, rank, displayName, icon, startTime, endTime = UnitChannelInfo(self.unit)
end
if (startTime and endTime) then
self.actionDuration = (endTime - startTime) / 1000
-- set start time here in case we start to monitor a cast that is underway already
self.actionStartTime = startTime / 1000
else
self.actionDuration = 1 -- instants/failures
end
if not (message) then
self.actionMessage = spell .. self:GetShortRank(rank)
end
self.frame:Show()
self.frame:SetScript("OnUpdate", function() self:OnUpdate() end)
end
function IceCastBar.prototype:StopBar()
self.action = IceCastBar.Actions.None
self.actionStartTime = nil
self.actionDuration = nil
self.frame:Hide()
self.frame:SetScript("OnUpdate", nil)
end
function IceCastBar.prototype:GetShortRank(rank)
if (rank) then
local _, _, sRank = string.find(rank, "(%d+)")
if (sRank) then
return " (" .. sRank .. ")"
end
end
return ""
end
-------------------------------------------------------------------------------
-- NORMAL SPELLS --
-------------------------------------------------------------------------------
function IceCastBar.prototype:SpellCastSent(unit, spell, rank, target)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastSent", unit, spell, rank, target)
end
function IceCastBar.prototype:SpellCastStart(unit)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastStart", unit, UnitCastingInfo(unit))
self:StartBar(IceCastBar.Actions.Cast)
end
function IceCastBar.prototype:SpellCastStop(unit)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastStop", unit)
if (self.action ~= IceCastBar.Actions.Success and
self.action ~= IceCastBar.Actions.Failure and
self.action ~= IceCastBar.Actions.Channel)
then
self:StopBar()
end
end
function IceCastBar.prototype:SpellCastFailed(unit)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastFailed", unit)
-- determine if we want to show failed casts
if (self.moduleSettings.flashFailures == "Never") then
return
elseif (self.moduleSettings.flashFailures == "Caster") then
if (UnitPowerType("player") ~= 0) then -- 0 == mana user
return
end
end
self:StartBar(IceCastBar.Actions.Failure, "Failed")
end
function IceCastBar.prototype:SpellCastInterrupted(unit)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastInterrupted", unit)
self:StartBar(IceCastBar.Actions.Failure, "Interrupted")
end
function IceCastBar.prototype:SpellCastDelayed(unit, delay)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastDelayed", unit, UnitCastingInfo(unit))
local spell, rank, displayName, icon, startTime, endTime, isTradeSkill = UnitCastingInfo(self.unit)
self.actionDuration = endTime/1000 - self.actionStartTime
end
function IceCastBar.prototype:SpellCastSucceeded(unit, spell, rank)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastSucceeded", unit, spell, rank)
-- never show on channeled (why on earth does this event even fire when channeling starts?)
if (self.action == IceCastBar.Actions.Channel) then
return
end
-- show after normal successfull cast
if (self.action == IceCastBar.Actions.Cast) then
self:StartBar(IceCastBar.Actions.Success, spell.. self:GetShortRank(rank))
return
end
-- determine if we want to show instant casts
if (self.moduleSettings.flashInstants == "Never") then
return
elseif (self.moduleSettings.flashInstants == "Caster") then
if (UnitPowerType("player") ~= 0) then -- 0 == mana user
return
end
end
self:StartBar(IceCastBar.Actions.Success, spell.. self:GetShortRank(rank))
end
-------------------------------------------------------------------------------
-- CHANNELING SPELLS --
-------------------------------------------------------------------------------
function IceCastBar.prototype:SpellCastChannelStart(unit)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastChannelStart", unit)
self:StartBar(IceCastBar.Actions.Channel)
end
function IceCastBar.prototype:SpellCastChannelUpdate(unit)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastChannelUpdate", unit, UnitChannelInfo(unit))
local spell, rank, displayName, icon, startTime, endTime = UnitChannelInfo(unit)
self.actionDuration = endTime/1000 - self.actionStartTime
end
function IceCastBar.prototype:SpellCastChannelStop(unit)
if (unit ~= self.unit) then return end
--IceHUD:Debug("SpellCastChannelStop", unit)
self:StopBar()
end

View File

@ -4,6 +4,8 @@ IceCore = AceOO.Class("AceEvent-2.0", "AceDB-2.0")
IceCore.Side = { Left = "LEFT", Right = "RIGHT" }
IceCore.BuffLimit = 40
-- Events modules should register/trigger during load
IceCore.Loaded = "IceCore_Loaded"
IceCore.RegisterModule = "IceCore_RegisterModule"
@ -88,6 +90,10 @@ function IceCore.prototype:Enable()
end
end
-- try to catch what's causing the cockblock message
self:RegisterEvent("ADDON_ACTION_FORBIDDEN", "ActionForbidden")
self:RegisterEvent("ADDON_ACTION_BLOCKED", "ActionBlocked")
self.enabled = true
end
@ -178,6 +184,12 @@ function IceCore.prototype:Register(element)
end
function IceCore.prototype:ActionForbidden(addon, msg)
IceHUD:Debug("Action Forbidden. ", addon, " : ", msg)
end
function IceCore.prototype:ActionBlocked(addon, msg)
IceHUD:Debug("Action Blocked. ", addon, " : ", msg)
end
-------------------------------------------------------------------------------
-- Configuration methods --

View File

@ -239,7 +239,7 @@ function IceElement.prototype:ConvertToHex(color)
end
function IceElement.prototype:FontFactory(weight, size, frame, font)
function IceElement.prototype:FontFactory(weight, size, frame, font, flags)
local weightString = ""
if (weight) then
weightString = "Bold"
@ -260,9 +260,11 @@ function IceElement.prototype:FontFactory(weight, size, frame, font)
else
fontString = font
end
fontString:SetFont(fontFile, size)
fontString:SetFont(fontFile, size, flags)
if not (flags) then
fontString:SetShadowColor(0, 0, 0, 1)
fontString:SetShadowOffset(1, -1)
end
return fontString
end

View File

@ -458,7 +458,13 @@ IceHUD.slashMenu =
'dontHook', true
)
end
if not (UnitAffectingCombat("player")) then
IceHUD.dewdrop:Open(IceHUD.IceCore.IceHUDFrame)
else
DEFAULT_CHAT_FRAME:AddMessage("|cff8888ffIceHUD|r: Combat lockdown restriction." ..
" Leave combat and try again.")
end
end
}
@ -492,7 +498,6 @@ function IceHUD:OnEnable()
self:Debug("IceHUD:OnEnable()")
self.IceCore:Enable()
self:SetDebugging(self.IceCore:GetDebug())
self.debugFrame = ChatFrame2

View File

@ -1,11 +1,12 @@
## Interface: 11200
## Interface: 20000
## Author: Iceroth
## Name: IceHUD
## Title: IceHUD |cff7fff7f -Ace2-|r
## Notes: Another HUD mod
## Version: 0.7.7 ($Revision$)
## Notes: Another HUD addon
## Version: 0.8 ($Revision$)
## SavedVariables: IceCoreDB
## OptionalDeps: Ace2, DewdropLib, FuBar_ToFu, DruidBar, SoleManax, MobHealth, SpellStatusLib
## OptionalDeps: Ace2, DewdropLib, DruidBar, SoleManax, MobHealth
## X-Embeds: Ace2, DewdropLib
## X-Category: UnitFrame
## X-Date: $Date$
## X-eMail: iceroth@iceroth.net
@ -16,18 +17,10 @@ libs\AceLibrary\AceLibrary.lua
libs\AceOO-2.0\AceOO-2.0.lua
libs\AceDB-2.0\AceDB-2.0.lua
libs\AceEvent-2.0\AceEvent-2.0.lua
libs\AceHook-2.0\AceHook-2.0.lua
libs\AceDebug-2.0\AceDebug-2.0.lua
libs\AceLocale-2.0\AceLocale-2.0.lua
libs\AceConsole-2.0\AceConsole-2.0.lua
libs\AceAddon-2.0\AceAddon-2.0.lua
libs\Dewdrop-2.0\Dewdrop-2.0.lua
libs\Deformat-2.0\Deformat-2.0.lua
libs\Gratuity-2.0\Gratuity-2.0.lua
libs\Babble-Spell-2.0\Babble-Spell-2.0.lua
libs\SpellCache-1.0\SpellCache-1.0.lua
libs\SpellStatus-1.0\SpellStatus-1.0.lua
libs\SpellStatus-AimedShot-1.0\SpellStatus-AimedShot-1.0.lua
# IceHUD core functionality
@ -36,6 +29,7 @@ IceHUD.lua
IceElement.lua
IceBarElement.lua
IceUnitBar.lua
IceCastBar.lua
# IceHUD modules
modules\PlayerHealth.lua
@ -49,6 +43,6 @@ modules\TargetInfo.lua
modules\TargetOfTarget.lua
modules\ComboPoints.lua
modules\CastBar.lua
modules\TargetCast.lua
modules\MirrorBar.lua
modules\TimerBar.lua

View File

@ -1,33 +1,15 @@
local AceOO = AceLibrary("AceOO-2.0")
local SpellStatus = AceLibrary("SpellStatus-1.0")
local SpellCache = AceLibrary("SpellCache-1.0")
local CastBar = AceOO.Class(IceBarElement)
CastBar.Actions = { None = 0, Cast = 1, Channel = 2, Instant = 3, Success = 4, Failure = 5 }
CastBar.prototype.action = nil
CastBar.prototype.actionStartTime = nil
CastBar.prototype.actionMessage = nil
local CastBar = AceOO.Class(IceCastBar)
-- Constructor --
function CastBar.prototype:init()
CastBar.super.prototype.init(self, "CastBar")
self:SetDefaultColor("CastCasting", 242, 242, 10)
self:SetDefaultColor("CastChanneling", 117, 113, 161)
self:SetDefaultColor("CastSuccess", 242, 242, 70)
self:SetDefaultColor("CastFail", 1, 0, 0)
self.delay = 0
self.action = CastBar.Actions.None
self.unit = "player"
end
-- 'Public' methods -----------------------------------------------------------
-- OVERRIDE
@ -81,274 +63,6 @@ function CastBar.prototype:GetOptions()
return opts
end
function CastBar.prototype:Enable(core)
CastBar.super.prototype.Enable(self, core)
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
CastingBarFrame:UnregisterAllEvents()
end
function CastBar.prototype:Disable(core)
CastBar.super.prototype.Disable(self, core)
-- restore blizz cast bar
CastingBarFrame:RegisterEvent("SPELLCAST_START");
CastingBarFrame:RegisterEvent("SPELLCAST_STOP");
CastingBarFrame:RegisterEvent("SPELLCAST_FAILED");
CastingBarFrame:RegisterEvent("SPELLCAST_INTERRUPTED");
CastingBarFrame:RegisterEvent("SPELLCAST_DELAYED");
CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_START");
CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_UPDATE");
CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_STOP");
end
-- 'Protected' methods --------------------------------------------------------
-- OVERRIDE
function CastBar.prototype:CreateFrame()
CastBar.super.prototype.CreateFrame(self)
self.frame.bottomUpperText:SetWidth(self.settings.gap + 30)
end
-- OnUpdate handler
function CastBar.prototype:OnUpdate()
-- safety catch
if (self.action == CastBar.Actions.None) then
IceHUD:Debug("Stopping action ", self.action)
self:StopBar()
return
end
local spellId, spellName, spellRank, spellFullName, spellCastStartTime, spellCastStopTime, spellCastDuration, spellAction = SpellStatus:GetActiveSpellData()
local time = GetTime()
self:Update()
local spellRankShort = ""
if (spellRank) then
spellRankShort = " (" .. SpellCache:GetRankNumber(spellRank or '') .. ")"
end
-- handle casting and channeling
if (SpellStatus:IsCastingOrChanneling()) then
local remainingTime = spellCastStopTime - time
local scale = 1 - (remainingTime / (spellCastDuration/1000))
if (SpellStatus:IsChanneling()) then
scale = remainingTime / spellCastDuration
end
if (remainingTime < 0 and remainingTime > -1.5) then -- lag compensation
remainingTime = 0
end
-- sanity check to make sure the bar doesn't over/underfill
scale = scale > 1 and 1 or scale
scale = scale < 0 and 0 or scale
self:UpdateBar(scale, "CastCasting")
self:SetBottomText1(string.format("%.1fs %s%s", remainingTime , spellName, spellRankShort))
return
end
-- stop bar if casting or channeling is done (in theory this should not be needed)
if (self.action == CastBar.Actions.Cast or self.action == CastBar.Actions.Channel) then
self:StopBar()
return
end
-- handle instant casts
if (self.action == CastBar.Actions.Instant) then
local instanting = time - self.actionStartTime
if (instanting > 1) then
self:StopBar()
return
end
self:FlashBar("CastSuccess", 1-instanting, (spellName or '') .. spellRankShort)
return
end
-- show failure bar
if (self.action == CastBar.Actions.Fail) then
local failing = time - self.actionStartTime
if (failing > 1) then
self:StopBar()
return
end
self:FlashBar("CastFail", 1-failing, self.actionMessage, "CastFail")
return
end
-- flash bar on succesful casts
if (self.action == CastBar.Actions.Success) then
local succeeding = time - self.actionStartTime
if (succeeding > 1) then
self:StopBar()
return
end
if (succeeding < 0.15) then -- lag compensation
return
end
self:FlashBar("CastSuccess", 1-succeeding)
return
end
IceHUD:Debug("OnUpdate error ", self.action, " -- ", spellId, spellName, spellRank, spellFullName, spellCastStartTime, spellCastStopTime, spellCastDuration, spellAction)
end
function CastBar.prototype:FlashBar(color, alpha, text, textColor)
self.frame:SetAlpha(alpha)
local r, g, b = self.settings.backgroundColor.r, self.settings.backgroundColor.g, self.settings.backgroundColor.b
if (self.settings.backgroundToggle) then
r, g, b = self:GetColor(color)
end
self.frame:SetStatusBarColor(r, g, b, 0.3)
self.barFrame:SetStatusBarColor(self:GetColor(color, 0.8))
self:SetScale(self.barFrame.bar, 1)
self:SetBottomText1(text, textColor or "Text")
end
function CastBar.prototype:StartBar(action, message)
self.action = action
self.actionStartTime = GetTime()
self.actionMessage = message
self.frame:Show()
self.frame:SetScript("OnUpdate", function() self:OnUpdate() end)
end
function CastBar.prototype:StopBar()
self.action = CastBar.Actions.None
self.actionStartTime = nil
self.frame:Hide()
self.frame:SetScript("OnUpdate", nil)
end
-------------------------------------------------------------------------------
-- INSTANT SPELLS --
-------------------------------------------------------------------------------
function CastBar.prototype:SpellStatus_SpellCastInstant(sId, sName, sRank, sFullName, sCastTime)
IceHUD:Debug("SpellStatus_SpellCastInstant", sId, sName, sRank, sFullName, sCastTime)
-- determine if we want to show instant casts
if (self.moduleSettings.flashInstants == "Never") then
return
elseif (self.moduleSettings.flashInstants == "Caster") then
if (UnitPowerType("player") ~= 0) then -- 0 == mana user
return
end
end
self:StartBar(CastBar.Actions.Instant)
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:StartBar(CastBar.Actions.Cast)
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:StartBar(CastBar.Actions.Success)
end
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)
-- do nothing if we are casting a spell but the error doesn't consern that spell
if (SpellStatus:IsCastingOrChanneling() and not SpellStatus:IsActiveSpell(sId, sName)) then
return
end
-- determine if we want to show failed casts
if (self.moduleSettings.flashFailures == "Never") then
return
elseif (self.moduleSettings.flashFailures == "Caster") then
if (UnitPowerType("player") ~= 0) then -- 0 == mana user
return
end
end
self:StartBar(CastBar.Actions.Fail, UIEM_Message)
end
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)
end
-------------------------------------------------------------------------------
-- 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:StartBar(CastBar.Actions.Channel)
end
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:StopBar()
end
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)
end
-------------------------------------------------------------------------------

View File

@ -91,7 +91,7 @@ function MirrorBar.prototype:OnUpdate(elapsed)
local text = self.label .. " " .. remaining .. "s"
if (math.mod(self.moduleSettings.offset, 2) == 1) then
if (math.fmod(self.moduleSettings.offset, 2) == 1) then
self:SetBottomText1(text)
self:SetBottomText2()
else

57
modules/TargetCast.lua Normal file
View File

@ -0,0 +1,57 @@
local AceOO = AceLibrary("AceOO-2.0")
local TargetCast = AceOO.Class(IceCastBar)
-- Constructor --
function TargetCast.prototype:init()
TargetCast.super.prototype.init(self, "TargetCast")
self.unit = "target"
end
-- 'Public' methods -----------------------------------------------------------
-- OVERRIDE
function TargetCast.prototype:GetDefaultSettings()
local settings = TargetCast.super.prototype.GetDefaultSettings(self)
settings["side"] = IceCore.Side.Right
settings["offset"] = 3
settings["flashInstants"] = "Never"
settings["flashFailures"] = "Never"
return settings
end
-- OVERRIDE
function TargetCast.prototype:Enable(core)
TargetCast.super.prototype.Enable(self, core)
self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged")
end
function TargetCast.prototype:TargetChanged(unit)
if not (UnitExists(self.unit)) then
self:StopBar()
return
end
local spell = UnitCastingInfo(self.unit)
if (spell) then
self:StartBar(IceCastBar.Actions.Cast)
return
end
local channel = UnitChannelInfo(self.unit)
if (channel) then
self:StartBar(IceCastBar.Actions.Channel)
return
end
end
-------------------------------------------------------------------------------
-- Load us up
TargetCast:new()

View File

@ -1,6 +1,6 @@
local AceOO = AceLibrary("AceOO-2.0")
local TargetHealth = AceOO.Class(IceUnitBar, "AceHook-2.0")
local TargetHealth = AceOO.Class(IceUnitBar)
TargetHealth.prototype.color = nil
@ -95,6 +95,7 @@ function TargetHealth.prototype:Enable(core)
self:RegisterEvent("UNIT_HEALTH", "Update")
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
self:RegisterEvent("UNIT_FLAGS", "Update")
self:RegisterEvent("UNIT_FACTION", "Update")
if (self.moduleSettings.hideBlizz) then
self:HideBlizz()

View File

@ -11,7 +11,6 @@ TargetInfo.prototype.width = nil
TargetInfo.prototype.name = nil
TargetInfo.prototype.guild = nil
TargetInfo.prototype.realm = nil
TargetInfo.prototype.rank = nil
TargetInfo.prototype.classLocale = nil
TargetInfo.prototype.classEnglish = nil
TargetInfo.prototype.leader = nil
@ -22,7 +21,6 @@ TargetInfo.prototype.level = nil
TargetInfo.prototype.classification = nil
TargetInfo.prototype.reaction = nil
TargetInfo.prototype.tapped = nil
TargetInfo.prototype.pvpRank = nil
TargetInfo.prototype.isPlayer = nil
@ -152,7 +150,7 @@ function TargetInfo.prototype:GetOptions()
self:RedrawBuffs()
end,
min = 8,
max = 20,
max = 30,
step = 1,
disabled = function()
return not self.moduleSettings.enabled
@ -160,24 +158,78 @@ function TargetInfo.prototype:GetOptions()
order = 34
}
opts["mouse"] = {
type = 'toggle',
name = 'Mouseover',
desc = 'Toggle mouseover on/off',
opts["filter"] = {
type = 'text',
name = 'Filter buffs/debuffs',
desc = 'Toggles filtering buffs and debuffs (uses Blizzard default filter code)',
get = function()
return self.moduleSettings.mouse
return self.moduleSettings.filter
end,
set = function(v)
self.moduleSettings.mouse = v
self:Redraw()
self.moduleSettings.filter = v
self:RedrawBuffs()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
validate = { "Never", "In Combat", "Always" },
order = 35
}
opts["perRow"] = {
type = 'range',
name = 'Buffs / row',
desc = 'How many buffs/debuffs is shown on each row',
get = function()
return self.moduleSettings.perRow
end,
set = function(v)
self.moduleSettings.perRow = v
self:RedrawBuffs()
end,
min = 5,
max = 20,
step = 1,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 36
}
opts["mouseTarget"] = {
type = 'toggle',
name = 'Mouseover for target',
desc = 'Toggle mouseover on/off for target',
get = function()
return self.moduleSettings.mouseTarget
end,
set = function(v)
self.moduleSettings.mouseTarget = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 37
}
opts["mouseBuff"] = {
type = 'toggle',
name = 'Mouseover for buffs',
desc = 'Toggle mouseover on/off for buffs/debuffs',
get = function()
return self.moduleSettings.mouseBuff
end,
set = function(v)
self.moduleSettings.mouseBuff = v
self:RedrawBuffs()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 38
}
return opts
end
@ -190,7 +242,10 @@ function TargetInfo.prototype:GetDefaultSettings()
defaults["vpos"] = -50
defaults["zoom"] = 0.08
defaults["buffSize"] = 14
defaults["mouse"] = true
defaults["mouseTarget"] = true
defaults["mouseBuff"] = true
defaults["filter"] = "Never"
defaults["perRow"] = 10
return defaults
end
@ -221,17 +276,61 @@ end
-- OVERRIDE
function TargetInfo.prototype:CreateFrame(redraw)
TargetInfo.super.prototype.CreateFrame(self)
if not (self.frame) then
self.frame = CreateFrame("Button", "IceHUD_"..self.elementName, self.parent, "SecureUnitButtonTemplate")
end
self.width = self.settings.gap + 50
self.frame:SetScale(self.moduleSettings.scale)
-- register showing/hiding the frame depending on current target
self.frame:SetAttribute("unit", target)
RegisterUnitWatch(self.frame)
self.frame:SetFrameStrata("BACKGROUND")
self.frame:SetWidth(self.width)
self.frame:SetHeight(42)
self.frame:SetHeight(32)
self.frame:ClearAllPoints()
self.frame:SetPoint("TOP", self.parent, "BOTTOM", 0, self.moduleSettings.vpos)
self.frame:SetScale(self.moduleSettings.scale)
if (self.moduleSettings.mouseTarget) then
self.frame:EnableMouse(true)
self.frame:RegisterForClicks("AnyUp")
self.frame:SetScript("OnEnter", function() self:OnEnter() end)
self.frame:SetScript("OnLeave", function() self:OnLeave() end)
else
self.frame:EnableMouse(false)
self.frame:RegisterForClicks()
self.frame:SetScript("OnEnter", nil)
self.frame:SetScript("OnLeave", nil)
end
self.frame.unit = target
-- set up stuff for clicking
self.frame:SetAttribute("type1", "target")
self.frame:SetAttribute("type2", "menu")
self.frame:SetAttribute("unit", target)
self.frame.menu = function()
ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor")
end
-- create a fancy highlight frame for mouse over
if (not self.frame.highLight) then
self.frame.highLight = self.frame:CreateTexture(nil, "OVERLAY")
self.frame.highLight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
self.frame.highLight:SetBlendMode("ADD")
self.frame.highLight:SetAllPoints(self.frame)
self.frame.highLight:SetVertexColor(1, 1, 1, 0.25)
self.frame.highLight:Hide()
end
-- create rest of the frames
self:CreateTextFrame()
self:CreateInfoTextFrame()
self:CreateGuildTextFrame()
@ -241,53 +340,18 @@ function TargetInfo.prototype:CreateFrame(redraw)
self:CreateRaidIconFrame()
self.frame:Hide()
-- set up click casting
ClickCastFrames = ClickCastFrames or {}
ClickCastFrames[self.frame] = true
end
function TargetInfo.prototype:CreateTextFrame()
if (not self.frame.target) then
self.frame.target = CreateFrame("Button", "IceHUD_TargetInfo_Name", self.frame)
end
self.frame.target.unit = target -- for blizz default tooltip handling
if (self.moduleSettings.mouse) then
self.frame.target:EnableMouse(true)
self.frame.target:RegisterForClicks("LeftButtonUp", "RightButtonUp")
self.frame.target:SetScript("OnClick", function() self:OnClick(arg1) end)
self.frame.target:SetScript("OnEnter", function() self:OnEnter() end)
self.frame.target:SetScript("OnLeave", function() self:OnLeave() end)
else
self.frame.target:EnableMouse(false)
self.frame.target:RegisterForClicks()
self.frame.target:SetScript("OnClick", nil)
self.frame.target:SetScript("OnEnter", nil)
self.frame.target:SetScript("OnLeave", nil)
end
self.frame.target:SetWidth(self.width)
self.frame.target:SetHeight(14)
self.frame.target:SetPoint("TOP", self.frame, "TOP", 0, -2)
self.frame.targetName = self:FontFactory("Bold", self.moduleSettings.fontSize+1, nil, self.frame.targetName)
self.frame.targetName:SetJustifyH("CENTER")
self.frame.targetName:SetJustifyV("TOP")
self.frame.targetName:SetAllPoints(self.frame.target)
if (not self.frame.target.highLight) then
self.frame.target.highLight = self.frame.target:CreateTexture(nil, "OVERLAY")
self.frame.target.highLight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
self.frame.target.highLight:SetBlendMode("ADD")
self.frame.target.highLight:SetAllPoints(self.frame.target)
self.frame.target.highLight:SetVertexColor(1, 1, 1, 0.25)
self.frame.target.highLight:Hide()
end
self.frame.target:Hide()
self.frame.targetName:SetAllPoints(self.frame)
end
@ -314,7 +378,7 @@ function TargetInfo.prototype:CreateGuildTextFrame()
self.frame.targetGuild:SetAlpha(0.6)
self.frame.targetGuild:SetPoint("TOP", self.frame, "TOP", 0, -30)
self.frame.targetGuild:SetPoint("TOP", self.frame, "BOTTOM", 0, 0)
self.frame.targetGuild:Show()
end
@ -382,7 +446,7 @@ end
function TargetInfo.prototype:CreateIconFrames(parent, direction, buffs, type)
for i = 1, 16 do
for i = 1, IceCore.BuffLimit do
if (not buffs[i]) then
buffs[i] = CreateFrame("Frame", nil, parent)
buffs[i].icon = CreateFrame("Frame", nil, buffs[i])
@ -396,13 +460,18 @@ function TargetInfo.prototype:CreateIconFrames(parent, direction, buffs, type)
buffs[i].icon:SetWidth(self.moduleSettings.buffSize-2)
buffs[i].icon:SetHeight(self.moduleSettings.buffSize-2)
local pos = (i > 8) and i-8 or i
local x = (((pos-1) * self.moduleSettings.buffSize) + (pos-0)) * direction
local y = (i > 8) and -self.moduleSettings.buffSize-1 or 0
local pos = math.fmod(i, self.moduleSettings.perRow)
if (pos == 0) then
pos = self.moduleSettings.perRow
end
local x = (((pos-1) * self.moduleSettings.buffSize) + pos) * direction
local y = math.floor((i-1) / self.moduleSettings.perRow) * self.moduleSettings.buffSize * -1
buffs[i]:ClearAllPoints()
buffs[i]:SetPoint("TOP", x, y)
buffs[i].icon:ClearAllPoints()
buffs[i].icon:SetPoint("CENTER", 0, 0)
@ -421,14 +490,16 @@ function TargetInfo.prototype:CreateIconFrames(parent, direction, buffs, type)
buffs[i].icon.texture:SetAllPoints(buffs[i].icon)
end
buffs[i].icon.stack = self:FontFactory("Bold", self.moduleSettings.stackFontSize, buffs[i].icon)
buffs[i].icon.stack =
self:FontFactory("Bold", self.moduleSettings.stackFontSize,buffs[i].icon,
buffs[i].icon.stack, "OUTLINE")
buffs[i].icon.stack:ClearAllPoints()
buffs[i].icon.stack:SetPoint("BOTTOMRIGHT" , buffs[i].icon, "BOTTOMRIGHT", 1, -1)
buffs[i].icon.stack:SetPoint("BOTTOMRIGHT" , buffs[i].icon, "BOTTOMRIGHT", 3, -1)
buffs[i].id = i
if (self.moduleSettings.mouse) then
if (self.moduleSettings.mouseBuff) then
buffs[i]:EnableMouse(true)
buffs[i]:SetScript("OnEnter", function() self:BuffOnEnter(type) end)
buffs[i]:SetScript("OnLeave", function() GameTooltip:Hide() end)
@ -447,11 +518,21 @@ end
function TargetInfo.prototype:UpdateBuffs()
local zoom = self.moduleSettings.zoom
local filter = false
for i = 1, 16 do
local buffTexture, buffApplications = UnitBuff("target", i)
if (self.moduleSettings.filter == "Always") then
filter = true
elseif (self.moduleSettings.filter == "In Combat") then
if (UnitAffectingCombat("player")) then
filter = true
end
end
--buffTexture = buffTexture or "Interface\\Icons\\Spell_Nature_Regeneration"
for i = 1, IceCore.BuffLimit do
local buffName, buffRank, buffTexture, buffApplications = UnitBuff("target", i, filter)
--buffTexture = buffTexture or "Interface\\Icons\\Ability_Racial_BloodRage"
self.frame.buffFrame.buffs[i].icon.texture:SetTexture(buffTexture)
self.frame.buffFrame.buffs[i].icon.texture:SetTexCoord(zoom, 1-zoom, zoom, 1-zoom)
@ -460,7 +541,7 @@ function TargetInfo.prototype:UpdateBuffs()
self.frame.buffFrame.buffs[i].texture:SetTexture(0, 0, 0, alpha)
--buffApplications = 2
--buffApplications = i
if (buffApplications and (buffApplications > 1)) then
self.frame.buffFrame.buffs[i].icon.stack:SetText(buffApplications)
@ -476,8 +557,8 @@ function TargetInfo.prototype:UpdateBuffs()
end
for i = 1, 16 do
local buffTexture, buffApplications, debuffDispelType = UnitDebuff("target", i)
for i = 1, IceCore.BuffLimit do
local buffName, buffRank, buffTexture, buffApplications, debuffDispelType = UnitDebuff("target", i, filter)
--buffTexture = buffTexture or "Interface\\Icons\\Ability_Creature_Disease_04"
@ -487,6 +568,7 @@ function TargetInfo.prototype:UpdateBuffs()
self.frame.debuffFrame.buffs[i].texture:SetVertexColor(color.r, color.g, color.b)
--buffApplications = i
self.frame.debuffFrame.buffs[i].icon.texture:SetTexture(buffTexture)
self.frame.debuffFrame.buffs[i].icon.texture:SetTexCoord(zoom, 1-zoom, zoom, 1-zoom)
@ -534,8 +616,8 @@ end
function TargetInfo.prototype:TargetChanged()
if (not UnitExists(target)) then
self.frame:Hide()
self.frame.target:Hide()
--self.frame:Hide()
--self.frame.target:Hide()
self.frame.targetName:SetText()
self.frame.targetInfo:SetText()
@ -546,15 +628,13 @@ function TargetInfo.prototype:TargetChanged()
return
end
self.frame:Show()
self.frame.target:Show()
--self.frame:Show()
--self.frame.target:Show()
self.name, self.realm = UnitName(target)
self.classLocale, self.classEnglish = UnitClass(target)
self.isPlayer = UnitIsPlayer(target)
local rank = UnitPVPRank(target)
self.pvpRank = (rank >= 5) and rank-4 or nil
local classification = UnitClassification(target)
if (string.find(classification, "boss")) then
@ -638,18 +718,15 @@ function TargetInfo.prototype:TargetFaction(unit)
if (UnitFactionGroup(target) ~= UnitFactionGroup("player")) then
color = "ffff1010" -- hostile
end
self.pvp = " |c" .. color .. "PvP"
self.pvp = " |c" .. color .. "PvP|r"
else
self.pvp = " |cff1010ffPvE"
self.pvp = " |cff1010ffPvE|r"
end
-- add rank
self.pvp = self.pvpRank and (self.pvp .. "/" .. self.pvpRank .. "|r") or (self.pvp .. "|r")
else
self.pvp = ""
end
self:TargetReaction(unit)
self:Update(unit)
end
end
@ -659,6 +736,7 @@ function TargetInfo.prototype:TargetFlags(unit)
if (unit == target or unit == internal) then
self.tapped = UnitIsTapped(target) and (not UnitIsTappedByPlayer(target))
self.combat = UnitAffectingCombat(target) and " |cffee4030Combat|r" or ""
self:UpdateBuffs()
self:Update(unit)
end
end
@ -687,35 +765,15 @@ function TargetInfo.prototype:Update(unit)
end
function TargetInfo.prototype:OnClick(button)
-- copy&paste from blizz code, it better work ;)
if (SpellIsTargeting() and button == "RightButton") then
SpellStopTargeting()
return
end
if (button == "LeftButton") then
if (SpellIsTargeting()) then
SpellTargetUnit(target)
elseif (CursorHasItem()) then
DropItemOnUnit(target)
end
else
ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor")
end
end
function TargetInfo.prototype:OnEnter()
UnitFrame_OnEnter()
self.frame.target.highLight:Show()
self.frame.highLight:Show()
end
function TargetInfo.prototype:OnLeave()
UnitFrame_OnLeave()
self.frame.target.highLight:Hide()
self.frame.highLight:Hide()
end

View File

@ -6,6 +6,7 @@ TargetOfTarget.prototype.stackedDebuffs = nil
TargetOfTarget.prototype.buffSize = nil
TargetOfTarget.prototype.height = nil
TargetOfTarget.prototype.unit = nil
TargetOfTarget.prototype.hadTarget = nil
-- Constructor --
@ -16,6 +17,7 @@ function TargetOfTarget.prototype:init()
self.height = 12
self.stackedDebuffs = {}
self.unit = "targettarget"
self.hadTarget = false
self.scalingEnabled = true
end
@ -129,7 +131,7 @@ function TargetOfTarget.prototype:Enable(core)
self:RegisterEvent("PLAYER_TARGET_CHANGED", "Update")
self:ScheduleRepeatingEvent(self.elementName, self.Update, 0.2, self)
self:ScheduleRepeatingEvent(self.elementName, self.Update, 0.3, self)
self:Update()
end
@ -146,7 +148,9 @@ end
-- OVERRIDE
function TargetOfTarget.prototype:CreateFrame()
if not (self.frame) then
self.frame = CreateFrame("Button", "IceHUD_"..self.elementName, self.parent)
self.frame = CreateFrame("Button", "IceHUD_"..self.elementName, self.parent, "SecureUnitButtonTemplate")
self.frame:SetAttribute("unit", self.unit)
RegisterUnitWatch(self.frame)
end
self.frame:SetFrameStrata("BACKGROUND")
@ -162,27 +166,35 @@ function TargetOfTarget.prototype:CreateFrame()
self.frame.texture:SetAllPoints(self.frame)
end
self.frame.unit = self.unit -- for blizz default tooltip handling
if (self.moduleSettings.mouse) then
self.frame:EnableMouse(true)
self.frame:RegisterForClicks("LeftButtonUp", "RightButtonUp")
self.frame:SetScript("OnClick", function() self:OnClick(arg1) end)
self.frame:RegisterForClicks("AnyUp")
self.frame:SetScript("OnEnter", function() self:OnEnter() end)
self.frame:SetScript("OnLeave", function() self:OnLeave() end)
else
self.frame:EnableMouse(false)
self.frame:RegisterForClicks()
self.frame:SetScript("OnClick", nil)
self.frame:SetScript("OnEnter", nil)
self.frame:SetScript("OnLeave", nil)
end
self.frame:SetAttribute("type1", "target")
self.frame:SetAttribute("unit", self.unit)
self:CreateBarFrame()
self:CreateToTFrame()
self:CreateToTHPFrame()
self:CreateDebuffFrame()
-- click casting support
ClickCastFrames = ClickCastFrames or {}
ClickCastFrames[self.frame] = true
end
@ -255,7 +267,7 @@ function TargetOfTarget.prototype:CreateDebuffFrame()
self.frame.debuffFrame:SetWidth(10)
self.frame.debuffFrame:SetHeight(self.height)
self.frame.debuffFrame:SetPoint("TOPLEFT", self.frame, "TOPRIGHT", 4, 0)
self.frame.debuffFrame:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT", 0, -2)
self.frame.debuffFrame:Show()
self.frame.debuffFrame.buffs = self:CreateIconFrames(self.frame.debuffFrame)
@ -265,7 +277,7 @@ end
function TargetOfTarget.prototype:CreateIconFrames(parent)
local buffs = {}
for i = 1, 16 do
for i = 1, IceCore.BuffLimit do
buffs[i] = CreateFrame("Frame", nil, parent)
buffs[i]:SetFrameStrata("BACKGROUND")
buffs[i]:SetWidth(self.buffSize)
@ -277,8 +289,20 @@ function TargetOfTarget.prototype:CreateIconFrames(parent)
buffs[i].texture:SetTexture(nil)
buffs[i].texture:SetAllPoints(buffs[i])
buffs[i].stack = self:FontFactory("Bold", 11, buffs[i])
buffs[i].stack:SetPoint("BOTTOMRIGHT" , buffs[i], "BOTTOMRIGHT", 0, -1)
buffs[i].stack = self:FontFactory("Bold", 11, buffs[i], buffs[i].stack, "OUTLINE")
buffs[i].stack:SetPoint("BOTTOMRIGHT" , buffs[i], "BOTTOMRIGHT", 2, -1)
if (self.moduleSettings.mouse) then
buffs[i]:EnableMouse(true)
buffs[i]:SetScript("OnEnter", function() self:BuffOnEnter() end)
buffs[i]:SetScript("OnLeave", function() GameTooltip:Hide() end)
else
buffs[i]:EnableMouse(false)
buffs[i]:SetScript("OnEnter", nil)
buffs[i]:SetScript("OnLeave", nil)
end
buffs[i].unit = self.unit
end
return buffs
end
@ -288,8 +312,8 @@ function TargetOfTarget.prototype:UpdateBuffs()
local debuffs = 0
if (self.moduleSettings.showDebuffs) then
for i = 1, 16 do
local buffTexture, buffApplications = UnitDebuff(self.unit, i)
for i = 1, IceCore.BuffLimit do
local buffName, buffRank, buffTexture, buffApplications = UnitDebuff(self.unit, i)
if (buffApplications and (buffApplications > 1)) then
debuffs = debuffs + 1
@ -300,33 +324,43 @@ function TargetOfTarget.prototype:UpdateBuffs()
self.stackedDebuffs[debuffs].texture = buffTexture
self.stackedDebuffs[debuffs].count = buffApplications
self.stackedDebuffs[debuffs].id = i
end
end
end
for i = 1, 16 do
for i = 1, IceCore.BuffLimit do
if (self.moduleSettings.showDebuffs and (i <= debuffs)) then
self.frame.debuffFrame.buffs[i]:Show()
self.frame.debuffFrame.buffs[i].texture:SetTexture(self.stackedDebuffs[i].texture)
self.frame.debuffFrame.buffs[i].stack:SetText(self.stackedDebuffs[i].count)
self.frame.debuffFrame.buffs[i].id = self.stackedDebuffs[debuffs].id
else
self.frame.debuffFrame.buffs[i]:Hide()
self.frame.debuffFrame.buffs[i].texture:SetTexture(nil)
self.frame.debuffFrame.buffs[i].stack:SetText(nil)
self.frame.debuffFrame.buffs[i].id = nil
end
end
end
function TargetOfTarget.prototype:Update()
self:UpdateBuffs()
if not (UnitExists(self.unit)) then
if not (self.hadTarget) then
return
end
self.hadTarget = false
self.frame.totName:SetText()
self.frame.totHealth:SetText()
self.frame:Hide()
self:UpdateBuffs()
return
end
self.frame:Show()
self.hadTarget = true
self:UpdateBuffs()
local _, unitClass = UnitClass(self.unit)
local name = UnitName(self.unit)
@ -362,26 +396,14 @@ function TargetOfTarget.prototype:OnLeave()
end
function TargetOfTarget.prototype:OnClick(button)
-- copy&paste from blizz code, it better work ;)
if (SpellIsTargeting() and button == "RightButton") then
SpellStopTargeting()
function TargetOfTarget.prototype:BuffOnEnter(type)
if (not this:IsVisible()) then
return
end
if (button == "LeftButton") then
if (SpellIsTargeting()) then
SpellTargetUnit(self.unit)
elseif (CursorHasItem()) then
DropItemOnUnit(self.unit)
else
TargetUnit(self.unit)
GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT")
GameTooltip:SetUnitDebuff(this.unit, this.id)
end
else
TargetUnit(self.unit)
end
end
-- load us up
IceHUD_Module_TargetOfTarget = TargetOfTarget:new()

View File

@ -1,72 +0,0 @@
local AceOO = AceLibrary("AceOO-2.0")
local TimerBar = AceOO.Class(IceBarElement, "AceHook-2.0")
local abacus = nil
-- Constructor --
function TimerBar.prototype:init()
TimerBar.super.prototype.init(self, "TimerBar")
self:SetDefaultColor("TimerFlight", 0.2, 0.7, 0.7)
end
-- 'Public' methods -----------------------------------------------------------
function TimerBar.prototype:GetDefaultSettings()
local settings = TimerBar.super.prototype.GetDefaultSettings(self)
settings["side"] = IceCore.Side.Right
settings["offset"] = 3
return settings
end
function TimerBar.prototype:Enable(core)
TimerBar.super.prototype.Enable(self, core)
self.frame.bottomUpperText:SetWidth(180)
self.frame:Hide()
self:Hook(ToFu, "OnTextUpdate")
end
function TimerBar.prototype:Disable(core)
TimerBar.super.prototype.Disable(self, core)
self:Unhook(ToFu, "OnTextUpdate")
end
-- 'Protected' methods --------------------------------------------------------
function TimerBar.prototype:OnTextUpdate(object)
self.hooks[object].OnTextUpdate.orig(object)
if (ToFu.inFlight) then
if (ToFu.timeAvg ~= 0) then
local timeRemaining = ToFu.timeAvg - ToFu.timeFlown
self.frame:Show()
self:UpdateBar(timeRemaining / ToFu.timeAvg, "TimerFlight")
self:Update()
local text = abacus:FormatDurationCondensed(timeRemaining, true)
self:SetBottomText1(text)
return
end
end
self.frame:Hide()
end
-- Load us up
if (IsAddOnLoaded("FuBar_ToFu")) then
abacus = AceLibrary("Abacus-2.0")
TimerBar:new()
end