Show window when player opens inventory
i'm making an addon to show my stats, updated in real time, when i'm in my inventory screen. That way i can see my stats change when i equip armor, etc.
Screenshot: http://imgur.com/r0OsZ6p.png However, i have no idea how to open and close that window when the player opens it's inventory. Right now the window is showed when I click on an invisible box in the lower left of my screen and hidden when i click again. Is there a way to open it when the inventory opens and close it when the inventory closes? |
There are a few ways to acomplish this but what I see is most common is to register a function in your addon with the event manager to be ran when the action layer is pushed, then check that the inventory frame (or whicher you like) is show, and lastly show your control window. You can also do the same to hide the window when done using the action layer popped event.
Lua Code:
|
Or you could attach it to the scene you'd like to attach it to directly:
Code:
local InventoryScene = SCENE_MANAGER.scenes.inventory and you're actually able to begin fading in your window on the exact same moment it begins to fadein the inventory (or after it is done -> shown, hidden). /zgoo SCENE_MANAGER.scenes for a list of all scenes |
Well, sure... If you want to do it the hard, complicated way. Or you can do it the easy-peasy lemon-squeezy way.
Set that inventory window as the parent to your addon's window. ;) |
Well if you prefer to attach it completely to the scene then correctly as a FadeSceneFragment. That way it autofades as well - thought a Scene can have different displaystates and sometimes you want to show your Window only in a specific case - if its hardlinked it will always show when that Scene is shown and there is no way to hide it yourself as it will always be faded in/out automatically in that case. To get the best of both worlds what I do in FastReport is add a virtual TopWindow that 's empty as a SceneFragment and use SetParent on it with my real Window. That way I can then check if my Addon triggered the Event and set it to hidden true/false in OnStateChange - and only in that specific case. Thought right now, Im not quite sure if it inherits the Alpha correctly (I'll check that out later).
Edit: F@cking WoT. Sorry I'm writing from my Phone right :) |
Children inherit the alpha of their parent. If the animation makes the equipped inventory frame fade out, it's changing its alpha.
You can always add a toggle for your frame as well (if you really want to), as whether or not a frame is shown or hidden will be independent of its parent's visibility. Though, if they OP just wanted a toggle, they wouldn't have asked the question they did. |
Nice! As I said, I knew there were a few ways to accomplish this when I supplied the action layer hook but it's great to see the others in one place as well. I'm happy this thread exists, I will certainly be back to try some of these as I continue developing some things.
Great input from Seerah and thelegendaryof! Thanks guys! :) Would be nice if we could start some threads on general topics like this, gather the many different ways to do things, and set some stickies! We could also transfer some of this info over to the Wiki which would be helpful. :banana: |
Quote:
|
I am trying to hide my UI when player is in any of the screens - inventory, character, mail, etc. I am using the pushed and popped events and checking for
Code:
if ZO_GameMenu_InGame:IsHidden() then BUT, pushed is also called when I get into the mouse mode, where I need it to stay visible because I want the user to be able to move it. Any idea how I can detect pure mouse mode vs inventory et al is shown? Thanks! |
Quote:
Code:
function AutoHide() EDIT: I'm not sure if this works with scene manager stuff, but you could change the code to show / hide depending on which menu system is currently opened. |
Perfect! Thanks good sir! Will confirm when I get home, saw your edit too.
|
Quote:
Contents of the myAddon.txt file: Code:
## Title: myAddon Code:
<GuiXml> Code:
function myAddonUpdate() EDIT: Please note that there might be an even easier way to do this, but I didn't spend a whole lot of time researching. :) |
|
Quote:
Code:
if not menu1 or not menu2 or not menu3 or not menu4 |
If your frame isn't being reshown when it you want it to be, then something isn't quite right with your code. :)
|
Quote:
|
All times are GMT -6. The time now is 07:46 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI