(forced) Views - kodi-community-addons/script.skin.helper.service GitHub Wiki
RunScript(script.skin.helper.service,action=setview)
This feature shows the user a select dialog with all the views that are available. This replaces the default "toggle" button in the MyXXNav.xml windows. Note that you must create a views.xml file in your skin's extras folder. The selection dialog is built from that views.xml file and auto checks the visibility conditions so a view will only be shown if it's suitable for the current media content.
example content of the views.xml file (to be placed in extras folder of your skin):
<views>
<view id="List" value="50" languageid="31443" type="all"/>
<view id="Thumbs details" value="512" languageid="31439" type="movies,setmovies,tvshows,musicvideos,seasons,sets,episodes,artists,albums,songs,tvchannels,tvrecordings,programs,pictures" />
<view id="Poster Shift" value="514" languageid="31441" type="movies,setmovies,tvshows,musicvideos,seasons,sets" />
</views>
id = the unlocalized version of the views name. value = the skin view ID. languageid = localized label ID. type = the type of content the view is suitable for, use "all" to support all types.
Supported types are currently: movies, setmovies, tvshows, musicvideos, seasons, sets, episodes, artists, albums, songs, tvchannels, tvrecordings, programs, pictures.
If you want to specify "all but.." use the following syntax: "all, !episodes". In that example the view is suitable for all types except episodes.
Note: If you want a thumbnail of the view displayed in the select dialog, you need to create some small screenshots of your views and place them in your skin's extras folder:
- in your skin\extras folder, create a subfolder "viewthumbs"
- inside that viewthumbs folder save a .JPG file (screenshot for all your views. Save them as [VIEWID].jpg where [VIEWID] is the numeric ID of the view.
RunScript(script.skin.helper.service,action=enableviews)
This will present a selection dialog to the user to enable (or disable views. It uses the views.xml file to display the available views (see above). When a view is disabled it will be hidden from the view selection dialog. Also, a Skin String will be set so you can check in your skin if the view has been disabled (and not include it or set a visiblity condition). The name of the Skin String that will be set by the script is: SkinHelper.View.Disabled.[VIEWID] where [VIEWID] is the numerical ID of the view.
Example:
<include condition="!Skin.HasSetting(SkinHelper.View.Disabled.55)">View_55_BannerList</include>
NOTE: If you have views that should not be disabled by the user (e.g. your fallback list), add the excludefromdisable attribute to a view and set it's value to true:
<view id="List" value="50" languageid="31443" type="all" excludefromdisable="true"/>
NOTE 2: By default the enable/disable view dialog will use the DialogSelect list 3, the simple list without any thumbs and with checkboxes. If you add checkboxes to the list with ID 6 of Dialogselect you can use the rich layout with thumbs. In that case enable the rich layout for the dialog:
RunScript(script.skin.helper.service,action=enableviews,richlayout=true)
RunScript(script.skin.helper.service,action=setforcedview,contenttype=[TYPE])
The script can help you to set a forced view for a specific contenttype in your skin. For example if the user wants to set the list view for all tvshow content etc. For [TYPE] you must fill in one of the content types, see above at "Views selector". When a button is pressed with the above command, a select dialog appears and the user can choose on of the available views. Disabled views and views that aren't suitable for the specified type are hidden from the list. When the user made a choice from the list a Skin String will be filled by the script: SkinHelper.ForcedViews.[TYPE] The value of that skin string is the numeric ID of the selected view.
Note: It is recommended that you create a Skin toggle to enable/disable the forced views feature.
Note 2: When the user select another view in the normal viewselector, the forcedview setting will also be set to the newly chosen view.
Example code to use in your skin settings:
<control type="radiobutton" id="6009">
<label>Enable forced views</label>
<onclick>Skin.ToggleSetting(SkinHelper.ForcedViews.Enabled)</onclick>
<selected>Skin.HasSetting(SkinHelper.ForcedViews.Enabled)</selected>
</control>
<control type="button" id="6010">
<onclick>RunScript(script.skin.helper.service,action=setforcedview,contenttype=movies)</onclick>
<visible>Skin.HasSetting(SkinHelper.ForcedViews.Enabled)</visible>
<label>Forced view for movies: $INFO[Skin.String(SkinHelper.ForcedViews.movies)]</label>
</control>
<control type="button" id="6011">
<onclick>RunScript(script.skin.helper.service,action=setforcedview,contenttype=tvshows)</onclick>
<visible>Skin.HasSetting(SkinHelper.ForcedViews.Enabled)</visible>
<label>Forced view for tv shows: $INFO[Skin.String(SkinHelper.ForcedViews.tvshows)]</label>
</control>
<control type="button" id="6012">
<onclick>RunScript(script.skin.helper.service,action=setforcedview,contenttype=seasons)</onclick>
<visible>Skin.HasSetting(SkinHelper.ForcedViews.Enabled)</visible>
<label>Forced view for seasons: $INFO[Skin.String(SkinHelper.ForcedViews.seasons)]</label>
</control>
<control type="button" id="6013">
<onclick>RunScript(script.skin.helper.service,action=setforcedview,contenttype=episodes)</onclick>
<visible>Skin.HasSetting(SkinHelper.ForcedViews.Enabled)</visible>
<label>Forced view for episodes: $INFO[Skin.String(SkinHelper.ForcedViews.episodes)]</label>
<font>Reg28</font>
</control>
<control type="button" id="6014">
<onclick>RunScript(script.skin.helper.service,action=setforcedview,contenttype=sets)</onclick>
<visible>Skin.HasSetting(SkinHelper.ForcedViews.Enabled)</visible>
<label>Forced view for movie sets: $INFO[Skin.String(SkinHelper.ForcedViews.sets)]</label>
</control>
<control type="button" id="6015">
<onclick>RunScript(script.skin.helper.service,action=setforcedview,contenttype=setmovies)</onclick>
<visible>Skin.HasSetting(SkinHelper.ForcedViews.Enabled)</visible>
<label>Forced view for movies inside set: $INFO[Skin.String(SkinHelper.ForcedViews.setmovies)]</label>
</control>
the above example can off course be extended with other view types, such as pvr channels etc.
Example code to use for your views visibility conditions:
<control type="panel" id="51">
<visible>StringCompare(Window(Home).Property(SkinHelper.ForcedView),53) | IsEmpty(Window(Home).Property(SkinHelper.ForcedView)))</visible>
</control>
Note: The forced view visibility condition has to be added to all view controls in order to work properly. The ForcedView window property will only be set if you have set this bool to true in your skin: SkinHelper.ForcedViews.Enabled