Thread Tools Display Modes
05/18/14, 05:32 PM   #1
Azbandar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 9
Hide when Compass Hides

Ok, I've hit a wall on this one. I've seen it done many times, but I can't figure out how to hide my AddOn UI when I enter a menu/chat/inventory/bank. I've seen it linked to hiding when the compass hides, but I can't figure it out for the life of me.

Anyone care to make a newbie feel like an idiot!?

Thanks!
  Reply With Quote
05/18/14, 05:42 PM   #2
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Hey,
when setting an anchor of your top level control just set it to ZO_Compass like this:

Lua Code:
  1. yourControl:SetAnchor(CENTER, ZO_Compass, CENTER)
In the above example you control will appear at the center of the compass
  Reply With Quote
05/18/14, 06:05 PM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
All default controls in game UI are shown/hidden using scene manager. You can do the same.

Create simple scene fragment:
Lua Code:
  1. local fragment = ZO_SimpleSceneFragment:New(yourControl)
or scene fragment with fade in/out animation:
Lua Code:
  1. local fragment = ZO_FadeSceneFragment:New(yourControl)

And then add your fragment to all scenes where it has to be shown (in your case probably scenes "hud" and "hudui"):
Lua Code:
  1. local scene = SCENE_MANAGER:GetScene("hud")
  2. scene:AddFragment(fragment)
If you want to add more fragments at once you can create fragment group:
Lua Code:
  1. local fragmentGroup = { fragment1, fragment2, fragment3 }
  2.  
  3. scene:AddFragmentGroup(fragmentGroup)
If you want to remove fragment/fragment group from scene use:
Lua Code:
  1. scene:RemoveFragment(fragment)
  2. scene:RemoveFragmentGroup(fragmentGroup)

You can find a few more about this topic here:
http://www.esoui.com/forums/showthread.php?t=1453

Last edited by Garkin : 05/23/14 at 05:32 AM. Reason: Updated for new patch 1.1.2
  Reply With Quote
05/18/14, 06:38 PM   #4
Azbandar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 9
Originally Posted by Garkin View Post
You can find a few more about this topic here:
http://www.esoui.com/forums/showthread.php?t=1453
I may just have to give up the hiding in menus, this is all greek to me. I've tried every style here and in the attached post. All errors.

Basically, I'm trying to take something like FreeSlots but make it disappear in a menu. I thought it would be simple, my brain can't grasp it though.
  Reply With Quote
05/18/14, 06:52 PM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Azbandar View Post
I may just have to give up the hiding in menus, this is all greek to me. I've tried every style here and in the attached post. All errors.

Basically, I'm trying to take something like FreeSlots but make it disappear in a menu. I thought it would be simple, my brain can't grasp it though.
What errors you get?

Here is sample code:
Lua Code:
  1. --simple window with texture:
  2. local tlw, texture
  3. tlw = WINDOW_MANAGER:CreateTopLevelWindow()
  4. tlw:SetDimensions(100,100)
  5. tlw:SetAnchor(CENTER, GuiRoot, CENTER, 0, 0)
  6. tlw:SetHidden(true)
  7. texture = WINDOW_MANAGER:CreateControl(nil, tlw, CT_TEXTURE)
  8. texture:SetTexture("/esoui/art/icons/poi/poi_groupboss_complete.dds")
  9. texture:SetAnchorFill(tlw)
  10.  
  11. --create simple fragment
  12. local fragment = ZO_FadeSceneFragment:New(tlw)
  13.  
  14. --add my fragment to scenes:
  15. local sceneHud = SCENE_MANAGER:GetScene("hud")
  16. local sceneHudUI = SCENE_MANAGER:GetScene("hudui")
  17.  
  18. sceneHud:AddFragment(fragment)
  19. sceneHudUI:AddFragment(fragment)
  Reply With Quote
05/18/14, 07:25 PM   #6
Azbandar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 9
It keeps coming back with the same line listed 1-30+ times as "the table index is nil". It's that, or I lose all menu functions all together. I can't even get my screenshot to show you.

I also get this weird error that seems to interact with the main ESOUI Libraries. Again, screenshots aren't taking.

Your example works great, but do you think I can get my text box to go into it? NO! Lol. Thanks though.

Last edited by Azbandar : 05/18/14 at 07:36 PM.
  Reply With Quote
05/18/14, 07:43 PM   #7
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Azbandar View Post
It keeps coming back with the same line listed 1-30+ times as "the table index is nil". It's that, or I lose all menu functions all together. I can't even get my screenshot to show you.

I also get this weird error that seems to interact with the main ESOUI Libraries. Again, screenshots aren't taking.

Your example works great, but do you think I can get my text box to go into it? NO! Lol. Thanks though.
If you want, post your code here or to pastebin.com and I will try to figure out what is wrong.
  Reply With Quote
05/18/14, 07:51 PM   #8
Azbandar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 9
Originally Posted by Garkin View Post
If you want, post your code here or to pastebin.com and I will try to figure out what is wrong.

Lua Code:
  1. local fragment = ZO_SimpleSceneFragment:New(FillingUp)
  2.  
  3. local sceneHud = SCENE_MANAGER:GetScene("hud")
  4. local sceneHudUI = SCENE_MANAGER:GetScene("hudui")
  5.  
  6. sceneHud:AddFragment(fragment)
  7. sceneHudUI:AddFragment(fragment)


