Begin work for making variables sizes

This commit is contained in:
Nick Bisby 2019-03-09 14:08:34 -06:00
parent f7a7146b94
commit 9efa3e4686
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36
6 changed files with 126 additions and 83 deletions

View File

@ -3,15 +3,11 @@
<children> <children>
<Poster id="moviePoster" <Poster id="moviePoster"
translation="[2, 0]" translation="[2, 0]"
width="196"
height="294"
/> />
<Label id="title" <Label id="title"
horizAlign="center" horizAlign="center"
translation="[0,319]" font="font:SmallSystemFont"
font="font:MediumSystemFont" />
width="196"
height="65" />
</children> </children>
<interface> <interface>
<field id="itemContent" type="node" onChange="itemContentChanged"/> <field id="itemContent" type="node" onChange="itemContentChanged"/>
@ -22,7 +18,15 @@
sub Init() sub Init()
m.title = m.top.findNode("title") m.title = m.top.findNode("title")
m.poster = m.top.findNode("moviePoster") m.poster = m.top.findNode("moviePoster")
m.title.text = "Loading..."
maxSize = m.top.getParent().itemSize
m.poster.width = int(maxSize[0]) - 4
m.poster.height = m.poster.width * 1.5
m.title.width = m.poster.width
m.title.height = int(maxSize[1]) - m.poster.height
m.title.translation = [0, m.poster.height]
end sub end sub
function itemContentChanged() as void function itemContentChanged() as void

View File

@ -0,0 +1,88 @@
sub itemContentChanged()
itemData = m.top.itemJson
m.top.findNode("moviePoster").uri = ImageURL(itemData.id)
' Handle all "As Is" fields
setFieldText("title", itemData.name)
setFieldText("releaseYear", itemData.productionYear)
setFieldText("officialRating", itemData.officialRating)
setFieldText("communityRating", str(itemData.communityRating))
setFieldText("overview", itemData.overview)
setFieldText("runtime", stri(getRuntime()) + " mins")
setFieldText("ends-at", "Ends at " + getEndTime())
if itemData.genres.count() > 0
setFieldText("genres", itemData.genres.join(", "))
end if
director = invalid
for each person in itemData.people
if person.type = "Director"
director = person.name
exit for
end if
end for
if director <> invalid
setFieldText("director", "Director: " + director)
end if
setFieldText("video_codec", "Video: " + itemData.mediaStreams[0].displayTitle)
setFieldText("audio_codec", "Audio: " + itemData.mediaStreams[1].displayTitle)
' TODO - cmon now. these are buttons, not words
setFieldText("buttons", "Play, Delete, Watched, Favorite, ...")
if itemData.taglines.count() > 0
setFieldText("tagline", itemData.taglines[0])
end if
end sub
sub setFieldText(field as string, value)
node = m.top.findNode(field)
if node = invalid then return
node.text = value
end sub
function getRuntime() as Integer
itemData = m.top.itemJson
' A tick is .1ms, so 1/10,000,000 for ticks to seconds,
' then 1/60 for seconds to minutess... 1/600,000,000
return round(itemData.RunTimeTicks / 600000000.0)
end function
function getEndTime() as string
itemData = m.top.itemJson
date = CreateObject("roDateTime")
duration_s = int(itemData.RunTimeTicks / 10000000.0)
date.fromSeconds(date.asSeconds() + duration_s)
date.toLocalTime()
hours = date.getHours()
meridian = "AM"
if hours = 0
hours = 12
meridian = "AM"
else if hours = 12
hours = 12
meridian = "PM"
else if hours > 12
hours = hours - 12
meridian = "PM"
end if
return Substitute("{0}:{1} {2}", stri(hours), stri(date.getMinutes()), meridian)
end function
function round(f as Float) as Integer
' BrightScript only has a "floor" round
' This compares floor to floor + 1 to find which is closer
m = int(f)
n = m + 1
x = abs(f - m)
y = abs(f - n)
if y > x
return m
else
return n
end if
end function

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<component name="MovieItemDetailScene" extends="Scene"> <component name="MovieItemDetailScene" extends="Scene">
<children> <children>
<LayoutGroup layoutDirection="horiz"> <LayoutGroup id="main_group" layoutDirection="horiz" translation="[50, 50]">
<Poster id="moviePoster" <Poster id="moviePoster"
translation="[150,150]" translation="[150,150]"
width="196" height="294" /> width="196" height="294" />
@ -30,79 +30,15 @@
</interface> </interface>
<script type="text/brightscript" uri="pkg:/source/config.brs" /> <script type="text/brightscript" uri="pkg:/source/config.brs" />
<script type="text/brightscript" uri="pkg:/source/JellyfinAPI.brs" /> <script type="text/brightscript" uri="pkg:/source/JellyfinAPI.brs" />
<script type="text/brightscript" uri="pkg:/components/MovieItemDetails.brs" />
<script type="text/brightscript"> <script type="text/brightscript">
<![CDATA[ <![CDATA[
sub init() sub init()
main = m.top.findNode("main_group")
dimensions = m.top.getScene().currentDesignResolution
end sub end sub
sub setFieldText(field as string, value)
node = m.top.findNode(field)
if node = invalid then return
node.text = value
end sub
function round(f as Float) as Integer
' BrightScript only has a "floor" round
' This compares floor to floor + 1 to find which is closer
m = int(f)
n = m + 1
x = abs(f - m)
y = abs(f - n)
if y > x
return m
else
return n
end if
end function
sub itemContentChanged()
itemData = m.top.itemJson
m.top.findNode("moviePoster").uri = ImageURL(itemData.id)
setFieldText("title", itemData.name)
setFieldText("releaseYear", itemData.productionYear)
' A tick is .1ms, so 1/10,000,000 for ticks to seconds,
' then 1/60 for seconds to minutess... 1/600,000,000
duration = round(itemData.RunTimeTicks / 600000000.0)
setFieldText("runtime", stri(duration) + " mins")
setFieldText("officialRating", itemData.officialRating)
setFieldText("communityRating", str(itemData.communityRating))
date = CreateObject("roDateTime")
duration_s = int(itemData.RunTimeTicks / 10000000.0)
date.fromSeconds(date.asSeconds() + duration_s)
date.toLocalTime()
d = date.toISOString()
' TODO - not full ISO format
setFieldText("ends-at", "Ends at " + d)
if itemData.genres.count() > 0
setFieldText("genres", itemData.genres.join(", "))
end if
director = invalid
for each person in itemData.people
if person.type = "Director"
director = person.name
exit for
end if
end for
if director <> invalid
setFieldText("director", "Director: " + director)
end if
setFieldText("video_codec", "Video: " + itemData.mediaStreams[0].displayTitle)
setFieldText("audio_codec", "Audio: " + itemData.mediaStreams[1].displayTitle)
' TODO - cmon now. these are buttons, not words
setFieldText("buttons", "Play, Delete, Watched, Favorite, ...")
if itemData.taglines.count() > 0
setFieldText("tagline", itemData.taglines[0])
end if
setFieldText("overview", itemData.overview)
end sub
]]> ]]>
</script> </script>
</component> </component>

