Add-on settings: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Ronie
(Created page with "settings.xml is a XML file that contains the current configuration for the addon and should be places in the resources direcory. If your addon has configurable items that are set...")
 
>Ronie
No edit summary
Line 31: Line 31:
| folder || Creates a folder selector ||  ||
| folder || Creates a folder selector ||  ||
|-
|-
| enum || Creates a select box || Pipe separated list of values e.g. "1|3|5|10|All" || Using xbmcplugin.getSetting(pluginId,'mytagname') on an enum will return the index into the list, not the value itself. Also be aware that 1 digit indexes may be returned as '01', '02' etc
| enum || Creates a select box || <nowiki>separated list of values: '1|3|5|10|All'</nowiki> || Using xbmcplugin.getSetting(pluginId,'mytagname') on an enum will return the index into the list, not the value itself.<br />Also be aware that 1 digit indexes may be returned as '01', '02' etc
|-
|-
| labelenum ||  ||  || Same as enum except the value  
| labelenum ||  ||  || Same as enum except the value is returned by getSetting() instead of the index
is returned by getSetting()  
instead of the index
|-
|-
| ipaddress || Creates IP dialog ||  ||
| ipaddress || Creates IP dialog ||  ||
Line 41: Line 39:
| integer || Creates numeric dialog ||  ||
| integer || Creates numeric dialog ||  ||
|-
|-
| bool || Creates radio button ||  || Set default or value attribute to to “true” or “false” (note case).
| bool || Creates radio button ||  || Set default or value attribute to to “true” or “false” (note case).<br />Using xbmcplugin.getSetting(pluginId,'mytagname') on a bool will return 'true' or 'false'.<br />Use appropriate conversion to turn into real boolean.
Using  
xbmcplugin.getSetting(pluginId,'
mytagname') on a bool will  
return 'true' or 'false'. Use  
appropriate conversion to turn  
into real boolean.
|-
|-
| sep || Creates a separator line in the dialog || Ignored ||
| sep || Creates a separator line in the dialog || Ignored ||
Line 61: Line 53:
| local ||  ||  ||
| local ||  ||  ||
|-
|-
| fileenum || Create a file selector based on path set in value attribute || Set value to root of directory you want to use for selection || cell
| fileenum || Create a file selector based on path set in value attribute || Set value to root of directory you want to use for selection ||
|-
|-
| action || Executes a script when selected ||  || Set the 'action' attribute to the  
| action || Executes a script when selected ||  || Set the 'action' attribute to the name of your function to execute:<br />action="RunPlugin(plugin://video/Apple Movie Trailers Plugin/?update=newest)"<br />Optionally set the 'option' attribute to “close” if you want to close the settings dialog when you click the setting.
name of your function to  
execute:
action="RunPlugin(plug
in://video/Apple Movie  
Trailers Plugin/?
update=newest)"
Optionally set the 'option'  
attribute to “close” if you want to  
close the settings dialog when  
you click the setting.
|}
|}


Line 80: Line 62:
{| class="wikitable" border="0"
{| class="wikitable" border="0"
|-
|-
| source="" || "video", "music", "pictures", "programs", "files", "local" or blank.
| source="" || "video", "music", "pictures", "programs", "files", "local" or blank."<br />if source is blank it will use the type for shares if it is a valid share if not a valid share it will use, both local and network drives.
if source is blank it will use the type for shares if it is a valid share if not a valid share it will use, both local and network drives.
|-
|-
| visible="" || "true", "false".
| visible="" || "true", "false" or conditional."<br />Determines if the setting is displayed in the settings dialog (default = 'true')"<br />You can also use a conditional statement: visible="System.HasAddon(plugin.video.youtube)"
Determines if the setting is displayed in the settings dialog (default = 'true')
|-
|-
| enable="" || Allows you to determine whether this setting should be shown based on the value of another setting. 3 comparators are available:
| enable="" || Allows you to determine whether this setting should be shown based on the value of another setting. 3 comparators are available:"
* eq() Equal to
* eq() Equal to
* gt() Greater than
* gt() Greater than
Line 100: Line 80:
: myThirdSetting
: myThirdSetting


for the third setting we might add the option:
for the third setting we might add the option:<br />
enable="gt(-2,3) + lt(-2,10)"
enable="gt(-2,3) + lt(-2,10)"<br /><br />
You can also use a conditional statement: enable="System.HasAddon(plugin.video.youtube)"
|}
|}

Revision as of 22:30, 15 January 2012

settings.xml is a XML file that contains the current configuration for the addon and should be places in the resources direcory. If your addon has configurable items that are set by the user, put them here. This file defines what the user sees when they click on Addon settings for your addon. You don't need to do any coding to utilise this functionality. The format for the settings file is relatively straightforward as can be seen in the following example:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
    <category label= ”32001”>
        <setting id="username" type="text" label="32011"    default=""/>
        <setting id="password" type="text" option="hidden" label="32012" enable="!eq(-1,)" default=""/>
        <setting type="sep"/>
        <setting id="debug" type="bool" label="32013" default ="false"/>
    </category>
</settings>


You need to supply at least one category element. The label attribute of both categories and settings should be the id of a language string in your language files.

Setting type and additional attributes can be one in the following table:

Type Description Value attribute (value="") Notes
text Creates keyboard input Can have 'option' attribute set “true” or “false”, will hide the text value if false.
file Creates a file selector
folder Creates a folder selector
enum Creates a select box separated list of values: '1|3|5|10|All' Using xbmcplugin.getSetting(pluginId,'mytagname') on an enum will return the index into the list, not the value itself.
Also be aware that 1 digit indexes may be returned as '01', '02' etc
labelenum Same as enum except the value is returned by getSetting() instead of the index
ipaddress Creates IP dialog
integer Creates numeric dialog
bool Creates radio button Set default or value attribute to to “true” or “false” (note case).
Using xbmcplugin.getSetting(pluginId,'mytagname') on a bool will return 'true' or 'false'.
Use appropriate conversion to turn into real boolean.
sep Creates a separator line in the dialog Ignored
music
video
pictures
programs
local
fileenum Create a file selector based on path set in value attribute Set value to root of directory you want to use for selection
action Executes a script when selected Set the 'action' attribute to the name of your function to execute:
action="RunPlugin(plugin://video/Apple Movie Trailers Plugin/?update=newest)"
Optionally set the 'option' attribute to “close” if you want to close the settings dialog when you click the setting.


Settings can have additional attributes:

source="" "video", "music", "pictures", "programs", "files", "local" or blank."
if source is blank it will use the type for shares if it is a valid share if not a valid share it will use, both local and network drives.
visible="" "true", "false" or conditional."
Determines if the setting is displayed in the settings dialog (default = 'true')"
You can also use a conditional statement: visible="System.HasAddon(plugin.video.youtube)"
enable="" Allows you to determine whether this setting should be shown based on the value of another setting. 3 comparators are available:"
  • eq() Equal to
  • gt() Greater than
  • lt() Less than

You can AND the comparators using the + symbol and negate it using the ! symbol (e.g. !eq() ). Each comparator takes 2 operands:

  • Relative position of setting to compare
  • Value to compare against

Thus if we place settings in our file in this order:

myFirst setting
mySecondSetting
myThirdSetting

for the third setting we might add the option:
enable="gt(-2,3) + lt(-2,10)"

You can also use a conditional statement: enable="System.HasAddon(plugin.video.youtube)"