Merge pull request #648 from 1hitsong/code-cleanup

Code cleanup - Setup option values by collection type
This commit is contained in:
Jimi 2022-06-12 16:43:22 -06:00 committed by GitHub
commit 0972687ccc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,15 +149,8 @@ sub loadInitialItems()
end sub
' Data to display when options button selected
sub SetUpOptions()
options = {}
options.filter = []
options.favorite = []
'Movies
if m.top.parentItem.collectionType = "movies"
' Set Movies view, sort, and filter options
sub setMoviesOptions(options)
options.views = [
{ "Title": tr("Movies"), "Name": "movies" },
]
@ -176,8 +169,10 @@ sub SetUpOptions()
{ "Title": tr("All"), "Name": "All" },
{ "Title": tr("Favorites"), "Name": "Favorites" }
]
'Boxsets
else if m.top.parentItem.collectionType = "boxsets"
end sub
' Set Boxset view, sort, and filter options
sub setBoxsetsOptions(options)
options.views = [{ "Title": tr("Shows"), "Name": "shows" }]
options.sort = [
{ "Title": tr("TITLE"), "Name": "SortName" },
@ -189,8 +184,10 @@ sub SetUpOptions()
{ "Title": tr("All"), "Name": "All" },
{ "Title": tr("Favorites"), "Name": "Favorites" }
]
'TV Shows
else if m.top.parentItem.collectionType = "tvshows"
end sub
' Set TV Show view, sort, and filter options
sub setTvShowsOptions(options)
options.views = [{ "Title": tr("Shows"), "Name": "shows" }]
options.sort = [
{ "Title": tr("TITLE"), "Name": "SortName" },
@ -204,8 +201,10 @@ sub SetUpOptions()
{ "Title": tr("All"), "Name": "All" },
{ "Title": tr("Favorites"), "Name": "Favorites" }
]
'Live TV
else if m.top.parentItem.collectionType = "livetv"
end sub
' Set Live TV view, sort, and filter options
sub setLiveTvOptions(options)
options.views = [
{ "Title": tr("Channels"), "Name": "livetv" },
{ "Title": tr("TV Guide"), "Name": "tvGuide" }
@ -220,24 +219,11 @@ sub SetUpOptions()
options.favorite = [
{ "Title": tr("Favorite"), "Name": "Favorite" }
]
else if m.top.parentItem.collectionType = "photoalbum" or m.top.parentItem.collectionType = "photo" or m.top.parentItem.collectionType = "homevideos"
' For some reason, my photo library shows up as "homevideos", maybe because it has some mp4 mixed in with the jpgs?
end sub
' TODO/FIXME: Show shuffle options once implemented
' options.views = [
' { "Title": tr("Don't Shuffle"), "Name": "singlephoto"}
' { "Title": tr("Shuffle"), "Name": "shufflephoto"}
' ]
options.views = []
options.sort = []
options.filter = []
'Music
else if m.top.parentItem.collectionType = "music"
options.views = [
{ "Title": tr("Default"), "Name": "music-default" },
{ "Title": tr("Artists"), "Name": "music-artist" },
{ "Title": tr("Albums"), "Name": "music-album" },
]
' Set Music view, sort, and filter options
sub setMusicOptions(options)
options.views = [{ "Title": tr("Music"), "Name": "music" }]
options.sort = [
{ "Title": tr("TITLE"), "Name": "SortName" },
{ "Title": tr("DATE_ADDED"), "Name": "DateCreated" },
@ -248,16 +234,66 @@ sub SetUpOptions()
{ "Title": tr("All"), "Name": "All" },
{ "Title": tr("Favorites"), "Name": "Favorites" }
]
else
end sub
' Set Photo Album view, sort, and filter options
sub setPhotoAlbumOptions(options)
' TODO/FIXME: Show shuffle options once implemented
' options.views = [
' { "Title": tr("Don't Shuffle"), "Name": "singlephoto"}
' { "Title": tr("Shuffle"), "Name": "shufflephoto"}
' ]
options.views = []
options.sort = []
end sub
' Set Default view, sort, and filter options
sub setDefaultOptions(options)
options.views = [
{ "Title": tr("Default"), "Name": "default" }
]
options.sort = [
{ "Title": tr("TITLE"), "Name": "SortName" }
]
end sub
' Return parent collection type
function getCollectionType() as string
return m.top.parentItem.collectionType
end function
' Search string array for search value. Return if it's found
function inStringArray(array, searchValue) as boolean
for each item in array
if lcase(item) = lcase(searchValue) then return true
end for
return false
end function
' Data to display when options button selected
sub SetUpOptions()
options = {}
options.filter = []
options.favorite = []
if getCollectionType() = "movies"
setMoviesOptions(options)
else if getCollectionType() = "boxsets"
setBoxsetsOptions(options)
else if getCollectionType() = "tvshows"
setTvShowsOptions(options)
else if getCollectionType() = "livetv"
setLiveTvOptions(options)
else if inStringArray(["photoalbum", "photo", "homevideos"], getCollectionType())
setPhotoAlbumOptions(options)
else if getCollectionType() = "music"
setMusicOptions(options)
else
setDefaultOptions(options)
end if
' Set selected view option
for each o in options.views
if o.Name = m.view
o.Selected = true
@ -266,6 +302,7 @@ sub SetUpOptions()
end if
end for
' Set selected sort option
for each o in options.sort
if o.Name = m.sortField
o.Selected = true
@ -274,6 +311,7 @@ sub SetUpOptions()
end if
end for
' Set selected filter option
for each o in options.filter
if o.Name = m.filter
o.Selected = true
@ -281,14 +319,7 @@ sub SetUpOptions()
end if
end for
' for each o in options.favorite
' if o.Name = m.favorite
' m.options.favorite = o.Name
' end if
' end for
m.options.options = options
end sub