Thread Tools Display Modes
Prev Previous Post   Next Post Next
11/09/20, 06:34 PM   #1
Nant
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)
Current XML:
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>
  Reply With Quote
 

ESOUI » Developer Discussions » General Authoring Discussion » Help with Hiding Addon except in Main Window


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