- fixed markers generating errors or just misbehaving when changing profiles (ticket #102)

This commit is contained in:
Parnic
2010-11-10 02:41:20 +00:00
parent 36c91a36c8
commit 32f58e18d6

View File

@ -106,6 +106,8 @@ function IceBarElement.prototype:Enable()
self:OnShow() self:OnShow()
end) end)
end end
self:Redraw()
end end
function IceBarElement.prototype:OnHide() function IceBarElement.prototype:OnHide()
@ -122,6 +124,8 @@ function IceBarElement.prototype:Disable(core)
IceBarElement.super.prototype.Disable(self, core) IceBarElement.super.prototype.Disable(self, core)
IceHUD.IceCore:RequestUpdates(self, nil) IceHUD.IceCore:RequestUpdates(self, nil)
self:ClearMarkers()
end end
@ -1458,6 +1462,12 @@ function IceBarElement.prototype:RepositionMarkers()
end end
end end
function IceBarElement.prototype:ClearMarkers()
for idx=1,#self.Markers do
self:RemoveMarker(idx, true)
end
end
function IceBarElement.prototype:AddNewMarker(inPosition, inColor, inHeight) function IceBarElement.prototype:AddNewMarker(inPosition, inColor, inHeight)
if not self.moduleSettings.markers then if not self.moduleSettings.markers then
self.moduleSettings.markers = {} self.moduleSettings.markers = {}
@ -1483,13 +1493,15 @@ function IceBarElement.prototype:EditMarker(idx, inPosition, inColor, inHeight)
self:CreateMarker(idx) self:CreateMarker(idx)
end end
function IceBarElement.prototype:RemoveMarker(idx) function IceBarElement.prototype:RemoveMarker(idx, bSkipSettings)
assert(idx > 0 and #self.Markers >= idx and self.Markers[idx] and self.Markers[idx].bar and #self.moduleSettings.markers >= idx, assert(idx > 0 and #self.Markers >= idx and self.Markers[idx] and self.Markers[idx].bar and #self.moduleSettings.markers >= idx,
"Bad marker passed to RemoveMarker. idx="..idx..", #Markers="..#self.Markers..", #settings.markers="..#self.moduleSettings.markers) "Bad marker passed to RemoveMarker. idx="..idx..", #Markers="..#self.Markers..", #settings.markers="..#self.moduleSettings.markers)
self.Markers[idx]:Hide() self.Markers[idx]:Hide()
table.remove(self.Markers, idx) table.remove(self.Markers, idx)
if not bSkipSettings then
table.remove(self.moduleSettings.markers, idx) table.remove(self.moduleSettings.markers, idx)
end end
end
function IceBarElement.prototype:CreateMarker(idx) function IceBarElement.prototype:CreateMarker(idx)
if self.Markers[idx] ~= nil then if self.Markers[idx] ~= nil then