Thread Tools Display Modes
11-10-14, 05:29 PM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
How Do I Hide the Quest Watcher Frame when im fighting a Boss?

How would one go about hiding the ObjectiveTrackerFrame you incounter a boss?

Would it be something like:
Code:
local f = CreateFrame("Frame")
f:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT")
if event == "INSTANCE_ENCOUNTER_ENGAGE_UNIT" then
    ObjectiveTrackerFrame:Hide()
end
The reasoning for this is with oUF_Neav when you start a boss fight the boss frame overlaps the Objective Tracker Frame (screenshot below).

Thanks for any help with this.

Coke
Attached Thumbnails
Click image for larger version

Name:	BossFrame.jpg
Views:	204
Size:	31.0 KB
ID:	8292  
  Reply With Quote
11-10-14, 07:08 PM   #2
Defective99
A Kobold Labourer
 
Defective99's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 1
Is it possible to change:

ObjectiveTrackerFrame:Hide()

to:

ObjectiveTracker_Collapse()

so it can be manually toggled and you wouldn't need to :Show() again to restore interactions with it.
  Reply With Quote
11-10-14, 07:16 PM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
The other method is to move the boss frames rather than the objective tracker.
  Reply With Quote
11-10-14, 08:41 PM   #4
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Originally Posted by Defective99 View Post
Is it possible to change:

ObjectiveTrackerFrame:Hide()

to:

ObjectiveTracker_Collapse()

so it can be manually toggled and you wouldn't need to :Show() again to restore interactions with it.
Use PLAYER_REGEN_ENABLED/DISABLED as event together with ObjectiveTracker_Collapse() (I think!)
__________________
  Reply With Quote
11-11-14, 01:22 AM   #5
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
Lua Code:
  1. local otf = ObjectiveTrackerFrame
  2.     local frame = CreateFrame'Frame'
  3.     frame:RegisterEvent'INSTANCE_ENCOUNTER_ENGAGE_UNIT'
  4.  
  5.     local function bossexists()
  6.         for i = 1, MAX_BOSS_FRAMES do
  7.                 if UnitExists('boss'..i) then
  8.                        return true
  9.                 end
  10.           end
  11.     end
  12.  
  13.     frame:SetScript('OnEvent', function(self, event)
  14.         local _, instanceType = IsInInstance()
  15.  
  16.         if bossexists() then
  17.                 if not otf.collapsed then
  18.                        ObjectiveTracker_Collapse()
  19.                 end
  20.         elseif otf.collapsed and instanceType=='raid' and not InCombatLockdown() then
  21.                  ObjectiveTracker_Expand()
  22.         end
  23.     end)
  Reply With Quote
11-11-14, 02:39 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Try this:
Lua Code:
  1. RegisterStateDriver(ObjectiveTrackerFrame, "visibility", "[nocombat] show; hide")

Or
Lua Code:
  1. local frame = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate")
  2. ObjectiveTrackerFrame:SetParent(frame)
  3. RegisterStateDriver(frame , "visibility", "[nocombat] show; hide")

Well. If the parenting does work properly you may be able to just work with an event handler on the frame and fade it in/out of combat.

Lua Code:
  1. --frame
  2.     local f= CreateFrame("Frame", nil, UIParent)
  3.     ObjectiveTrackerFrame:SetParent(f)
  4.  
  5.     --fade in anim
  6.     f.fadeIn = f:CreateAnimationGroup()
  7.     f.fadeIn.anim = f.fadeIn:CreateAnimation("Alpha")
  8.     f.fadeIn.anim:SetDuration(0.8)
  9.     f.fadeIn.anim:SetSmoothing("IN")
  10.     f.fadeIn.anim:SetChange(1)
  11.     f.fadeIn:HookScript("OnFinished", function(self)
  12.       self:GetParent():SetAlpha(1)
  13.     end)
  14.  
  15.     --fade out anim
  16.     f.fadeOut = f:CreateAnimationGroup()
  17.     f.fadeOut.anim = f.fadeOut:CreateAnimation("Alpha")
  18.     f.fadeOut.anim:SetDuration(0.8)
  19.     f.fadeOut.anim:SetSmoothing("OUT")
  20.     f.fadeOut.anim:SetChange(-1)
  21.     f.fadeOut:HookScript("OnFinished", function(self)
  22.       self:GetParent():SetAlpha(0)
  23.       --hide frame
  24.       self:GetParent():Hide()
  25.     end)
  26.  
  27.     -- canvas enable func
  28.     function f:Enable()
  29.       self:Show()
  30.       self.fadeIn:Play()
  31.     end
  32.  
  33.     -- canvas disable func
  34.     function f:Disable()
  35.       self.fadeOut:Play()
  36.     end
  37.  
  38.    function f:OnEvent(event)
  39.      if event == "PLAYER_REGEN_ENABLED" then
  40.        self:Enable()
  41.      else
  42.        self:Disable()
  43.      end
  44.    end
  45.  
  46.    f:RegisterEvent("PLAYER_REGEN_ENABLED")
  47.    f:RegisterEvent("PLAYER_REGEN_DISABLED")
  48.  
  49.    f:SetScript("OnEvent",f.OnEvent)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-11-14 at 02:49 AM.
  Reply With Quote
