2023-05-03 21:21:04 +00:00
|
|
|
import "pkg:/source/utils/config.brs"
|
|
|
|
import "pkg:/source/utils/misc.brs"
|
|
|
|
|
2019-05-03 12:48:59 +00:00
|
|
|
sub init()
|
|
|
|
m.title = m.top.findNode("title")
|
2020-05-29 16:47:16 +00:00
|
|
|
m.staticTitle = m.top.findNode("staticTitle")
|
2022-09-05 06:50:13 +00:00
|
|
|
m.series = m.top.findNode("Series")
|
2019-05-03 12:48:59 +00:00
|
|
|
m.poster = m.top.findNode("poster")
|
2022-12-10 21:41:40 +00:00
|
|
|
m.unplayedCount = m.top.findNode("unplayedCount")
|
|
|
|
m.unplayedEpisodeCount = m.top.findNode("unplayedEpisodeCount")
|
2021-07-09 20:08:32 +00:00
|
|
|
|
2019-05-03 12:48:59 +00:00
|
|
|
m.backdrop = m.top.findNode("backdrop")
|
2021-07-09 20:08:32 +00:00
|
|
|
|
2020-05-31 13:47:03 +00:00
|
|
|
' Randmomise the background colors
|
2020-08-16 14:44:03 +00:00
|
|
|
posterBackgrounds = m.global.constants.poster_bg_pallet
|
2020-05-31 13:47:03 +00:00
|
|
|
m.backdrop.color = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
|
|
|
|
|
2019-05-03 12:48:59 +00:00
|
|
|
updateSize()
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub updateSize()
|
2019-05-10 04:24:19 +00:00
|
|
|
image = invalid
|
2023-03-09 19:35:29 +00:00
|
|
|
if isValid(m.top.itemContent) and isValid(m.top.itemContent.image)
|
2021-07-09 20:08:32 +00:00
|
|
|
image = m.top.itemContent.image
|
2019-05-10 04:24:19 +00:00
|
|
|
end if
|
|
|
|
|
|
|
|
if image = invalid
|
2021-07-09 20:08:32 +00:00
|
|
|
m.backdrop.visible = true
|
2019-05-10 04:24:19 +00:00
|
|
|
else
|
2021-07-09 20:08:32 +00:00
|
|
|
m.backdrop.visible = false
|
2019-05-10 04:24:19 +00:00
|
|
|
end if
|
|
|
|
|
2019-05-03 12:48:59 +00:00
|
|
|
' TODO - abstract this in case the parent doesnt have itemSize
|
|
|
|
maxSize = m.top.getParent().itemSize
|
|
|
|
|
2019-05-10 04:24:19 +00:00
|
|
|
' Always reserve the bottom for the Poster Title
|
2020-05-29 16:47:16 +00:00
|
|
|
m.title.maxWidth = maxSize[0]
|
2022-04-19 16:50:34 +00:00
|
|
|
m.title.height = 40
|
|
|
|
m.title.translation = [0, int(maxSize[1]) - m.title.height + 5]
|
2019-05-10 04:24:19 +00:00
|
|
|
|
2020-05-29 16:47:16 +00:00
|
|
|
m.staticTitle.width = maxSize[0]
|
2022-04-19 16:50:34 +00:00
|
|
|
m.staticTitle.height = m.title.height
|
|
|
|
m.staticTitle.translation = m.title.translation
|
2019-05-10 04:24:19 +00:00
|
|
|
|
2022-09-05 06:50:13 +00:00
|
|
|
m.series.maxWidth = maxSize[0]
|
|
|
|
|
2019-05-03 12:48:59 +00:00
|
|
|
m.poster.width = int(maxSize[0]) - 4
|
2022-04-20 08:27:14 +00:00
|
|
|
m.poster.height = int(maxSize[1]) - m.title.height 'Set poster height to available space
|
2019-05-03 12:48:59 +00:00
|
|
|
|
|
|
|
m.backdrop.width = m.poster.width
|
|
|
|
m.backdrop.height = m.poster.height
|
|
|
|
end sub
|
|
|
|
|
2021-06-26 10:18:09 +00:00
|
|
|
sub itemContentChanged() as void
|
2021-07-09 20:08:32 +00:00
|
|
|
m.poster = m.top.findNode("poster")
|
|
|
|
itemData = m.top.itemContent
|
|
|
|
m.title.text = itemData.title
|
2022-06-09 23:50:05 +00:00
|
|
|
|
2023-06-01 12:43:27 +00:00
|
|
|
if m.global.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"] = false
|
2023-03-09 19:35:29 +00:00
|
|
|
if isValid(itemData.json.UserData) and isValid(itemData.json.UserData.UnplayedItemCount)
|
2023-02-04 23:16:36 +00:00
|
|
|
if itemData.json.UserData.UnplayedItemCount > 0
|
|
|
|
m.unplayedCount.visible = true
|
|
|
|
m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount
|
|
|
|
end if
|
2022-12-10 22:41:22 +00:00
|
|
|
end if
|
2022-12-10 21:41:40 +00:00
|
|
|
end if
|
|
|
|
|
2023-03-09 19:35:29 +00:00
|
|
|
if itemData.json.lookup("Type") = "Episode" and isValid(itemData.json.IndexNumber)
|
2021-07-09 20:08:32 +00:00
|
|
|
m.title.text = StrI(itemData.json.IndexNumber) + ". " + m.title.text
|
2022-09-05 06:50:13 +00:00
|
|
|
|
|
|
|
m.series.text = itemData.json.Series
|
|
|
|
m.series.visible = true
|
2022-06-09 23:50:05 +00:00
|
|
|
else if itemData.json.lookup("Type") = "MusicAlbum"
|
|
|
|
m.title.font = "font:SmallestSystemFont"
|
|
|
|
m.staticTitle.font = "font:SmallestSystemFont"
|
2022-09-15 04:03:13 +00:00
|
|
|
else
|
|
|
|
m.series.visible = false
|
2021-07-09 20:08:32 +00:00
|
|
|
end if
|
|
|
|
m.staticTitle.text = m.title.text
|
2020-05-29 16:47:16 +00:00
|
|
|
|
2022-06-19 22:23:56 +00:00
|
|
|
imageUrl = itemData.posterURL
|
|
|
|
|
2023-06-01 12:43:27 +00:00
|
|
|
if m.global.session.user.settings["ui.tvshows.blurunwatched"] = true
|
2023-03-09 19:35:29 +00:00
|
|
|
if itemData.json.lookup("Type") = "Episode" and isValid(itemData.json.userdata)
|
2022-06-19 22:23:56 +00:00
|
|
|
if not itemData.json.userdata.played
|
|
|
|
imageUrl = imageUrl + "&blur=15"
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
m.poster.uri = imageUrl
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
updateSize()
|
2021-06-26 10:18:09 +00:00
|
|
|
end sub
|
2020-05-29 16:47:16 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
' Enable title scrolling based on item Focus
|
|
|
|
sub focusChanged()
|
2021-07-09 20:08:32 +00:00
|
|
|
if m.top.itemHasFocus = true
|
|
|
|
m.title.repeatCount = -1
|
2022-09-05 06:50:13 +00:00
|
|
|
m.series.repeatCount = -1
|
2021-07-09 20:08:32 +00:00
|
|
|
m.staticTitle.visible = false
|
|
|
|
m.title.visible = true
|
2022-04-26 01:02:50 +00:00
|
|
|
' text to speech for accessibility
|
2023-03-27 16:50:44 +00:00
|
|
|
if m.global.device.isAudioGuideEnabled = true
|
2022-04-26 01:02:50 +00:00
|
|
|
txt2Speech = CreateObject("roTextToSpeech")
|
|
|
|
txt2Speech.Flush()
|
|
|
|
txt2Speech.Say(m.title.text)
|
|
|
|
end if
|
2021-07-09 20:08:32 +00:00
|
|
|
else
|
|
|
|
m.title.repeatCount = 0
|
2022-09-05 06:50:13 +00:00
|
|
|
m.series.repeatCount = 0
|
2021-07-09 20:08:32 +00:00
|
|
|
m.staticTitle.visible = true
|
|
|
|
m.title.visible = false
|
|
|
|
end if
|
2020-05-29 16:47:16 +00:00
|
|
|
end sub
|