mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
- fix for custom modules generating a ton of errors if they're disabled while active (such as when changing profiles). there is still a bug where they stop running their updates like they're supposed to, but this will at least take care of the error spam
This commit is contained in:
@ -61,6 +61,12 @@ function IceBarElement.prototype:Enable()
|
|||||||
self:RegisterFontStrings()
|
self:RegisterFontStrings()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function IceBarElement.prototype:Disable(core)
|
||||||
|
IceBarElement.super.prototype.Disable(self, core)
|
||||||
|
|
||||||
|
self.frame:SetScript("OnUpdate", nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function IceBarElement.prototype:RegisterFontStrings()
|
function IceBarElement.prototype:RegisterFontStrings()
|
||||||
if DogTag ~= nil and self.moduleSettings ~= nil and self.moduleSettings.usesDogTagStrings then
|
if DogTag ~= nil and self.moduleSettings ~= nil and self.moduleSettings.usesDogTagStrings then
|
||||||
|
29
IceCore.lua
29
IceCore.lua
@ -25,7 +25,6 @@ IceCore.prototype.defaults = {}
|
|||||||
IceCore.prototype.settings = nil
|
IceCore.prototype.settings = nil
|
||||||
IceCore.prototype.IceHUDFrame = nil
|
IceCore.prototype.IceHUDFrame = nil
|
||||||
IceCore.prototype.updatees = {}
|
IceCore.prototype.updatees = {}
|
||||||
IceCore.prototype.updatee_count = 0
|
|
||||||
IceCore.prototype.update_elapsed = 0
|
IceCore.prototype.update_elapsed = 0
|
||||||
IceCore.prototype.elements = {}
|
IceCore.prototype.elements = {}
|
||||||
IceCore.prototype.enabled = nil
|
IceCore.prototype.enabled = nil
|
||||||
@ -295,6 +294,13 @@ function IceCore.prototype:Disable(userToggle)
|
|||||||
|
|
||||||
self.IceHUDFrame:Hide()
|
self.IceHUDFrame:Hide()
|
||||||
self:EmptyUpdates()
|
self:EmptyUpdates()
|
||||||
|
|
||||||
|
for i=#self.elements, 1, -1 do
|
||||||
|
if self.elements[i].moduleSettings.customBarType ~= nil then
|
||||||
|
table.remove(self.elements, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.enabled = false
|
self.enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -661,8 +667,9 @@ function IceCore.prototype:SetUpdatePeriod(period)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- For elements that want to receive updates even when hidden
|
-- For elements that want to receive updates even when hidden
|
||||||
function IceCore.HandleUpdates(frame, elapsed)
|
function IceCore.HandleUpdates()
|
||||||
local update_period = IceHUD.IceCore:UpdatePeriod()
|
local update_period = IceHUD.IceCore:UpdatePeriod()
|
||||||
|
local elapsed = 1 / GetFramerate()
|
||||||
IceCore.prototype.update_elapsed = IceCore.prototype.update_elapsed + elapsed
|
IceCore.prototype.update_elapsed = IceCore.prototype.update_elapsed + elapsed
|
||||||
if (IceCore.prototype.update_elapsed > update_period) then
|
if (IceCore.prototype.update_elapsed > update_period) then
|
||||||
for frame, func in pairs(IceCore.prototype.updatees)
|
for frame, func in pairs(IceCore.prototype.updatees)
|
||||||
@ -678,23 +685,18 @@ function IceCore.HandleUpdates(frame, elapsed)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function IceCore.prototype:RequestUpdates(frame, func)
|
function IceCore.prototype:RequestUpdates(frame, func)
|
||||||
if self.updatees[frame] then
|
self.updatees[frame] = func
|
||||||
if not func then
|
|
||||||
self.updatee_count = self.updatee_count - 1
|
local count = 0
|
||||||
end
|
for k,v in pairs(self.updatees) do
|
||||||
else
|
count = count + 1
|
||||||
if func then
|
|
||||||
self.updatee_count = self.updatee_count + 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.updatee_count == 0) then
|
if (count == 0) then
|
||||||
self.IceHUDFrame:SetScript("OnUpdate", nil)
|
self.IceHUDFrame:SetScript("OnUpdate", nil)
|
||||||
else
|
else
|
||||||
self.IceHUDFrame:SetScript("OnUpdate", IceCore.HandleUpdates)
|
self.IceHUDFrame:SetScript("OnUpdate", IceCore.HandleUpdates)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.updatees[frame] = func
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function IceCore.prototype:IsUpdateSubscribed(frame)
|
function IceCore.prototype:IsUpdateSubscribed(frame)
|
||||||
@ -704,7 +706,6 @@ end
|
|||||||
function IceCore.prototype:EmptyUpdates()
|
function IceCore.prototype:EmptyUpdates()
|
||||||
self.IceHUDFrame:SetScript("OnUpdate", nil)
|
self.IceHUDFrame:SetScript("OnUpdate", nil)
|
||||||
self.updatees = {}
|
self.updatees = {}
|
||||||
self.updatee_count = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
@ -33,7 +33,7 @@ function IceCustomBar.prototype:Enable(core)
|
|||||||
self:Show(true)
|
self:Show(true)
|
||||||
|
|
||||||
self.unit = self.moduleSettings.myUnit
|
self.unit = self.moduleSettings.myUnit
|
||||||
self:CheckShouldSubscribe()
|
self:ConditionalSubscribe()
|
||||||
|
|
||||||
self:UpdateCustomBar(self.unit)
|
self:UpdateCustomBar(self.unit)
|
||||||
|
|
||||||
@ -45,14 +45,18 @@ function IceCustomBar.prototype:Enable(core)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function IceCustomBar.prototype:CheckShouldSubscribe()
|
function IceCustomBar.prototype:ConditionalSubscribe()
|
||||||
if self.unit == "focustarget" or self.unit == "pettarget" then
|
if self:ShouldAlwaysSubscribe() then
|
||||||
IceHUD.IceCore:RequestUpdates(self.frame, function() self:UpdateCustomBar() end)
|
IceHUD.IceCore:RequestUpdates(self.frame, function() self:UpdateCustomBar() end)
|
||||||
else
|
else
|
||||||
IceHUD.IceCore:RequestUpdates(self.frame, nil)
|
IceHUD.IceCore:RequestUpdates(self.frame, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function IceCustomBar.prototype:ShouldAlwaysSubscribe()
|
||||||
|
return self.unit == "focustarget" or self.unit == "pettarget"
|
||||||
|
end
|
||||||
|
|
||||||
function IceCustomBar.prototype:TargetChanged()
|
function IceCustomBar.prototype:TargetChanged()
|
||||||
IceCustomBar.super.prototype.TargetChanged(self)
|
IceCustomBar.super.prototype.TargetChanged(self)
|
||||||
|
|
||||||
@ -185,7 +189,7 @@ function IceCustomBar.prototype:GetOptions()
|
|||||||
set = function(info, v)
|
set = function(info, v)
|
||||||
self.moduleSettings.myUnit = info.option.values[v]
|
self.moduleSettings.myUnit = info.option.values[v]
|
||||||
self.unit = info.option.values[v]
|
self.unit = info.option.values[v]
|
||||||
self:CheckShouldSubscribe()
|
self:ConditionalSubscribe()
|
||||||
self:Redraw()
|
self:Redraw()
|
||||||
self:UpdateCustomBar(self.unit)
|
self:UpdateCustomBar(self.unit)
|
||||||
IceHUD:NotifyOptionsChange()
|
IceHUD:NotifyOptionsChange()
|
||||||
@ -536,9 +540,8 @@ function IceCustomBar.prototype:UpdateCustomBar(unit, fromUpdate)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.auraEndTime ~= nil and (self.auraEndTime == 0 or self.auraEndTime >= now) then
|
if self.auraEndTime ~= nil and (self.auraEndTime == 0 or self.auraEndTime >= now) then
|
||||||
if not fromUpdate and not IceHUD.IceCore:IsUpdateSubscribed(self.frame) then
|
if not self:ShouldAlwaysSubscribe() and not fromUpdate and not IceHUD.IceCore:IsUpdateSubscribed(self.frame) then
|
||||||
IceHUD.IceCore:RequestUpdates(self.frame, function() self:UpdateCustomBar(self.unit, true) end)
|
IceHUD.IceCore:RequestUpdates(self.frame, function() self:UpdateCustomBar(self.unit, true) end)
|
||||||
--self.frame:SetScript("OnUpdate", function() self:UpdateCustomBar(self.unit, true) end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self:Show(true)
|
self:Show(true)
|
||||||
@ -555,7 +558,9 @@ function IceCustomBar.prototype:UpdateCustomBar(unit, fromUpdate)
|
|||||||
else
|
else
|
||||||
self:UpdateBar(0, "undef")
|
self:UpdateBar(0, "undef")
|
||||||
self:Show(false)
|
self:Show(false)
|
||||||
self.frame:SetScript("OnUpdate", nil)
|
if not self:ShouldAlwaysSubscribe() then
|
||||||
|
IceHUD.IceCore:RequestUpdates(self.frame, nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (remaining ~= nil) then
|
if (remaining ~= nil) then
|
||||||
|
Reference in New Issue
Block a user