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

View File

@ -3,18 +3,8 @@
<children> <children>
<VoiceTextEditBox id="VoiceBox" visible="true" width = "40" translation = "[52, 120]" /> <VoiceTextEditBox id="VoiceBox" visible="true" width = "40" translation = "[52, 120]" />
<Rectangle id="VoiceBoxCover" height="240" width="100" color="0x262626ff" translation = "[25, 75]" /> <Rectangle id="VoiceBoxCover" height="240" width="100" color="0x262626ff" translation = "[25, 75]" />
<poster id="backdrop" <poster id="backdrop" loadDisplayMode="scaleToFill" width="1920" height="1080" opacity="0.25" />
loadDisplayMode="scaleToFill" <poster id="backdropTransition" loadDisplayMode="scaleToFill" width="1920" height="1080" opacity="0.25" />
width="1920"
height="1080"
opacity="0.25"
/>
<poster id="backdropTransition"
loadDisplayMode="scaleToFill"
width="1920"
height="1080"
opacity="0.25"
/>
<MarkupGrid <MarkupGrid
id = "itemGrid" id = "itemGrid"
translation = "[ 96, 160 ]" translation = "[ 96, 160 ]"
@ -25,14 +15,17 @@
itemSize = "[ 290, 425 ]" itemSize = "[ 290, 425 ]"
itemSpacing = "[ 0, 45 ]" itemSpacing = "[ 0, 45 ]"
drawFocusFeedback = "false" /> 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"/> <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" /> <Label translation="[0,540]" id="emptyText" font="font:LargeSystemFont" width="1910" horizAlign="center" vertAlign="center" height="64" visible="false" />
<ItemGridOptions id="options" visible="false" /> <ItemGridOptions id="options" visible="false" />
<Spinner id="spinner" translation="[900, 450]" /> <Spinner id="spinner" translation="[900, 450]" />
<Animation id="backroundSwapAnimation" duration="1" repeat="false" easeFunction="linear" > <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 = "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" /> <FloatFieldInterpolator id = "fadeoutLoaded" key="[0.0, 1.0]" keyValue="[ 0.25, 0.00 ]" fieldToInterp="backdrop.opacity" />
</Animation> </Animation>
<Alpha id="AlphaMenu" /> <Alpha id="AlphaMenu" />
</children> </children>

View File

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

View File

@ -252,7 +252,7 @@ sub setMoviesOptions(options)
] ]
if m.options.view = "Genres" or m.view = "Genres" if m.options.view = "Genres" or m.view = "Genres"
options.sort = [] options.sort = [{ "Title": tr("TITLE"), "Name": "SortName" }]
options.filter = [] options.filter = []
end if 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> <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> <extracomment>Settings Menu - Description for option</extracomment>
</message> </message>
<message> <message>
<source>MPEG-4</source> <source>MPEG-4</source>
<translation>MPEG-4</translation> <translation>MPEG-4</translation>
<extracomment>Name of codec used in settings menu</extracomment> <extracomment>Name of codec used in settings menu</extracomment>
@ -973,6 +973,10 @@
<source>Resumable</source> <source>Resumable</source>
<translation>Resumable</translation> <translation>Resumable</translation>
</message> </message>
<message>
<source>View All</source>
<translation>View All</translation>
</message>
<message> <message>
<source>Disable Community Rating for Episodes</source> <source>Disable Community Rating for Episodes</source>
<translation>Disable Community Rating for Episodes</translation> <translation>Disable Community Rating for Episodes</translation>

View File

@ -124,7 +124,7 @@ sub Main (args as dynamic) as void
selectedItem = msg.getData() selectedItem = msg.getData()
m.selectedItemType = selectedItem.type m.selectedItemType = selectedItem.type
'
if selectedItem.type = "CollectionFolder" if selectedItem.type = "CollectionFolder"
if selectedItem.collectionType = "movies" if selectedItem.collectionType = "movies"
group = CreateMovieLibraryView(selectedItem) group = CreateMovieLibraryView(selectedItem)
@ -135,7 +135,13 @@ sub Main (args as dynamic) as void
end if end if
sceneManager.callFunc("pushScene", group) sceneManager.callFunc("pushScene", group)
else if selectedItem.type = "Folder" and selectedItem.json.type = "Genre" 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" else if selectedItem.type = "Folder" and selectedItem.json.type = "MusicGenre"
group = CreateMusicLibraryView(selectedItem) group = CreateMusicLibraryView(selectedItem)
sceneManager.callFunc("pushScene", group) sceneManager.callFunc("pushScene", group)