Thread Tools Display Modes
Prev Previous Post   Next Post Next
01-19-21, 03:17 AM   #1
Jumpercable
A Murloc Raider
Join Date: Jan 2021
Posts: 7
Having trouble with multiple frames and switching data between them.

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

Last edited by Jumpercable : 01-19-21 at 05:17 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » General Authoring Discussion » Having trouble with multiple frames and switching data between them.

Thread Tools
Display Modes

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