11-12-14, 11:11 PM   #7
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by ObbleYeah View Post
Lua Code:
  1. local otf = ObjectiveTrackerFrame
  2.     local frame = CreateFrame'Frame'
  3.     frame:RegisterEvent'INSTANCE_ENCOUNTER_ENGAGE_UNIT'
  4.  
  5.     local function bossexists()
  6.         for i = 1, MAX_BOSS_FRAMES do
  7.                 if UnitExists('boss'..i) then
  8.                        return true
  9.                 end
  10.           end
  11.     end
  12.  
  13.     frame:SetScript('OnEvent', function(self, event)
  14.         local _, instanceType = IsInInstance()
  15.  
  16.         if bossexists() then
  17.                 if not otf.collapsed then
  18.                        ObjectiveTracker_Collapse()
  19.                 end
  20.         elseif otf.collapsed and instanceType=='raid' and not InCombatLockdown() then
  21.                  ObjectiveTracker_Expand()
  22.         end
  23.     end)
Thank you for this it collapses the tracker nicely, but knowing my luck I would forget to bring it back and mis something. But thank you for the code.

Originally Posted by zork View Post
Try this:
Lua Code:
  1. RegisterStateDriver(ObjectiveTrackerFrame, "visibility", "[nocombat] show; hide")

Or
Lua Code:
  1. local frame = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate")
  2. ObjectiveTrackerFrame:SetParent(frame)
  3. RegisterStateDriver(frame , "visibility", "[nocombat] show; hide")

Well. If the parenting does work properly you may be able to just work with an event handler on the frame and fade it in/out of combat.

Lua Code:
  1. --frame
  2.     local f= CreateFrame("Frame", nil, UIParent)
  3.     ObjectiveTrackerFrame:SetParent(f)
  4.  
  5.     --fade in anim
  6.     f.fadeIn = f:CreateAnimationGroup()
  7.     f.fadeIn.anim = f.fadeIn:CreateAnimation("Alpha")
  8.     f.fadeIn.anim:SetDuration(0.8)
  9.     f.fadeIn.anim:SetSmoothing("IN")
  10.     f.fadeIn.anim:SetChange(1)
  11.     f.fadeIn:HookScript("OnFinished", function(self)
  12.       self:GetParent():SetAlpha(1)
  13.     end)
  14.  
  15.     --fade out anim
  16.     f.fadeOut = f:CreateAnimationGroup()
  17.     f.fadeOut.anim = f.fadeOut:CreateAnimation("Alpha")
  18.     f.fadeOut.anim:SetDuration(0.8)
  19.     f.fadeOut.anim:SetSmoothing("OUT")
  20.     f.fadeOut.anim:SetChange(-1)
  21.     f.fadeOut:HookScript("OnFinished", function(self)
  22.       self:GetParent():SetAlpha(0)
  23.       --hide frame
  24.       self:GetParent():Hide()
  25.     end)
  26.  
  27.     -- canvas enable func
  28.     function f:Enable()
  29.       self:Show()
  30.       self.fadeIn:Play()
  31.     end
  32.  
  33.     -- canvas disable func
  34.     function f:Disable()
  35.       self.fadeOut:Play()
  36.     end
  37.  
  38.    function f:OnEvent(event)
  39.      if event == "PLAYER_REGEN_ENABLED" then
  40.        self:Enable()
  41.      else
  42.        self:Disable()
  43.      end
  44.    end
  45.  
  46.    f:RegisterEvent("PLAYER_REGEN_ENABLED")
  47.    f:RegisterEvent("PLAYER_REGEN_DISABLED")
  48.  
  49.    f:SetScript("OnEvent",f.OnEvent)
All three work, I like the fade in fade out functionality but is there a way to make this only happen on boss fights? In and Out of combat triggers a lot of fade in and out when running a lower instance and Im just wondering if that is a lot of strain on the game/fps.

Thanks for the code help with this.

Coke
  Reply With Quote
11-13-14, 02:41 AM   #8
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
@coke
Well of course. You can change the event handler to a script handler.
Lua Code:
  1. BossFrame1:HookScript("OnShow",f.Disable)
  2. BossFrame1:HookScript("OnHide",f.Enable)
OnShow you fadeIn the frame. OnHide you fadeOut the frame.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
11-13-14, 08:54 AM   #9
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by zork View Post
@coke
Well of course. You can change the event handler to a script handler.
Lua Code:
  1. BossFrame1:HookScript("OnShow",f.Disable)
  2. BossFrame1:HookScript("OnHide",f.Enable)
OnShow you fadeIn the frame. OnHide you fadeOut the frame.
Now with multiple bosses like the second boss in the deadlines would this still work once the BossFrame1 gets removed, cause once you lol the big guy the little guy hopes off his shoulders.

Or will I have to mske something like:
Code:
for I = 1, MAX_BOSS_ FRAME
   BossFrame.."I":HookScipt("OnShow", f.Disable)
   BossFrame.."I":HookScipt("OnHide", f.Enable)
End
Or am I just over thinking this.

Coke
  Reply With Quote
11-13-14, 09:24 AM   #10
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Well. Yeah you probably need a function that checks if any of the bossframes is still visible and keep track of the visibility state of your frame aswell.

Lua Code:
  1. function f:IsBossFrameShown()
  2.   for i = 1, MAX_BOSS_FRAMES do
  3.     local b = _G["BossFrame"..i]
  4.     if b and b:IsShown() then
  5.       return true
  6.     end
  7.   end
  8.   return false
  9. end
  10.  
  11. function f:UpdateView()
  12.   if self:IsBossFrameShown() then
  13.     self:Enable()
  14.   else
  15.     self:Disable()
  16.   end
  17. end
  18.    
  19. for i = 1, MAX_BOSS_FRAMES do
  20.   local b = _G["BossFrame"..i]
  21.   b:HookScript("OnShow",function() f:UpdateView() end)
  22.   b:HookScript("OnHide",function() f:UpdateView() end)
  23. end

*edit* fixed the issue Phanx pointed out
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-14-14 at 02:47 AM.
  Reply With Quote
11-13-14, 08:18 PM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'm not sure that code is doing what you think it's doing.... you're calling Enable and Disable on the boss frames, which is (a) not what I think anyone in this thread is trying to do, and (b) not allowed in combat, so you can't just do it when the frames are hidden/shown, since you may be in combat when that happens.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-14-14, 02:45 AM   #12
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Yeah you are right that should be a different reference.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
11-14-14, 07:23 AM   #13
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Phanx View Post
I'm not sure that code is doing what you think it's doing.... you're calling Enable and Disable on the boss frames, which is (a) not what I think anyone in this thread is trying to do, and (b) not allowed in combat, so you can't just do it when the frames are hidden/shown, since you may be in combat when that happens.
So by looking at all the codes posted (BTW thank you to you code gurus for helping) it seems that this setup should give me the results I am looking for.

Lua Code:
  1. -- Main Code provided by Zork from WoWInterface
  2.     local ObjectiveTracker = CreateFrame("Frame", nil, UIParent)
  3.     ObjectiveTrackerFrame:SetParent(ObjectiveTracker)
  4.  
  5.     --Animation Fade In Code
  6.     ObjectiveTracker.fadeIn = ObjectiveTracker:CreateAnimationGroup()
  7.     ObjectiveTracker.fadeIn.anim = ObjectiveTracker.fadeIn:CreateAnimation("Alpha")
  8.     ObjectiveTracker.fadeIn.anim:SetDuration(0.8)
  9.     ObjectiveTracker.fadeIn.anim:SetSmoothing("IN")
  10.     ObjectiveTracker.fadeIn.anim:SetChange(1)
  11.     ObjectiveTracker.fadeIn:HookScript("OnFinished", function(self)
  12.         self:GetParent():SetAlpha(1)
  13.     end)
  14.  
  15.     --Animation Fade Out Code
  16.     ObjectiveTracker.fadeOut = ObjectiveTracker:CreateAnimationGroup()
  17.     ObjectiveTracker.fadeOut.anim = ObjectiveTracker.fadeOut:CreateAnimation("Alpha")
  18.     ObjectiveTracker.fadeOut.anim:SetDuration(0.8)
  19.     ObjectiveTracker.fadeOut.anim:SetSmoothing("OUT")
  20.     ObjectiveTracker.fadeOut.anim:SetChange(-1)
  21.     ObjectiveTracker.fadeOut:HookScript("OnFinished", function(self)
  22.       self:GetParent():SetAlpha(0)
  23.       --hide frame
  24.       self:GetParent():Hide()
  25.     end)
  26.  
  27.     -- Show Tracker Function
  28.     function ObjectiveTracker:Enable()
  29.       self:Show()
  30.       self.fadeIn:Play()
  31.     end
  32.  
  33.     -- Hide Tracker Function
  34.     function ObjectiveTracker:Disable()
  35.       self.fadeOut:Play()
  36.     end
  37.        
  38.     function ObjectiveTracker:OnEvent(event)
  39.         if event == "INSTANCE_ENCOUNTER_ENGAGE_UNIT" then
  40.             self:Disable()
  41.         elseif event == "PLAYER_REGEN_ENABLED" then
  42.             self:Enable()          
  43.         end
  44.    end
  45.  
  46.    ObjectiveTracker:RegisterEvent("PLAYER_REGEN_ENABLED")
  47.    ObjectiveTracker:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT")
  48.  
  49.    ObjectiveTracker:SetScript("OnEvent",ObjectiveTracker.OnEvent)

