View Single Post
11/07/16, 05:06 PM   #1
jellyalex978
 
jellyalex978's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2016
Posts: 8
Post i can't saved the GuiXml position with ZO_SavedVars

i am learning my first addon XD

i follow this link :
http://wiki.esoui.com/Writing_your_first_addon
http://wiki.esoui.com/Circonians_Sav...ables_Tutorial

question :
when addon loads
jellyIndicator always start : 300,70
why i can't change the last position


xml : event
Code:
<GuiXml>
    <Controls>
        <TopLevelControl name="jellyIndicator" mouseEnabled="true" movable="true" clampedToScreen="true">
            <Dimensions x="200" y="25" />
            <Anchor point="BOTTOM" relativeTo="GuiRoot" relativePoint="CENTER" offsetY="-20" />
            <OnMoveStop>
                jelly.OnIndicatorMoveStop()
            </OnMoveStop>
            <Controls>
                <Label name="$(parent)Label" width="200" height="25" font="ZoFontWinH1" inheritAlpha="true" color="FF0000"
                    wrapMode="TRUNCATE" verticalAlignment="TOP" horizontalAlignment="CENTER" text="CombatTipId">
                    <Anchor point="TOP" relativeTo="$(parent)" relativePoint="TOP" />
                </Label>
            </Controls>
        </TopLevelControl>
    </Controls>
</GuiXml>
lua :
Code:
jelly = {}
jelly.name = "jelly"
jelly.version = 1
jelly.jellyIndicatorDef = {
	OffsetX = 300,
	OffsetY = 70
}

function jelly:Initialize()
    jelly.savedVars = ZO_SavedVars:New("jellyVars", jelly.version, nil, jelly.jellyIndicatorDef)
    jelly:RestorePosition()
end

function jelly.OnIndicatorMoveStop()
    jelly.savedVars.OffsetX = jellyIndicator:GetLeft()
    jelly.savedVars.OffsetY = jellyIndicator:GetTop()
end

function jelly:RestorePosition()
    jellyIndicator:ClearAnchors()
    jellyIndicator:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, jelly.savedVars.OffsetX, jelly.savedVars.OffsetY)
end

function jelly.OnAddOnLoaded(event, addonName)
    if addonName == jelly.name then
        jelly:Initialize()
    end
end

EVENT_MANAGER:RegisterForEvent(jelly.name, EVENT_ADD_ON_LOADED, jelly.OnAddOnLoaded)
  Reply With Quote