Add an internal flag so that if the user manually toggles Omen's visibility, it stays shown/hidden until he next zones, join/leave a party/raid, or change any Auto Show/Hide settings.

This commit is contained in:
Xinhuan
2008-10-31 16:17:59 +08:00
parent 14def8a171
commit 1a4bd3a0cf
7 changed files with 34 additions and 15 deletions
+28 -15
View File
@@ -142,10 +142,8 @@ local defaults = {
Alone = false,
Party = true,
Raid = true,
--Resting = false,
--PVP = false,
--Dungeon = true,
--ShowOnlyInCombat = false,
-- Deprecated SV values
-- Resting = false, PVP = false, Dungeon = true, ShowOnlyInCombat = false,
HideWhileResting = true,
HideInPVP = true,
HideWhenOOC = false,
@@ -177,6 +175,7 @@ local timers = {} -- Format: timers.timerName = timer returned from Ac
local bars = {} -- Format: bars[i] = frame containing the i-th bar from the top of Omen
local inRaid, inParty -- boolean variables indicating if the player is in a raid and/or party
local testMode = false -- boolean: Are we in test mode?
local manualToggle = false -- boolean: Did we manually toggle Omen?
Omen.GuidNameLookup = guidNameLookup
Omen.GuidClassLookup = guidClassLookup
@@ -543,7 +542,7 @@ function Omen:OnDisable()
timers[k] = nil
end
self:Toggle(false)
self:_toggle(false)
end
function Omen:OnProfileChanged(event, database, newProfileKey)
@@ -598,7 +597,14 @@ function Omen:SetAnchors(useDB)
db.PositionW, db.PositionH = w, h
end
-- For public use
function Omen:Toggle(setting)
manualToggle = true
return self:_toggle(setting)
end
-- For internal use
function Omen:_toggle(setting)
if setting == nil then
setting = not self.Anchor:IsShown()
end
@@ -610,13 +616,15 @@ function Omen:Toggle(setting)
end
function Omen:UpdateVisible(event)
if event == "PLAYER_ENTERING_WORLD" then manualToggle = false end
local t = db.ShowWith
if not t.UseShowWith then return end
if not t.UseShowWith or manualToggle then return end
-- Hide if HideWhenOOC option is on, we're not in combat, and the triggering event is not
-- "PLAYER_REGEN_DISABLED" (we're out of combat during this event just before entering combat)
if t.HideWhenOOC and not InCombatLockdown() and event ~= "PLAYER_REGEN_DISABLED" then
self:Toggle(false)
self:_toggle(false)
return
end
@@ -632,7 +640,7 @@ function Omen:UpdateVisible(event)
show = false
end
self:Toggle(show)
self:_toggle(show)
end
local bgFrame = {insets = {}}
@@ -1059,8 +1067,10 @@ end
local lastPartyUpdateTime = GetTime()
function Omen:PARTY_MEMBERS_CHANGED()
inRaid = GetNumRaidMembers() > 0
local oldInParty, oldInRaid = inParty, inRaid
inParty = GetNumPartyMembers() > 0
inRaid = GetNumRaidMembers() > 0
if oldInParty ~= inParty or oldInRaid ~= inRaid then manualToggle = false end
self:UpdateVisible()
-- Run the update if the last call is more than 0.5 seconds ago else
@@ -1859,6 +1869,7 @@ local options = {
get = function(info) return db.ShowWith[ info[#info] ] end,
set = function(info, value)
db.ShowWith[ info[#info] ] = value
manualToggle = false
Omen:UpdateVisible()
Omen:UpdateBars()
end,
@@ -1940,6 +1951,7 @@ local options = {
desc = L["Turning this on will cause Omen to hide whenever you are not in combat."],
set = function(info, value)
db.ShowWith.HideWhenOOC = value
manualToggle = false
if value then
Omen:RegisterEvent("PLAYER_REGEN_DISABLED", "UpdateVisible")
Omen:RegisterEvent("PLAYER_REGEN_ENABLED", "UpdateVisible")
@@ -1951,6 +1963,11 @@ local options = {
Omen:UpdateBars()
end,
},
intro4 = {
order = 30,
type = "description",
name = L["AUTO_SHOW/HIDE_NOTE"],
},
},
},
},
@@ -2578,9 +2595,7 @@ local optionsSlash = {
type = "execute",
name = L["Toggle Omen"],
desc = L["Toggle Omen"].." ( /omen toggle )",
func = function()
Omen:Toggle()
end,
func = function() Omen:Toggle() end,
},
center = {
type = "execute",
@@ -2596,9 +2611,7 @@ local optionsSlash = {
type = "execute",
name = L["Configure"],
desc = L["Open the configuration dialog"].." ( /omen config )",
func = function()
Omen:ShowConfig()
end,
func = function() Omen:ShowConfig() end,
guiHidden = true,
},
},