2023-10-03 16:11:25 +00:00
|
|
|
import "pkg:/source/utils/config.bs"
|
|
|
|
import "pkg:/source/utils/misc.bs"
|
2023-10-03 16:27:07 +00:00
|
|
|
import "pkg:/source/roku_modules/log/LogMixin.brs"
|
2023-05-03 21:21:04 +00:00
|
|
|
|
2020-06-10 16:43:32 +00:00
|
|
|
sub init()
|
2023-05-03 21:21:04 +00:00
|
|
|
m.log = log.Logger("GridItem")
|
2021-07-09 20:08:32 +00:00
|
|
|
m.posterMask = m.top.findNode("posterMask")
|
|
|
|
m.itemPoster = m.top.findNode("itemPoster")
|
|
|
|
m.itemIcon = m.top.findNode("itemIcon")
|
|
|
|
m.posterText = m.top.findNode("posterText")
|
|
|
|
m.itemText = m.top.findNode("itemText")
|
|
|
|
m.backdrop = m.top.findNode("backdrop")
|
2020-07-04 15:10:56 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged")
|
2020-06-18 15:09:18 +00:00
|
|
|
|
2022-12-10 22:25:00 +00:00
|
|
|
m.unplayedCount = m.top.findNode("unplayedCount")
|
|
|
|
m.unplayedEpisodeCount = m.top.findNode("unplayedEpisodeCount")
|
2023-12-03 01:06:18 +00:00
|
|
|
m.playedIndicator = m.top.findNode("playedIndicator")
|
|
|
|
m.checkmark = m.top.findNode("checkmark")
|
|
|
|
m.checkmark.width = 90
|
|
|
|
m.checkmark.height = 60
|
2022-12-10 22:25:00 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemText.translation = [0, m.itemPoster.height + 7]
|
2020-10-25 15:46:08 +00:00
|
|
|
|
2023-06-01 12:43:27 +00:00
|
|
|
m.gridTitles = m.global.session.user.settings["itemgrid.gridTitles"]
|
2023-01-28 16:24:40 +00:00
|
|
|
m.itemText.visible = m.gridTitles = "showalways"
|
2022-05-14 08:52:01 +00:00
|
|
|
|
|
|
|
' Add some padding space when Item Titles are always showing
|
2023-01-28 16:24:40 +00:00
|
|
|
if m.itemText.visible then m.itemText.maxWidth = 250
|
2022-05-14 08:52:01 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
'Parent is MarkupGrid and it's parent is the ItemGrid
|
2022-06-03 05:25:00 +00:00
|
|
|
m.topParent = m.top.GetParent().GetParent()
|
2021-07-09 20:08:32 +00:00
|
|
|
'Get the imageDisplayMode for these grid items
|
2023-03-09 19:35:29 +00:00
|
|
|
if isValid(m.topParent.imageDisplayMode)
|
2022-06-03 05:25:00 +00:00
|
|
|
m.itemPoster.loadDisplayMode = m.topParent.imageDisplayMode
|
2021-07-09 20:08:32 +00:00
|
|
|
end if
|
2020-10-25 15:46:08 +00:00
|
|
|
|
2020-06-10 16:43:32 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
sub itemContentChanged()
|
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
' Set Random background colors from pallet
|
|
|
|
posterBackgrounds = m.global.constants.poster_bg_pallet
|
|
|
|
m.backdrop.blendColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
|
|
|
|
|
|
|
|
itemData = m.top.itemContent
|
|
|
|
|
|
|
|
if itemData = invalid then return
|
|
|
|
|
|
|
|
if itemData.type = "Movie"
|
2023-12-04 03:16:21 +00:00
|
|
|
if isValid(itemData.json) and isValid(itemData.json.UserData) and isValid(itemData.json.UserData.Played) and itemData.json.UserData.Played
|
2023-12-03 01:06:18 +00:00
|
|
|
m.playedIndicator.visible = true
|
|
|
|
end if
|
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
2022-07-09 08:39:29 +00:00
|
|
|
m.itemIcon.uri = itemData.iconUrl
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemText.text = itemData.Title
|
|
|
|
else if itemData.type = "Series"
|
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) and 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
|
2023-09-13 14:37:21 +00:00
|
|
|
else
|
|
|
|
m.unplayedCount.visible = false
|
|
|
|
m.unplayedEpisodeCount.text = ""
|
2023-02-04 23:16:36 +00:00
|
|
|
end if
|
2022-12-10 22:41:22 +00:00
|
|
|
end if
|
2022-12-10 22:25:00 +00:00
|
|
|
end if
|
2023-12-03 01:06:18 +00:00
|
|
|
if isValid(itemData.json) and isValid(itemData.json.UserData) and isValid(itemData.json.UserData.Played) and itemData.json.UserData.Played = true
|
|
|
|
m.playedIndicator.visible = true
|
|
|
|
end if
|
2022-12-10 22:25:00 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
2022-07-09 08:39:29 +00:00
|
|
|
m.itemIcon.uri = itemData.iconUrl
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemText.text = itemData.Title
|
|
|
|
else if itemData.type = "Boxset"
|
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
2022-07-09 08:39:29 +00:00
|
|
|
m.itemIcon.uri = itemData.iconUrl
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemText.text = itemData.Title
|
|
|
|
else if itemData.type = "TvChannel"
|
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
2022-07-09 08:39:29 +00:00
|
|
|
m.itemIcon.uri = itemData.iconUrl
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemText.text = itemData.Title
|
|
|
|
else if itemData.type = "Folder"
|
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
2022-07-09 08:39:29 +00:00
|
|
|
'm.itemIcon.uri = itemData.iconUrl
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemText.text = itemData.Title
|
2022-07-09 08:39:29 +00:00
|
|
|
m.itemPoster.loadDisplayMode = m.topParent.imageDisplayMode
|
2021-07-09 20:08:32 +00:00
|
|
|
else if itemData.type = "Video"
|
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
2022-07-09 08:39:29 +00:00
|
|
|
m.itemIcon.uri = itemData.iconUrl
|
2021-07-09 20:08:32 +00:00
|
|
|
m.itemText.text = itemData.Title
|
2023-02-25 16:43:36 +00:00
|
|
|
else if itemData.type = "Playlist"
|
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
|
|
|
m.itemIcon.uri = itemData.iconUrl
|
|
|
|
m.itemText.text = itemData.Title
|
2022-02-06 15:37:02 +00:00
|
|
|
else if itemData.type = "Photo"
|
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
2022-07-09 08:39:29 +00:00
|
|
|
m.itemIcon.uri = itemData.iconUrl
|
2022-02-06 15:37:02 +00:00
|
|
|
m.itemText.text = itemData.Title
|
2022-07-09 08:39:29 +00:00
|
|
|
else if itemData.type = "Episode"
|
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
|
|
|
m.itemIcon.uri = itemData.iconUrl
|
2023-03-05 18:57:32 +00:00
|
|
|
if isValid(itemData.json) and isValid(itemData.json.SeriesName)
|
2023-03-04 01:38:21 +00:00
|
|
|
m.itemText.text = itemData.json.SeriesName + " - " + itemData.Title
|
|
|
|
else
|
|
|
|
m.itemText.text = itemData.Title
|
|
|
|
end if
|
2022-05-14 02:35:50 +00:00
|
|
|
else if itemData.type = "MusicArtist"
|
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
|
|
|
m.itemText.text = itemData.Title
|
2022-06-09 23:50:05 +00:00
|
|
|
|
2022-06-09 23:56:40 +00:00
|
|
|
m.itemPoster.height = 290
|
|
|
|
m.itemPoster.width = 290
|
2022-06-09 23:50:05 +00:00
|
|
|
|
|
|
|
m.itemText.translation = [0, m.itemPoster.height + 7]
|
|
|
|
|
2022-06-09 23:56:40 +00:00
|
|
|
m.backdrop.height = 290
|
|
|
|
m.backdrop.width = 290
|
2022-06-09 23:50:05 +00:00
|
|
|
|
2022-10-02 18:23:42 +00:00
|
|
|
m.posterText.height = 200
|
|
|
|
m.posterText.width = 280
|
2023-03-09 19:35:29 +00:00
|
|
|
else if isValid(itemData.json.type) and itemData.json.type = "MusicAlbum"
|
2022-10-02 18:23:42 +00:00
|
|
|
m.itemPoster.uri = itemData.PosterUrl
|
|
|
|
m.itemText.text = itemData.Title
|
|
|
|
|
|
|
|
m.itemPoster.height = 290
|
|
|
|
m.itemPoster.width = 290
|
|
|
|
|
|
|
|
m.itemText.translation = [0, m.itemPoster.height + 7]
|
|
|
|
|
|
|
|
m.backdrop.height = 290
|
|
|
|
m.backdrop.width = 290
|
|
|
|
|
2022-06-09 23:50:05 +00:00
|
|
|
m.posterText.height = 200
|
2022-06-09 23:56:40 +00:00
|
|
|
m.posterText.width = 280
|
2021-07-09 20:08:32 +00:00
|
|
|
else
|
2023-05-03 21:21:04 +00:00
|
|
|
m.log.warn("Unhandled Grid Item Type", itemData.type)
|
2021-07-09 20:08:32 +00:00
|
|
|
end if
|
|
|
|
|
|
|
|
'If Poster not loaded, ensure "blue box" is shown until loaded
|
|
|
|
if m.itemPoster.loadStatus <> "ready"
|
|
|
|
m.backdrop.visible = true
|
|
|
|
m.posterText.visible = true
|
|
|
|
end if
|
|
|
|
|
|
|
|
m.posterText.text = m.itemText.text
|
2020-06-10 16:43:32 +00:00
|
|
|
|
|
|
|
end sub
|
|
|
|
|
|
|
|
'
|
2020-06-11 06:57:31 +00:00
|
|
|
'Use FocusPercent to animate scaling of Poser Image
|
|
|
|
sub focusChanging()
|
2021-07-09 20:08:32 +00:00
|
|
|
scaleFactor = 0.85 + (m.top.focusPercent * 0.15)
|
|
|
|
m.posterMask.scale = [scaleFactor, scaleFactor]
|
2020-06-11 06:57:31 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
'
|
|
|
|
'Display or hide title Visibility on focus change
|
2020-06-10 16:43:32 +00:00
|
|
|
sub focusChanged()
|
2021-07-09 20:08:32 +00:00
|
|
|
if m.top.itemHasFocus = true
|
|
|
|
m.itemText.repeatCount = -1
|
2022-06-04 03:29:22 +00:00
|
|
|
m.posterMask.scale = [1, 1]
|
2021-07-09 20:08:32 +00:00
|
|
|
else
|
|
|
|
m.itemText.repeatCount = 0
|
2022-06-04 03:29:22 +00:00
|
|
|
if m.topParent.alphaActive = true
|
|
|
|
m.posterMask.scale = [0.85, 0.85]
|
|
|
|
end if
|
2021-07-09 20:08:32 +00:00
|
|
|
end if
|
2023-01-28 16:24:40 +00:00
|
|
|
if m.gridTitles = "showonhover"
|
|
|
|
m.itemText.visible = m.top.itemHasFocus
|
|
|
|
end if
|
2020-06-10 16:43:32 +00:00
|
|
|
end sub
|
2020-07-04 15:10:56 +00:00
|
|
|
|
|
|
|
'Hide backdrop and text when poster loaded
|
|
|
|
sub onPosterLoadStatusChanged()
|
2021-07-09 20:08:32 +00:00
|
|
|
if m.itemPoster.loadStatus = "ready"
|
|
|
|
m.backdrop.visible = false
|
|
|
|
m.posterText.visible = false
|
|
|
|
end if
|
2020-07-04 15:10:56 +00:00
|
|
|
end sub
|