From cd35e2b61ac1b3c3267be6ab687f3b1384954312 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Sat, 28 Sep 2013 12:50:00 +0000 Subject: [PATCH] Fix ticket 246 - Option to disable in pet battles Instead of an option, always hide Ovale when the Pet Battle UI is active. This should match player expectations. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1038 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- Ovale.lua | 38 +++++++++++++++++++++----------------- OvaleFrame.lua | 9 ++++++++- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Ovale.lua b/Ovale.lua index 877e027..a9f471a 100644 --- a/Ovale.lua +++ b/Ovale.lua @@ -165,27 +165,31 @@ function Ovale:UpdateLastSpellcast(spellcast) end function Ovale:UpdateVisibility() + local visible = true local profile = OvaleOptions:GetProfile() - if not profile.display then - self.frame:Hide() - return + if not self.frame.hider:IsVisible() then + visible = false + elseif not profile.display then + visible = false + else + if profile.apparence.hideVehicule and API_UnitHasVehicleUI("player") then + visible = false + end + if profile.apparence.avecCible and not API_UnitExists("target") then + visible = false + end + if profile.apparence.enCombat and not Ovale.enCombat then + visible = false + end + if profile.apparence.targetHostileOnly and (API_UnitIsDead("target") or not API_UnitCanAttack("player", "target")) then + visible = false + end end - self.frame:Show() - if profile.apparence.hideVehicule and API_UnitHasVehicleUI("player") then - self.frame:Hide() - end - - if profile.apparence.avecCible and not API_UnitExists("target") then - self.frame:Hide() - end - - if profile.apparence.enCombat and not Ovale.enCombat then - self.frame:Hide() - end - - if profile.apparence.targetHostileOnly and (API_UnitIsDead("target") or not API_UnitCanAttack("player", "target")) then + if visible then + self.frame:Show() + else self.frame:Hide() end end diff --git a/OvaleFrame.lua b/OvaleFrame.lua index ffaa159..43e03fc 100644 --- a/OvaleFrame.lua +++ b/OvaleFrame.lua @@ -31,6 +31,7 @@ do local API_GetSpellInfo = GetSpellInfo local API_GetSpellTexture = GetSpellTexture local API_GetTime = GetTime + local API_RegisterStateDriver = RegisterStateDriver -- -- @@ -423,7 +424,12 @@ do end local function Constructor() - local frame = API_CreateFrame("Frame",nil,UIParent) + -- Create parent frame for Ovale that auto-hides/shows based on whether the Pet Battle UI is active. + local hider = API_CreateFrame("Frame", "OvalePetBattleFrameHider", UIParent, "SecureHandlerStateTemplate") + hider:SetAllPoints(true) + API_RegisterStateDriver(hider, "visibility", "[petbattle] hide; show") + + local frame = API_CreateFrame("Frame", nil, hider) local self = {} local profile = OvaleOptions:GetProfile() @@ -444,6 +450,7 @@ do self.localstatus = {} self.actions = {} self.frame = frame + self.hider = hider self.updateFrame = API_CreateFrame("Frame") self.barre = self.frame:CreateTexture(); self.content = API_CreateFrame("Frame",nil,frame) -- 1.7.9.5