Go to Page... |
Thread Tools | Display Modes |
11/09/20, 06:34 PM | #1 | |
Join Date: Nov 2020
Posts: 2
|
Help with Hiding Addon except in Main Window
Good day all.
I have followed the tutorials to create my first addon. I am making a simple pane that displays stats such as Max(Mag/Stam), Recovery, SP/WP, SC/WC, etc in real time. I plan on extending the functionality later on, as well as changing to templates for the controls, but for now, I just want the addon to not display unless the character is in the main window. Currently, when I access the game menu, the addon is still visible until I log out etc. Is there an event I need to register for to toggle the view? I realize my code is pretty ugly at this point, but any help or guidance would be appreciated. Current lua: Code:
SimpleStats = {} SimpleStats.name = "SimpleStats" function SimpleStats.OnWindowMoveStop() SimpleStats.savedVariables.left = SimpleStatsWindow:GetLeft() SimpleStats.savedVariables.top = SimpleStatsWindow:GetTop() end function SimpleStats:RestorePosition() local left = self.savedVariables.left local top = self.savedVariables.top SimpleStatsWindow:ClearAnchors() SimpleStatsWindow:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, left, top) end function SimpleStats:Initialize() self.savedVariables = ZO_SavedVars:New("SimpleStatsSavedVariables", 1, nil, {}) self:RestorePosition() end function SimpleStats.OnAddOnLoaded(event, addonName) if addonName == SimpleStats.name then SimpleStats:Initialize() end end EVENT_MANAGER:RegisterForEvent(SimpleStats.name, EVENT_ADD_ON_LOADED, SimpleStats.OnAddOnLoaded) Code:
<GuiXml> <Controls> <TopLevelControl name="SimpleStatsWindow" mouseEnabled="true" movable="true" clampedToScreen="true"> <Dimensions x="200" y="150" /> <Anchor point="TOPLEFT" relativeTo="GuiRoot" relativePoint="TOPLEFT" offsetY="-150" /> <OnMoveStop> SimpleStats.OnWindowMoveStop() </OnMoveStop> <Controls> <Backdrop name="$(parent)Bg" inherits="ZO_DefaultBackdrop" /> <Label name="$(parent)Label-Max" width="100" height="5" font="ZoFontGameLarge" inheritAlpha="true" color="FFFFFF" wrapMode="TRUNCATE" text="Max"> <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" /> </Label> <Label name="$(parent)Label-Rec" width="100" height="5" font="ZoFontGameLarge" inheritAlpha="true" color="FFFFFF" wrapMode="TRUNCATE" text="Rec"> <Anchor point="TOPLEFT" relativeTo="$(parent)Label-Max" relativePoint="BOTTOMLEFT" /> </Label> <Label name="$(parent)Label-Power" width="100" height="5" font="ZoFontGameLarge" inheritAlpha="true" color="FFFFFF" wrapMode="TRUNCATE" text="Pow"> <Anchor point="TOPLEFT" relativeTo="$(parent)Label-Rec" relativePoint="BOTTOMLEFT" /> </Label> <Label name="$(parent)Label-Crit" width="100" height="5" font="ZoFontGameLarge" inheritAlpha="true" color="FFFFFF" wrapMode="TRUNCATE" text="Cri"> <Anchor point="TOPLEFT" relativeTo="$(parent)Label-Power" relativePoint="BOTTOMLEFT" /> </Label> <Label name="$(parent)Label-Pen" width="100" height="5" font="ZoFontGameLarge" inheritAlpha="true" color="FFFFFF" wrapMode="TRUNCATE" text="Pen"> <Anchor point="TOPLEFT" relativeTo="$(parent)Label-Crit" relativePoint="BOTTOMLEFT" /> </Label> </Controls> </TopLevelControl> </Controls> </GuiXml> |
|
11/10/20, 02:30 AM | #2 |
https://wiki.esoui.com/Main_Page
Lower bottom right -> Templates: Scene Manager: On scene change Fragments in a scene: On fragment state change (e.g. Hide control as menu opens) The game uses SCENES which are a kind of "visible tables storing controls and data", and each scene got 1 to n fragments attached. You are able to react on the scenes and/or fragments as they are going to be shown (showing), are shown (shown), going to be hidden (hiding) or are hidden (hidden) again via a callback function. If you register your own fragment, add your Top Level Control to it and thena dd this fragment to an exisitng scene like the hud or hud_ui the standard show/hide functions will handle the show/hide of your fragment as well, automatically. Edit about your code: You should not mix up the usage of . and : in your code. https://wiki.esoui.com/SimpleNotebookTutorial/part5 function SimpleStats.OnWindowMoveStop() function SimpleStats:RestorePosition As your SimpleStats is ONLY a anormal table, defined via = {}, and it's not a kind of object or class defined via ZO_Object:Subclass() or ZO_Object:New() I'd go with the normal . instead of a :. In this curren simple example it does not make a big difference. But if you will use objects and "subclasses" one day you'll get into trouble if you only use . as the parameters of the functions do not automatically add the object (self) and you manually need to isert it as always 1st parameter. Difference shown with an example: Lua Code:
Classes within ESO lua are just tables using the setmetatable functions to "inherit data from the tables above", so no real classes lie within other languages. Now an example where the created object will be calling the Test function without :, only by . Lua Code:
Now to the normal addon table approach Lua Code:
Last edited by Baertram : 12/16/20 at 10:51 AM. |
|
11/10/20, 06:53 PM | #3 | |
Join Date: Nov 2020
Posts: 2
|
Baertram,
TYVM for the info and the explanation. I will look at that template page for direction. As far as the difference in "." and ":", I was a little confused on that. I have never seen both being used, generally only one or the other based on language syntax. If you look at https://wiki.esoui.com/Writing_your_first_addon, the "Basic Skeleton Code" section does exactly the flip-flop you mentioned. I haven't coded in Lua in over 10 years (not since I played WoW) and didn't feel comfortable deviating from the tutorial until I had a working framework that I could go back and break. But, I will revisit the lua.org manual for more guidance as it has been some time. On a side note, what version of LUA is ESO using? |
|
11/11/20, 02:46 AM | #4 |
Last edited by Baertram : 12/16/20 at 10:51 AM. |
|
ESOUI » Developer Discussions » General Authoring Discussion » Help with Hiding Addon except in Main Window |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|