Thread Tools Display Modes
04/07/14, 12:27 AM   #1
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Detecting interface open

Hello there.

How to detect if 'any' of the interface layer is popped open ? I.e. inventory or team window or any other window including the 'esc' menu. Do I have to check for every one of it ? And which event(s) is that related to ?

I would like to fire an event if any UI window is open to hide my AddOn.

And by the way, is there a function to hide/show a control 'smoothly' - that is to have it fade to transparent or pop visible elegantly like you could do in JQuery ? Is this integrated or requires to code a function for that ?

A nice day to you - thanks for any feedback.

*edit* I forgot to ask : I want to detect if the player sheathed/unsheathed his/her weapon (~combat mode) to hide/unhide my UI. I checked the doc but didn't find anything so far.

Last edited by Edda : 04/07/14 at 12:53 AM. Reason: moar
  Reply With Quote
04/07/14, 02:29 AM   #2
Wukar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 27
I assume, every TopLevelControl has the function :IsHidden(), for example
lua Code:
  1. if (ZO_PlayerInventory:IsHidden() == false) then { doMyStuff } end
  Reply With Quote
04/07/14, 03:25 AM   #3
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Okay fine - where can I get a list of all the ZO_ top level controls ? I need to check if *any* is not hidden.

Thanks
  Reply With Quote
04/07/14, 03:31 AM   #4
vapakule
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 15
Thumbs up

Originally Posted by Edda View Post
ZO_ top level controls
You can find them here http://wiki.esoui.com/Raw_globals_dump

btw, does any one know is there any possibility to change Key Icon:
For example Key icon under cursor, when mouse over on NPC to interact with, and other key icons throw all UI? Thnaks

Last edited by vapakule : 04/07/14 at 03:37 AM. Reason: add. question
  Reply With Quote
04/07/14, 03:54 AM   #5
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Okay that's a big list :|

I will try to trigger some events that may return the names of the windows.

Thanks tho.
  Reply With Quote
04/07/14, 04:18 AM   #6
Kith
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 49
Originally Posted by Edda View Post
Okay that's a big list :|

I will try to trigger some events that may return the names of the windows.

Thanks tho.
An easier way to do this would be to download Zgoo http://www.esoui.com/downloads/info24-Zgoo.html and then once in-game, place the mouse cursor out in the world and type "/zgoo mouse". It should bring up the specifics of GuiRoot (the frame the whole UI is parented to), then you can go down to GetChildren() and expand it to see the list of TopLevel frames.
  Reply With Quote
04/07/14, 05:39 AM   #7
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Okay I might check that - thanks for the link. I assume I could make a PlayerInventory:getParent() or something then loop through childrens ? Anyway will try it thx.
  Reply With Quote
04/07/14, 10:49 AM   #8
Cr4x
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Edda,

http://wiki.esoui.com/Events#UI

EVENT_ACTION_LAYER_POPPED (luaindex layerIndex, luaindex activeLayerIndex)
EVENT_ACTION_LAYER_PUSHED (luaindex layerIndex, luaindex activeLayerIndex)

both are fired when anything is shown such inventories or menus.

If you need to hook a specific then you really need the ZO_ globals.

However your post tells me you are looking for the 2 mentioned above.

For your "fade" you have diferrenct animation controls which can be found here:
http://wiki.esoui.com/UI_XML
  Reply With Quote
04/07/14, 03:16 PM   #9
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
All right looking forward to it...

What about the ~Weapon (un)sheated~ event ??? I tried EVENT_PLAYER_COMBAT_STATE but it doesnt work the way I want. Does this event exist (if anyone knows) ? I just want to detect if you sheated or unsheated weapon.

And now for another basic noob question : how do I actually use an event in the fired function ?

I have

Code:
EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, MXPV.GetCombatState);
Now I want to check if EVENT_PLAYER_COMBAT_STATE is true or false -> documentation says -> (bool inCombat).

I tried

Code:
EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, MXPV.GetCombatState(event));
Doesnt work (event = nil) and

Code:
MXPV.CombatState = EVENT_PLAYER_COMBAT_STATE;
Gives event_id and as well

Code:
MXPV.CombatState = EVENT_PLAYER_COMBAT_STATE.inCombat;
Property = nil

So ?
  Reply With Quote
04/07/14, 03:36 PM   #10
Dio
 
Dio's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 29
Regarding character menus, an easy way to run a function when a menu opens or closes is to bind to the handler of the menu categories (the top icons bar when you open a menu)

Code:
ZO_PreHookHandler(ZO_MainMenuCategoryBar, "OnShow", function()
end)

ZO_PreHookHandler(ZO_MainMenuCategoryBar, "OnHide", function()
end)
  Reply With Quote
04/07/14, 04:15 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Originally Posted by Edda View Post
And now for another basic noob question : how do I actually use an event in the fired function ?

I have

Code:
EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, MXPV.GetCombatState);
Now I want to check if EVENT_PLAYER_COMBAT_STATE is true or false -> documentation says -> (bool inCombat).

I tried

Code:
EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, MXPV.GetCombatState(event));
MXPV.GetCombatState <-- assigns this function to the event handler
MXPV.GetCombatState(event) <-- calls this function with event as the first argument and assigns the result of that function call to the event handler

You want this:
Lua Code:
  1. function MXPV.GetCombatState(event, inCombat)
  2.      if inCombat then
  3.           --do stuff
  4.      end
  5. end
  6.  
  7. EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, MXPV.GetCombatState)

or this:
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, function(event, inCombat)
  2.           if inCombat then
  3.                MXPV.GetCombatState(inCombat)
  4.           end
  5.      end)
  Reply With Quote
04/08/14, 02:42 AM   #12
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Yes that's what I was looking for - noob question soz but Im new to Lua

Anyway thanks.
  Reply With Quote
04/09/14, 05:32 AM   #13
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
EVENT_ACTION_LAYER_POPPED/PUSHED did the trick.

*edit* I gave up on weapon sheated/unsheathed event to hide/display my mod (bad idea).

As for now only hide it when interface popped (or pushed never remember which one is what :P). I grabbed the LayerIds for the 'Esc' window and other Menu windows (which are only 2 Ids btw) - can't remember them right now but will post them later maybe in case anyone needs em.

IIRC : any basic layers (inventory - group window - skills - character - etc etc..) are layers 2 & 16 and loot window is 11.

Last edited by Edda : 04/10/14 at 02:41 AM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Detecting interface open

Thread Tools
Display Modes

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