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!
==== Custom Update Functions ==== We now have a function that will be called when our variables are loaded. It will need to: * load default SavedVariable values * register addon with [[myAddOns]] * record that configuration was loaded '''within myClockIndicatorFrame.lua''' ... function myClockIndicatorFrame_VARIABLES_LOADED() -- initialize our SavedVariable if ( not myClockConfig ) then myClockConfig = {}; end if ( not myClockConfig[myClockRealm] ) then myClockConfig[myClockRealm] = {}; end if ( not myClockConfig[myClockRealm][myClockChar] ) then myClockConfig[myClockRealm][myClockChar] = {}; end -- load each option, set default if not there if ( not myClockConfig[myClockRealm][myClockChar].on ) then myClockConfig[myClockRealm][myClockChar].on = myClockConfig_defaultOn; end if ( not myClockConfig[myClockRealm][myClockChar].time24 ) then myClockConfig[myClockRealm][myClockChar].time24 = myClockConfig_defaultTime24; end if ( not myClockConfig[myClockRealm].offset ) then myClockConfig[myClockRealm].offset = myClockConfig_defaultOffset; end -- record that we have been loaded myClock_variablesLoaded = true; -- we know other addons have been "loaded" now -- optional dependance on myAddOns, leads to our config panel if( myAddOnsFrame_Register ) then myAddOnsFrame_Register( myClock_details ); end -- configuration might have changed myClock_ConfigChange(); end ... So this function is very simple, it created a new table for storing our configuration on a addon-wide, realm-wide and character basis, then checked for every config option and made sure it was loaded, if not then set it to the default. We added myAddons support, telling myAddons what our mod's name, main frame, and config frame was using a table declared in our globals. The last line is interesting, we make a call to myClock_ConfigChange(). This is the function that will actually change our mod based on our settings. In the case of a clock most of those options ('time24', 'offset') are actually in OnUpdate, but we would handle the 'on' in this function. Our config change should: * Turn the mod on and off '''within myClockIndicatorFrame.lua''' ... function myClock_ConfigChange() -- make sure that our profile has been loaded before allowing this function to be called if ( not myClock_variablesLoaded ) then -- config not loaded myClockIndicatorFrame:Hide(); -- turn our mod off return; end -- make sure to use the frame's name here, cannot rely on 'this' to mean the main frame if ( myClockConfig[myClockRealm][myClockChar].on ) then myClockIndicatorFrame:Show(); -- show our mod frame else myClockIndicatorFrame:Hide(); -- hide our mod frame end end ... It can also be useful to have a function to set everything back to defaults... here is one you might use in this case '''within myClockIndicatorFrame.lua''' ... -- reset to defaults function grokClock_ConfigToDefault() -- make sure that our profile has been loaded before allowing this function to be called if ( not myClock_variablesLoaded ) then -- config not loaded myClockIndicatorFrame:Hide(); -- turn our mod off return; end -- set our profile to defaults myClockConfig[myClockRealm][myClockChar].on = myClockConfig_defaultOn; myClockConfig[myClockRealm][myClockChar].time24 = myClockConfig_defaultTime24; myClockConfig[myClockRealm][myClockChar].offset = myClockConfig_defaultOffset; -- frame name used since called from various places -- set the location of the frame... in case they dragged it away myClockIndicatorFrame:SetPoint("TOPLEFT", "MinimapCluster", "TOPLEFT", 122, -28); -- wow automatically saves the location of frames on the screen! -- make sure the defaults are loaded onto our mod frame myClock_ConfigChange(); end ...
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)