- fixed custom bars throwing all sorts of errors when creating/changing profiles with them active

This commit is contained in:
Parnic
2009-07-25 04:47:02 +00:00
parent 2835f2d2f8
commit 33aa08552d

View File

@ -94,11 +94,25 @@ function IceCore.prototype:Enable()
self:DrawFrame() self:DrawFrame()
for i = 1, table.getn(self.elements) do for i = 1, table.getn(self.elements) do
-- 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) self.elements[i]:Create(self.IceHUDFrame)
if (self.elements[i]:IsEnabled()) then if (self.elements[i]:IsEnabled()) then
self.elements[i]:Enable(true) self.elements[i]:Enable(true)
end end
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 for k,v in pairs(self.settings.modules) do
if self.settings.modules[k].customBarType == "Bar" then if self.settings.modules[k].customBarType == "Bar" then
@ -119,6 +133,10 @@ function IceCore.prototype:Enable()
end end
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 self.enabled = true
end end