Merge pull request #933 from 1hitsong/FixTVGenres

Update genre view for TV series
This commit is contained in:
1hitsong 2023-01-02 10:17:23 -05:00 committed by GitHub
commit 5ab6742ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 117 additions and 45 deletions

View File

@ -12,6 +12,11 @@ sub init()
m.newBackdrop = m.top.findNode("backdropTransition")
m.emptyText = m.top.findNode("emptyText")
m.genreList = m.top.findNode("genrelist")
m.genreList.observeField("itemSelected", "onGenreItemSelected")
m.genreData = CreateObject("roSGNode", "ContentNode")
m.genreList.content = m.genreData
m.swapAnimation = m.top.findNode("backroundSwapAnimation")
m.swapAnimation.observeField("state", "swapDone")
@ -74,6 +79,12 @@ sub init()
end if
end sub
'
'Genre Item Selected
sub onGenreItemSelected()
m.top.selectedItem = m.genreList.content.getChild(m.genreList.rowItemSelected[0]).getChild(m.genreList.rowItemSelected[1])
end sub
'
'Load initial set of Data
sub loadInitialItems()
@ -287,6 +298,14 @@ sub setTvShowsOptions(options)
{ "Title": tr("Played"), "Name": "Played" },
{ "Title": tr("Unplayed"), "Name": "Unplayed" }
]
if isValid(m.view)
if LCase(m.options.view) = "genres" or LCase(m.view) = "genres"
options.sort = [{ "Title": tr("TITLE"), "Name": "SortName" }]
options.filter = []
end if
end if
end sub
' Set Live TV view, sort, and filter options
@ -430,10 +449,32 @@ sub ItemDataLoaded(msg)
return
end if
if m.loadItemsTask.view = "Genres"
' Reset genre list data
m.genreData.removeChildren(m.genreData.getChildren(-1, 0))
for each item in itemData
m.genreData.appendChild(item)
end for
m.itemGrid.opacity = "0"
m.genreList.opacity = "1"
m.itemGrid.setFocus(false)
m.genreList.setFocus(true)
m.loading = false
m.spinner.visible = false
return
end if
for each item in itemData
m.data.appendChild(item)
end for
m.itemGrid.opacity = "1"
m.genreList.opacity = "0"
'Update the stored counts
m.loadedItems = m.itemGrid.content.getChildCount()
m.loadedRows = m.loadedItems / m.itemGrid.numColumns
@ -445,6 +486,7 @@ sub ItemDataLoaded(msg)
end if
m.itemGrid.setFocus(true)
m.genreList.setFocus(false)
m.spinner.visible = false
end sub
@ -652,7 +694,10 @@ sub optionsClosed()
m.itemGrid.content = m.data
loadInitialItems()
end if
m.itemGrid.setFocus(true)
m.itemGrid.setFocus(m.itemGrid.opacity = 1)
m.genreList.setFocus(m.genreList.opacity = 1)
if m.tvGuide <> invalid
m.tvGuide.lastFocus.setFocus(true)
end if
@ -688,13 +733,19 @@ end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
topGrp = m.top.findNode("itemGrid")
if m.itemGrid.opacity = 1
topGrp = m.itemGrid
else
topGrp = m.genreList
end if
searchGrp = m.top.findNode("voiceBox")
if key = "left" and searchGrp.isinFocusChain()
topGrp.setFocus(true)
searchGrp.setFocus(false)
end if
if key = "options"
if m.options.visible = true
m.options.visible = false
@ -780,14 +831,16 @@ function onKeyEvent(key as string, press as boolean) as boolean
end function
sub updateTitle()
if m.filter = "All"
m.top.overhangTitle = m.top.parentItem.title
else if m.filter = "Favorites"
m.top.overhangTitle = m.top.parentItem.title
if m.filter = "Favorites"
m.top.overhangTitle = m.top.parentItem.title + " " + tr("(Favorites)")
end if
if m.voiceBox.text <> ""
m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.searchTerm + ")"
end if
if m.top.alphaSelected <> ""
m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.nameStartsWith + ")"
end if
@ -801,14 +854,18 @@ sub updateTitle()
if m.options.view = "Networks" or m.view = "Networks"
m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Networks"))
end if
if m.options.view = "Studios" or m.view = "Studios"
m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Studios"))
end if
if m.options.view = "Genres" or m.view = "Genres"
m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Genres"))
end if
actInt = m.itemGrid.itemFocused + 1
if m.showItemCount and m.loadItemsTask.totalRecordCount > 0
if m.showItemCount and m.loadItemsTask.totalRecordCount > 0 and m.options.view <> "Genres" and m.view <> "Genres"
m.top.overhangTitle += " (" + tr("%1 of %2").Replace("%1", actInt.toStr()).Replace("%2", m.loadItemsTask.totalRecordCount.toStr()) + ")"
end if

