View Single Post
02-03-15, 11:18 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by rocnroll View Post
One of my favorite subjects in school. Four years Marching and Symphonic band playing trumpet.
3 years in band playing flute here (no, I never went to band camp!) but switched to choir my last 2 years of high school due to scheduling conflicts... was the only girl not in the soprano section. Both were among the only classes I wasn't totally bored with. Unfortunately small schools in rural areas are not well-equipped to provide a useful or enjoyable education for smart kids.

Originally Posted by siweia View Post
I just start to add few options, but I don't know how to update it to swith on/off addon function. It is only a panel which stands alone.
Well, your code is quite convoluted and overcomplicated, so I'm not surprised you're getting confused, and I'm not going to dig through it to address any specifics, but generally speaking, if your saved variables are a table that looks like this:

Code:
MyAddonDB = {
    width = 64,
    height = 24,
    bgColor = { r = 0, g = 1, b = 0 }
}
... and your addon does something like this on login:

Code:
MyAddonFrame:SetSize( MyAddonDB.width, MyAddonDB.height )
MyAddonFrame:SetBackdropColor( MyAddonDB.bgColor.r, MyAddonDB.bgColor.g, MyAddonDB.bgColor.b )
... then when your width option was changed you'd just set the new value in the table:

Code:
MyAddonDB.width = NEW_OPTION_VALUE
... and then apply it to your frame:

Code:
MyAddonFrame:SetWidth( NEW_OPTION_VALUE )
It kind of looks like you're trying to write a generalized options framework, rather than just hardcoding the specific options you want. If that's the case (eg. if you need dynamic options because the user can add or remove instances of some kind of object, like action bars, that each have their own set of options) I'd suggest just using AceConfig instead. That way you can just:

1. Create an options table and add/remove/change sections as needed.
2. Register it with AceConfig-Registry.
3a. Open an options window with AceConfig-Dialog, which automatically generates and lays out all the actual option widgets and container frames using AceGUI behind the scenes.
3b. AceConfig-Dialog can also add your options window to the Interface Options frame.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote