ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   i can't saved the GuiXml position with ZO_SavedVars (https://www.esoui.com/forums/showthread.php?t=6618)

jellyalex978 11/07/16 05:06 PM

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)


merlight 11/07/16 05:30 PM

Do your addon's settings actually get saved in SavedVariables/? If not, your addon manifest is probably missing the line ## SavedVariables: jellyVars

jellyalex978 11/07/16 05:41 PM

hi merlight

thank for help

i understand now !!


All times are GMT -6. The time now is 04:29 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI