Customizing the menu
Create a configuration, add custom pages and fill more details for your module
Setting up
By setting the MODULE.menu
, you will be able to customize your module's menu.
The setup should looks like this:
local MODULE = {
-- ...
}
MODULE.menu = {
-- here we will customize our menu:
-- config = {},
-- pages = {},
-- details = {},
}
-- ...
return MODULE
Adding configuration
TODO
Adding pages
Pages are additionals DForms that will be created in the module's menu.
To do so, you need to specify the pages
table variable.
Each 'page' element must be a function( DForm )
which will modify its own form as you want it to be.
Example
Work-Arounds page, code from base module:
MODULE.menu = {
-- ...
pages = {
-- workaround
function( form )
form:SetName( "Work-Arounds" )
form:Help( "This is where you can toggle fixes of other addons" )
-- populate workarounds
local checkboxes = {}
for k, v in pairs( guthscp.workarounds ) do
local checkbox = form:CheckBox( v.name )
checkbox:SetChecked( v:is_enabled() )
checkbox:SetDisabled( not v:is_active() )
checkboxes[k] = checkbox
end
-- apply changes
local button = form:Button( "Apply" )
function button:DoClick()
-- some non-related code...
end
end,
},
-- ...
}
Adding details
By default, these module properties will show in the sidebar, such as:
the author name
the local version
the remote version (if
MODULE.version_url
was set and the request was successful)
If you want to customize your module's sidebar such as adding informations & links, you have to specify the details
table variable and add all the content you want.
Each string element will show as a category in the sidebar. You can also give a structured table to create links, actions or texts:
Structure
string
text
Text of the label
(optional)
string
icon=nil
Icon path of the detail, used in the menu. The pointed material must be a 16x16px image, use a Silkicon or make your own. You can also use the icons released with the base.
(optional)
string
url=nil
URL to open when the user clicks on this detail. NOT compatible with the callback
property.
(optional)
function
callback=nil
Custom callback to run when the user clicks on this detail. NOT compatible with the url
property.
Example
Code from base module:
MODULE.menu = {
-- ...
details = {
"Wiki",
{
text = "Read Me",
icon = "icon16/information.png",
url = "https://github.com/Guthen/guthscpbase/blob/master/README.md",
},
{
text = "API",
icon = "icon16/script_code.png",
url = "https://github.com/Guthen/guthscpbase/wiki/API",
},
-- ...
"Social",
{
text = "Github",
icon = "guthscp/icons/github.png",
url = "https://github.com/Guthen/guthscpbase",
},
{
text = "Steam",
icon = "guthscp/icons/steam.png",
url = "https://steamcommunity.com/sharedfiles/filedetails/?id=2139692777",
},
-- ...
},
}
Last updated