View File

@ -3,18 +3,8 @@
<children>
<VoiceTextEditBox id="VoiceBox" visible="true" width = "40" translation = "[52, 120]" />
<Rectangle id="VoiceBoxCover" height="240" width="100" color="0x262626ff" translation = "[25, 75]" />
<poster id="backdrop"
loadDisplayMode="scaleToFill"
width="1920"
height="1080"
opacity="0.25"
/>
<poster id="backdropTransition"
loadDisplayMode="scaleToFill"
width="1920"
height="1080"
opacity="0.25"
/>
<poster id="backdrop" loadDisplayMode="scaleToFill" width="1920" height="1080" opacity="0.25" />
<poster id="backdropTransition" loadDisplayMode="scaleToFill" width="1920" height="1080" opacity="0.25" />
<MarkupGrid
id = "itemGrid"
translation = "[ 96, 160 ]"
@ -25,14 +15,17 @@
itemSize = "[ 290, 425 ]"
itemSpacing = "[ 0, 45 ]"
drawFocusFeedback = "false" />
<Label id="micButtonText" font="font:SmallSystemFont" visible="false" />
<RowList opacity="0" id="genrelist" translation="[120, 160]" showRowLabel="true" itemComponentName="GridItemSmall" numColumns="1" numRows="3" vertFocusAnimationStyle="fixed" itemSize = "[1900, 360]" rowItemSize="[ [230, 320] ]" rowItemSpacing="[ [20, 0] ]" itemSpacing="[0, 60]" />
<Label id="micButtonText" font="font:SmallSystemFont" visible="false" />
<Button id = "micButton" maxWidth = "20" translation = "[20, 120]" iconUri = "pkg:/images/icons/mic_icon.png"/>
<Label translation="[0,540]" id="emptyText" font="font:LargeSystemFont" width="1910" horizAlign="center" vertAlign="center" height="64" visible="false" />
<ItemGridOptions id="options" visible="false" />
<Spinner id="spinner" translation="[900, 450]" />
<Animation id="backroundSwapAnimation" duration="1" repeat="false" easeFunction="linear" >
<FloatFieldInterpolator id = "fadeinLoading" key="[0.0, 1.0]" keyValue="[ 0.00, 0.25 ]" fieldToInterp="backdropTransition.opacity" />
<FloatFieldInterpolator id = "fadeoutLoaded" key="[0.0, 1.0]" keyValue="[ 0.25, 0.00 ]" fieldToInterp="backdrop.opacity" />
<Animation id="backroundSwapAnimation" duration="1" repeat="false" easeFunction="linear">
<FloatFieldInterpolator id = "fadeinLoading" key="[0.0, 1.0]" keyValue="[ 0.00, 0.25 ]" fieldToInterp="backdropTransition.opacity" />
<FloatFieldInterpolator id = "fadeoutLoaded" key="[0.0, 1.0]" keyValue="[ 0.25, 0.00 ]" fieldToInterp="backdrop.opacity" />
</Animation>
<Alpha id="AlphaMenu" />
</children>

View File

