Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:Creating GUI configuration options
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== config frame .lua === Our lua file for the config frame then breaks down into just 2 functions, one for when the frame is shown, the other for when an option in the config frame (like a checkbox, or a slider is moved) changes. '''within myClockConfigFrame.lua''' -- OnShow function myClockConfigFrame_OnShow() -- make sure our profile has been loaded if ( not myClock_variablesLoaded ) then -- config not loaded this:Hide(); -- hide our config pane return; end -- read settings from profile, and change our checkbuttons and slider to represent them getglobal(this:GetName().."CheckButtonOn"):SetChecked( myClockConfig[myClockRealm][myClockChar].on ); getglobal(this:GetName().."CheckButtonTime24"):SetChecked( myClockConfig[myClockRealm][myClockChar].time24 ); getglobal(this:GetName().."SliderOffset"):SetValue( myClockConfig[myClockRealm].offset ); end You'll notice again that we have to make sure that the profile is there (or variables loaded). The code also uses the getglobal() function to construct the names of the controls, so it doesn't matter what we called our frame. After that it's a simple matter of using SetChecked() or SetValue() with our profile settings to make our config dialog look right. The last part is making sure that when they change something in the config dialog, it changes the profile. Here's what that would look like: '''within myClockConfigFrame.lua''' -- OnClick function grokClockConfigFrameOption_OnClick() -- make sure our profile has been loaded if ( not myClock_variablesLoaded ) then -- config not loaded this:GetParent():Hide(); -- hide our config pane (this is now a checkbox) return; end -- read setting out of checkbox (or slider) and put into profile -- use this:GetName() to know which checkbox was hit. if ( this:GetName() == (this:GetParent():GetName().."CheckButtonOn" ) ) then myClockConfig[myClockRealm][myClockChar].on = this:GetChecked(); -- set profile elseif ( this:GetName() == (this:GetParent():GetName().."CheckButtonTime24" ) ) then myClockConfig[myClockRealm][myClockChar].time24 = this:GetChecked(); elseif ( this:GetName() == (this:GetParent():GetName().."SliderOffset" ) ) then myClockConfig[myClockRealm].offset = this:GetValue(); end -- configuration was changed, make sure our addon changes too! -- notice our addon is changed right away, not when we hit 'done'. myClock_ConfigChange(); end Again we have a check to make sure our profile is loaded, and then a mock switch/case statement to determine which CheckButton was pressed. Once we know, it's a simple issue of using this:GetChecked() or this:GetValue() to set our profile config! At the end we make sure our main addon knows that something was changed. Alternatively you could leave out the 'myClock_ConfigChange();' of this function, and add it to the Done button OnClick event to make a Save/Cancel dialog. Generally speaking for a config people want to see the changes happen live so they can tweak them. You're done! Hopefully this provided some concrete examples on how to make a config dialog, and much thanks to Scheid for being the ginipig! You could easily go from here to make a more complex configuration pane, using tabs, multiple pages, or even using Cosmos' Khaos (another howto someday). [[Category:HOWTOs|Create GUI Config Options]]
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)