2014-08-17, 03:06
I'm developing an addon that uses built in skins to display a list of items (games). I'm not using a custom WindowXML for the list, simply using the selected skins default list layout. I'm setting the list item properties like so:
This is working fine and the list looks great.
I've created a custom WindowXMLDialog class to display some extended properties, along with an XML file (resources/skins/Default/720p/info_dlg.xml). This is working fairly well however I am using a textbox to display the game description and for whatever reason this textbox doesn't render any text when used with certain skins. For example, if I use Aeon MQ5 or Xperience1080, no text is displayed however in Confluence and Transparency! it appears to work perfectly. If I change this control to a label, the text displays regardless of skin, however I don't have the ability to make it autoscroll vertically when there is more text than fits in the controls boundaries.
I'm quite new to Python/Add-on development and I'm very new to skinning and WindowXML but for the life of me I can't figure this one out. I've tried specifying fonts that I know are part of the selected skin to no avail.
Here's my WindowXMLDialog class and associated XML file. Like I said I'm quite new to all of this so please pardon any best practices that I might be missing, still learning!
context.py:
info_dlg.xml (textbox control is right at the end):
Code:
li.setInfo('video',{'plot': game.Description, 'rating': game.Rating, 'genre': '/'.join(game.Genres), 'premiered': 'TEST3', 'studio': '/'.join(game.Developers)})
This is working fine and the list looks great.
I've created a custom WindowXMLDialog class to display some extended properties, along with an XML file (resources/skins/Default/720p/info_dlg.xml). This is working fairly well however I am using a textbox to display the game description and for whatever reason this textbox doesn't render any text when used with certain skins. For example, if I use Aeon MQ5 or Xperience1080, no text is displayed however in Confluence and Transparency! it appears to work perfectly. If I change this control to a label, the text displays regardless of skin, however I don't have the ability to make it autoscroll vertically when there is more text than fits in the controls boundaries.
I'm quite new to Python/Add-on development and I'm very new to skinning and WindowXML but for the life of me I can't figure this one out. I've tried specifying fonts that I know are part of the selected skin to no avail.
Here's my WindowXMLDialog class and associated XML file. Like I said I'm quite new to all of this so please pardon any best practices that I might be missing, still learning!
context.py:
Code:
import sys, os, xbmc, xbmcgui, steamuidb
_addon_id = 'plugin.program.steamui'
_addon_path = xbmc.translatePath('special://home/addons/%s' % _addon_id)
_addon_profile_path = xbmc.translatePath('special://profile/addon_data/%s' % _addon_id)
_cache_img_path = xbmc.translatePath('special://profile/addon_data/%s/cache/img' % _addon_id)
_db = steamuidb.SteamUIDB(xbmc.translatePath('special://profile/addon_data/%s/games.db' % _addon_id))
game = _db.GetGamesByAppIDs([sys.argv[1]])[0]
headerImg = os.path.join(_cache_img_path,game.AppID+'_header.jpg')
backImg = os.path.join(_cache_img_path,game.AppID+'_screen.jpg')
img_path = os.path.join(_addon_path,'resources','img')
class DlgInfoWindow(xbmcgui.WindowXMLDialog):
def __init__(self, strXMLname, strFallbackPath, strDefaultName, forceFallback):
xbmcgui.Window(10000).setProperty('steamui_background', backImg)
xbmcgui.Window(10000).setProperty('steamui_game_icon', headerImg)
for x in range(13):
xbmcgui.Window(10000).setProperty('steamui_cat%s_png' % str(x), '')
xbmcgui.Window(10000).setProperty('steamui_cat%s_txt' % str(x), '')
_catCount = 0
for category in game.Categories:
_catCount = _catCount+1
xbmcgui.Window(10000).setProperty('steamui_cat%s_png' % str(_catCount), 'cat%s.png' % category['id'])
xbmcgui.Window(10000).setProperty('steamui_cat%s_txt' % str(_catCount), category['description'])
xbmcgui.Window(10000).setProperty('steamui_game_name', game.Name)
xbmcgui.Window(10000).setProperty('steamui_game_genre', ', '.join(game.Genres))
xbmcgui.Window(10000).setProperty('steamui_game_developer', '/'.join(game.Developers))
xbmcgui.Window(10000).setProperty('steamui_game_publisher', '/'.join(game.Publishers))
xbmcgui.Window(10000).setProperty('steamui_game_release', game.ReleaseDate)
xbmcgui.Window(10000).setProperty('steamui_game_rating', str(game.Rating))
xbmcgui.Window(10000).setProperty('steamui_game_about', game.Description)
def main():
dlg = DlgInfoWindow("info_dlg.xml", _addon_path, "Default", "720p")
dlg.doModal()
del dlg
main()
info_dlg.xml (textbox control is right at the end):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<window>
<defaultcontrol always="false">75</defaultcontrol>
<allowoverlay>no</allowoverlay>
<backgroundcolor>0xFF000000</backgroundcolor>
<animation effect="fade" time="300">WindowOpen</animation>
<animation effect="fade" time="300">WindowClose</animation>
<zorder>1</zorder>
<coordinates>
<system>1</system>
<posx>0</posx>
<posy>0</posy>
</coordinates>
<controls>
<!-- background -->
<control type="image" id="75">
<description>background image</description>
<posx>0</posx>
<posy>0</posy>
<width>1280</width>
<height>720</height>
<texture>$INFO[Window(HOME).Property(steamui_background)]</texture>
</control>
<control type="image">
<description>dialog background</description>
<posx>0</posx>
<posy>0</posy>
<width>1280</width>
<height>720</height>
<texture>dlg_back.png</texture>
</control>
<!-- Game Icon image -->
<control type="image">
<description>game_icon</description>
<posx>45</posx>
<posy>45</posy>
<width>460</width>
<height>215</height>
<texture>$INFO[Window(HOME).Property(steamui_game_icon)]</texture>
</control>
<!-- Category Images -->
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>296</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat1_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>328</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat2_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>360</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat3_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>392</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat4_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>424</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat5_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>456</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat6_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>488</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat7_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>520</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat8_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>552</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat9_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>584</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat10_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>616</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat11_png)]</texture>
</control>
<control type="image">
<description>game_icon</description>
<posx>32</posx>
<posy>648</posy>
<width>52</width>
<height>32</height>
<texture>$INFO[Window(HOME).Property(steamui_cat12_png)]</texture>
</control>
<!-- Category Labels -->
<control type="label">
<posx>90</posx>
<posy>296</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat1_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>328</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat2_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>360</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat3_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>392</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat4_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>424</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat5_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>456</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat6_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>488</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat7_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>520</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat8_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>552</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat9_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>584</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat10_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>616</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat11_txt)]</label>
</control>
<control type="label">
<posx>90</posx>
<posy>648</posy>
<width>450</width>
<height>32</height>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_cat12_txt)]</label>
</control>
<!-- Detail Headings -->
<control type="label">
<posx>584</posx>
<posy>40</posy>
<height>32</height>
<width>180</width>
<aligny>center</aligny>
<textcolor>FF979797</textcolor>
<align>left</align>
<label>Title</label>
</control>
<control type="label">
<posx>584</posx>
<posy>72</posy>
<height>32</height>
<width>180</width>
<aligny>center</aligny>
<textcolor>FF979797</textcolor>
<align>left</align>
<label>Genre</label>
</control>
<control type="label">
<posx>584</posx>
<posy>104</posy>
<height>32</height>
<width>180</width>
<aligny>center</aligny>
<textcolor>FF979797</textcolor>
<align>left</align>
<label>Developer</label>
</control>
<control type="label">
<posx>584</posx>
<posy>136</posy>
<height>32</height>
<width>180</width>
<aligny>center</aligny>
<textcolor>FF979797</textcolor>
<align>left</align>
<label>Publisher</label>
</control>
<control type="label">
<posx>584</posx>
<posy>168</posy>
<height>32</height>
<width>180</width>
<aligny>center</aligny>
<textcolor>FF979797</textcolor>
<align>left</align>
<label>Release Date</label>
</control>
<control type="label">
<posx>584</posx>
<posy>200</posy>
<height>32</height>
<width>180</width>
<aligny>center</aligny>
<textcolor>FF979797</textcolor>
<align>left</align>
<label>Metacritic Rating</label>
</control>
<control type="label">
<posx>584</posx>
<posy>264</posy>
<height>32</height>
<width>180</width>
<aligny>center</aligny>
<textcolor>FF979797</textcolor>
<align>left</align>
<label>About The Game</label>
</control>
<!-- Detail Values -->
<control type="label">
<posx>784</posx>
<posy>40</posy>
<height>32</height>
<width>464</width>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_game_name)]</label>
</control>
<control type="label">
<posx>784</posx>
<posy>72</posy>
<height>32</height>
<width>464</width>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_game_genre)]</label>
</control>
<control type="label">
<posx>784</posx>
<posy>104</posy>
<height>32</height>
<width>464</width>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_game_developer)]</label>
</control>
<control type="label">
<posx>784</posx>
<posy>136</posy>
<height>32</height>
<width>464</width>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_game_publisher)]</label>
</control>
<control type="label">
<posx>784</posx>
<posy>168</posy>
<height>32</height>
<width>464</width>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_game_release)]</label>
</control>
<control type="label">
<posx>784</posx>
<posy>200</posy>
<height>32</height>
<width>464</width>
<aligny>center</aligny>
<textcolor>FFFFFFFF</textcolor>
<align>left</align>
<label>$INFO[Window(HOME).Property(steamui_game_rating)]</label>
</control>
<control type="textbox">
<posx>584</posx>
<posy>328</posy>
<width>664</width>
<height>360</height>
<enable>true</enable>
<visible>true</visible>
<autoscroll delay="3000" time="1000" repeat="10000">true</autoscroll>
<label>$INFO[Window(HOME).Property(steamui_game_about)]</label>
</control>
</controls>
</window>