Skip to content
Marcel van der Veldt edited this page Dec 1, 2016 · 2 revisions

Skin Settings feature

This script provides a comprehensive method of setting skin settings. This will allow you to set complex configurations without complexity for the user or for you in the skin XML code. The main idea is that settings can be selected (either single or Multi select) in a dialogselect.

skinsettings.xml

You need to create the file skinsettings.xml in your extras folder (special://skin/extras/skinsettings.xml). Inside that xml file you define all options that a user can choose when setting a specific skinsetting.

For example:

<settings>
    <!-- home layout -->
    <setting id="HomeLayout" value="1" label="$LOCALIZE[31309] - 1 row" condition="" icon="" description=""/>
    <setting id="HomeLayout" value="2" label="$LOCALIZE[31309] - 2 rows" condition="" icon="" description="" default="true"/>
    <setting id="HomeLayout" value="3" label="$LOCALIZE[31309] - 3 rows" condition="" icon="" description=""/>
    
    <!-- background setting -->
    <setting id="CustomBackgroundSetting" value="default" label="$LOCALIZE[31023]" condition="" icon="special://skin/extras/backgrounds/global.jpg" description=""/>
    <setting id="CustomBackgroundSetting" value="weather" label="$LOCALIZE[31025]" condition="" icon="$VAR[WeatherFanArtPath]$INFO[Window(Weather).Property(current.fanartCode)]/weather.jpg" description=""/>
    <setting id="CustomBackgroundSetting" value="||BROWSEIMAGE||" label="Custom image" condition="" description=""/>
</settings>

Attributes for the XML:

  • id: name of the setting, required attribute
  • value: the value that should be written when selecting this value, required attribute
  • label: label for the option (will also be written to setting.label), required attribute
  • condition: any kodi condition syntax to make the option show up or not, optional attribute
  • icon: icon to show in dialogselect, optional attribute
  • description: description to show in dialogselect (label2), optional attribute
  • default: if set to "true" this will be the default value for your skin (will be set at skin startup/change/update), you may use a visibility condition instead of true

Set skin setting

Can be used to present a select dialog to specify a certain skin setting. Prevents you from creating all kinds of toggle options.

If you want to set the Skin String "HomeLayout", you can call the script like this:

<control type="button" id="423003">
    <label>[B]$LOCALIZE[31121]:[/B] $INFO[Skin.String(HomeLayout.label)]</label>
    <onclick>RunScript(script.skin.helper.service,action=setskinsetting,setting=HomeLayout,header=$LOCALIZE[31124])</onclick>
</control>         

This will present DialogSelect with your options. Once the user makes a selection, the value will be written to the Skin String. Also the prefix .label will store the label from the selected settingvalue.

Working with sublevels

It's possible to have a sublevel in the settings dialog, for example if you have many options for one setting. This way you can have layered navigation. Syntax:

<settings>
    <!-- home layout -->
    <setting id="HomeLayout" value="||SUBLEVEL||HomeLayout_horizontal" label="Horizontal home layouts" condition="" icon="" description="All horizontal homemenu layouts"/>
    <setting id="HomeLayout" value="tiles" label="Tile based layout" condition="" icon="" description=""/>
    
    <!-- sublevel: horizontal home layouts -->
    <setting id="HomeLayout_horizontal" value="layout1" label="Horizontal layout 1" condition="" icon="" description="" />
    <setting id="HomeLayout_horizontal" value="layout2" label="Horizontal layout 2" condition="" icon="" description="" />

</settings>

Special values to use as the value argument

Instead of a predefined value you can also have an option to let the user input the value himself. In that case you have to use a special syntax as the value:

||PROMPTNUMERIC|| --> Asks the user for a numeric input

||PROMPTSTRING|| --> Asks the user for a string input

||PROMPTSTRINGASNUMERIC|| --> Asks the user for a string which must be numeric (allows having negative numbers)

||BROWSEIMAGE|| --> Asks the user to select a single image or imagepath

||BROWSESINGLEIMAGE|| --> Asks the user to select a single image

||BROWSEMULTIIMAGE|| --> Asks the user to select a image path (multiimage)

||SKIPSTRING|| --> Do not write the results to a skin string (can be used if you only use the script with the onselect actions)

Apply other actions when user selects a value

It is possible to apply other settings when the user selects a certain value. Syntax:

<settings>
    <setting id="HomeLayout" value="mylayout" label="My great layout" condition="" icon="" description="">
        <onselect condition="True">Skin.Reset(OpenSubMenuOnClick)</onselect>
        <onselect condition="True">Skin.SetString(widgetstyle,landscape)</onselect>
    </setting>

</settings>

Multiselect

If you have some sort of multiple options the user can enable and you don't want to create a whole bunch of radiobuttons (and set default values).. Syntax:

    <!-- options to show in videoinfo - multiselect -->
    <setting id="videoinfo_buttons" value="||MULTISELECT||" label="" condition="" icon="" description="">
        <option id="videoinfo_button_play" label="$LOCALIZE[208]" condition="" default="true"/>
        <option id="videoinfo_button_trailer" label="$LOCALIZE[20410]" condition="" default="true"/>
        <option id="videoinfo_button_cast" label="$LOCALIZE[206]" condition="" default="true"/>
    </setting>

The ID specified in the option will be set as Skin Bool. E.g. if you call the script with RunScript(script.skin.helper.service,action=setskinsetting,setting=videoinfo_buttons,header=Enable buttons in videoinfo) If the user enables the playbutton, the command Skin.SetBool(videoinfo_button_play will be called, otherwise it will be reset. With the default attribute you can specify what the default value should be for the setting (applied at skin startup, change or update)

Write constants to includes file

You can use the above described approach for skin settings also to write constants to an includes file. For this you can use the same settings file with the same xml elements etc. Only, instead of calling "setskinsetting", you should call "setskinconstant". Any value that is selected by the user will be written to an XML file in your skin directory called script-skin_helper_service-includes.xml

RunScript(script.skin.helper.service,action=setskinconstant,setting=PanelWidth,header=Width for Panel)
Default value for constant

On your defined you may use the additional attribute constantdefault="MyVisibilityCondition" to set your default value at skin install/update. You can use any Kodi visibility condition. Example:

<settings>
    <setting id="PanelWidth" value="1" label="1 pixel" condition="" icon="" description=""/>
    <setting id="PanelWidth" value="2" label="2 pixels" condition="" icon="" description="" constantdefault="Skin.HasSetting(UseWidePanels)"/>
    <setting id="PanelWidth" value="3" label="3 pixels" condition="" icon="" description="" constantdefault="!Skin.HasSetting(UseWidePanels)"/>
</settings>

In the above example, if no value is set for the PanelWidth constant it will default to value 2 if the skin bool UseWidePanels is true, otherwise it will set value 3 as default.

Only set the value for a constant

It is also possible to directly pass the value to the script so the settings dialog won't be opened. In this case, just add the optional value argument to the script and that value will be written to the constant.

RunScript(script.skin.helper.service,action=setskinconstant,setting=PanelWidth,value=13)
Value of the skinconstant as skinstring

If you'd like to display the value of your constant in the GUI, it might be comfortable to also have the value of the constant as a skin string. All values you set for constants will also be written to a skin string for easy access within your skin. For example you've set the contstant PanelWidth with the script, this means that besides a constant you will also have a skin string with that name, e.g. Skin.String(PanelWidth)

Copy value of constant

If you want to copy the value of an constant to another constant, there is an easy trick. Just use the above explained skinstring for that. For example, you want to use the value of PanelWidth to also set the PanelWidth2 constant:

RunScript(script.skin.helper.service,action=setskinconstant,setting=PanelWidth2,value=$INFO[Skin.String(PanelWidth)])
Set multiple constants at once

If you want to set a whole bunch of constants in one single command (so there is only 1 reloadskin command issued), you can use this syntax:

RunScript(script.skin.helper.service,action=setskinconstant,settings=PanelWidth|PanelWidth2,values=13|14)

use the settings parameter to define all constants you want to set, seperate with | use the values parameter to define all values for the constants, seperate with |


Clone this wiki locally