@ -95,7 +95,7 @@ sub loadItems()
params.append({ UserId: get_setting("active_user") })
else if m.top.view = "Genres"
url = "Genres"
params.append({ UserId: get_setting("active_user") })
params.append({ UserId: get_setting("active_user"), includeItemTypes: m.top.itemType })
else if m.top.ItemType = "MusicArtist"
url = "Artists"
params.append({
@ -143,7 +143,7 @@ sub loadItems()
genreData = api_API().users.getitemsbyquery(get_setting("active_user"), {
SortBy: "Random",
SortOrder: "Ascending",
IncludeItemTypes: "Movie",
IncludeItemTypes: m.top.itemType,
Recursive: true,
Fields: "PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo",
ImageTypeLimit: 1,
@ -158,26 +158,38 @@ sub loadItems()
' Add View All item to the start of the row
row = tmp.createChild("FolderData")
row.parentFolder = m.top.itemId
genreMovieImage = api_API().items.getimageurl(item.id)
row.title = item.name
row.title = tr("View All") + " " + item.name
item.name = tr("View All") + " " + item.name
row.json = item
row.FHDPOSTERURL = genreMovieImage
row.HDPOSTERURL = genreMovieImage
row.SDPOSTERURL = genreMovieImage
row.type = "Folder"
if LCase(m.top.itemType) = "movie"
genreItemImage = api_API().items.getimageurl(item.id)
else
genreItemImage = invalid
row.posterURL = invalid
end if
row.FHDPOSTERURL = genreItemImage
row.HDPOSTERURL = genreItemImage
row.SDPOSTERURL = genreItemImage
end if
for each genreMovie in genreData.Items
row = tmp.createChild("MovieData")
for each genreItem in genreData.Items
if LCase(m.top.itemType) = "movie"
row = tmp.createChild("MovieData")
else
row = tmp.createChild("SeriesData")
end if
genreMovieImage = api_API().items.getimageurl(genreMovie.id)
row.title = genreMovie.name
row.FHDPOSTERURL = genreMovieImage
row.HDPOSTERURL = genreMovieImage
row.SDPOSTERURL = genreMovieImage
row.json = genreMovie
row.id = genreMovie.id
row.type = genreMovie.type
genreItemImage = api_API().items.getimageurl(genreItem.id)
row.title = genreItem.name
row.FHDPOSTERURL = genreItemImage
row.HDPOSTERURL = genreItemImage
row.SDPOSTERURL = genreItemImage
row.json = genreItem
row.id = genreItem.id
row.type = genreItem.type
end for
else if item.Type = "Studio"

View File

@ -252,7 +252,7 @@ sub setMoviesOptions(options)
]
if m.options.view = "Genres" or m.view = "Genres"
options.sort = []
options.sort = [{ "Title": tr("TITLE"), "Name": "SortName" }]
options.filter = []
end if

View File

@ -515,7 +515,7 @@
<translation>Support Direct Play of MPEG-2 content (e.g., Live TV). This will prevent transcoding of MPEG-2 content, but uses significantly more bandwidth.</translation>
<extracomment>Settings Menu - Description for option</extracomment>
</message>
<message>
<message>
<source>MPEG-4</source>
<translation>MPEG-4</translation>
<extracomment>Name of codec used in settings menu</extracomment>
@ -973,6 +973,10 @@
<source>Resumable</source>
<translation>Resumable</translation>
</message>
<message>
<source>View All</source>
<translation>View All</translation>
</message>
<message>
<source>Disable Community Rating for Episodes</source>
<translation>Disable Community Rating for Episodes</translation>

View File

@ -124,7 +124,7 @@ sub Main (args as dynamic) as void
selectedItem = msg.getData()
m.selectedItemType = selectedItem.type
'
if selectedItem.type = "CollectionFolder"
if selectedItem.collectionType = "movies"
group = CreateMovieLibraryView(selectedItem)
@ -135,7 +135,13 @@ sub Main (args as dynamic) as void
end if
sceneManager.callFunc("pushScene", group)
else if selectedItem.type = "Folder" and selectedItem.json.type = "Genre"
group = CreateMovieLibraryView(selectedItem)
' User clicked on a genre folder
if selectedItem.collectionType = "movies"
group = CreateMovieLibraryView(selectedItem)
else
group = CreateItemGrid(selectedItem)
end if
sceneManager.callFunc("pushScene", group)
else if selectedItem.type = "Folder" and selectedItem.json.type = "MusicGenre"
group = CreateMusicLibraryView(selectedItem)
sceneManager.callFunc("pushScene", group)