Skip to content

Commit

Permalink
Merge pull request #120 from wackerl91/feature/LUNA-64
Browse files Browse the repository at this point in the history
LUNA-64: New game info view
  • Loading branch information
wackerl91 authored Dec 23, 2016
2 parents ccd37a8 + 0f89c67 commit fe7b548
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 133 deletions.
22 changes: 18 additions & 4 deletions resources/lib/controller/gameinfocontroller.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import xbmcgui
from resources.lib.controller.basecontroller import BaseController, route
from resources.lib.views.gameinfo import GameInfo

Expand All @@ -8,13 +9,26 @@ def __init__(self, core):
self.window = None

@route(name='details')
def show_game_info_action(self, game, title):
self.window = GameInfo(self, game, title)
def show_game_info_action(self, host, game):
self.window = GameInfo(self, host, game)
self.window.doModal()
del self.window

def get_active_skin(self):
return self.core.get_active_skin()
def select_cover_art(self, game, list_item):
browser = xbmcgui.Dialog().browse(2, 'Select Cover Art', 'files', '.jpg|.png', False, False,
game.get_poster(0, ''))
if browser:
game.selected_poster = browser
list_item.setThumbnailImage(browser)
self.sync_storage()

def select_fanart(self, game, list_item):
browser = xbmcgui.Dialog().browse(2, 'Select Fanart', 'files', '.jpg|.png', False, False,
game.get_selected_fanart().get_thumb())
if browser:
game.set_selected_fanart(browser)
list_item.setProperty('fanart', browser)
self.sync_storage()

def sync_storage(self):
return self.core.get_storage().sync()
2 changes: 1 addition & 1 deletion resources/lib/views/gamecontextmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def onAction(self, action):
if self.getFocus() == self.list and action.getId() == xbmcgui.ACTION_SELECT_ITEM:
selected_position = self.list.getSelectedPosition()
if selected_position == 0:
self.controller.render('gameinfo_details', {'game': self.current_game, 'title': self.current_game.name})
self.controller.render('gameinfo_details', {'host': self.host, 'game': self.current_game})
if selected_position == 1:
self.refresh_required = True
self.close()
Expand Down
164 changes: 43 additions & 121 deletions resources/lib/views/gameinfo.py
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))
5 changes: 2 additions & 3 deletions resources/lib/views/gamelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def onInit(self):

def build_list(self):
items = []
# game = self.games[0]

for game in self.games:
item = xbmcgui.ListItem()
item.setLabel(game['label'])
Expand Down Expand Up @@ -69,12 +69,11 @@ def onAction(self, action):

if cover_cache != loaded_game.get_selected_poster():
self.list.getSelectedItem().setProperty('icon', loaded_game.get_selected_poster())
self.list.getSelectedItem().setThumbnailImage(loaded_game.get_selected_poster())

if refresh:
self.controller.refresh_list(self.host)

self.setFocus(self.list)

elif self.getFocus() == self.list and action == xbmcgui.ACTION_SELECT_ITEM:
current_item = self.list.getListItem(self.list.getSelectedPosition())
loaded_game = self.controller.get_game_by_id(self.host, current_item.getProperty('id'))
Expand Down
158 changes: 158 additions & 0 deletions resources/skins/Default/720p/gameinfo.xml
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>
Loading

0 comments on commit fe7b548

Please sign in to comment.