Hi guys,
I am trying to add the LibAddonMenu-2.0 to this addon. I am able to get the settings window to work, but now that I have added that I am no longer able to access a function from within the xml. If I comment out the
Lua Code:
LAM2:RegisterAddonPanel("ReloadButton", panelData)
LAM2:RegisterOptionControls("ReloadButton", optionsTable)
Then I again am able to access my functions from within the xml. I am hoping someone sees what am doing wrong?
Lua Code:
ReloadButton = {}
ReloadButton.Default = { OffsetX = 300, OffsetY = 300, Show = true, version = 2}
ReloadButton.name = "ReloadButton"
ReloadButton.version = 2
ReloadButton.show = true
ZO_CreateStringId("SI_BINDING_NAME_TARLAC_RELOADBUTTON", "Show/Hide ReloadButton") -- This is not showing up
function ReloadButton.OnAddOnLoaded(event, addonName)
if addonName == ReloadButton.name then
ReloadButton:Initialize()
end
end
function ReloadButton:Initialize()
ReloadButton.savedVariables = ZO_SavedVars:NewCharacterIdSettings("ReloadButtonSavedVariables", ReloadButton.version, nil, ReloadButton.Default)
--Load Defaults
ReloadButtonWindow:ClearAnchors()
ReloadButtonWindow:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, ReloadButton.savedVariables.OffsetX, ReloadButton.savedVariables.OffsetY)
ReloadButton.ControlSettings()
EVENT_MANAGER:UnregisterForEvent(ReloadButton.name, EVENT_ADD_ON_LOADED)
end
function ReloadButton.SaveSettings()
ReloadButton.version = ReloadButton.version + 1
ReloadButton.savedVariables.version = ReloadButton.version
ReloadButton.savedVariables.OffsetX = ReloadButtonWindow:GetLeft()
ReloadButton.savedVariables.OffsetY = ReloadButtonWindow:GetTop()
d("Saved = " .. tostring(ReloadButton.savedVariables.OffsetX))
end
function ReloadButton.Close()
ReloadButtonWindow:SetHidden(true)
ReloadButton.show = false
ReloadButton.savedVariables.Show = false
end
function ReloadButton.Open()
ReloadButtonWindow:SetHidden(false)
ReloadButton.show = true
ReloadButton.savedVariables.Show = true
end
function ReloadButton.Reload()
ReloadUI("ingame")
end
function ReloadButton.Check()
if ReloadButton.show == true then
ReloadButton.Open()
else
ReloadButton.Close()
end
end
function ReloadButton.ControlSettings()
d("Control Settings Started")
local tempVersion = ReloadButton.version
local panelData = {
type = "panel",
name = "ReloadButton",
displayName = "ReloadButton",
author = "Tarlac",
version = tempVersion,
slashCommand = "/reloadbuttonsettings", --(optional) will register a keybind to open to this panel
registerForRefresh = true, --boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown)
registerForDefaults = true, --boolean (optional) (will set all options controls back to default values)
}
local optionsTable = {
[1] = {
type = "header",
name = "ReloadButton",
width = "full", --or "half" (optional)
},
[2] = {
type = "checkbox",
name = "Show/Hide ReloadButton",
tooltip = "Checkbox's tooltip text.",
getFunc = function() return true end,
setFunc = function(value) ReloadButton.show = value ReloadButtonWindow:SetHidden (not value) end,
width = "half", --or "half" (optional)
},
}
local LAM2 = LibStub("LibAddonMenu-2.0")
---------------------------------If I comments these out then my addon works.--------------------
LAM2:RegisterAddonPanel("ReloadButton", panelData)
LAM2:RegisterOptionControls("ReloadButton", optionsTable)
-------------------------------------------------------------------------------------------------
d("Control Settings Ended")
end
d("Loaded ReloadButton...")
EVENT_MANAGER:RegisterForEvent(ReloadButton.name, EVENT_ADD_ON_LOADED, ReloadButton.OnAddOnLoaded)
SLASH_COMMANDS["/reloadbutton"] = function() ReloadButton.Open() end
Code:
GuiXml>
<Controls>
<TopLevelControl name="ReloadButtonWindow" clampedToScreen="true" mouseEnabled="true" movable="true" hidden="false">
<Dimensions x="50" y="20" />
<Anchor point="TOPLEFT" relativeTo="GuiRoot" relativePoint="CENTER" offsetX="0" offsetY="-30"/>
<OnMoveStop>
ReloadButton.SaveSettings()
</OnMoveStop>
<Controls>
<Backdrop name="$(parent)Backdrop" edgeColor="FF0000" centerColor="6495ED" alpha="0.6" >
<Dimensions x="50" y="50" />
<Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="50" offsetY="20"/>
<Edge edgeSize="6" />
</Backdrop>
<Button name="$(parent)Button" >
<Dimensions x="50" y="50" />
<Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="50" offsetY="20"/>
<Textures
normal ="/esoui/art/help/help_tabicon_feedback_up.dds"
mouseOver ="/esoui/art/help/help_tabicon_feedback_over.dds"/>
<OnClicked>
ReloadButton.Reload()
</OnClicked>
</Button>
<Button name="$(parent)ButtonCloseAddon" inherits="ZO_ButtonBehaviorClickSound">
<Dimensions x="40" y="40" />
<Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetX="40" />
<Textures normal="EsoUI/Art/Buttons/closebutton_up.dds"
pressed="EsoUI/Art/Buttons/closebutton_down.dds"
mouseOver="EsoUI/Art/Buttons/closebutton_mouseover.dds"
disabled="EsoUI/Art/Buttons/closebutton_disabled.dds"/>
<OnClicked>
ReloadButton.Close()
</OnClicked>
</Button>
<Label name="$(parent)Label" font="ZoFontWinH3" color="ffffff" text="Reload" verticalAlignment="CENTER" horizontalAlignment="LEFT" alpha="0.85">
<Dimensions x="60" y="20" />
<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="-5" offsetY="0"/>
</Label>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>