Files
ice-hud/modules/FocusCast.lua
Parnic ba8748ecca First batch of WoW Classic compatibility updates
This has been tested on Classic with a Rogue up to level 5 using various modules and casually checked against a few level 1 classes. I'm sure there's a lot more to do here. I also made sure to test on Live.

Where possible I tried to check for API availability rather than specific client versions or program IDs. There are many cases where that's impractical, however, so version/program ID checks were used.

This was tested with:
* Ace3 @r1225
* AceGUI-3.0-SharedMediaWidgets @r61
* LibDBIcon-1.0 @v8.2.0
* LibDogTag-3.0 @v80200.1
* LibDogTag-Unit-3.0 @v80200.1-2-g93a898d-alpha
* LibRangeCheck-2.0 @v4.2.3 (with a couple of local changes)
* LibSharedMedia-3.0 @r113-alpha
2019-08-11 23:21:06 -05:00

124 lines
2.6 KiB
Lua

local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
local FocusCast = IceCore_CreateClass(IceCastBar)
local UnitCastingInfo, UnitChannelInfo = UnitCastingInfo, UnitChannelInfo
if IceHUD.WowClassic then
UnitCastingInfo = CastingInfo
UnitChannelInfo = ChannelInfo
end
-- Constructor --
function FocusCast.prototype:init()
FocusCast.super.prototype.init(self, "FocusCast")
self.unit = "focus"
end
-- 'Public' methods -----------------------------------------------------------
-- OVERRIDE
function FocusCast.prototype:GetDefaultSettings()
local settings = FocusCast.super.prototype.GetDefaultSettings(self)
settings["side"] = IceCore.Side.Right
settings["offset"] = -3
settings["scale"] = 0.7
settings["flashInstants"] = "Never"
settings["flashFailures"] = "Never"
settings["shouldAnimate"] = false
settings["hideAnimationSettings"] = true
settings["usesDogTagStrings"] = false
settings["enabled"] = false
settings["barVerticalOffset"] = 35
return settings
end
-- OVERRIDE
function FocusCast.prototype:Enable(core)
FocusCast.super.prototype.Enable(self, core)
self:RegisterEvent("PLAYER_FOCUS_CHANGED", "FocusChanged")
end
function FocusCast.prototype:FocusChanged(event, 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
self:StopBar()
end
function FocusCast.prototype:GetOptions()
local opts = FocusCast.super.prototype.GetOptions(self)
opts["barVisible"] = {
type = 'toggle',
name = L["Bar visible"],
desc = L["Toggle bar visibility"],
get = function()
return self.moduleSettings.barVisible['bar']
end,
set = function(info, v)
self.moduleSettings.barVisible['bar'] = v
if v then
self.barFrame:Show()
else
self.barFrame:Hide()
end
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 28
}
opts["bgVisible"] = {
type = 'toggle',
name = L["Bar background visible"],
desc = L["Toggle bar background visibility"],
get = function()
return self.moduleSettings.barVisible['bg']
end,
set = function(info, v)
self.moduleSettings.barVisible['bg'] = v
if v then
self.frame.bg:Show()
else
self.frame.bg:Hide()
end
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 29
}
return opts
end
-------------------------------------------------------------------------------
-- Load us up
if FocusUnit then
IceHUD.FocusCast = FocusCast:new()
end