-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from wackerl91/feature/LUNA-64
LUNA-64: New game info view
- Loading branch information
Showing
7 changed files
with
224 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,49 @@ | ||
import os | ||
|
||
import pyxbmct.addonwindow as pyxbmct | ||
# coding=utf-8 | ||
import xbmcaddon | ||
import xbmcgui | ||
from resources.lib.views.windowxmldialog import WindowXMLDialog | ||
|
||
COLOR_FO = '0xFFE0B074' | ||
COLOR_NF = '0xFF808080' | ||
COLOR_HEADING = '0xFFD6D6D6' | ||
COLOR_DETAILS = '0xFF707070' | ||
COLOR_SELECTED = '0xFFF1F1F1' | ||
|
||
class GameInfo(WindowXMLDialog): | ||
def __new__(cls, *args, **kwargs): | ||
return super(GameInfo, cls).__new__(cls, 'gameinfo.xml', xbmcaddon.Addon().getAddonInfo('path')) | ||
|
||
class GameInfo(pyxbmct.AddonDialogWindow): | ||
def __init__(self, controller, game, title=''): | ||
super(GameInfo, self).__init__(title) | ||
def __init__(self, controller, host, game): | ||
super(GameInfo, self).__init__('gameinfo.xml', xbmcaddon.Addon().getAddonInfo('path')) | ||
self.controller = controller | ||
self.host = host | ||
self.game = game | ||
|
||
background = None | ||
if self.controller.get_active_skin() == 'skin.osmc': | ||
media_path = '/usr/share/kodi/addons/skin.osmc/media' | ||
if os.path.exists(media_path): | ||
background = os.path.join(media_path, 'dialogs/DialogBackground_old.png') | ||
|
||
if background is not None: | ||
self.background.setImage(background) | ||
self.removeControl(self.title_background) | ||
self.removeControl(self.window_close_button) | ||
self.removeControl(self.title_bar) | ||
|
||
# init controls | ||
self.image = None | ||
self.genre = None | ||
self.year = None | ||
self.plot = None | ||
self.button_play = None | ||
self.button_cover_art = None | ||
self.button_fanart = None | ||
|
||
self.setGeometry(1280, 720, 12, 6, padding=60) | ||
self.set_info_controls(game) | ||
self.set_active_controls(game) | ||
self.set_navigation() | ||
self.connect(pyxbmct.ACTION_NAV_BACK, self.close) | ||
|
||
def set_info_controls(self, game): | ||
title_label = pyxbmct.Label(game.name, alignment=pyxbmct.ALIGN_LEFT, font='XLarge', textColor=COLOR_HEADING) | ||
self.placeControl(title_label, 0, 0, 2, 3) | ||
|
||
image_path = game.get_selected_poster() | ||
if image_path is None: | ||
image_path = '' | ||
self.image = pyxbmct.Image(image_path) | ||
self.placeControl(self.image, 2, 0, 6, 1) | ||
|
||
genre_label = pyxbmct.Label('Genre', alignment=pyxbmct.ALIGN_LEFT, font='Med', textColor=COLOR_DETAILS) | ||
self.placeControl(genre_label, 2, 2) | ||
self.genre = pyxbmct.FadeLabel(_alignment=pyxbmct.ALIGN_LEFT, font='Med') | ||
self.placeControl(self.genre, 2, 3, columnspan=3) | ||
self.genre.addLabel(game.get_genre_as_string()) | ||
|
||
year_label = pyxbmct.Label('Year', alignment=pyxbmct.ALIGN_LEFT, font='Med', textColor=COLOR_DETAILS) | ||
self.placeControl(year_label, 3, 2) | ||
self.year = pyxbmct.Label(game.year, alignment=pyxbmct.ALIGN_LEFT, font='Med') | ||
self.placeControl(self.year, 3, 3) | ||
|
||
self.plot = pyxbmct.TextBox() | ||
self.placeControl(self.plot, 4, 2, 6, 3) | ||
self.plot.setText(game.plot) | ||
self.plot.autoScroll(delay=5000, time=2000, repeat=10000) | ||
|
||
def set_active_controls(self, game): | ||
self.button_play = pyxbmct.Button('Play', focusTexture='', noFocusTexture='', focusedColor=COLOR_FO, | ||
textColor=COLOR_NF, font='Med', alignment=pyxbmct.ALIGN_LEFT) | ||
self.placeControl(self.button_play, 11, 0) | ||
# self.connect(self.button_play, self.launch_game) | ||
|
||
self.button_cover_art = pyxbmct.Button('Choose Cover Art', focusTexture='', noFocusTexture='', | ||
focusedColor=COLOR_FO, textColor=COLOR_NF, font='Med', | ||
alignment=pyxbmct.ALIGN_LEFT) | ||
self.placeControl(self.button_cover_art, 11, 1, columnspan=2) | ||
self.connect(self.button_cover_art, self.select_cover_art) | ||
|
||
self.button_fanart = pyxbmct.Button('Choose Fanart', focusTexture='', noFocusTexture='', | ||
focusedColor=COLOR_FO, textColor=COLOR_NF, font='Med', | ||
alignment=pyxbmct.ALIGN_LEFT) | ||
self.placeControl(self.button_fanart, 11, 3, columnspan=2) | ||
self.connect(self.button_fanart, self.select_fanart) | ||
|
||
def set_navigation(self): | ||
self.button_play.controlRight(self.button_cover_art) | ||
self.button_play.controlLeft(self.button_fanart) | ||
self.button_cover_art.controlRight(self.button_fanart) | ||
self.button_cover_art.controlLeft(self.button_play) | ||
self.button_fanart.controlRight(self.button_play) | ||
self.button_fanart.controlLeft(self.button_cover_art) | ||
|
||
self.setFocus(self.button_play) | ||
|
||
# def launch_game(self): | ||
# xbmc.executebuiltin('XBMC.RunPlugin(%s)' % self.plugin.url_for( | ||
# endpoint='launch_game', | ||
# game_id=self.game.name)) | ||
|
||
def select_fanart(self): | ||
browser = xbmcgui.Dialog().browse(2, 'Select Fanart', 'files', '.jpg|.png', False, False, | ||
self.game.get_selected_fanart().get_thumb()) | ||
if browser: | ||
self.game.set_selected_fanart(browser) | ||
self.controller.sync_storage() | ||
|
||
def select_cover_art(self): | ||
browser = xbmcgui.Dialog().browse(2, 'Select Cover Art', 'files', '.jpg|.png', False, False, | ||
self.game.get_poster(0, '')) | ||
if browser: | ||
self.game.selected_poster = browser | ||
self.controller.sync_storage() | ||
self.image = pyxbmct.Image(browser) | ||
self.placeControl(self.image, 2, 0, 6, 1) | ||
|
||
def setAnimation(self, control): | ||
control.setAnimations( | ||
[ | ||
('WindowOpen', 'effect=fade start=0 end=100 time=500',), | ||
('WindowClose', 'effect=fade start=100 end=0 time=500',) | ||
] | ||
) | ||
self.list = None | ||
self.play_btn = None | ||
self.select_poster_btn = None | ||
self.select_fanart_btn = None | ||
|
||
def onInit(self): | ||
self.list = self.getControl(51) | ||
self.play_btn = self.getControl(52) | ||
self.select_poster_btn = self.getControl(53) | ||
self.select_fanart_btn = self.getControl(54) | ||
self.setFocus(self.play_btn) | ||
|
||
item = xbmcgui.ListItem() | ||
item.setLabel(self.game.name) | ||
item.setIconImage(self.game.get_selected_poster()) | ||
item.setThumbnailImage(self.game.get_selected_poster()) | ||
item.setInfo('video', { | ||
'year': self.game.year, | ||
'plot': self.game.plot, | ||
'genre': self.game.genre, | ||
'originaltitle': self.game.name | ||
}) | ||
item.setProperty('icon', self.game.get_selected_poster()) | ||
item.setProperty('fanart', self.game.get_selected_fanart().get_original()) | ||
item.setProperty('year_genre', '%s • %s' % (self.game.year, ', '.join(self.game.genre))) | ||
item.setProperty('description', self.game.plot) | ||
item.setProperty('id', self.game.id) | ||
|
||
self.list.addItems([item]) | ||
|
||
self.connect(xbmcgui.ACTION_NAV_BACK, self.close) | ||
self.connect(self.play_btn, lambda: self.controller.render("game_launch", {'game': self.game})) | ||
self.connect(self.select_poster_btn, lambda: self.controller.select_cover_art(self.game, item)) | ||
self.connect(self.select_fanart_btn, lambda: self.controller.select_fanart(self.game, item)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<window> | ||
<animation effect="fade" time="500" start="20" end="100">WindowOpen</animation> | ||
<animation effect="fade" time="500" start="100" end="20">WindowClose</animation> | ||
<controls> | ||
<!-- Background --> | ||
<control type="image"> | ||
<left>-100</left> | ||
<top>-100</top> | ||
<width>1920</width> | ||
<height>1080</height> | ||
<texture>common/black.png</texture> | ||
</control> | ||
|
||
<control type="image"> | ||
<description>luna logo</description> | ||
<top>50</top> | ||
<left>50</left> | ||
<width>100</width> | ||
<height>50</height> | ||
<aspectratio>keep</aspectratio> | ||
<texture>common/luna.png</texture> | ||
</control> | ||
<!-- System Clock widget is copied from the old OSMC skin to match their location --> | ||
<control type="label"> | ||
<right>47</right> | ||
<top>44</top> | ||
<width>800</width> | ||
<height>40</height> | ||
<align>right</align> | ||
<label>$INFO[System.Time]</label> | ||
<font>Large</font> | ||
<textcolor>ColorHeading</textcolor> | ||
</control> | ||
<control type="label"> | ||
<right>47</right> | ||
<top>88</top> | ||
<width>800</width> | ||
<height>33</height> | ||
<align>right</align> | ||
<label>$INFO[System.Date]</label> | ||
<font>XSmall</font> | ||
<textcolor>ColorDetails</textcolor> | ||
</control> | ||
|
||
<control type="image"> | ||
<description>background image</description> | ||
<posx>0</posx> | ||
<posy>0</posy> | ||
<width>1280</width> | ||
<height>720</height> | ||
<fadetime>200</fadetime> | ||
<texture colordiffuse="50D3D3D3">$INFO[Container(51).ListItem(0).Property(fanart)]</texture> | ||
</control> | ||
|
||
<control type="textbox" id="55"> | ||
<left>350</left> | ||
<top>250</top> | ||
<width>600</width> | ||
<height>230</height> | ||
<wrapmultiline>true</wrapmultiline> | ||
<textcolor>ColorHeading</textcolor> | ||
<font>XSmall</font> | ||
<autoscroll delay="10000" time="3000" repeat="10000">true</autoscroll> | ||
<label>$INFO[Container(51).ListItem(0).Property(description)]</label> | ||
</control> | ||
|
||
<control type="list" id="51"> | ||
<width>1280</width> | ||
<height>720</height> | ||
<itemlayout> | ||
<control type="image"> | ||
<left>50</left> | ||
<top>150</top> | ||
<width>250</width> | ||
<height>334</height> | ||
<aspectratio>keep</aspectratio> | ||
<texture>$INFO[ListItem.Art(thumb)]</texture> | ||
</control> | ||
<control type="label"> | ||
<left>350</left> | ||
<top>150</top> | ||
<width>880</width> | ||
<font>Large</font> | ||
<textcolor>ColorHeading</textcolor> | ||
<info>ListItem.Label</info> | ||
</control> | ||
<control type="label"> | ||
<left>350</left> | ||
<top>180</top> | ||
<width>400</width> | ||
<font>XSmall</font> | ||
<textcolor>ColorDetails</textcolor> | ||
<info>ListItem.Property(year_genre)</info> | ||
</control> | ||
</itemlayout> | ||
<focusedlayout> | ||
<control type="image"> | ||
<left>50</left> | ||
<top>150</top> | ||
<width>250</width> | ||
<height>334</height> | ||
<aspectratio>keep</aspectratio> | ||
<texture>$INFO[ListItem.Art(thumb)]</texture> | ||
</control> | ||
<control type="label"> | ||
<left>350</left> | ||
<top>150</top> | ||
<width>880</width> | ||
<font>Large</font> | ||
<textcolor>ColorHeading</textcolor> | ||
<info>ListItem.Label</info> | ||
</control> | ||
<control type="label"> | ||
<left>350</left> | ||
<top>180</top> | ||
<width>400</width> | ||
<font>XSmall</font> | ||
<textcolor>ColorDetails</textcolor> | ||
<info>ListItem.Property(year_genre)</info> | ||
</control> | ||
</focusedlayout> | ||
</control> | ||
|
||
<control type="button" id="52"> | ||
<top>570</top> | ||
<left>50</left> | ||
<font>Large</font> | ||
<label>Play</label> | ||
<textcolor>FF808080</textcolor> | ||
<focusedcolor>FFE0B074</focusedcolor> | ||
<onleft>54</onleft> | ||
<onright>53</onright> | ||
</control> | ||
|
||
<control type="button" id="53"> | ||
<top>570</top> | ||
<left>300</left> | ||
<font>Large</font> | ||
<label>Choose Cover Art</label> | ||
<textcolor>FF808080</textcolor> | ||
<focusedcolor>FFE0B074</focusedcolor> | ||
<onleft>52</onleft> | ||
<onright>54</onright> | ||
</control> | ||
|
||
<control type="button" id="54"> | ||
<top>570</top> | ||
<left>600</left> | ||
<font>Large</font> | ||
<label>Choose Fanart</label> | ||
<textcolor>FF808080</textcolor> | ||
<focusedcolor>FFE0B074</focusedcolor> | ||
<onright>52</onright> | ||
<onleft>53</onleft> | ||
</control> | ||
</controls> | ||
</window> |
Oops, something went wrong.