Thread Tools Display Modes
Prev Previous Post   Next Post Next
01/25/16, 02:35 AM   #1
Terrillyn
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 24
Having issues creating an account-wide settings toggle

Hi, I'm having trouble create an 'account-wide settings' toggle for one of my addons, well actually I've got it working but its causing weird behavior with the colorpicker controls and some of the other controls, and I'm hoping someone can help me figure out what I'm doing wrong, here is some scippets of how I'm accomplishing the accountwide toggle:

When my addon loads here is how I load the settings:
Lua Code:
  1. SimpleXPBar.accountwide_settings = ZO_SavedVars:NewAccountWide("SimpleXPBar_Settings", "1", nil, { isAccountWide = false }, 'SimpleXPBar.AccountWide')
  2. SimpleXPBar.AWSV = ZO_SavedVars:NewAccountWide("SimpleXPBar_Settings", "1", nil, SimpleXPBar.default_settings)
  3. SimpleXPBar.CharSV = ZO_SavedVars:New("SimpleXPBar_Settings", "1", nil, SimpleXPBar.default_settings)
  4.    
  5. if SimpleXPBar.accountwide_settings.isAccountWide then
  6.     ZO_DeepTableCopy(SimpleXPBar.AWSV, SimpleXPBar.CharSV)
  7.     SimpleXPBar.CurSV = SimpleXPBar.AWSV
  8. else
  9.     SimpleXPBar.CurSV = SimpleXPBar.CharSV
  10. end

and here is how my 'Account-Wide' toggle is setup (using libaddonmenu):
Lua Code:
  1. {
  2.     type = "checkbox",
  3.     name = "Use Account-Wide settings",
  4.     getFunc = function()
  5.         return SimpleXPBar.accountwide_settings.isAccountWide
  6.     end,
  7.     setFunc = function(val)
  8.         SimpleXPBar.accountwide_settings.isAccountWide = val
  9.         if SimpleXPBar.accountwide_settings.isAccountWide then
  10.             ZO_DeepTableCopy(SimpleXPBar.AWSV, SimpleXPBar.CharSV)
  11.             SimpleXPBar.CurSV = SimpleXPBar.AWSV
  12.         else
  13.             ZO_DeepTableCopy(SimpleXPBar.CharSV, SimpleXPBar.AWSV)
  14.             SimpleXPBar.CurSV = SimpleXPBar.CharSV
  15.         end
  16.     end,
  17. },

Just for reference here is how the Colorpicker is setup:
Lua Code:
  1. {
  2.     type = "colorpicker",
  3.     name = "Color",
  4.     width = "full",
  5.     getFunc = function()
  6.         return SimpleXPBar.CurSV.textbar.color.r, SimpleXPBar.CurSV.textbar.color.b, SimpleXPBar.CurSV.textbar.color.g, SimpleXPBar.CurSV.textbar.color.a
  7.     end,
  8.     setFunc = function(r, g, b, a)
  9.         SimpleXPBar.CurSV.textbar.color.r = r
  10.         SimpleXPBar.CurSV.textbar.color.b = b
  11.         SimpleXPBar.CurSV.textbar.color.g = g
  12.         SimpleXPBar.CurSV.textbar.color.a = a
  13.         SimpleXPBar:UpdateControls()
  14.     end,
  15. },

I'm using SimpleXPBar.CurSV to reference my settings through-out the rest of the code, and the issue I'm having with the colorpicker is that it keeps flipping back and forth between 2 different color settings everytime I click it, I have a feeling this has to do with how lua is referencing the object but I cant figure what its doing in this case. I've already searched around the forums and google trying to find some sample of how to create a accountwide toggle correctly but I ended up looking at how Destinations and MasterMerchant do it and trying something similar.

Any suggestions on a better way of implementing this or a fix would be appreciated.
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Having issues creating an account-wide settings toggle


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