View File

@ -13,15 +13,29 @@
m.top.content = getData() m.top.content = getData()
m.top.numrows = 1 m.top.numrows = 1
m.top.rowSize = 4 m.top.rowSize = 5
dimensions = m.top.getScene().currentDesignResolution
border = 75
m.top.translation = [border, border]
textHeight = 50
' Do we decide width by rowSize, or rowSize by width...
itemWidth = (dimensions["width"] - border*2) / m.top.rowSize
itemHeight = itemWidth * 1.5 + textHeight
m.top.visible = true m.top.visible = true
m.top.itemSize = [200 * 4 + 20 * 3, 400]
m.top.rowHeights = [400] ' size of the whole row
m.top.rowItemSize = [ [200, 400] ] m.top.itemSize = [dimensions["width"] - border*2, itemHeight]
m.top.itemSpacing = [ 0, 50 ] ' spacing between rows
m.top.rowItemSpacing = [ [20, 0] ] m.top.itemSpacing = [ 0, 10 ]
m.top.rowLabelOffset = [ [0, 30] ]
' size of the item in the row
m.top.rowItemSize = [ itemWidth, itemHeight ]
' spacing between items in a row
m.top.rowItemSpacing = [ 0, 0 ]
m.top.rowFocusAnimationStyle = "floatingFocus" m.top.rowFocusAnimationStyle = "floatingFocus"
'm.top.vertFocusAnimationStyle = "floatingFocus" 'm.top.vertFocusAnimationStyle = "floatingFocus"

View File

@ -4,7 +4,6 @@
<MovieRow <MovieRow
id="MovieSelect" id="MovieSelect"
visible="true" visible="true"
translation="[150,150]"
/> />
</children> </children>
</component> </component>

View File

@ -17,5 +17,7 @@ splash_screen_sd=pkg:/images/splash-screen_sd.jpg
splash_min_time=1500 splash_min_time=1500
ui_resolutions=hd,fhd
screensaver_private=0 screensaver_private=0
screensaver_title=Jellyfin screensaver_title=Jellyfin