Rewrite Auto Show/Hide options to be more intuitive. Add option not to use Auto Show/Hide.

This commit is contained in:
Xinhuan
2008-10-31 14:45:16 +08:00
parent 3992eacb48
commit 14def8a171
7 changed files with 140 additions and 118 deletions
+104 -82
View File
@@ -137,14 +137,18 @@ local defaults = {
AggroBarColor = {r = 1, g = 0, b = 0, a = 1,},
},
ShowWith = {
UseShowWith = true,
Pet = true,
Alone = false,
Party = true,
Raid = true,
Resting = false,
PVP = false,
Dungeon = true,
ShowOnlyInCombat = false,
--Resting = false,
--PVP = false,
--Dungeon = true,
--ShowOnlyInCombat = false,
HideWhileResting = true,
HideInPVP = true,
HideWhenOOC = false,
},
FuBar = {
HideMinimapButton = true,
@@ -518,7 +522,7 @@ function Omen:OnEnable()
self:RegisterEvent("PLAYER_UPDATE_RESTING", "UpdateVisible")
self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateVisible")
if db.ShowWith.ShowOnlyInCombat then
if db.ShowWith.HideWhenOOC then
self:RegisterEvent("PLAYER_REGEN_DISABLED", "UpdateVisible")
self:RegisterEvent("PLAYER_REGEN_ENABLED", "UpdateVisible")
end
@@ -607,28 +611,27 @@ end
function Omen:UpdateVisible(event)
local t = db.ShowWith
if t.ShowOnlyInCombat and not InCombatLockdown() and event ~= "PLAYER_REGEN_DISABLED" then
if not t.UseShowWith 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)
return
end
-- Check for pet|party|raid|alone
local show = (t.Pet and UnitExists("pet")) or
(t.Party and inParty) or
(t.Raid and inRaid) or
(t.Alone and not inParty and not inRaid and not UnitExists("pet"))
-- Then hide override if necessary for resting|pvp
local inInstance, instanceType = IsInInstance()
local show
if not t.Resting and IsResting() then
if (t.HideWhileResting and IsResting()) or (t.HideInPVP and (instanceType == "pvp" or instanceType == "arena")) then
show = false
end
if not t.PVP and inInstance and (instanceType == "pvp" or instanceType == "arena") then
show = false
end
if not t.Dungeon and inInstance and (instanceType == "party" or instanceType == "raid") then
show = false
end
if show == nil then
show = (t.Pet and UnitExists("pet")) or
(t.Alone and GetNumPartyMembers() + GetNumRaidMembers() == 0 and not UnitExists("pet")) or
(t.Party and GetNumPartyMembers() > 0) or
(t.Raid and GetNumRaidMembers() > 0)
end
self:Toggle(show)
end
@@ -1863,73 +1866,92 @@ local options = {
intro = {
order = 1,
type = "description",
name = L["Show Omen when any of the following are true"],
name = L["This section controls when Omen is automatically shown or hidden."],
disabled = false,
},
Alone = {
UseShowWith = {
type = "toggle",
order = 2,
name = L["You are alone"],
desc = L["Show Omen when you are alone"],
name = L["Use Auto Show/Hide"],
desc = L["Use Auto Show/Hide"],
disabled = false,
},
PVP = {
type = "toggle",
ShowWithGroup = {
type = "group",
order = 3,
name = L["You are in a battleground"],
desc = L["Show Omen when you are in a battleground or arena"],
},
Dungeon = {
type = "toggle",
order = 4,
name = L["You are in a dungeon"],
desc = L["Show Omen when you are in a dungeon (5 man and raid)"],
},
Party = {
type = "toggle",
order = 5,
name = L["You are in a party"],
desc = L["Show Omen when you are in a 5-man party"],
},
Raid = {
type = "toggle",
order = 6,
name = L["You are in a raid"],
desc = L["Show Omen when you are in a raid"],
},
Resting = {
type = "toggle",
order = 7,
name = L["You are resting"],
desc = L["Show Omen when you are resting"],
},
Pet = {
type = "toggle",
order = 8,
name = L["You have a pet"],
desc = L["Show Omen when you have a pet out"],
},
intro2 = {
order = 10,
type = "description",
name = L["In addition to the above options..."],
},
ShowOnlyInCombat = {
type = "toggle",
order = 11,
width = "double",
name = L["Only show when in combat"],
desc = L["Turning this on will cause Omen to hide whenever you are not in combat."],
set = function(info, value)
db.ShowWith.ShowOnlyInCombat = value
if value then
Omen:RegisterEvent("PLAYER_REGEN_DISABLED", "UpdateVisible")
Omen:RegisterEvent("PLAYER_REGEN_ENABLED", "UpdateVisible")
else
Omen:UnregisterEvent("PLAYER_REGEN_DISABLED")
Omen:UnregisterEvent("PLAYER_REGEN_ENABLED")
end
Omen:UpdateVisible()
Omen:UpdateBars()
end,
guiInline = true,
name = L["Use Auto Show/Hide"],
desc = L["Use Auto Show/Hide"],
disabled = function(info) return not db.ShowWith.UseShowWith end,
args = {
intro2 = {
order = 10,
type = "description",
name = L["Show Omen when any of the following are true"],
},
Alone = {
type = "toggle",
order = 11,
name = L["You are alone"],
desc = L["Show Omen when you are alone"],
},
Party = {
type = "toggle",
order = 12,
name = L["You are in a party"],
desc = L["Show Omen when you are in a 5-man party"],
},
Raid = {
type = "toggle",
order = 13,
name = L["You are in a raid"],
desc = L["Show Omen when you are in a raid"],
},
Pet = {
type = "toggle",
order = 14,
name = L["You have a pet"],
desc = L["Show Omen when you have a pet out"],
},
intro3 = {
order = 20,
type = "description",
name = L["However, hide Omen if any of the following are true (higher priority than the above)."],
},
HideInPVP = {
type = "toggle",
order = 21,
width = "double",
name = L["You are in a battleground"],
desc = L["Turning this on will cause Omen to hide whenever you are in a battleground or arena."],
},
HideWhileResting = {
type = "toggle",
order = 22,
width = "double",
name = L["You are resting"],
desc = L["Turning this on will cause Omen to hide whenever you are in a city or inn."],
},
HideWhenOOC = {
type = "toggle",
order = 23,
width = "double",
name = L["You are not in combat"],
desc = L["Turning this on will cause Omen to hide whenever you are not in combat."],
set = function(info, value)
db.ShowWith.HideWhenOOC = value
if value then
Omen:RegisterEvent("PLAYER_REGEN_DISABLED", "UpdateVisible")
Omen:RegisterEvent("PLAYER_REGEN_ENABLED", "UpdateVisible")
else
Omen:UnregisterEvent("PLAYER_REGEN_DISABLED")
Omen:UnregisterEvent("PLAYER_REGEN_ENABLED")
end
Omen:UpdateVisible()
Omen:UpdateBars()
end,
},
},
},
},
},