There's a lot more, but this is the only spot not working. The code works 100% to the "end" before this. I'm thinking it's just too late and I can't think, but any help would be greatly appreciated. If you need the entire code, let me know.

This is what I have that seems to disable every menu option I have.

Last edited by Azbandar : 05/18/14 at 07:53 PM.
  Reply With Quote
05/18/14, 07:56 PM   #9
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Azbandar View Post
Lua Code:
  1. local fragment = ZO_SimpleSceneFragment:New(FillingUp)
  2.  
  3. local sceneHud = SCENE_MANAGER:GetScene("hud")
  4. local sceneHudUI = SCENE_MANAGER:GetScene("hudui")
  5.  
  6. sceneHud:AddFragment(fragment)
  7. sceneHudUI:AddFragment(fragment)


There's a lot more, but this is the only spot not working. The code works 100% to the "end" before this. I'm thinking it's just too late and I can't think, but any help would be greatly appreciated. If you need the entire code, let me know.

This is what I have that seems to disable every menu option I have.
How you have defined "FillingUp"? Is it top level window?
  Reply With Quote
05/18/14, 08:01 PM   #10
Azbandar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 9
Originally Posted by Garkin View Post
How you have defined "FillingUp"? Is it top level window?
That may be where my issue is, that's what I named the AddOn, I've got nothing defined anywhere. That's the part I bet is stumping me in the "simple" hide feature!
  Reply With Quote
05/18/14, 08:06 PM   #11
Azbandar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 9


Got it to screen that error with the exact code I posted.

and since that link won't work...

http://smg.photobucket.com/user/Azba...tml?sort=3&o=0
  Reply With Quote
05/18/14, 08:12 PM   #12
Azbandar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 9
OMFG!

I AM an idiot.

My initial copy and paste in my txt file was the error... It listed lua before xml. Thanks Garkin, it works now.

~Az~
  Reply With Quote
05/19/14, 04:37 AM   #13
Tar000un
 
Tar000un's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 47
Can you move the addonUI while the scene manager is hidden ? I mean, if it's hidden, can you use a setHidden(false) to show it and move it ?
  Reply With Quote
05/19/14, 05:18 AM   #14
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Tar000un View Post
Can you move the addonUI while the scene manager is hidden ? I mean, if it's hidden, can you use a setHidden(false) to show it and move it ?
Yes, you can.
  Reply With Quote
06/10/14, 10:14 AM   #15
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
FYI:

You can break fast travel system is you add fade scene fragment to the HUD_SCENE. Don't ask me why, I have no idea.

This code breaks fast travel system (fast travel using the wayshrine costs money):
Lua Code:
  1. local CompassDistance = ZO_Object:Subclass()
  2.  
  3. function CompassDistance:New()
  4.    local obj = ZO_Object.New(self)
  5.    obj:Initialize()
  6.    return obj
  7. end
  8.  
  9. function CompassDistance:Initialize()
  10.    self.control = WINDOW_MANAGER:CreateTopLevelWindow()
  11.    self.control:SetAnchor(LEFT, COMPASS.control, RIGHT, 25, 0)
  12.    self.control:SetHidden(true)
  13.  
  14.    self.label = WINDOW_MANAGER:CreateControl(nil, self.control, CT_LABEL)
  15.    self.label:SetAnchor(LEFT, self.control, LEFT, 0, 0)
  16.    self.label:SetFont("ZoFontWinH3")
  17.    self.label:SetColor(ZO_CONTRAST_TEXT:UnpackRGBA())
  18.  
  19.    self:UpdateScale()
  20.  
  21.    CALLBACK_MANAGER:RegisterCallback("CustomCompassPins_MapChanged", function() self:UpdateScale() end)
  22. end
  23.  
  24. COMPASS_DISTANCE = CompassDistance:New()
  25. HUD_SCENE:AddFragment(ZO_FadeSceneFragment:New(COMPASS_DISTANCE.control))

But if you use ZO_SimpleSceneFragment instead of ZO_FadeSceneFragment, everything works correctly:
Lua Code:
  1. HUD_SCENE:AddFragment(ZO_SimpleSceneFragment:New(COMPASS_DISTANCE.control))
  Reply With Quote
06/28/14, 09:30 AM   #16
klaro00
 
klaro00's Avatar
Join Date: Apr 2014
Posts: 31
Hi,

anyone having an idea which scene name to use if I wanted to bind my control's visibility to the settings menu? I would like to see some of my controls during change it's settings value.

Cheers,
Klaro
  Reply With Quote
06/28/14, 10:38 AM   #17
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by klaro00 View Post
Hi,

anyone having an idea which scene name to use if I wanted to bind my control's visibility to the settings menu? I would like to see some of my controls during change it's settings value.

Cheers,
Klaro
Global reference is:
GAME_MENU_SCENE
or if you want to get scene by name:
SCENE_MANAGER:GetScene("gameMenuInGame")

How to find out which scene is currently active:
Code:
/script d(SCENE_MANAGER:GetCurrentScene():GetName())

Last edited by Garkin : 06/28/14 at 10:41 AM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Hide when Compass Hides


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