From 33aa08552d12eeb2f9fe45e0b5a570f6e25af468 Mon Sep 17 00:00:00 2001 From: Parnic Date: Sat, 25 Jul 2009 04:47:02 +0000 Subject: [PATCH] - fixed custom bars throwing all sorts of errors when creating/changing profiles with them active --- IceCore.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/IceCore.lua b/IceCore.lua index 886a630..187a97a 100644 --- a/IceCore.lua +++ b/IceCore.lua @@ -94,12 +94,26 @@ function IceCore.prototype:Enable() self:DrawFrame() for i = 1, table.getn(self.elements) do - self.elements[i]:Create(self.IceHUDFrame) - if (self.elements[i]:IsEnabled()) then - self.elements[i]:Enable(true) + -- make sure there are settings for this bar (might not if we make a new profile with existing custom bars) + if self.settings.modules[self.elements[i].elementName] then + self.elements[i]:Create(self.IceHUDFrame) + if (self.elements[i]:IsEnabled()) then + self.elements[i]:Enable(true) + end end end + -- go through the list of loaded elements that don't have associated settings and dump them + toRemove = {} + for i = 1, table.getn(self.elements) do + if not self.settings.modules[self.elements[i]:GetElementName()] then + toRemove[#toRemove + 1] = i + end + end + for i=1,#toRemove do + table.remove(self.elements, toRemove[i]) + end + for k,v in pairs(self.settings.modules) do if self.settings.modules[k].customBarType == "Bar" then local newBar @@ -119,6 +133,10 @@ function IceCore.prototype:Enable() end end + + -- make sure the module options are re-generated. if we switched profiles, we don't want the old elements hanging around + IceHUD:GenerateModuleOptions() + self.enabled = true end