Fix bugs with "Hide Omen on 0 bars" option not working properly.

This commit is contained in:
Xinhuan
2008-11-04 06:06:58 +08:00
parent 0a91f771cf
commit f82c78c1eb
+30 -4
View File
@@ -349,6 +349,7 @@ function Omen:CreateFrames()
self.BarList:SetPoint("BOTTOMRIGHT", self.Anchor, "BOTTOMRIGHT")
self.BarList:SetScript("OnMouseDown", startmoving)
self.BarList:SetScript("OnMouseUp", stopmoving)
self.BarList.barsShown = 0
-- Create resizing corner grip
self.Grip = CreateFrame("Button", "OmenResizeGrip", self.BarList)
@@ -459,6 +460,7 @@ function Omen:PLAYER_LOGIN()
self:UpdateBackdrop()
self:UpdateTitleBar()
self:UpdateGrips()
self:ClearAll()
self:UnregisterEvent("PLAYER_LOGIN")
if LDB then
@@ -634,7 +636,10 @@ end
-- For public use
function Omen:Toggle(setting)
manualToggle = true
-- Don't set the manualToggle flag is "Hide Omen on 0 bars" option is active
if not (db.Autocollapse and db.CollapseHide) then
manualToggle = true
end
return self:_toggle(setting)
end
@@ -675,6 +680,11 @@ function Omen:UpdateVisible(event)
show = false
end
-- Hide if Autocollapse and Hide Omen on 0 Bars are both active and there are 0 bars.
if db.Autocollapse and db.CollapseHide and self.BarList.barsShown == 0 then
show = false
end
self:_toggle(show)
end
@@ -994,6 +1004,7 @@ do
bar.Text3:SetText(L["TPS"])
color = db.Bar.HeadingBGColor
bar.texture:SetVertexColor(color.r, color.g, color.b, color.a)
bar:Hide()
elseif barID == 1 then
-- Parent our TPS update frame to the first bar, so that TPS updates
-- updates happen when at least 1 bar (the first bar) is shown.
@@ -1255,7 +1266,15 @@ end
local queried = false
function Omen:UpdateBars()
if not self.Anchor:IsShown() and not db.CollapseHide then return end
if db.Autocollapse and db.CollapseHide then
-- Update the visibility because it could have been hidden on 0 bars
self.BarList.barsShown = 1 -- Dummy value
self:UpdateVisible()
end
if not self.Anchor:IsShown() then
self.BarList.barsShown = 0
return
end
-- TODO: Put a update throtle on this function
@@ -1466,8 +1485,8 @@ function Omen:UpdateBars()
if db.Autocollapse then
self.Anchor:SetHeight((i-1)*dbBar.Height + (i-2)*dbBar.Spacing + self.Title:GetHeight() + inset)
end
self.Anchor:Show()
self.BarList:Show()
self.BarList.barsShown = dbBar.ShowHeadings and i-2 or i-1
-- Threat warnings
if testMode then
@@ -1507,10 +1526,11 @@ function Omen:ClearAll()
if db.Autocollapse then
self.Anchor:SetHeight(self.Title:GetHeight())
self.BarList:Hide()
if db.CollapseHide and not self.Anchor.IsMovingOrSizing then
if db.CollapseHide and not self.Anchor.IsMovingOrSizing and not manualToggle then
self.Anchor:Hide()
end
end
self.BarList.barsShown = 0
-- Store last scanned mob GUID
lastWarn.mobGUID = nil
lastWarn.threatpercent = 0
@@ -1840,6 +1860,12 @@ local options = {
type = "toggle",
name = L["Hide Omen on 0 bars"],
desc = L["Hide Omen entirely if it collapses to show 0 bars"],
set = function(info, value)
db.CollapseHide = value
if value then manualToggle = false end
Omen:UpdateVisible()
Omen:UpdateBars()
end,
},
NumBars = {
order = 4,