Thread Tools Display Modes
04/16/14, 07:44 AM   #1
Archer
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1
Question 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?
  Reply With Quote
04/16/14, 07:58 AM   #2
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
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:
  1. EVENT_MANAGER:RegisterForEvent("youraddonpusheventname", EVENT_ACTION_LAYER_PUSHED, YourAddonPushFunction)
  2.  
  3. EVENT_MANAGER:RegisterForEvent("youraddonpusheventname", EVENT_ACTION_LAYER_POPPED, YourAddonPopFunction)

Last edited by Vicster0 : 04/16/14 at 08:17 AM. Reason: Fixed a few logical things for clarification.
  Reply With Quote
04/16/14, 11:11 AM   #3
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 161
Or you could attach it to the scene you'd like to attach it to directly:

Code:
local InventoryScene = SCENE_MANAGER.scenes.inventory
InventoryScene:RegisterCallback("StateChange", function(oldState, newState) 
	-- states: hiding, showing, shown, hidden
	if(newState == "showing") then
		-- do something if the inventory is beginning to show
	elseif(newState == "hiding") then
		-- do something if the inventory is beginning to hide
	end
end)
That way it really only triggers when the inventory-scene changes (and not for any other scene)
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

Last edited by thelegendaryof : 04/16/14 at 11:24 AM.
  Reply With Quote
04/16/14, 12:45 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
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.
  Reply With Quote
04/16/14, 08:39 PM   #5
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 161
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
  Reply With Quote
04/16/14, 08:42 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
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.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Show window when player opens inventory


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