From what im gathering the event INSTANCE_ENCOUNTER_ENGAGE_UNIT should fire when any Boss Frame is toggled. I could not find a event that fired after the boss frame disappears (that would be to easy) so going with Zork's idea I used PLAYER_REGEN_ENABLED to show the tracker.

Thanks to all that helped me with this.

Coke
  Reply With Quote
11-14-14, 09:43 AM   #14
Blooblahguy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 18
Originally Posted by zork View Post
Well. Yeah you probably need a function that checks if any of the bossframes is still visible and keep track of the visibility state of your frame aswell.

Lua Code:
  1. function f:IsBossFrameShown()
  2.   for i = 1, MAX_BOSS_FRAMES do
  3.     local b = _G["BossFrame"..i]
  4.     if b and b:IsShown() then
  5.       return true
  6.     end
  7.   end
  8.   return false
  9. end
  10.  
  11. function f:UpdateView()
  12.   if self:IsBossFrameShown() then
  13.     self:Enable()
  14.   else
  15.     self:Disable()
  16.   end
  17. end
  18.    
  19. for i = 1, MAX_BOSS_FRAMES do
  20.   local b = _G["BossFrame"..i]
  21.   b:HookScript("OnShow",function() f:UpdateView() end)
  22.   b:HookScript("OnHide",function() f:UpdateView() end)
  23. end

*edit* fixed the issue Phanx pointed out

You could always update the original code to register the ENCOUNTER_START/ENCOUNTER_END events, no? Then intelligently enable or disable depending on the encounter difficulty.

Lua Code:
  1. local f= CreateFrame("Frame", nil, UIParent)
  2. ObjectiveTrackerFrame:SetParent(f)
  3.  
  4. --fade in anim
  5. f.fadeIn = f:CreateAnimationGroup()
  6. f.fadeIn.anim = f.fadeIn:CreateAnimation("Alpha")
  7. f.fadeIn.anim:SetDuration(0.8)
  8. f.fadeIn.anim:SetSmoothing("IN")
  9. f.fadeIn.anim:SetChange(1)
  10. f.fadeIn:HookScript("OnFinished", function(self)
  11.     self:GetParent():SetAlpha(1)
  12. end)
  13.  
  14. --fade out anim
  15. f.fadeOut = f:CreateAnimationGroup()
  16. f.fadeOut.anim = f.fadeOut:CreateAnimation("Alpha")
  17. f.fadeOut.anim:SetDuration(0.8)
  18. f.fadeOut.anim:SetSmoothing("OUT")
  19. f.fadeOut.anim:SetChange(-1)
  20. f.fadeOut:HookScript("OnFinished", function(self)
  21.     self:GetParent():SetAlpha(0)
  22.     --hide frame
  23.     self:GetParent():Hide()
  24. end)
  25.  
  26. function f:OnEvent(event, enounterID, encounterName, difficultyID)
  27.     if event == "ENCOUNTER_START" then
  28.         self.fadeOut:Play()
  29.     else
  30.         self:Show()
  31.         self.fadeIn:Play()
  32.     end
  33. end
  34.  
  35. f:RegisterEvent("ENCOUNTER_START")
  36. f:RegisterEvent("ENCOUNTER_END")
  37.  
  38. f:SetScript("OnEvent",f.OnEvent)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How Do I Hide the Quest Watcher Frame when im fighting a Boss?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off