-
Notifications
You must be signed in to change notification settings - Fork 24
Viewtype Builder
script.skinvariables also provides the ability to build viewtype rule expressions. These will allow you to lock viewtypes to specific rules in the library and in plugins.
Create a file skinviewtypes.json in folder skin.name/shortcuts
{
"prefix": "Exp_View",
"viewtypes": {
"50": "List",
"51": "Banner",
"52": "Poster"
},
"rules": {
"movies": {
"rule": "Container.Content(movies)",
"viewtypes": ["52"],
"library": "52",
"plugins": "50"
},
"tvshows": {
"rule": "Container.Content(tvshows)",
"viewtypes": ["51", "52"],
"library": "51",
"plugins": "50"
},
"other": {
"rule": "!Container.Content(movies) + !Container.Content(tvshows)",
"viewtypes": ["50"],
"library": "50"
}
}
}The rules section of the json file defines the rules for which content type conditions allow which viewtypes and which viewtype ID should be used by default. There are separate definitions for default viewtype IDs for plugins and library.
| Key | Meaning |
|---|---|
| "rule" | The visibility condition to be used |
| "viewtypes" | Which view IDs the user can select from for this rule |
| "library" | Which view ID is set as default for this rule |
| "plugins" | Optional. Sets a different default view for this rule if a plugin |
When the script runs it will generate the expressions based upon the rules.
<onload>RunScript(script.skinvariables,action=buildviews)</onload>Generates a file in skin.name/xml or equivalent 1080i etc. folder.
script-skinviewtypes-includes.xml
Include the file in Includes.xml
<include file="script-skinviewtypes-includes.xml" />The file will generate expressions for each defined viewtype ID in "viewtypes": {} with the name {prefix}_{viewtype_id}
<expression name="Exp_View_51">[Container.Content(tvshows)]</expression>
<expression name="Exp_View_52">[Container.Content(movies)]</expression>Replace the visible conditions for each viewtype in your skin with the corresponding expression. The expression from skinviewtypes will now control the visibility of each of your viewtypes.
<!-- List View 51 -->
<control type="list" id="51">
[...]
<visible>$EXP[Exp_View_51]</visible>
</control>
<!-- List View 52-->
<control type="list" id="52">
[...]
<visible>$EXP[Exp_View_52]</visible>
</control>
[etc]Allow the user to select a new viewtype ID by specifying a contentid
Runscript(script.skinvariables,action=buildviews,contentid=movies)Use a variable matching your rulesets to control which contentID is being set if the contentIDs don't directly map to Container.Content types.
For instance, our example has contentIDs for "movies", "tvshows", and "other". The first two contentIDs match Container.Content types but the "other" condition will need special handling via a variable like so:
<variable name="Viewtype_ContentID">
<value condition="!Container.Content(movies) + !Container.Content(tvshows)">other</value>
<value>$INFO[Container.Content]</value>
</variable>
<onclick>Runscript(script.skinvariables,action=buildviews,contentid=$VAR[Viewtype_ContentID])</onclick>Use the pluginname parameter if you wish to allow users to specify different viewtypes per plugin.
Set view for specific plugin and contentid
Runscript(script.skinvariables,action=buildviews,contentid=movies,pluginname=plugin.video.themoviedb.helper)
Set view for current plugin
Runscript(script.skinvariables,action=buildviews,contentid=$VAR[Viewtype_ContentID],pluginname=$INFO[Container.PluginName])
Set view for all other plugins not set individually
Runscript(script.skinvariables,action=buildviews,contentid=$VAR[Viewtype_ContentID],pluginname=plugin)
Set view for library (all below variants accepted)
Runscript(script.skinvariables,action=buildviews,contentid=$VAR[Viewtype_ContentID],pluginname=library)
Runscript(script.skinvariables,action=buildviews,contentid=$VAR[Viewtype_ContentID],pluginname=)
Runscript(script.skinvariables,action=buildviews,contentid=$VAR[Viewtype_ContentID])
Depending on the user configuration, some viewtypes might not be used at all.
It might be desirable to include viewtypes conditionally based on the configuration to minimise the amount of additional skin code loaded. The viewtype builder generates special include expressions set to true or false for this purpose.
These expressions follow a {prefix}_{viewtype_id}_Include naming scheme.
Example usage (e.g. MyVideoNav.xml)
<include condition="$EXP[Exp_View_51_Include]">ViewType_51_Banner</include>
<include condition="$EXP[Exp_View_52_Include]">ViewType_52_Poster</include>
etc.You can present the user with a configuration dialog to configure all available contentids
<onclick>runscript(script.skinvariables,action=buildviews,configure)</onclick>Specify contentid and/or pluginname params to configure only a specific subset of views.
Configure all library and plugin views for specific contentid
runscript(script.skinvariables,action=buildviews,contentid=movies,configure)
Configure all contentIDs for generic plugins
runscript(script.skinvariables,action=buildviews,pluginname=plugin,configure)
Configure all contentIDs for library
runscript(script.skinvariables,action=buildviews,pluginname=library,configure)
Configure all contentIDs for specific pluginname
runscript(script.skinvariables,action=buildviews,pluginname=plugin.video.themoviedb.helper,configure)
The following condition will be true when the viewtypes selector dialog is active. It can be used in DialogSelect.xml to define an alternative layout
!String.IsEmpty(Window(Home).Property(SkinViewtypes.DialogIsActive))
Preview images / icons for each viewtype can be defined in skinviewtypes.json and are available in $INFO[Container(6).ListItem.Icon]
{
"prefix": "Exp_View",
"viewtypes": {
"50": "List",
"51": "Banner",
"52": "Poster"
},
"icons": {
"50": "special://skin/extras/viewtypes/list.jpg",
"51": "special://skin/extras/viewtypes/banner.jpg",
"52": "special://skin/extras/viewtypes/poster.jpg"
}
}