Hi guys, my names Jumpercable, author of EZ Mount addon.
Ive been trying to find a way to add options to my addon using: InterfaceOptions_AddCategory()
Im struggling to get the SavedVariablesPerChar into the options frame, and then any changes saved back when the player_logout event fires ( my belief is that it should auto write the savedvariables per char without any extra code ).
The purpose of this is to let me load the savedvariablespercharacter and update the options frame based on saved variables. If the options are changed the variables are saved on logout. The slash command is what my addon uses to run from an ingame macro.
Heres some code ive being trying to work with before adding it into my addon:
Any advice here or if i can even do this, any help is appreciated.
Code:
local EZTest_Main = CreateFrame("Frame","EZTest")
local EZTest = CreateFrame("Button","EZTest",EZTest_Main,"SecureActionButtonTemplate")
EZTest:RegisterEvent("PLAYER_LOGIN")
EZTest:SetScript("OnEvent", function(self,event,...)
if type(EZTestData) ~= "table" then
print(type(EZTestData))
EZTestData = {}
EZTestData.Config_Flying = 0
EZTestData.Config_Dismount = 0
ChatFrame1:AddMessage('EZ Mount: Initial variables set for '..UnitName("player"))
else
print(EZTestData.Config_Flying, EZTestData.Config_Dismount)
if not EZTestData.Config_Flying then
EZTestData.Config_Flying = 0
ChatFrame1:AddMessage('Empty Data for Flying')
else
if EZTestData.Config_Flying == 0 then
ChatFrame1:AddMessage('No flying')
else
ChatFrame1:AddMessage('Flying')
end
end
if not EZTestData.Config_Dismount then
EZTestData.Config_Dismount = 0
ChatFrame1:AddMessage('Empty Data for Dismount')
else
if EZTestData.Config_Dismount == 0 then
ChatFrame1:AddMessage('No Dismount')
else
ChatFrame1:AddMessage('Dismount')
end
end
end
Create_GUI()
end)
SLASH_EZTEST1 = "/EZTest"
SlashCmdList["EZTest"] = function(msg)
print(EZTestData.Config_Flying,' Config Variable')
end
-----------------------------
-- Create GUI for options ---
-----------------------------
--[[Use Blizzards config frame. We do not use the Configator lib]]
function Create_GUI()
if EZTest_Config then return end
EZTest_Config = CreateFrame("Frame", "EZTest Options", EZTest_Main, UIParent)
EZTest_Config:SetWidth(420)
EZTest_Config:SetHeight(400)
EZTest_Config:SetToplevel(true)
EZTest_Config:Hide()
EZTest_Config.name = "EZ TEST"
InterfaceOptions_AddCategory(EZTest_Config)
EZTest_Config.help = EZTest_Config:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
EZTest_Config.help:SetText("EZ TEST")
EZTest_Config.help:SetPoint("TOPLEFT", EZTest_Config,"TOPLEFT" , 12, -20)
--- Add UI changable elements
EZTest_Config.DismountCheck = CreateFrame("CheckButton", "EZTESTDISMOUNT", EZTest_Config, "InterfaceOptionsCheckButtonTemplate")
EZTESTDISMOUNTText:SetText("Enable Dismount while in air")
EZTest_Config.DismountCheck:SetPoint("LEFT", EZTest_Config, "TOPLEFT", 10, -50)
EZTest_Config.DismountCheck:SetChecked(EZTestData.Config_Dismount)
function EZTest_Config.DismountCheck.setFunc(state)
EZTestData.Config_Dismount = state
lib.ApplyLayout()
end
EZTest_Config.FlyingCheck = CreateFrame("CheckButton", "EZTESTFLYING", EZTest_Config, "InterfaceOptionsCheckButtonTemplate")
EZTESTFLYINGText:SetText("Use flying mounts when you cannot fly")
EZTest_Config.FlyingCheck:SetPoint("LEFT", EZTest_Config, "TOPLEFT", 10, -70)
EZTest_Config.FlyingCheck:SetChecked(EZTestData.Config_Flying)
function EZTest_Config.FlyingCheck.setFunc(state)
EZTestData.Config_Flying = state
lib.ApplyLayout()
end
end