View Single Post
08/18/14, 04:24 PM   #8
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Dero View Post
What i wanted to do is Adding something to the HUD_SCENE and HUD_UI_SCENE.
But within this i wanted the option to set it Hidden, when the user decides to hide it.
this works at the first Moment with a simple control:SetHidden(true) but then after opening a map or another SCENE, the window will pop up if i go back to the HUD_SCENE or HUD_UI_SCENE no matter if it was hidden before or not. (that was ment with losing visible status)
i think i misunderstood the way the SCENE_MANAGER works.
I get it now. You want it to only be visible in that scene but still have the option to force it to stay hidden...or not.
You can set conditions to whether or not the fragment gets shown with a scene. You have to keep track of the state you want it to be in. You can just store it in a variable (as true or false) whenever the user pushes your show/hide button. Lets say the variable that holds that information is this:
Lua Code:
  1. myAddon.ShowWindow = false

Then add this line to your code:
Lua Code:
  1. tlw = WINDOW_MANAGER:CreateTopLevelWindow("tlw")
  2.  
  3. zo_callLater(function() addon.AddUiFragment(tlw) end,4000)
  4.  
  5. function addon.AddUiFragment(Newfragment)
  6.     local HideFragment = Newfragment:IsHidden()
  7.     local Hud = SCENE_MANAGER:GetScene("hud")
  8.     local HudUI = SCENE_MANAGER:GetScene("hudui")
  9.     local fragment = ZO_SimpleSceneFragment:New(Newfragment)
  10.     Hud:AddFragment(fragment)
  11.     HudUI:AddFragment(fragment)
  12.     Newfragment:SetHidden(HideFragment)
  13.  
  14. ------------  Add this  -----------------------------
  15.     Newfragment:SetConditional(function()
  16.         return myAddon.ShowWindow
  17.     end)
  18. -----------------------------------------------------
  19. end

Last edited by circonian : 08/18/14 at 04:29 PM.
  Reply With Quote